From e923c67b06d2449f35fa7373c9562a68c17df31d Mon Sep 17 00:00:00 2001 From: Mathieu Suen Date: Mon, 21 Mar 2022 14:20:27 +0100 Subject: [PATCH] SONAR-16155 Adding filter on security report link to hotspot page --- .../security-hotspots/SecurityHotspotsApp.tsx | 1 + .../src/main/js/helpers/__tests__/urls-test.ts | 16 +++++++++++++++- server/sonar-web/src/main/js/helpers/urls.ts | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) 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 f8a2a7dbe5f..e774afc2b45 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 @@ -447,6 +447,7 @@ export class SecurityHotspotsApp extends React.PureComponent { [SecurityStandard.OWASP_TOP10]: undefined, [SecurityStandard.SANS_TOP25]: undefined, [SecurityStandard.SONARSOURCE]: undefined, + [SecurityStandard.OWASP_TOP10_2021]: undefined, file: undefined } }); diff --git a/server/sonar-web/src/main/js/helpers/__tests__/urls-test.ts b/server/sonar-web/src/main/js/helpers/__tests__/urls-test.ts index 63fc209c51f..81cfc0f0fa8 100644 --- a/server/sonar-web/src/main/js/helpers/__tests__/urls-test.ts +++ b/server/sonar-web/src/main/js/helpers/__tests__/urls-test.ts @@ -20,6 +20,7 @@ import { AlmKeys } from '../../types/alm-settings'; import { ComponentQualifier } from '../../types/component'; import { IssueType } from '../../types/issues'; +import { SecurityStandard } from '../../types/security'; import { mockBranch, mockMainBranch, mockPullRequest } from '../mocks/branch-like'; import { convertGithubApiUrlToLink, @@ -88,11 +89,24 @@ describe('#getComponentSecurityHotspotsUrl', () => { expect( getComponentSecurityHotspotsUrl(SIMPLE_COMPONENT_KEY, { sinceLeakPeriod: 'true', + [SecurityStandard.OWASP_TOP10_2021]: 'a1', + [SecurityStandard.CWE]: 'a1', + [SecurityStandard.OWASP_TOP10]: 'a1', + [SecurityStandard.SANS_TOP25]: 'a1', + [SecurityStandard.SONARSOURCE]: 'a1', ignoredParam: '1234' }) ).toEqual({ pathname: '/security_hotspots', - query: { id: SIMPLE_COMPONENT_KEY, sinceLeakPeriod: 'true' } + query: { + id: SIMPLE_COMPONENT_KEY, + [SecurityStandard.OWASP_TOP10_2021]: 'a1', + [SecurityStandard.CWE]: 'a1', + [SecurityStandard.OWASP_TOP10]: 'a1', + [SecurityStandard.SANS_TOP25]: 'a1', + [SecurityStandard.SONARSOURCE]: 'a1', + sinceLeakPeriod: 'true' + } }); }); }); diff --git a/server/sonar-web/src/main/js/helpers/urls.ts b/server/sonar-web/src/main/js/helpers/urls.ts index cfcf6564696..3051feb0f29 100644 --- a/server/sonar-web/src/main/js/helpers/urls.ts +++ b/server/sonar-web/src/main/js/helpers/urls.ts @@ -144,6 +144,7 @@ export function getComponentSecurityHotspotsUrl(componentKey: string, query: Que assignedToMe, file, ...pick(query, [ + SecurityStandard.OWASP_TOP10_2021, SecurityStandard.SONARSOURCE, SecurityStandard.OWASP_TOP10, SecurityStandard.SANS_TOP25, -- 2.39.5