Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0826891c
Commit
0826891c
authored
Mar 08, 2021
by
Mehmet Emin INAC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add info column into security_scans table
This new JSONB column will be used to store error information
parent
f98e6652
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
63 additions
and
1 deletion
+63
-1
app/validators/json_schemas/security_scan_info.json
app/validators/json_schemas/security_scan_info.json
+28
-0
db/migrate/20210308125742_add_info_column_into_security_scans_table.rb
...210308125742_add_info_column_into_security_scans_table.rb
+9
-0
db/schema_migrations/20210308125742
db/schema_migrations/20210308125742
+1
-0
db/structure.sql
db/structure.sql
+2
-1
ee/app/models/security/scan.rb
ee/app/models/security/scan.rb
+1
-0
ee/spec/models/security/scan_spec.rb
ee/spec/models/security/scan_spec.rb
+22
-0
No files found.
app/validators/json_schemas/security_scan_info.json
0 → 100644
View file @
0826891c
{
"$schema"
:
"http://json-schema.org/draft-07/schema#"
,
"type"
:
"object"
,
"title"
:
"Security::Scan#info schema"
,
"description"
:
"The schema validates the content of the Security::Scan#info attribute"
,
"additionalProperties"
:
false
,
"properties"
:
{
"errors"
:
{
"type"
:
"array"
,
"items"
:
{
"type"
:
"object"
,
"additionalProperties"
:
false
,
"properties"
:
{
"type"
:
{
"type"
:
"string"
},
"message"
:
{
"type"
:
"string"
}
},
"required"
:
[
"type"
,
"message"
]
}
}
}
}
db/migrate/20210308125742_add_info_column_into_security_scans_table.rb
0 → 100644
View file @
0826891c
# frozen_string_literal: true
class
AddInfoColumnIntoSecurityScansTable
<
ActiveRecord
::
Migration
[
6.0
]
DOWNTIME
=
false
def
change
add_column
:security_scans
,
:info
,
:jsonb
,
null:
false
,
default:
{}
end
end
db/schema_migrations/20210308125742
0 → 100644
View file @
0826891c
a81f3555d0e1159569687d4967edcd2b5706cdafd5defb8dc725e295eb969861
\ No newline at end of file
db/structure.sql
View file @
0826891c
...
...
@@ -17243,7 +17243,8 @@ CREATE TABLE security_scans (
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
build_id bigint NOT NULL,
scan_type smallint NOT NULL
scan_type smallint NOT NULL,
info jsonb DEFAULT '{}'::jsonb NOT NULL
);
CREATE SEQUENCE security_scans_id_seq
ee/app/models/security/scan.rb
View file @
0826891c
...
...
@@ -8,6 +8,7 @@ module Security
validates
:build_id
,
presence:
true
validates
:scan_type
,
presence:
true
validates
:info
,
json_schema:
{
filename:
'security_scan_info'
,
draft:
7
}
belongs_to
:build
,
class_name:
'Ci::Build'
...
...
ee/spec/models/security/scan_spec.rb
View file @
0826891c
...
...
@@ -12,6 +12,28 @@ RSpec.describe Security::Scan do
describe
'validations'
do
it
{
is_expected
.
to
validate_presence_of
(
:build_id
)
}
it
{
is_expected
.
to
validate_presence_of
(
:scan_type
)
}
describe
'info'
do
let
(
:scan
)
{
build
(
:security_scan
,
info:
info
)
}
subject
{
scan
.
errors
.
details
[
:info
]
}
before
do
scan
.
validate
end
context
'when the value for info field is valid'
do
let
(
:info
)
{
{
errors:
[{
type:
'Foo'
,
message:
'Message'
}]
}
}
it
{
is_expected
.
to
be_empty
}
end
context
'when the value for info field is invalid'
do
let
(
:info
)
{
{
errors:
[{
type:
'Foo'
}]
}
}
it
{
is_expected
.
not_to
be_empty
}
end
end
end
describe
'#project'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment