this.setState({ showCWE: checked }, this.fetchSecurityHotspots);
};
+ renderAdditionalRulesMessage = () => {
+ const { component } = this.props;
+ const { findings, type } = this.state;
+ if (findings.length === 0) {
+ return null;
+ }
+
+ const total = findings.map(f => f.totalRules).reduce((sum, count) => sum + count);
+ const active = findings.map(f => f.activeRules).reduce((sum, count) => sum + count);
+ if (active === total) {
+ return null;
+ }
+
+ const standard = translate('security_reports', type, 'page');
+ return (
+ <div className="alert alert-info spacer-top display-inline-block">
+ <FormattedMessage
+ defaultMessage={translate('security_reports.info')}
+ id="security_reports.info"
+ tagName="p"
+ values={{
+ link: (
+ <Link
+ to={getRulesUrl(
+ { types: [RuleType.Vulnerability, RuleType.Hotspot].join() },
+ isSonarCloud() ? component.organization : undefined
+ )}>
+ {translate('security_reports.info.link')}
+ </Link>
+ ),
+ standard,
+ total: total - active
+ }}
+ />
+ </div>
+ );
+ };
+
render() {
const { branchLike, component, params } = this.props;
const { loading, findings, showCWE, type } = this.state;
to={{ pathname: '/documentation/user-guide/security-reports/' }}>
{translate('learn_more')}
</Link>
- <div className="alert alert-info spacer-top display-inline-block">
- <FormattedMessage
- defaultMessage={translate('security_reports.info')}
- id="security_reports.info"
- tagName="p"
- values={{
- link: (
- <Link
- to={getRulesUrl(
- { types: [RuleType.Vulnerability, RuleType.Hotspot].join() },
- isSonarCloud() ? component.organization : undefined
- )}>
- {translate('security_reports.info.link')}
- </Link>
- )
- }}
- />
- </div>
+ {this.renderAdditionalRulesMessage()}
</div>
</header>
<div className="display-inline-flex-center">
toReviewSecurityHotspots: 8,
openSecurityHotspots: 100,
wontFixSecurityHotspots: 10
+ },
+ {
+ activeRules: 0,
+ totalRules: 1,
+ category: 'a3',
+ vulnerabilities: 3,
+ vulnerabiliyRating: 3,
+ toReviewSecurityHotspots: 8,
+ openSecurityHotspots: 100,
+ wontFixSecurityHotspots: 10
}
]
});
expect(wrapper).toMatchSnapshot();
});
-it('renders owaspTop10', () => {
+it('renders owaspTop10', async () => {
const wrapper = shallow(<App component={component} location={location} params={owaspParams} />, {
context
});
+ await waitAndUpdate(wrapper);
expect(getSecurityHotspots).toBeCalledWith({
project: 'foo',
standard: 'owaspTop10',
>
learn_more
</Link>
- <div
- className="alert alert-info spacer-top display-inline-block"
- >
- <FormattedMessage
- defaultMessage="security_reports.info"
- id="security_reports.info"
- tagName="p"
- values={
- Object {
- "link": <Link
- onlyActiveOnIndex={false}
- style={Object {}}
- to={
- Object {
- "pathname": "/coding_rules",
- "query": Object {
- "types": "VULNERABILITY,SECURITY_HOTSPOT",
- },
- }
- }
- >
- security_reports.info.link
- </Link>,
- }
- }
- />
- </div>
</div>
</header>
<div
>
security_reports.info.link
</Link>,
+ "standard": "security_reports.owaspTop10.page",
+ "total": 1,
}
}
/>
"vulnerabiliyRating": 3,
"wontFixSecurityHotspots": 10,
},
+ Object {
+ "activeRules": 0,
+ "category": "a3",
+ "openSecurityHotspots": 100,
+ "toReviewSecurityHotspots": 8,
+ "totalRules": 1,
+ "vulnerabilities": 3,
+ "vulnerabiliyRating": 3,
+ "wontFixSecurityHotspots": 10,
+ },
]
}
showCWE={true}
>
security_reports.info.link
</Link>,
+ "standard": "security_reports.owaspTop10.page",
+ "total": 1,
}
}
/>
<Checkbox
checked={false}
className="spacer-left spacer-right vertical-middle"
- disabled={true}
+ disabled={false}
id="showCWE"
onCheck={[Function]}
thirdState={false}
</Checkbox>
</div>
<DeferredSpinner
- loading={true}
+ loading={false}
timeout={100}
>
<VulnerabilityList
"qualifier": "TRK",
}
}
- findings={Array []}
+ findings={
+ Array [
+ Object {
+ "activeRules": 1,
+ "category": "a1",
+ "distribution": Array [
+ Object {
+ "cwe": "477",
+ "openSecurityHotspots": 10,
+ "toReviewSecurityHotspots": 2,
+ "vulnerabilities": 1,
+ "vulnerabiliyRating": 1,
+ "wontFixSecurityHotspots": 0,
+ },
+ Object {
+ "cwe": "396",
+ "openSecurityHotspots": 10,
+ "toReviewSecurityHotspots": 2,
+ "vulnerabilities": 2,
+ "vulnerabiliyRating": 2,
+ "wontFixSecurityHotspots": 0,
+ },
+ ],
+ "openSecurityHotspots": 10,
+ "toReviewSecurityHotspots": 2,
+ "totalRules": 1,
+ "vulnerabilities": 2,
+ "vulnerabiliyRating": 5,
+ "wontFixSecurityHotspots": 0,
+ },
+ Object {
+ "activeRules": 1,
+ "category": "a2",
+ "openSecurityHotspots": 100,
+ "toReviewSecurityHotspots": 8,
+ "totalRules": 1,
+ "vulnerabilities": 3,
+ "vulnerabiliyRating": 3,
+ "wontFixSecurityHotspots": 10,
+ },
+ Object {
+ "activeRules": 0,
+ "category": "a3",
+ "openSecurityHotspots": 100,
+ "toReviewSecurityHotspots": 8,
+ "totalRules": 1,
+ "vulnerabilities": 3,
+ "vulnerabiliyRating": 3,
+ "wontFixSecurityHotspots": 10,
+ },
+ ]
+ }
showCWE={false}
type="owaspTop10"
/>
>
learn_more
</Link>
- <div
- className="alert alert-info spacer-top display-inline-block"
- >
- <FormattedMessage
- defaultMessage="security_reports.info"
- id="security_reports.info"
- tagName="p"
- values={
- Object {
- "link": <Link
- onlyActiveOnIndex={false}
- style={Object {}}
- to={
- Object {
- "pathname": "/coding_rules",
- "query": Object {
- "types": "VULNERABILITY,SECURITY_HOTSPOT",
- },
- }
- }
- >
- security_reports.info.link
- </Link>,
- }
- }
- />
- </div>
</div>
</header>
<div
>
learn_more
</Link>
- <div
- className="alert alert-info spacer-top display-inline-block"
- >
- <FormattedMessage
- defaultMessage="security_reports.info"
- id="security_reports.info"
- tagName="p"
- values={
- Object {
- "link": <Link
- onlyActiveOnIndex={false}
- style={Object {}}
- to={
- Object {
- "pathname": "/coding_rules",
- "query": Object {
- "types": "VULNERABILITY,SECURITY_HOTSPOT",
- },
- }
- }
- >
- security_reports.info.link
- </Link>,
- }
- }
- />
- </div>
</div>
</header>
<div