Skip to content
Open
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
30 changes: 18 additions & 12 deletions client/src/app/pages/sbom-details/sbom-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export const SbomDetails: React.FC = () => {
tabKeys: ["info", "packages", "vulnerabilities", "models"],
});

const isAibom = sbom?.labels["kind"] === "aibom";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Accessing sbom.labels["kind"] can throw when labels is undefined.

The optional chaining only guards sbom, not labels. If labels is undefined or null, this will still throw. Use sbom?.labels?.['kind'] === 'aibom' (or sbom?.labels?.kind) so access is fully safe.


const infoTabRef = React.useRef<HTMLElement>();
const packagesTabRef = React.useRef<HTMLElement>();
const vulnerabilitiesTabRef = React.useRef<HTMLElement>();
Expand Down Expand Up @@ -229,11 +231,13 @@ export const SbomDetails: React.FC = () => {
</>
}
/>
<Tab
{...getTabProps("models")}
title={<TabTitleText>Models</TabTitleText>}
tabContentRef={modelsTabRef}
/>
{isAibom && (
<Tab
{...getTabProps("models")}
title={<TabTitleText>Models</TabTitleText>}
tabContentRef={modelsTabRef}
/>
)}
</Tabs>
</PageSection>
<PageSection>
Expand All @@ -260,13 +264,15 @@ export const SbomDetails: React.FC = () => {
>
{sbomId && <VulnerabilitiesBySbom sbomId={sbomId} />}
</TabContent>
<TabContent
{...getTabContentProps("models")}
ref={modelsTabRef}
aria-label="AI models within the SBOM"
>
{sbomId && <ModelsBySbom sbomId={sbomId} />}
</TabContent>
{isAibom && (
<TabContent
{...getTabContentProps("models")}
ref={modelsTabRef}
aria-label="AI models within the SBOM"
>
{sbomId && <ModelsBySbom sbomId={sbomId} />}
</TabContent>
)}
</PageSection>

<ConfirmDialog
Expand Down