Browse Source

SONAR-16245 Place others category at the end

tags/9.5.0.56709
Jeremy Davis 2 years ago
parent
commit
baaa4fd2ce

+ 20
- 20
server/sonar-web/src/main/js/apps/security-hotspots/components/__tests__/__snapshots__/HotspotList-test.tsx.snap View File

<ul> <ul>
<li <li
className="spacer-bottom" className="spacer-bottom"
key="cat2"
key="cat1"
> >
<HotspotCategory <HotspotCategory
categoryKey="cat2"
categoryKey="cat1"
hotspots={ hotspots={
Array [ Array [
Object { Object {
"author": "Developer 1", "author": "Developer 1",
"component": "com.github.kevinsawicki:http-request:com.github.kevinsawicki.http.HttpRequest", "component": "com.github.kevinsawicki:http-request:com.github.kevinsawicki.http.HttpRequest",
"creationDate": "2013-05-13T17:55:39+0200", "creationDate": "2013-05-13T17:55:39+0200",
"key": "h1",
"key": "h2",
"line": 81, "line": 81,
"message": "'3' is a magic number.", "message": "'3' is a magic number.",
"project": "com.github.kevinsawicki:http-request", "project": "com.github.kevinsawicki:http-request",
"resolution": undefined, "resolution": undefined,
"rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck", "rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck",
"securityCategory": "cat2",
"securityCategory": "cat1",
"status": "TO_REVIEW", "status": "TO_REVIEW",
"updateDate": "2013-05-13T17:55:39+0200", "updateDate": "2013-05-13T17:55:39+0200",
"vulnerabilityProbability": "HIGH", "vulnerabilityProbability": "HIGH",
"vulnerabilityProbability": "HIGH", "vulnerabilityProbability": "HIGH",
} }
} }
title="cat2"
title="cat1"
/> />
</li> </li>
<li <li
className="spacer-bottom" className="spacer-bottom"
key="cat1"
key="cat2"
> >
<HotspotCategory <HotspotCategory
categoryKey="cat1"
categoryKey="cat2"
hotspots={ hotspots={
Array [ Array [
Object { Object {
"author": "Developer 1", "author": "Developer 1",
"component": "com.github.kevinsawicki:http-request:com.github.kevinsawicki.http.HttpRequest", "component": "com.github.kevinsawicki:http-request:com.github.kevinsawicki.http.HttpRequest",
"creationDate": "2013-05-13T17:55:39+0200", "creationDate": "2013-05-13T17:55:39+0200",
"key": "h2",
"key": "h1",
"line": 81, "line": 81,
"message": "'3' is a magic number.", "message": "'3' is a magic number.",
"project": "com.github.kevinsawicki:http-request", "project": "com.github.kevinsawicki:http-request",
"resolution": undefined, "resolution": undefined,
"rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck", "rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck",
"securityCategory": "cat1",
"securityCategory": "cat2",
"status": "TO_REVIEW", "status": "TO_REVIEW",
"updateDate": "2013-05-13T17:55:39+0200", "updateDate": "2013-05-13T17:55:39+0200",
"vulnerabilityProbability": "HIGH", "vulnerabilityProbability": "HIGH",
"vulnerabilityProbability": "HIGH", "vulnerabilityProbability": "HIGH",
} }
} }
title="cat1"
title="cat2"
/> />
</li> </li>
</ul> </ul>
<ul> <ul>
<li <li
className="spacer-bottom" className="spacer-bottom"
key="cat2"
key="cat1"
> >
<HotspotCategory <HotspotCategory
categoryKey="cat2"
categoryKey="cat1"
hotspots={ hotspots={
Array [ Array [
Object { Object {
"author": "Developer 1", "author": "Developer 1",
"component": "com.github.kevinsawicki:http-request:com.github.kevinsawicki.http.HttpRequest", "component": "com.github.kevinsawicki:http-request:com.github.kevinsawicki.http.HttpRequest",
"creationDate": "2013-05-13T17:55:39+0200", "creationDate": "2013-05-13T17:55:39+0200",
"key": "h1",
"key": "h2",
"line": 81, "line": 81,
"message": "'3' is a magic number.", "message": "'3' is a magic number.",
"project": "com.github.kevinsawicki:http-request", "project": "com.github.kevinsawicki:http-request",
"resolution": undefined, "resolution": undefined,
"rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck", "rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck",
"securityCategory": "cat2",
"securityCategory": "cat1",
"status": "TO_REVIEW", "status": "TO_REVIEW",
"updateDate": "2013-05-13T17:55:39+0200", "updateDate": "2013-05-13T17:55:39+0200",
"vulnerabilityProbability": "HIGH", "vulnerabilityProbability": "HIGH",
"vulnerabilityProbability": "HIGH", "vulnerabilityProbability": "HIGH",
} }
} }
title="cat2"
title="cat1"
/> />
</li> </li>
<li <li
className="spacer-bottom" className="spacer-bottom"
key="cat1"
key="cat2"
> >
<HotspotCategory <HotspotCategory
categoryKey="cat1"
categoryKey="cat2"
hotspots={ hotspots={
Array [ Array [
Object { Object {
"author": "Developer 1", "author": "Developer 1",
"component": "com.github.kevinsawicki:http-request:com.github.kevinsawicki.http.HttpRequest", "component": "com.github.kevinsawicki:http-request:com.github.kevinsawicki.http.HttpRequest",
"creationDate": "2013-05-13T17:55:39+0200", "creationDate": "2013-05-13T17:55:39+0200",
"key": "h2",
"key": "h1",
"line": 81, "line": 81,
"message": "'3' is a magic number.", "message": "'3' is a magic number.",
"project": "com.github.kevinsawicki:http-request", "project": "com.github.kevinsawicki:http-request",
"resolution": undefined, "resolution": undefined,
"rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck", "rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck",
"securityCategory": "cat1",
"securityCategory": "cat2",
"status": "TO_REVIEW", "status": "TO_REVIEW",
"updateDate": "2013-05-13T17:55:39+0200", "updateDate": "2013-05-13T17:55:39+0200",
"vulnerabilityProbability": "HIGH", "vulnerabilityProbability": "HIGH",
"vulnerabilityProbability": "HIGH", "vulnerabilityProbability": "HIGH",
} }
} }
title="cat1"
title="cat2"
/> />
</li> </li>
</ul> </ul>

+ 11
- 1
server/sonar-web/src/main/js/apps/security-hotspots/utils.ts View File

StandardSecurityCategories StandardSecurityCategories
} from '../../types/types'; } from '../../types/types';


const OTHERS_SECURITY_CATEGORY = 'others';

export const RISK_EXPOSURE_LEVELS = [RiskExposure.HIGH, RiskExposure.MEDIUM, RiskExposure.LOW]; export const RISK_EXPOSURE_LEVELS = [RiskExposure.HIGH, RiskExposure.MEDIUM, RiskExposure.LOW];
export const SECURITY_STANDARDS = [ export const SECURITY_STANDARDS = [
SecurityStandard.SONARSOURCE, SecurityStandard.SONARSOURCE,
) { ) {
const groups = groupBy(hotspots, h => h.securityCategory); const groups = groupBy(hotspots, h => h.securityCategory);


return Object.keys(groups).map(key => ({
const groupList = Object.keys(groups).map(key => ({
key, key,
title: getCategoryTitle(key, securityCategories), title: getCategoryTitle(key, securityCategories),
hotspots: groups[key] hotspots: groups[key]
})); }));

return [
...sortBy(
groupList.filter(group => group.key !== OTHERS_SECURITY_CATEGORY),
group => group.title
),
...groupList.filter(({ key }) => key === OTHERS_SECURITY_CATEGORY)
];
} }


export function sortHotspots(hotspots: RawHotspot[], securityCategories: Dict<{ title: string }>) { export function sortHotspots(hotspots: RawHotspot[], securityCategories: Dict<{ title: string }>) {

Loading…
Cancel
Save