diff options
Diffstat (limited to 'server/sonar-web/src/main/js/apps/issues')
4 files changed, 45 insertions, 16 deletions
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 2b4751b9b8e..39e584cb163 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 @@ -53,6 +53,8 @@ describe('serialize/deserialize', () => { languages: ['a', 'b'], owaspTop10: ['a', 'b'], 'owaspTop10-2021': ['a', 'b'], + 'pciDss-3.2': ['a', 'b'], + 'pciDss-4.0': ['a', 'b'], projects: ['a', 'b'], resolutions: ['a', 'b'], resolved: true, @@ -81,6 +83,8 @@ describe('serialize/deserialize', () => { languages: 'a,b', owaspTop10: 'a,b', 'owaspTop10-2021': 'a,b', + 'pciDss-3.2': 'a,b', + 'pciDss-4.0': 'a,b', 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 65ca848f341..7bb7a106350 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 @@ -140,6 +140,8 @@ exports[`should show warnning when not all projects are accessible 1`] = ` "languages": Array [], "owaspTop10": Array [], "owaspTop10-2021": Array [], + "pciDss-3.2": Array [], + "pciDss-4.0": Array [], "projects": Array [], "resolutions": Array [], "resolved": true, diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx index ca13e67a7e3..b093d6a73e1 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx @@ -40,7 +40,7 @@ import { renderSonarSourceSecurityCategory } from '../../../helpers/security-standard'; import { Facet } from '../../../types/issues'; -import { SecurityStandard, Standards, StandardType } from '../../../types/security'; +import { SecurityStandard, Standards } from '../../../types/security'; import { Dict } from '../../../types/types'; import { formatFacetStat, Query, STANDARDS } from '../utils'; @@ -83,7 +83,7 @@ type StatsProp = | 'cweStats' | 'sansTop25Stats' | 'sonarsourceSecurityStats'; -type ValuesProp = StandardType; +type ValuesProp = 'owaspTop10-2021' | 'owaspTop10' | 'sansTop25' | 'sonarsourceSecurity' | 'cwe'; const INITIAL_FACET_COUNT = 15; export default class StandardFacet extends React.PureComponent<Props, State> { @@ -96,7 +96,9 @@ export default class StandardFacet extends React.PureComponent<Props, State> { 'owaspTop10-2021': {}, sansTop25: {}, cwe: {}, - sonarsourceSecurity: {} + sonarsourceSecurity: {}, + 'pciDss-3.2': {}, + 'pciDss-4.0': {} } }; @@ -133,7 +135,9 @@ export default class StandardFacet extends React.PureComponent<Props, State> { owaspTop10, sansTop25, cwe, - sonarsourceSecurity + sonarsourceSecurity, + 'pciDss-3.2': pciDss3_2, + 'pciDss-4.0': pciDss4_0 }: Standards) => { if (this.mounted) { this.setState({ @@ -142,7 +146,9 @@ export default class StandardFacet extends React.PureComponent<Props, State> { owaspTop10, sansTop25, cwe, - sonarsourceSecurity + sonarsourceSecurity, + 'pciDss-3.2': pciDss3_2, + 'pciDss-4.0': pciDss4_0 } }); } 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 e89d4b011ca..2ace6b60664 100644 --- a/server/sonar-web/src/main/js/apps/issues/utils.ts +++ b/server/sonar-web/src/main/js/apps/issues/utils.ts @@ -35,7 +35,7 @@ import { scrollToElement } from '../../helpers/scrolling'; import { get, save } from '../../helpers/storage'; import { isDefined } from '../../helpers/types'; import { Facet, RawFacet } from '../../types/issues'; -import { SecurityStandard, StandardType } from '../../types/security'; +import { SecurityStandard } from '../../types/security'; import { Dict, Issue, Paging, RawQuery } from '../../types/types'; import { UserBase } from '../../types/users'; @@ -54,6 +54,8 @@ export interface Query { languages: string[]; owaspTop10: string[]; 'owaspTop10-2021': string[]; + 'pciDss-3.2': string[]; + 'pciDss-4.0': string[]; projects: string[]; resolutions: string[]; resolved: boolean; @@ -70,12 +72,6 @@ export interface Query { } export const STANDARDS = 'standards'; -export const STANDARD_TYPES: StandardType[] = [ - SecurityStandard.OWASP_TOP10, - SecurityStandard.SANS_TOP25, - SecurityStandard.CWE, - SecurityStandard.SONARSOURCE -]; // allow sorting by CREATION_DATE only const parseAsSort = (sort: string) => (sort === 'CREATION_DATE' ? 'CREATION_DATE' : ''); @@ -93,10 +89,13 @@ export function parseQuery(query: RawQuery): Query { cwe: parseAsArray(query.cwe, parseAsString), directories: parseAsArray(query.directories, parseAsString), files: parseAsArray(query.files, parseAsString), + inNewCodePeriod: parseAsBoolean(query.inNewCodePeriod, false), issues: parseAsArray(query.issues, parseAsString), languages: parseAsArray(query.languages, parseAsString), owaspTop10: parseAsArray(query.owaspTop10, parseAsString), 'owaspTop10-2021': parseAsArray(query['owaspTop10-2021'], parseAsString), + 'pciDss-3.2': parseAsArray(query['pciDss-3.2'], parseAsString), + 'pciDss-4.0': parseAsArray(query['pciDss-4.0'], parseAsString), projects: parseAsArray(query.projects, parseAsString), resolutions: parseAsArray(query.resolutions, parseAsString), resolved: parseAsBoolean(query.resolved), @@ -104,7 +103,6 @@ export function parseQuery(query: RawQuery): Query { sansTop25: parseAsArray(query.sansTop25, parseAsString), scopes: parseAsArray(query.scopes, parseAsString), severities: parseAsArray(query.severities, parseAsString), - inNewCodePeriod: parseAsBoolean(query.inNewCodePeriod, false), sonarsourceSecurity: parseAsArray(query.sonarsourceSecurity, parseAsString), sort: parseAsSort(query.s), statuses: parseAsArray(query.statuses, parseAsString), @@ -140,6 +138,8 @@ export function serializeQuery(query: Query): RawQuery { languages: serializeStringArray(query.languages), owaspTop10: serializeStringArray(query.owaspTop10), 'owaspTop10-2021': serializeStringArray(query['owaspTop10-2021']), + 'pciDss-3.2': serializeStringArray(query['pciDss-3.2']), + 'pciDss-4.0': serializeStringArray(query['pciDss-4.0']), projects: serializeStringArray(query.projects), resolutions: serializeStringArray(query.resolutions), resolved: query.resolved ? undefined : 'false', @@ -257,7 +257,12 @@ export function shouldOpenStandardsFacet( export function shouldOpenStandardsChildFacet( openFacets: Dict<boolean>, query: Partial<Query>, - standardType: SecurityStandard + standardType: + | SecurityStandard.CWE + | SecurityStandard.OWASP_TOP10 + | SecurityStandard.OWASP_TOP10_2021 + | SecurityStandard.SANS_TOP25 + | SecurityStandard.SONARSOURCE ): boolean { const filter = query[standardType]; return ( @@ -283,7 +288,19 @@ function isFilteredBySecurityIssueTypes(query: Partial<Query>): boolean { } function isOneStandardChildFacetOpen(openFacets: Dict<boolean>, query: Partial<Query>): boolean { - return STANDARD_TYPES.some(standardType => - shouldOpenStandardsChildFacet(openFacets, query, standardType) + return [ + SecurityStandard.OWASP_TOP10, + SecurityStandard.SANS_TOP25, + SecurityStandard.CWE, + SecurityStandard.SONARSOURCE + ].some( + ( + standardType: + | SecurityStandard.CWE + | SecurityStandard.OWASP_TOP10 + | SecurityStandard.OWASP_TOP10_2021 + | SecurityStandard.SANS_TOP25 + | SecurityStandard.SONARSOURCE + ) => shouldOpenStandardsChildFacet(openFacets, query, standardType) ); } |