renderOwaspTop10Category,
renderSansTop25Category,
renderCWECategory,
- Standards
+ Standards,
+ StandardType
} from '../utils';
import DetachIcon from '../../../components/icons-components/DetachIcon';
import Tooltip from '../../../components/controls/Tooltip';
component: Component;
findings: SecurityHotspot[];
showCWE: boolean;
- type: 'owaspTop10' | 'sansTop25' | 'cwe';
+ type: StandardType;
}
interface State {
standards: Standards;
}
+const STANDARDS_TAGS = {
+ owaspTop10: 'owasp',
+ sansTop25: 'sans-top25',
+ cwe: 'cwe'
+};
+
export default class VulnerabilityList extends React.PureComponent<Props, State> {
mounted = false;
state: State = { standards: { owaspTop10: {}, sansTop25: {}, cwe: {} } };
);
};
- getName(
- finding: SecurityHotspot,
- type: 'owaspTop10' | 'sansTop25' | 'cwe',
- activeRules: number,
- totalRules: number
- ) {
+ getName(finding: SecurityHotspot, type: StandardType, activeRules: number, totalRules: number) {
const category = finding.category || finding.cwe || 'unknown';
const renderers = {
owaspTop10: renderOwaspTop10Category,
/>
)}
{activeRules === 0 &&
- totalRules > 0 && (
- <HelpTooltip className="spacer-left" overlay={this.renderMoreRulesOverlay(totalRules)}>
+ totalRules > 0 &&
+ category !== 'unknown' && (
+ <HelpTooltip
+ className="spacer-left"
+ overlay={this.renderMoreRulesOverlay(totalRules, type, category)}>
<PlusCircleIcon className="vertical-middle" fill={theme.blue} size={12} />
</HelpTooltip>
)}
);
}
- renderMoreRulesOverlay = (totalRules: number) => {
+ // We redirect the user to the rules page, using languages, types, keywords and tags filters
+ // to display the correct list of rules
+ renderMoreRulesOverlay = (totalRules: number, type: StandardType, category: string) => {
const languages = this.props.component.qualityProfiles
? this.props.component.qualityProfiles.map(qp => qp.language).join(',')
: '';
+ let tags;
+ let q;
+ if (type === 'cwe') {
+ q = `${STANDARDS_TAGS[type]}:${category.toLowerCase()}`;
+ tags = 'cwe';
+ } else {
+ tags = `${STANDARDS_TAGS[type]}-${category.toLowerCase()}`;
+ }
return (
<>
<p>{translate('security_reports.activate_rules')}</p>
<Link
className="spacer-left link-no-underline"
to={getRulesUrl(
- { languages, types: `${IssueType.Hotspot},${IssueType.Vulnerability}` },
+ { languages, tags, q, types: `${IssueType.Hotspot},${IssueType.Vulnerability}` },
isSonarCloud() ? this.props.component.organization : undefined
)}>
{translateWithParameters('security_reports.activate_rules.link', totalRules)}