Skip to content

Commit

Permalink
Also consider fips findings (PoC)
Browse files Browse the repository at this point in the history
  • Loading branch information
8R0WNI3 committed Dec 12, 2024
1 parent 0981559 commit 2db5b8f
Show file tree
Hide file tree
Showing 5 changed files with 218 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/compliance/Compliance.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ const TypeFilter = ({
artefactMetadataTypes.LICENSE,
artefactMetadataTypes.VULNERABILITY,
artefactMetadataTypes.FINDING_MALWARE,
artefactMetadataTypes.FINDING_FIPS,
]

return <FormControl variant='standard' fullWidth>
Expand Down
89 changes: 89 additions & 0 deletions src/components/dependencies/ComplianceCells.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,17 @@ const ComplianceCell = ({
timestamp={lastScanTimestampStr(lastCryptoScan)}
/>
}
{
artefact.kind === ARTEFACT_KIND.RESOURCE && lastCryptoScan && <FipsFindingCell
ocmNodes={ocmNodes}
ocmRepo={ocmRepo}
metadataTypedef={findTypedefByName({name: artefactMetadataTypes.FINDING_FIPS})}
fetchComplianceSummary={fetchComplianceSummary}
lastScan={lastCryptoScan}
severity={getMaxSeverity(artefactMetadataTypes.FINDING_FIPS)}
isLoading={state.isLoading}
/>
}
{
artefact.kind === ARTEFACT_KIND.RESOURCE && <MalwareFindingCell
ocmNodes={ocmNodes}
Expand Down Expand Up @@ -871,4 +882,82 @@ BDBACell.propTypes = {
}


const FipsFindingCell = ({
ocmNodes,
ocmRepo,
metadataTypedef,
fetchComplianceSummary,
lastScan,
severity,
isLoading,
}) => {
const [mountRescoring, setMountRescoring] = React.useState(false)

const handleRescoringClose = () => {
setMountRescoring(false)
}

const title = metadataTypedef.friendlyName

return <Grid item onClick={(e) => e.stopPropagation()}>
{
mountRescoring && <RescoringModal
ocmNodes={ocmNodes}
ocmRepo={ocmRepo}
handleClose={handleRescoringClose}
fetchComplianceSummary={fetchComplianceSummary}
/>
}
<Tooltip
title={
<Stack>
<RescoringButton
setMountRescoring={setMountRescoring}
title='Rescoring'
/>
{
isLoading ? <Skeleton/> : <Typography variant='inherit'>
{
lastScanTimestampStr(lastScan)
}
</Typography>
}
</Stack>
}
>
{
lastScan || isLoading ? <Chip
color={severity.color}
label={severity.name === SEVERITIES.CLEAN
? `No ${title} Findings`
: `${title} ${capitalise(severity.name)}`
}
variant='outlined'
size='small'
icon={<UnfoldMoreIcon/>}
clickable={false}
/> : <Chip
color='default'
label={`No ${title} Scan`}
variant='outlined'
size='small'
icon={<UnfoldMoreIcon/>}
clickable={false}
/>
}
</Tooltip>
</Grid>
}
FipsFindingCell.displayName = 'FipsFindingCell'
FipsFindingCell.propTypes = {
ocmNodes: PropTypes.arrayOf(PropTypes.object).isRequired,
ocmRepo: PropTypes.string,
metadataTypedef: PropTypes.object.isRequired,
fetchComplianceSummary: PropTypes.func.isRequired,
lastScan: PropTypes.object,
severity: PropTypes.object.isRequired,
isLoading: PropTypes.bool.isRequired,
}


export { ComplianceCell, ArtefactCell, IconCell }
107 changes: 107 additions & 0 deletions src/components/dependencies/RescoringModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,55 @@ MalwareExtraInfo.propTypes = {
}


const FipsExtraInfo = ({
locations,
properties,
}) => {
return <ExtraWideTooltip
title={
<div style={{ overflowY: 'auto', maxHeight: '15rem' }}>
<Typography
variant='inherit'
sx={{
fontWeight: 'bold',
}}
marginBottom='0.5rem'
>
Locations
</Typography>
<Typography variant='inherit' whiteSpace='pre-wrap'>
{
JSON.stringify(locations, null, 2)
}
</Typography>
<Divider/>
<Typography
variant='inherit'
sx={{
fontWeight: 'bold',
}}
marginBottom='0.5rem'
>
Properties
</Typography>
<Typography variant='inherit' whiteSpace='pre-wrap'>
{
JSON.stringify(properties, null, 2)
}
</Typography>
</div>
}
>
<InfoOutlinedIcon sx={{ height: '1rem' }}/>
</ExtraWideTooltip>
}
FipsExtraInfo.displayName = 'FipsExtraInfo'
FipsExtraInfo.propTypes = {
locations: PropTypes.arrayOf(PropTypes.string).isRequired,
properties: PropTypes.object.isRequired,
}


const Subject = ({
rescoring,
ocmNode,
Expand Down Expand Up @@ -1225,6 +1274,20 @@ const Subject = ({
<OcmNodeDetails ocmNode={ocmNode} ocmRepo={ocmRepo} iconProps={{ sx: { height: '1rem' } }}/>
</div>
</Stack>
} else if (rescoring.finding_type === artefactMetadataTypes.FINDING_FIPS) {
return <Stack>
<div style={{ display: 'flex', alignItems: 'center' }}>
<TruncatedTextWithTooltip
text={finding.asset.names.sort().join('\n')}
maxLength={24}
typographyProps={{
variant: 'inherit',
whiteSpace: 'pre-line',
}}
/>
<OcmNodeDetails ocmNode={ocmNode} ocmRepo={ocmRepo} iconProps={{ sx: { height: '1rem' } }}/>
</div>
</Stack>
}
}
Subject.displayName = 'Subject'
Expand Down Expand Up @@ -1331,6 +1394,36 @@ const Finding = ({
/>
</div>
</Stack>

} else if (rescoring.finding_type === artefactMetadataTypes.FINDING_FIPS) {
return <Stack spacing={0.5}>
<Tooltip
title={<div style={{ overflowY: 'auto', maxHeight: '15rem' }}>
{
finding.summary ?? 'No summary available'
}
</div>}
>
<Typography variant='inherit' marginRight='0.4rem'>
{
finding.asset.asset_type
}
</Typography>
</Tooltip>
<div style={{ display: 'flex' }}>
<Typography variant='inherit' marginRight='0.4rem'>Original:</Typography>
<Typography variant='inherit' color={`${findSeverityCfgByName({name: finding.severity}).color}.main`}>
{
finding.severity
}
</Typography>
<FipsExtraInfo
locations={finding.asset.locations}
properties={finding.asset.properties}
/>
</div>
</Stack>

} else if (rescoring.finding_type === artefactMetadataTypes.LICENSE) {
return <Stack spacing={0.5}>
<div style={{ display: 'flex' }}>
Expand Down Expand Up @@ -1770,13 +1863,24 @@ const RescoringContent = ({
[orderAttributes.TYPE]: rescoring.finding_type,
}

const fipsAccess = {
[orderAttributes.SUBJECT]: rescoring.finding.asset?.names.sort(),
[orderAttributes.FINDING]: `${rescoring.finding_type}_${rescoring.finding.asset?.asset_type}`,
[orderAttributes.SPRINT]: rescoring.sprint ? new Date(rescoring.sprint.end_date) : new Date(8640000000000000),
[orderAttributes.CURRENT]: findSeverityCfgByName({name: rescoringProposalSeverity(rescoring)}).value,
[orderAttributes.RESCORED]: findSeverityCfgByName({name: rescoring.severity}).value,
[orderAttributes.TYPE]: rescoring.finding_type,
}

if (
rescoringType === artefactMetadataTypes.VULNERABILITY
|| rescoringType === artefactMetadataTypes.LICENSE
) {
return bdbaAccesses[desired]
} else if (rescoringType === artefactMetadataTypes.FINDING_MALWARE) {
return malwareAccess[desired]
} else if (rescoringType === artefactMetadataTypes.FINDING_FIPS) {
return fipsAccess[desired]
}

}
Expand Down Expand Up @@ -2079,6 +2183,7 @@ const Rescoring = ({
artefactMetadataTypes.VULNERABILITY,
artefactMetadataTypes.LICENSE,
artefactMetadataTypes.FINDING_MALWARE,
artefactMetadataTypes.FINDING_FIPS,
],
scanConfigName: scanConfig?.name,
}),
Expand Down Expand Up @@ -2236,6 +2341,8 @@ const Rescore = ({
filename: rescoring.finding.filename,
malware: rescoring.finding.malware,
}
} else if (type === artefactMetadataTypes.FINDING_FIPS) {
return rescoring.finding.asset
}
}

Expand Down
21 changes: 19 additions & 2 deletions src/ocm/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import CheckCircleOutlineOutlinedIcon from '@mui/icons-material/CheckCircleOutli
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
import HelpOutlineOutlinedIcon from '@mui/icons-material/HelpOutlineOutlined'
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'
import LockIcon from '@mui/icons-material/Lock'
import ReportProblemIcon from '@mui/icons-material/ReportProblem'
import ReportProblemOutlinedIcon from '@mui/icons-material/ReportProblemOutlined'

Expand Down Expand Up @@ -75,6 +76,7 @@ const artefactMetadataTypes = {
OS_IDS: 'os_ids',
CODECHECKS_AGGREGATED: 'codechecks/aggregated',
CRYPTO_ASSET: 'crypto_asset',
FINDING_FIPS: 'finding/fips',
RESCORINGS: 'rescorings',
}
Object.freeze(artefactMetadataTypes)
Expand Down Expand Up @@ -124,11 +126,11 @@ export const dataKey = ({type, data}) => {
})

if (type === CRYPTO_ASSET_TYPES.ALGORITHM) return asKey({
props: [data.primitive, data.parameter_set_identifier, data.curve, data.padding],
props: [data.name, data.primitive, data.parameter_set_identifier, data.curve, data.padding],
})

if (type === CRYPTO_ASSET_TYPES.CERTIFICATE) return asKey({
props: [data.subject_algorithm_ref, data.subject_public_key_ref],
props: [data.signature_algorithm_ref, data.subject_public_key_ref],
})

if (type === CRYPTO_ASSET_TYPES.LIBRARY) return asKey({
Expand All @@ -146,6 +148,10 @@ export const dataKey = ({type, data}) => {
if (type === artefactMetadataTypes.CRYPTO_ASSET) return asKey({
props: [data.asset_type, dataKey({type: data.asset_type, data: data.properties})],
})

if (type === artefactMetadataTypes.FINDING_FIPS) return asKey({
props: [dataKey({type: artefactMetadataTypes.CRYPTO_ASSET, data: data.asset})],
})
}


Expand Down Expand Up @@ -211,6 +217,11 @@ const displayNameForData = ({
return `${displayName} ${data.license.name}`
} else if (type === artefactMetadataTypes.STRUCTURE_INFO) {
return `Package ${data.package_name} ${data.package_version}`
} else if (type === artefactMetadataTypes.FINDING_FIPS) {
// if asset type is certificate, don't show all names as they are usually more irrelevant
return `Fips ${data.asset.asset_type} ${data.asset.asset_type !== CRYPTO_ASSET_TYPES.CERTIFICATE ? data.asset.names.sort().join(', ') : ''}`
} else if (type === artefactMetadataTypes.CRYPTO_ASSET) {
return `Crypto Asset ${data.asset_type} ${data.asset_type !== CRYPTO_ASSET_TYPES.CERTIFICATE ? data.names.sort().join(', ') : ''}`
} else {
return displayName
}
Expand Down Expand Up @@ -367,6 +378,12 @@ const knownMetadataTypes = [
SpecificTypeHandler: MultilineTextViewer,
Icon: ArticleIcon,
},
{
name: 'finding/fips',
friendlyName: 'Fips',
SpecificTypeHandler: MultilineTextViewer,
Icon: LockIcon,
},
]


Expand Down
2 changes: 2 additions & 0 deletions src/pages/LandingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1153,12 +1153,14 @@ const ComponentCompliance = ({ component }) => {
const worstMalware = worstSeverityByType(artefactMetadataTypes.FINDING_MALWARE, complianceSummary.complianceSummary)
const worstLicenses = worstSeverityByType(artefactMetadataTypes.LICENSE, complianceSummary.complianceSummary)
const worstCodeChecks = worstSeverityByType(artefactMetadataTypes.CODECHECKS_AGGREGATED, complianceSummary.complianceSummary)
const worstFips = worstSeverityByType(artefactMetadataTypes.FINDING_FIPS, complianceSummary.complianceSummary)

if (worstVulnerability) yield worstVulnerability
if (worstOsInformation) yield worstOsInformation
if (worstMalware) yield worstMalware
if (worstLicenses) yield worstLicenses
if (worstCodeChecks) yield worstCodeChecks
if (worstFips) yield worstFips
}

const componentSummary = {
Expand Down

0 comments on commit 2db5b8f

Please sign in to comment.