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
7c5a5558
Commit
7c5a5558
authored
Mar 30, 2020
by
Michał Zając
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check that all properties are returned correctly
parent
c0f4f041
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
14 deletions
+44
-14
ee/spec/factories/vulnerabilities.rb
ee/spec/factories/vulnerabilities.rb
+9
-1
ee/spec/factories/vulnerabilities/occurrences.rb
ee/spec/factories/vulnerabilities/occurrences.rb
+13
-0
ee/spec/helpers/ee/vulnerabilities_helper_spec.rb
ee/spec/helpers/ee/vulnerabilities_helper_spec.rb
+22
-13
No files found.
ee/spec/factories/vulnerabilities.rb
View file @
7c5a5558
...
@@ -43,12 +43,20 @@ FactoryBot.define do
...
@@ -43,12 +43,20 @@ FactoryBot.define do
trait
:with_findings
do
trait
:with_findings
do
after
(
:build
)
do
|
vulnerability
|
after
(
:build
)
do
|
vulnerability
|
vulnerability
.
findings
=
build_list
(
occurrences_with_solution
=
build_list
(
:vulnerabilities_occurrence
,
:vulnerabilities_occurrence
,
2
,
2
,
vulnerability:
vulnerability
,
vulnerability:
vulnerability
,
report_type:
vulnerability
.
report_type
,
report_type:
vulnerability
.
report_type
,
project:
vulnerability
.
project
)
project:
vulnerability
.
project
)
occurrences_with_remediation
=
build_list
(
:vulnerabilities_occurrence
,
2
,
:with_remediation
,
vulnerability:
vulnerability
,
report_type:
vulnerability
.
report_type
,
project:
vulnerability
.
project
)
vulnerability
.
findings
=
occurrences_with_solution
+
occurrences_with_remediation
end
end
end
end
...
...
ee/spec/factories/vulnerabilities/occurrences.rb
View file @
7c5a5558
...
@@ -69,6 +69,19 @@ FactoryBot.define do
...
@@ -69,6 +69,19 @@ FactoryBot.define do
end
end
end
end
trait
:with_remediation
do
after
(
:build
)
do
|
finding
|
raw_metadata
=
JSON
.
parse
(
finding
.
raw_metadata
)
raw_metadata
.
delete
(
:solution
)
raw_metadata
[
:remediations
]
=
[
{
summary:
"Use GCM mode which includes HMAC in the resulting encrypted data, providing integrity of the result."
}
]
finding
.
raw_metadata
=
raw_metadata
.
to_json
end
end
::
Vulnerabilities
::
Occurrence
::
REPORT_TYPES
.
keys
.
each
do
|
security_report_type
|
::
Vulnerabilities
::
Occurrence
::
REPORT_TYPES
.
keys
.
each
do
|
security_report_type
|
trait
security_report_type
do
trait
security_report_type
do
report_type
{
security_report_type
}
report_type
{
security_report_type
}
...
...
ee/spec/helpers/ee/vulnerabilities_helper_spec.rb
View file @
7c5a5558
...
@@ -57,21 +57,30 @@ describe VulnerabilitiesHelper do
...
@@ -57,21 +57,30 @@ describe VulnerabilitiesHelper do
subject
{
helper
.
vulnerability_finding_data
(
finding
)
}
subject
{
helper
.
vulnerability_finding_data
(
finding
)
}
it
'returns finding information'
do
it
"returns finding information"
do
puts
finding
.
to_json
expect
(
subject
[
:name
]).
not_to
be_nil
expect
(
subject
[
:description
]).
not_to
be_nil
expect
(
subject
).
to
include
(
expect
(
subject
).
to
include
(
:solution
=>
finding
.
solution
,
description:
finding
.
description
,
:remediation
=>
nil
,
identifiers:
finding
.
identifiers
,
:issue_feedback
=>
finding
.
issue_feedback
,
links:
finding
.
links
,
:project
=>
finding
.
project
,
location:
finding
.
location
,
:description
=>
finding
.
description
,
name:
finding
.
name
:identifiers
=>
finding
.
identifiers
,
:links
=>
finding
.
links
,
:location
=>
finding
.
location
,
:name
=>
finding
.
name
)
)
end
end
context
"when finding has a remediations key"
do
let
(
:finding
)
{
vulnerability
.
findings
.
select
{
|
finding
|
finding
.
raw_metadata
.
include?
(
"remediations"
)
}.
first
}
it
"uses the first remediation summary"
do
expect
(
subject
[
:solution
]).
to
start_with
"Use GCM mode"
end
end
context
"when finding has a solution key"
do
let
(
:finding
)
{
vulnerability
.
findings
.
select
{
|
finding
|
finding
.
raw_metadata
.
include?
(
"solution"
)
}.
first
}
it
"uses the solution key"
do
expect
(
subject
[
:solution
]).
to
start_with
"GCM mode"
end
end
end
end
end
end
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