Skip to content

feat(sbom-details): add CBOM tab to SBOM Explorer - #1247

Closed
gildub wants to merge 1 commit into
guacsec:mainfrom
gildub:TC-5854
Closed

gildub wants to merge 1 commit into
guacsec:mainfrom
gildub:TC-5854

Conversation

@gildub

@gildub gildub commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a Cryptographic Bill of Materials (CBOM) tab to the SBOM Explorer detail page
  • Create useFetchCryptoBySbom query hook that filters GET /v3/crypto/algorithm by sbom_id
  • New CbomBySbom component renders a filterable, paginated table with columns: Asset Name, Type, Primitive, OID, Policy Status, Properties
  • Add unit tests covering table rendering, empty state, and column display

Implements TC-5854

Note: This PR depends on the cryptography backend API from trustify#2619.

Test plan

  • Verify CBOM tab appears on SBOM detail pages
  • Verify table displays crypto assets filtered to the selected SBOM
  • Verify empty state message when SBOM has no crypto assets
  • Verify pagination and text filtering work correctly
  • Verify tab switching between Info, Packages, Vulnerabilities, Models, and CBOM
  • Run npm run test — all 122 tests pass
  • Run npm run lint — no errors or warnings

🤖 Generated with Claude Code

Summary by Sourcery

Add cryptographic asset visibility to SBOM details through a filterable, paginated CBOM tab.

New Features:

  • Add a CBOM tab to SBOM detail pages displaying cryptographic assets associated with the selected SBOM.
  • Support filtering and pagination for SBOM-specific cryptographic asset results.

Enhancements:

  • Present cryptographic asset details including primitive, OID, policy status, and properties with an empty-state message when no assets are available.

Tests:

  • Add unit coverage for CBOM table columns, asset rows, formatted values, policy statuses, empty state, and pagination controls.

Add a Cryptographic Bill of Materials tab to the SBOM detail page,
surfacing per-SBOM cryptographic assets with a filterable, paginated
table showing asset name, type, primitive, OID, policy status, and
properties columns.

- Add useFetchCryptoBySbom query hook filtering by sbom_id
- Create CbomBySbom tab content component following existing patterns
- Register CBOM tab in sbom-details alongside info/packages/vulns/models
- Add unit tests for table rendering, empty state, and column display

Implements TC-5854

Assisted-by: Claude Code
@sourcery-ai

sourcery-ai Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds a CBOM tab to SBOM Explorer details, backed by a new SBOM-filtered crypto query and a tested table that supports search, pagination, policy/status rendering, and empty-state handling.

Sequence diagram for loading SBOM-scoped CBOM assets

sequenceDiagram
    participant User
    participant SbomDetails
    participant CbomBySbom
    participant useFetchCryptoBySbom
    participant CryptoAPI

    User->>SbomDetails: Select CBOM tab
    SbomDetails->>CbomBySbom: Render sbomId
    CbomBySbom->>useFetchCryptoBySbom: useFetchCryptoBySbom(sbomId, params)
    useFetchCryptoBySbom->>CryptoAPI: GET /api/v3/crypto/algorithm?q=sbom_id=sbomId
    CryptoAPI-->>useFetchCryptoBySbom: CryptoAlgorithm items and total
    useFetchCryptoBySbom-->>CbomBySbom: data, total, isFetching, fetchError
    CbomBySbom-->>User: Render filterable paginated CBOM table
Loading

File-Level Changes

Change Details Files
Adds a reusable CBOM detail view for cryptographic assets associated with the selected SBOM.
  • Introduces a filterable, paginated table with six asset and policy columns.
  • Extracts primitive and formatted algorithm properties from nested crypto metadata.
  • Handles loading, errors, empty results, null OIDs, and unknown policy statuses.
  • Adds focused tests for columns, rows, formatting, policy badges, empty state, and pagination.
client/src/app/pages/sbom-details/cbom-by-sbom.tsx
client/src/app/pages/sbom-details/cbom-by-sbom.test.tsx
Integrates CBOM into SBOM detail navigation and tab content.
  • Registers the cbom tab with URL-persisted tab controls.
  • Adds the CBOM tab and mounts its content with the current SBOM ID.
client/src/app/pages/sbom-details/sbom-details.tsx
Adds an SBOM-scoped crypto algorithms query hook.
  • Queries the crypto algorithm endpoint with an sbom_id filter.
  • Combines the SBOM filter with existing request and text-search parameters.
  • Returns normalized data, totals, loading, error, and refetch state for table controls.
client/src/app/queries/crypto.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

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.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="client/src/app/pages/sbom-details/cbom-by-sbom.test.tsx" line_range="103-109" />
<code_context>
+  });
+
+  /** Verifies that the empty state message is shown when no crypto assets exist. */
+  it("shows empty state when SBOM has no crypto assets", () => {
+    mockData = [];
+    renderComponent();
+
+    expect(
+      screen.getByText("No cryptographic assets found for this SBOM."),
+    ).toBeInTheDocument();
+    mockData = mockCryptoAssets;
+  });
+
</code_context>
<issue_to_address>
**nitpick (testing):** The empty-state test mutates module-level `mockData` and restores it only after the assertion; if rendering or the assertion throws, later tests retain the empty dataset and fail or silently test the wrong state.

**Triggers:** When the empty-state assertion fails or the test exits before the manual restoration.

**Suggested fix:** Reset `mockData` in an `afterEach`/`finally` block instead of relying on an inline restoration.

```suggestion
    mockData = [];
    try {
      renderComponent();

      expect(
        screen.getByText("No cryptographic assets found for this SBOM."),
      ).toBeInTheDocument();
    } finally {
      mockData = mockCryptoAssets;
    }
```
</issue_to_address>

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment on lines +103 to +109
mockData = [];
renderComponent();

expect(
screen.getByText("No cryptographic assets found for this SBOM."),
).toBeInTheDocument();
mockData = mockCryptoAssets;

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.

nitpick (testing): The empty-state test mutates module-level mockData and restores it only after the assertion; if rendering or the assertion throws, later tests retain the empty dataset and fail or silently test the wrong state.

Triggers: When the empty-state assertion fails or the test exits before the manual restoration.

Suggested fix: Reset mockData in an afterEach/finally block instead of relying on an inline restoration.

Suggested change
mockData = [];
renderComponent();
expect(
screen.getByText("No cryptographic assets found for this SBOM."),
).toBeInTheDocument();
mockData = mockCryptoAssets;
mockData = [];
try {
renderComponent();
expect(
screen.getByText("No cryptographic assets found for this SBOM."),
).toBeInTheDocument();
} finally {
mockData = mockCryptoAssets;
}

@gildub

gildub commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Closing — implementation was based on the wrong mock-up. Will re-implement with the correct design.

@gildub gildub closed this Sep 14, 2026
@github-project-automation github-project-automation Bot moved this to Done in Trustify Sep 14, 2026
@gildub
gildub deleted the TC-5854 branch September 14, 2026 12:11
@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.81818% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.97%. Comparing base (ce8e3b4) to head (e1d079d).

Files with missing lines Patch % Lines
client/src/app/pages/sbom-details/cbom-by-sbom.tsx 80.95% 4 Missing ⚠️
client/src/app/queries/crypto.ts 80.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1247      +/-   ##
==========================================
+ Coverage   56.81%   56.97%   +0.15%     
==========================================
  Files         261      262       +1     
  Lines        5859     5892      +33     
  Branches     1830     1840      +10     
==========================================
+ Hits         3329     3357      +28     
- Misses       2284     2286       +2     
- Partials      246      249       +3     
Flag Coverage Δ
e2e 70.05% <81.81%> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant