Commit 4d65dbd9 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '254637-update-getters-count' into 'master'

Update getter in group security reports

Closes #254637

See merge request gitlab-org/gitlab!43531
parents 185b5541 dd1533c0
......@@ -44,6 +44,7 @@ export const summaryCounts = ({
dependencyScanning,
sast,
secretScanning,
coverageFuzzing,
} = {}) => {
const allNewVulns = [
...containerScanning.newIssues,
......@@ -51,6 +52,7 @@ export const summaryCounts = ({
...dependencyScanning.newIssues,
...sast.newIssues,
...secretScanning.newIssues,
...coverageFuzzing.newIssues,
];
return countVulnerabilities(allNewVulns);
......@@ -123,49 +125,56 @@ export const areReportsLoading = state =>
state.dast.isLoading ||
state.containerScanning.isLoading ||
state.dependencyScanning.isLoading ||
state.secretScanning.isLoading;
state.secretScanning.isLoading ||
state.coverageFuzzing.isLoading;
export const areAllReportsLoading = state =>
state.sast.isLoading &&
state.dast.isLoading &&
state.containerScanning.isLoading &&
state.dependencyScanning.isLoading &&
state.secretScanning.isLoading;
state.secretScanning.isLoading &&
state.coverageFuzzing.isLoading;
export const allReportsHaveError = state =>
state.sast.hasError &&
state.dast.hasError &&
state.containerScanning.hasError &&
state.dependencyScanning.hasError &&
state.secretScanning.hasError;
state.secretScanning.hasError &&
state.coverageFuzzing.hasError;
export const anyReportHasError = state =>
state.sast.hasError ||
state.dast.hasError ||
state.containerScanning.hasError ||
state.dependencyScanning.hasError ||
state.secretScanning.hasError;
state.secretScanning.hasError ||
state.coverageFuzzing.hasError;
export const noBaseInAllReports = state =>
!state.sast.hasBaseReport &&
!state.dast.hasBaseReport &&
!state.containerScanning.hasBaseReport &&
!state.dependencyScanning.hasBaseReport &&
!state.secretScanning.hasBaseReport;
!state.secretScanning.hasBaseReport &&
!state.coverageFuzzing.hasBaseReport;
export const anyReportHasIssues = state =>
state.sast.newIssues.length > 0 ||
state.dast.newIssues.length > 0 ||
state.containerScanning.newIssues.length > 0 ||
state.dependencyScanning.newIssues.length > 0 ||
state.secretScanning.newIssues.length > 0;
state.secretScanning.newIssues.length > 0 ||
state.coverageFuzzing.newIssues.length > 0;
export const isBaseSecurityReportOutOfDate = state =>
state.sast.baseReportOutofDate ||
state.dast.baseReportOutofDate ||
state.containerScanning.baseReportOutofDate ||
state.dependencyScanning.baseReportOutofDate ||
state.secretScanning.baseReportOutofDate;
state.secretScanning.baseReportOutofDate ||
state.coverageFuzzing.baseReportOutofDate;
export const canCreateIssue = state => Boolean(state.createVulnerabilityFeedbackIssuePath);
......
......@@ -273,7 +273,7 @@ describe('Grouped security reports app', () => {
// Renders the summary text
expect(wrapper.vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual(
'Security scanning detected 5 critical and 3 high severity vulnerabilities.',
'Security scanning detected 6 critical and 4 high severity vulnerabilities.',
);
// Renders the expand button
......
......@@ -5,6 +5,7 @@ import {
groupedDastText,
groupedDependencyText,
groupedSecretScanningText,
groupedCoverageFuzzingText,
groupedSummaryText,
allReportsHaveError,
noBaseInAllReports,
......@@ -44,6 +45,7 @@ describe('Security reports getters', () => {
${'Dependency scanning'} | ${'dependencyScanning'} | ${groupedDependencyText}
${'Container scanning'} | ${'containerScanning'} | ${groupedContainerScanningText}
${'DAST'} | ${'dast'} | ${groupedDastText}
${'Coverage fuzzing'} | ${'coverageFuzzing'} | ${groupedCoverageFuzzingText}
`('grouped text for $name', ({ name, scanner, getter }) => {
describe('with no issues', () => {
it('returns no issues text', () => {
......@@ -79,9 +81,10 @@ describe('Security reports getters', () => {
state.containerScanning.newIssues = [generateVuln(CRITICAL)];
state.dast.newIssues = [generateVuln(CRITICAL)];
state.dependencyScanning.newIssues = [generateVuln(CRITICAL)];
state.coverageFuzzing.newIssues = [generateVuln(CRITICAL)];
expect(summaryCounts(state)).toEqual({
critical: 3,
critical: 4,
high: 0,
other: 0,
});
......@@ -91,10 +94,11 @@ describe('Security reports getters', () => {
state.containerScanning.newIssues = [generateVuln(CRITICAL)];
state.dast.newIssues = [generateVuln(CRITICAL), generateVuln(HIGH)];
state.dependencyScanning.newIssues = [generateVuln(LOW)];
state.coverageFuzzing.newIssues = [generateVuln(HIGH)];
expect(summaryCounts(state)).toEqual({
critical: 2,
high: 1,
high: 2,
other: 1,
});
});
......@@ -221,6 +225,7 @@ describe('Security reports getters', () => {
state.containerScanning.hasError = true;
state.dependencyScanning.hasError = true;
state.secretScanning.hasError = true;
state.coverageFuzzing.hasError = true;
expect(allReportsHaveError(state)).toEqual(true);
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment