From 212c08317d8a3a054a32cbf9aa8715d56b1c0384 Mon Sep 17 00:00:00 2001 From: Revanshu Paliwal Date: Wed, 5 Oct 2022 15:31:57 +0200 Subject: [PATCH] SONAR-17399 Adding level selector for OWASP ASVS --- .../sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts | 2 ++ .../components/__tests__/__snapshots__/IssuesApp-test.tsx.snap | 1 + server/sonar-web/src/main/js/apps/issues/utils.ts | 3 +++ .../src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx | 2 ++ server/sonar-web/src/main/js/helpers/urls.ts | 3 ++- 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts b/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts index 2f23a97d038..3b2c8a7c5dc 100644 --- a/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts +++ b/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts @@ -54,6 +54,7 @@ describe('serialize/deserialize', () => { 'pciDss-3.2': ['a', 'b'], 'pciDss-4.0': ['a', 'b'], 'owaspAsvs-4.0': ['2'], + owaspAsvsLevel: '2', projects: ['a', 'b'], resolutions: ['a', 'b'], resolved: true, @@ -85,6 +86,7 @@ describe('serialize/deserialize', () => { 'pciDss-3.2': 'a,b', 'pciDss-4.0': 'a,b', 'owaspAsvs-4.0': '2', + owaspAsvsLevel: '2', projects: 'a,b', resolutions: 'a,b', rules: 'a,b', diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/IssuesApp-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/IssuesApp-test.tsx.snap index 31fcf90c9f7..0be1d5defdf 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/IssuesApp-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/IssuesApp-test.tsx.snap @@ -119,6 +119,7 @@ exports[`should show warnning when not all projects are accessible 1`] = ` "issues": Array [], "languages": Array [], "owaspAsvs-4.0": Array [], + "owaspAsvsLevel": "", "owaspTop10": Array [], "owaspTop10-2021": Array [], "pciDss-3.2": Array [], diff --git a/server/sonar-web/src/main/js/apps/issues/utils.ts b/server/sonar-web/src/main/js/apps/issues/utils.ts index 9eac3657ed8..cd77fa72956 100644 --- a/server/sonar-web/src/main/js/apps/issues/utils.ts +++ b/server/sonar-web/src/main/js/apps/issues/utils.ts @@ -58,6 +58,7 @@ export interface Query { 'pciDss-3.2': string[]; 'pciDss-4.0': string[]; [OWASP_ASVS_4_0]: string[]; + owaspAsvsLevel: string; projects: string[]; resolutions: string[]; resolved: boolean; @@ -99,6 +100,7 @@ export function parseQuery(query: RawQuery): Query { 'pciDss-3.2': parseAsArray(query['pciDss-3.2'], parseAsString), 'pciDss-4.0': parseAsArray(query['pciDss-4.0'], parseAsString), [OWASP_ASVS_4_0]: parseAsArray(query[OWASP_ASVS_4_0], parseAsString), + owaspAsvsLevel: parseAsString(query['owaspAsvsLevel']), projects: parseAsArray(query.projects, parseAsString), resolutions: parseAsArray(query.resolutions, parseAsString), resolved: parseAsBoolean(query.resolved), @@ -144,6 +146,7 @@ export function serializeQuery(query: Query): RawQuery { 'pciDss-3.2': serializeStringArray(query['pciDss-3.2']), 'pciDss-4.0': serializeStringArray(query['pciDss-4.0']), [OWASP_ASVS_4_0]: serializeStringArray(query[OWASP_ASVS_4_0]), + owaspAsvsLevel: serializeString(query['owaspAsvsLevel']), projects: serializeStringArray(query.projects), resolutions: serializeStringArray(query.resolutions), resolved: query.resolved ? undefined : 'false', diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx index d4669b90065..60206865f5c 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx @@ -341,6 +341,8 @@ export class SecurityHotspotsApp extends React.PureComponent { hotspotFilters.files = filterByFile; } + hotspotFilters['owaspAsvsLevel'] = location.query['owaspAsvsLevel']; + return getSecurityHotspots({ ...hotspotFilters, projectKey: component.key, diff --git a/server/sonar-web/src/main/js/helpers/urls.ts b/server/sonar-web/src/main/js/helpers/urls.ts index c7d6cffd444..d8ccb3ecb8b 100644 --- a/server/sonar-web/src/main/js/helpers/urls.ts +++ b/server/sonar-web/src/main/js/helpers/urls.ts @@ -214,7 +214,8 @@ export function getComponentSecurityHotspotsUrl(componentKey: string, query: Que SecurityStandard.CWE, SecurityStandard.PCI_DSS_3_2, SecurityStandard.PCI_DSS_4_0, - SecurityStandard.OWASP_ASVS_4_0 + SecurityStandard.OWASP_ASVS_4_0, + 'owaspAsvsLevel' ]) }), hash: '' -- 2.39.5