Skip to content

feat(advisory): add CSAF 2.0 types, query hook, and ECharts dependency#1063

Draft
CryptoRodeo wants to merge 1 commit into
guacsec:mainfrom
CryptoRodeo:TC-4618
Draft

feat(advisory): add CSAF 2.0 types, query hook, and ECharts dependency#1063
CryptoRodeo wants to merge 1 commit into
guacsec:mainfrom
CryptoRodeo:TC-4618

Conversation

@CryptoRodeo
Copy link
Copy Markdown
Collaborator

@CryptoRodeo CryptoRodeo commented May 28, 2026

Summary

  • Define TypeScript interfaces for the full CSAF 2.0 VEX document structure (CsafDocument, CsafVulnerability, CsafProductTree, CsafBranch, CsafRelationship, etc.)
  • Add useFetchAdvisoryCsafById query hook that fetches raw CSAF JSON via downloadAdvisory endpoint and parses Blob into typed CsafDocument
  • Add echarts and echarts-for-react dependencies to client workspace

Test plan

  • npm run build -w client succeeds
  • All 24 unit tests pass
  • Biome check passes
  • TypeScript compilation verifies CSAF type correctness

Implements TC-4618

Assisted-by: Claude Code

Summary by Sourcery

Introduce CSAF 2.0 VEX document support in the client, including typed models and a query hook for fetching advisory CSAF data.

New Features:

  • Add a React Query hook to fetch and parse CSAF JSON for an advisory into a typed CsafDocument.
  • Define TypeScript interfaces representing the CSAF 2.0 VEX document structure used by advisories.

Enhancements:

  • Integrate ECharts dependencies into the client workspace to enable future CSAF-related visualizations.

Build:

  • Add echarts and echarts-for-react runtime dependencies to the client package configuration.

Define TypeScript interfaces for the full CSAF 2.0 VEX document
structure (CsafDocument, CsafVulnerability, CsafProductTree, etc.)
and add useFetchAdvisoryCsafById query hook that fetches raw CSAF JSON
via the downloadAdvisory endpoint and parses the Blob into typed data.

Also add echarts and echarts-for-react dependencies for upcoming
tree visualization components.

Implements TC-4618

Assisted-by: Claude Code
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 28, 2026

Reviewer's Guide

Adds strongly-typed CSAF 2.0 VEX document models, a React Query hook to fetch and parse CSAF advisory documents, and new charting dependencies for future visualizations.

Sequence diagram for useFetchAdvisoryCsafById hook

sequenceDiagram
  actor UserComponent
  participant useFetchAdvisoryCsafById
  participant useQuery
  participant downloadAdvisory

  UserComponent->>useFetchAdvisoryCsafById: call with id
  useFetchAdvisoryCsafById->>useQuery: useQuery<CsafDocument>()
  useQuery->>downloadAdvisory: downloadAdvisory({ client, path: { key: id } })
  downloadAdvisory-->>useQuery: response.data (Blob)
  useQuery->>useQuery: blob.text()
  useQuery->>useQuery: JSON.parse(text) as CsafDocument
  useQuery-->>useFetchAdvisoryCsafById: data, isLoading, error
  useFetchAdvisoryCsafById-->>UserComponent: { csafDocument, isFetching, fetchError }
Loading

File-Level Changes

Change Details Files
Introduce comprehensive TypeScript interfaces for CSAF 2.0 VEX documents to enable type-safe handling of advisory data.
  • Create top-level CsafDocument and CsafDocumentMetadata types for CSAF documents
  • Define product tree-related types including CsafProductTree, CsafBranch, CsafFullProductName, and CsafRelationship
  • Add vulnerability-related types such as CsafVulnerability, CsafScore, CsafProductStatus, CsafRemediation, and CVSS structures
  • Model supporting structures like publisher, tracking, distribution, notes, references, and acknowledgments
client/src/app/types/csaf.ts
Add a React Query hook to download, parse, and expose CSAF advisory JSON as a typed document.
  • Define useFetchAdvisoryCsafById hook that uses downloadAdvisory to retrieve CSAF JSON blobs
  • Parse Blob responses into text and JSON, casting the result to CsafDocument
  • Return a stable shape with csafDocument, isFetching, and fetchError mapped from React Query state
client/src/app/queries/advisories.ts
Add charting dependencies required for CSAF visualizations in the client workspace.
  • Declare echarts and echarts-for-react as runtime dependencies in the client package manifest
  • Update lockfile to include newly added charting libraries and their transitive dependencies
client/package.json
package-lock.json

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

@CryptoRodeo CryptoRodeo marked this pull request as draft May 28, 2026 18:03
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

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, and left some high level feedback:

  • In useFetchAdvisoryCsafById, consider adding basic error handling/validation around JSON.parse(text) (e.g., try/catch and asserting that document and csaf_version exist) so that malformed or non-CSAF responses are surfaced more clearly than a generic runtime parse error.
  • Several CSAF interfaces (e.g., CsafPublisher.category, CsafTracking.status, CsafProductStatus keys, CsafRemediation.category, CsafThreat.category) are currently plain strings; tightening these to string-literal unions that reflect the CSAF 2.0 spec will give better type safety and editor assistance when working with these fields.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `useFetchAdvisoryCsafById`, consider adding basic error handling/validation around `JSON.parse(text)` (e.g., try/catch and asserting that `document` and `csaf_version` exist) so that malformed or non-CSAF responses are surfaced more clearly than a generic runtime parse error.
- Several CSAF interfaces (e.g., `CsafPublisher.category`, `CsafTracking.status`, `CsafProductStatus` keys, `CsafRemediation.category`, `CsafThreat.category`) are currently plain `string`s; tightening these to string-literal unions that reflect the CSAF 2.0 spec will give better type safety and editor assistance when working with these fields.

## Individual Comments

### Comment 1
<location path="client/src/app/queries/advisories.ts" line_range="161" />
<code_context>
+  return {
+    csafDocument: data,
+    isFetching: isLoading,
+    fetchError: error as AxiosError | null,
+  };
+};
</code_context>
<issue_to_address>
**issue (bug_risk):** Avoid over-narrowing the error type to AxiosError since JSON.parse can also throw non-Axios errors.

The query can fail for non-Axios reasons (e.g., `blob.text()` / `JSON.parse` throwing `TypeError` or `SyntaxError`), so forcing `error` to `AxiosError | null` can lead to incorrect assumptions at call sites (like always accessing `error.response`). Instead, keep `error` as `unknown`/`Error` and use a type guard (e.g., `isAxiosError(error)`) before treating it as an `AxiosError`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread client/src/app/queries/advisories.ts
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

❌ Patch coverage is 12.50000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.10%. Comparing base (def496d) to head (feec631).

Files with missing lines Patch % Lines
client/src/app/queries/advisories.ts 12.50% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1063      +/-   ##
==========================================
- Coverage   49.17%   49.10%   -0.08%     
==========================================
  Files         253      253              
  Lines        5499     5507       +8     
  Branches     1660     1660              
==========================================
  Hits         2704     2704              
- Misses       2519     2528       +9     
+ Partials      276      275       -1     
Flag Coverage Δ
e2e 66.74% <14.28%> (-0.12%) ⬇️
unit 2.01% <0.00%> (-0.01%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 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.

@CryptoRodeo
Copy link
Copy Markdown
Collaborator Author

Verification Report for TC-4618 (commit feec631)

Check Result Details
Review Feedback PASS 1 bot comment classified as suggestion (codebase convention pattern)
Root-Cause Investigation N/A No sub-tasks created
Scope Containment PASS 4 files: types/csaf.ts (new), queries/advisories.ts (modified), package.json (modified), package-lock.json (expected)
Diff Size PASS 366 lines added — appropriate for CSAF type definitions + query hook
Commit Traceability PASS 1 commit with Conventional Commits format referencing TC-4618
Sensitive Patterns PASS No secrets detected
CI Status PASS Build succeeds
Acceptance Criteria PASS 6/6 criteria met
Test Quality N/A No test files in scope
Test Change Classification N/A No test files modified
Verification Commands PASS build succeeds, 24/24 tests pass

Overall: PASS

All acceptance criteria met. Single bot review comment assessed as suggestion (follows existing codebase convention).


This comment was AI-generated by sdlc-workflow/verify-pr v0.9.1.

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

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant