Skip to content

Commit

Permalink
Add SBOM's packages table view (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosthe19916 authored Jun 19, 2024
1 parent 8c1e4ce commit cd8a62c
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 96 deletions.
1 change: 1 addition & 0 deletions client/src/app/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const TablePersistenceKeyPrefixes = {
vulnerabilities: "vn",
sboms: "sb",
packages: "pk",
sbom_packages: "spk",
};

// URL param prefixes: should be short, must be unique for each table that uses one
Expand Down
15 changes: 9 additions & 6 deletions client/src/app/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ export interface HubPaginatedResult<T> {

// Base

export interface PackageBase {
uuid: string;
purl: string;
}

export interface SBOMBase {
id: string;
type: "CycloneDX" | "SPDX";
Expand Down Expand Up @@ -101,7 +96,9 @@ export interface VulnerabilityAdvisory extends AdvisoryBase {

// Package

export interface Package extends PackageBase {
export interface Package {
uuid: string;
purl: string;
// This field is added by the UI
package?: {
name: string;
Expand All @@ -115,6 +112,12 @@ export interface Package extends PackageBase {
related_sboms: SBOMBase[];
}

export interface SBOMPackage {
id: string;
name: string;
purl: string[];
}

// SBOM

export interface SBOM extends SBOMBase {
Expand Down
3 changes: 2 additions & 1 deletion client/src/app/api/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
ImporterReport,
Package,
SBOM,
SBOMPackage,
Vulnerability,
} from "./models";

Expand Down Expand Up @@ -120,7 +121,7 @@ export const downloadSBOMById = (id: number | string) =>
export const getPackagesBySbomId = (
id: number | string,
params: HubRequestParams = {}
) => getHubPaginatedResult<Package>(`${SBOMS}/${id}/packages`, params);
) => getHubPaginatedResult<SBOMPackage>(`${SBOMS}/${id}/packages`, params);

export const getVulnerabilitiesBySbomId = (id: string | number) =>
axios
Expand Down
20 changes: 20 additions & 0 deletions client/src/app/components/PackageQualifiers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react";

import { Label } from "@patternfly/react-core";

interface PackageQualifiersProps {
value: { [key: string]: string }
}

export const PackageQualifiers: React.FC<PackageQualifiersProps> = ({
value,
}) => {
return <>
{Object.entries(value).map(([k, v], index) => (
<Label
key={index}
isCompact
>{`${k}=${v}`}</Label>
))}
</>
};
Loading

0 comments on commit cd8a62c

Please sign in to comment.