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
1d1e95c8
Commit
1d1e95c8
authored
Jan 02, 2019
by
samdbeckham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reverts the changes to the data model on the GSD
Specifically, the vulnerability counts.
parent
c8094c7c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
10 deletions
+99
-10
ee/app/assets/javascripts/security_dashboard/components/vulnerability_count_list.vue
...ecurity_dashboard/components/vulnerability_count_list.vue
+7
-3
ee/app/assets/javascripts/security_dashboard/store/modules/vulnerabilities/getters.js
...curity_dashboard/store/modules/vulnerabilities/getters.js
+10
-0
ee/spec/javascripts/security_dashboard/components/vulnerability_count_list_spec.js
...ity_dashboard/components/vulnerability_count_list_spec.js
+5
-1
ee/spec/javascripts/security_dashboard/store/vulnerabilities/data/mock_data_vulnerabilities_count.json
...vulnerabilities/data/mock_data_vulnerabilities_count.json
+29
-6
ee/spec/javascripts/security_dashboard/store/vulnerabilities/getters_spec.js
.../security_dashboard/store/vulnerabilities/getters_spec.js
+48
-0
No files found.
ee/app/assets/javascripts/security_dashboard/components/vulnerability_count_list.vue
View file @
1d1e95c8
...
@@ -11,11 +11,15 @@ export default {
...
@@ -11,11 +11,15 @@ export default {
VulnerabilityCount
,
VulnerabilityCount
,
},
},
computed
:
{
computed
:
{
...
mapGetters
(
'
vulnerabilities
'
,
[
'
dashboardCountError
'
,
'
dashboardError
'
]),
...
mapGetters
(
'
vulnerabilities
'
,
[
...
mapState
(
'
vulnerabilities
'
,
[
'
isLoadingVulnerabilitiesCount
'
,
'
vulnerabilitiesCount
'
]),
'
vulnerabilitiesCountBySeverity
'
,
'
dashboardCountError
'
,
'
dashboardError
'
,
]),
...
mapState
(
'
vulnerabilities
'
,
[
'
isLoadingVulnerabilitiesCount
'
]),
counts
()
{
counts
()
{
return
SEVERITIES
.
map
(
severity
=>
{
return
SEVERITIES
.
map
(
severity
=>
{
const
count
=
this
.
vulnerabilitiesCount
[
severity
]
||
0
;
const
count
=
this
.
vulnerabilitiesCount
BySeverity
(
severity
)
;
return
{
severity
,
count
};
return
{
severity
,
count
};
});
});
},
},
...
...
ee/app/assets/javascripts/security_dashboard/store/modules/vulnerabilities/getters.js
View file @
1d1e95c8
import
{
sum
}
from
'
~/lib/utils/number_utils
'
;
export
const
vulnerabilitiesCountBySeverity
=
state
=>
severity
=>
Object
.
values
(
state
.
vulnerabilitiesCount
)
.
map
(
count
=>
count
[
severity
])
.
reduce
(
sum
,
0
);
export
const
vulnerabilitiesCountByReportType
=
state
=>
type
=>
{
const
counts
=
state
.
vulnerabilitiesCount
[
type
];
return
counts
?
Object
.
values
(
counts
).
reduce
(
sum
,
0
)
:
0
;
};
export
const
dashboardError
=
state
=>
export
const
dashboardError
=
state
=>
state
.
errorLoadingVulnerabilities
&&
state
.
errorLoadingVulnerabilitiesCount
;
state
.
errorLoadingVulnerabilities
&&
state
.
errorLoadingVulnerabilitiesCount
;
export
const
dashboardListError
=
state
=>
export
const
dashboardListError
=
state
=>
...
...
ee/spec/javascripts/security_dashboard/components/vulnerability_count_list_spec.js
View file @
1d1e95c8
...
@@ -21,7 +21,11 @@ describe('Vulnerability Count List', () => {
...
@@ -21,7 +21,11 @@ describe('Vulnerability Count List', () => {
});
});
it
(
'
should fetch the counts for each severity
'
,
()
=>
{
it
(
'
should fetch the counts for each severity
'
,
()
=>
{
expect
(
vm
.
counts
[
0
]).
toEqual
({
severity
:
'
critical
'
,
count
:
mockData
.
critical
});
const
{
sast
,
container_scanning
,
dependency_scanning
,
dast
}
=
mockData
;
const
count
=
sast
.
critical
+
container_scanning
.
critical
+
dependency_scanning
.
critical
+
dast
.
critical
;
expect
(
vm
.
counts
[
0
]).
toEqual
({
severity
:
'
critical
'
,
count
});
});
});
it
(
'
should render a counter for each severity
'
,
()
=>
{
it
(
'
should render a counter for each severity
'
,
()
=>
{
...
...
ee/spec/javascripts/security_dashboard/store/vulnerabilities/data/mock_data_vulnerabilities_count.json
View file @
1d1e95c8
{
{
"sast"
:
{
"critical"
:
2
,
"critical"
:
2
,
"high"
:
4
,
"high"
:
4
,
"low"
:
7
,
"low"
:
7
,
"medium"
:
8
,
"medium"
:
8
,
"unknown"
:
0
"unknown"
:
9
},
"container_scanning"
:
{
"critical"
:
3
,
"high"
:
3
,
"low"
:
2
,
"medium"
:
9
,
"unknown"
:
7
},
"dependency_scanning"
:
{
"critical"
:
2
,
"high"
:
3
,
"low"
:
9
,
"medium"
:
4
,
"unknown"
:
7
},
"dast"
:
{
"critical"
:
2
,
"high"
:
3
,
"low"
:
9
,
"medium"
:
4
,
"unknown"
:
7
}
}
}
ee/spec/javascripts/security_dashboard/store/vulnerabilities/getters_spec.js
View file @
1d1e95c8
import
State
from
'
ee/security_dashboard/store/modules/vulnerabilities/state
'
;
import
*
as
getters
from
'
ee/security_dashboard/store/modules/vulnerabilities/getters
'
;
import
*
as
getters
from
'
ee/security_dashboard/store/modules/vulnerabilities/getters
'
;
describe
(
'
vulnerabilities module getters
'
,
()
=>
{
describe
(
'
vulnerabilities module getters
'
,
()
=>
{
const
initialState
=
State
();
describe
(
'
vulnerabilitiesCountBySeverity
'
,
()
=>
{
const
sast
=
{
critical
:
10
};
const
dast
=
{
critical
:
66
};
const
expectedValue
=
sast
.
critical
+
dast
.
critical
;
const
vulnerabilitiesCount
=
{
sast
,
dast
};
const
state
=
{
vulnerabilitiesCount
};
it
(
'
should add up all the counts with `high` severity
'
,
()
=>
{
const
result
=
getters
.
vulnerabilitiesCountBySeverity
(
state
)(
'
critical
'
);
expect
(
result
).
toBe
(
expectedValue
);
});
it
(
'
should return 0 if no counts match the severity name
'
,
()
=>
{
const
result
=
getters
.
vulnerabilitiesCountBySeverity
(
state
)(
'
medium
'
);
expect
(
result
).
toBe
(
0
);
});
it
(
'
should return 0 if there are no counts at all
'
,
()
=>
{
const
result
=
getters
.
vulnerabilitiesCountBySeverity
(
initialState
)(
'
critical
'
);
expect
(
result
).
toBe
(
0
);
});
});
describe
(
'
vulnerabilitiesCountByReportType
'
,
()
=>
{
const
sast
=
{
critical
:
10
,
medium
:
22
};
const
dast
=
{
critical
:
66
};
const
expectedValue
=
sast
.
critical
+
sast
.
medium
;
const
vulnerabilitiesCount
=
{
sast
,
dast
};
const
state
=
{
vulnerabilitiesCount
};
it
(
'
should add up all the counts in the sast report
'
,
()
=>
{
const
result
=
getters
.
vulnerabilitiesCountByReportType
(
state
)(
'
sast
'
);
expect
(
result
).
toBe
(
expectedValue
);
});
it
(
'
should return 0 if there are no reports for a severity type
'
,
()
=>
{
const
result
=
getters
.
vulnerabilitiesCountByReportType
(
initialState
)(
'
sast
'
);
expect
(
result
).
toBe
(
0
);
});
});
describe
(
'
dashboardError
'
,
()
=>
{
describe
(
'
dashboardError
'
,
()
=>
{
it
(
'
should return true when both error states exist
'
,
()
=>
{
it
(
'
should return true when both error states exist
'
,
()
=>
{
const
errorLoadingVulnerabilities
=
true
;
const
errorLoadingVulnerabilities
=
true
;
...
...
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