Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sbom details-vulnerability tab-render "affected dependencies" #271

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 75 additions & 23 deletions client/src/app/pages/sbom-details/vulnerabilities-by-sbom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ import {

import { getSeverityPriority } from "@app/api/model-utils";
import { VulnerabilityStatus } from "@app/api/models";
import { SbomAdvisory, SbomPackage, SbomStatus } from "@app/client";
import {
PurlSummary,
SbomAdvisory,
SbomPackage,
SbomStatus,
} from "@app/client";
import { LoadingWrapper } from "@app/components/LoadingWrapper";
import { PackageQualifiers } from "@app/components/PackageQualifiers";
import { SbomVulnerabilitiesDonutChart } from "@app/components/SbomVulnerabilitiesDonutChart";
Expand Down Expand Up @@ -328,29 +333,76 @@ export const VulnerabilitiesBySbom: React.FC<VulnerabilitiesBySbomProps> = ({
</Thead>
<Tbody>
{item.summary.allPackages
.flatMap((item) => item.purl)
.flatMap((item) => {
// Workaround against https://github.com/trustification/trustify/issues/1043
// Some packages do not have purl neither ID. So we render only the parent name meanwhile
type EnrichedPurlSummary = {
parentName: string;
purlSummary?: PurlSummary;
};

const hasNoPurlsButOnlyName =
item.name && item.purl.length == 0;

if (hasNoPurlsButOnlyName) {
const result: EnrichedPurlSummary = {
parentName: item.name,
};
return [result];
} else {
return item.purl.map((i) => {
const result: EnrichedPurlSummary =
{
...i,
parentName: item.name,
};
return result;
});
}
})
.map((purl, index) => {
const decomposedPurl = decomposePurl(
purl.purl
);
return (
<Tr key={index}>
<Td>{decomposedPurl?.type}</Td>
<Td>{decomposedPurl?.namespace}</Td>
<Td>{decomposedPurl?.name}</Td>
<Td>{decomposedPurl?.version}</Td>
<Td>{decomposedPurl?.path}</Td>
<Td>
{decomposedPurl?.qualifiers && (
<PackageQualifiers
value={
decomposedPurl?.qualifiers
}
/>
)}
</Td>
</Tr>
);
if (purl.purlSummary) {
const decomposedPurl = decomposePurl(
purl.purlSummary.purl
);
return (
<Tr key={`${index}-purl`}>
<Td>{decomposedPurl?.type}</Td>
<Td>
{decomposedPurl?.namespace}
</Td>
<Td>
<Link
to={`/packages/${purl.purlSummary.uuid}`}
>
{decomposedPurl?.name}
</Link>
</Td>
<Td>{decomposedPurl?.version}</Td>
<Td>{decomposedPurl?.path}</Td>
<Td>
{decomposedPurl?.qualifiers && (
<PackageQualifiers
value={
decomposedPurl?.qualifiers
}
/>
)}
</Td>
</Tr>
);
} else {
return (
<Tr key={`${index}-name`}>
<Td></Td>
<Td></Td>
<Td>{purl.parentName}</Td>
<Td></Td>
<Td></Td>
<Td></Td>
</Tr>
);
}
})}
</Tbody>
</Table>
Expand Down
Loading