Skip to content

Commit 870c6dc

Browse files
committed
WIP: Support rescorings of type finding/falco
1 parent fa0124b commit 870c6dc

File tree

4 files changed

+91
-3
lines changed

4 files changed

+91
-3
lines changed

src/findings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { artefactMetadataFilter } from './ocm/util'
2020
export const FINDING_TYPES = {
2121
CRYPTO: 'finding/crypto',
2222
DIKI: 'finding/diki',
23+
FALCO: 'finding/falco',
2324
LICENSE: 'finding/license',
2425
MALWARE: 'finding/malware',
2526
OSID: 'finding/osid',

src/ocm/model.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ export const dataKey = ({type, data}) => {
166166
if (type === FINDING_TYPES.DIKI) return asKey({
167167
props: [data.provider_id, data.ruleset_id, data.rule_id]
168168
})
169+
170+
if (type === FINDING_TYPES.FALCO) return asKey({
171+
props: [data.finding.group_hash],
172+
})
169173
}
170174

171175

src/rescoring.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,38 @@ DikiExtraInfo.propTypes = {
12331233
}
12341234

12351235

1236+
const FalcoExtraInfo = ({
1237+
finding,
1238+
}) => {
1239+
return <ExtraWideTooltip
1240+
title={
1241+
<div style={{ overflowY: 'auto', maxHeight: '30rem' }}>
1242+
<Typography
1243+
variant='inherit'
1244+
sx={{
1245+
fontWeight: 'bold',
1246+
}}
1247+
marginBottom='0.5rem'
1248+
>
1249+
Properties
1250+
</Typography>
1251+
<Typography variant='inherit' whiteSpace='pre-wrap'>
1252+
{
1253+
JSON.stringify(finding, null, 2)
1254+
}
1255+
</Typography>
1256+
</div>
1257+
}
1258+
>
1259+
<InfoOutlinedIcon sx={{ height: '1rem' }}/>
1260+
</ExtraWideTooltip>
1261+
}
1262+
FalcoExtraInfo.displayName = 'FalcoExtraInfo'
1263+
FalcoExtraInfo.propTypes = {
1264+
finding: PropTypes.object.isRequired,
1265+
}
1266+
1267+
12361268
const Subject = ({
12371269
rescoring,
12381270
ocmNode,
@@ -1310,6 +1342,31 @@ const Subject = ({
13101342
</div>
13111343
</div>
13121344
</Stack>
1345+
} else if (rescoring.finding_type === FINDING_TYPES.FALCO) {
1346+
return <Stack>
1347+
<div style={{ display: 'flex', alignItems: 'center' }}>
1348+
<div>
1349+
<Typography variant='inherit'>
1350+
{
1351+
finding.finding.landscape
1352+
}
1353+
</Typography>
1354+
<Typography variant='inherit' marginRight='0.4rem'>
1355+
{
1356+
`Project: ${finding.finding.project}`
1357+
}
1358+
</Typography>
1359+
<Typography variant='inherit'>Clusters:</Typography>
1360+
{
1361+
finding.finding.clusters.map((cluster, idx) => <Typography key={idx} variant='inherit'>
1362+
{
1363+
`- ${cluster.name}`
1364+
}
1365+
</Typography>)
1366+
}
1367+
</div>
1368+
</div>
1369+
</Stack>
13131370
}
13141371
}
13151372
Subject.displayName = 'Subject'
@@ -1581,6 +1638,15 @@ const Finding = ({
15811638
</Typography>
15821639
</div>
15831640
</Stack>
1641+
} else if (rescoring.finding_type === FINDING_TYPES.FALCO) {
1642+
return <div style={{ display: 'flex' }}>
1643+
<Typography variant='inherit' marginRight='0.4rem'>
1644+
{
1645+
`Rule: ${finding.finding.rule}`
1646+
}
1647+
</Typography>
1648+
<FalcoExtraInfo finding={finding.finding}/>
1649+
</div>
15841650
}
15851651
}
15861652
Finding.displayName = 'Finding'
@@ -2054,6 +2120,17 @@ const RescoringContent = ({
20542120
}).value,
20552121
}
20562122

2123+
const falcoAccess = {
2124+
[orderAttributes.SUBJECT]: rescoring.finding.finding?.landscape,
2125+
[orderAttributes.FINDING]: rescoring.finding.finding?.rule,
2126+
[orderAttributes.SPRINT]: rescoring.sprint ? new Date(rescoring.sprint.end_date) : new Date(8640000000000000),
2127+
[orderAttributes.CURRENT]: categoriseRescoringProposal({rescoring, findingCfg}).value,
2128+
[orderAttributes.RESCORED]: findCategorisationById({
2129+
id: rescoring.severity,
2130+
findingCfg: findingCfg,
2131+
}).value,
2132+
}
2133+
20572134
if (
20582135
rescoringType === FINDING_TYPES.VULNERABILITY
20592136
|| rescoringType === FINDING_TYPES.LICENSE
@@ -2067,6 +2144,8 @@ const RescoringContent = ({
20672144
return cryptoAccess[desired]
20682145
} else if (rescoringType === FINDING_TYPES.DIKI) {
20692146
return dikiAccess[desired]
2147+
} else if (rescoringType === FINDING_TYPES.FALCO) {
2148+
return falcoAccess[desired]
20702149
}
20712150

20722151
}
@@ -2524,6 +2603,10 @@ const Rescore = ({
25242603
ruleset_id: rescoring.finding.ruleset_id,
25252604
rule_id: rescoring.finding.rule_id,
25262605
}
2606+
} else if (type === FINDING_TYPES.FALCO) {
2607+
return {
2608+
group_hash: rescoring.finding.finding.group_hash,
2609+
}
25272610
}
25282611
}
25292612

src/util.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ export const filterRescoringsForFinding = (finding, rescorings) => {
199199
rescoring.data.finding.license.name !== finding.data.license.name
200200
|| rescoring.data.finding.package_name !== finding.data.package_name
201201
) return false
202-
} else if (finding.meta.type === FINDING_TYPES.MALWARE) {
203-
// `malware` has a little special handling here because its findings contain a
204-
// sub-property `finding` whereas its rescoring does not contain this sub-property anymore
202+
} else if ([FINDING_TYPES.MALWARE, FINDING_TYPES.FALCO].includes(finding.meta.type)) {
203+
// `malware` and `falco` have a little special handling here because their findings contain a
204+
// sub-property `finding` whereas their rescoring does not contain this sub-property anymore
205205
if (
206206
dataKey({type: finding.meta.type, data: rescoring.data})
207207
!== dataKey({type: finding.meta.type, data: finding.data})

0 commit comments

Comments
 (0)