feat(csaf-visualizer): add ECharts dependency and CSAF 2.0 types#1061
feat(csaf-visualizer): add ECharts dependency and CSAF 2.0 types#1061carlosthe19916 wants to merge 1 commit into
Conversation
Add echarts and echarts-for-react as dependencies for interactive tree visualizations. Create TypeScript type definitions for the complete CSAF 2.0 document structure and utility functions for product tree traversal and relationship resolution. Implements TC-4598 Assisted-by: Claude Code
Reviewer's GuideAdds ECharts client dependencies and introduces CSAF 2.0 TypeScript models plus tree/relationship helper utilities and tests to support CSAF visualizations. Flow diagram for collectRelationshipProducts utilityflowchart TD
A["Input relationships: Relationship[]"] --> B["Input productMap: Map(product_id, name)"]
B --> C[Iterate relationships with map]
C --> D[Lookup product_reference in productMap]
C --> E[Lookup relates_to_product_reference in productMap]
D --> F[Build result item with productReferenceName]
E --> F[Build result item with relatesToProductReferenceName]
F --> G[Output array of resolved relationship objects]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The recursive tree traversal logic in
collectProductsandcollectProductNodesis duplicated; consider extracting a shared internalwalkBrancheshelper or parameterizing the collector function to reduce repetition and keep behavior changes in one place. - Some CSAF fields that are modeled as required (e.g.,
product_tree.branches,vulnerabilities) may be optional or absent in real-world CSAF 2.0 documents; it might be safer to align the type definitions more closely with the spec and mark such fields optional where appropriate to avoid runtime parsing issues.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The recursive tree traversal logic in `collectProducts` and `collectProductNodes` is duplicated; consider extracting a shared internal `walkBranches` helper or parameterizing the collector function to reduce repetition and keep behavior changes in one place.
- Some CSAF fields that are modeled as required (e.g., `product_tree.branches`, `vulnerabilities`) may be optional or absent in real-world CSAF 2.0 documents; it might be safer to align the type definitions more closely with the spec and mark such fields optional where appropriate to avoid runtime parsing issues.
## Individual Comments
### Comment 1
<location path="client/src/app/pages/csaf-visualizer/types.ts" line_range="69-73" />
<code_context>
+}
+
+/** Product tree containing branch hierarchy and product relationships. */
+export interface ProductTree {
+ branches: Branch[];
+ relationships?: Relationship[];
+}
+
</code_context>
<issue_to_address>
**suggestion:** Align `ProductTree.branches` optionality with the helpers that accept `Branch[] | undefined`.
The helpers in `utils.ts` take `branches: Branch[] | undefined`, implying callers may legitimately pass `undefined` (e.g. `collectProducts(productTree.branches)` when `branches` is missing). To keep types self-consistent, either declare `branches?: Branch[];` on `ProductTree` if CSAF data can omit it, or narrow the helper signatures to `Branch[]` so incorrect usage is caught at compile time.
```suggestion
/** Product tree containing branch hierarchy and product relationships. */
export interface ProductTree {
branches?: Branch[];
relationships?: Relationship[];
}
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| /** Product tree containing branch hierarchy and product relationships. */ | ||
| export interface ProductTree { | ||
| branches: Branch[]; | ||
| relationships?: Relationship[]; | ||
| } |
There was a problem hiding this comment.
suggestion: Align ProductTree.branches optionality with the helpers that accept Branch[] | undefined.
The helpers in utils.ts take branches: Branch[] | undefined, implying callers may legitimately pass undefined (e.g. collectProducts(productTree.branches) when branches is missing). To keep types self-consistent, either declare branches?: Branch[]; on ProductTree if CSAF data can omit it, or narrow the helper signatures to Branch[] so incorrect usage is caught at compile time.
| /** Product tree containing branch hierarchy and product relationships. */ | |
| export interface ProductTree { | |
| branches: Branch[]; | |
| relationships?: Relationship[]; | |
| } | |
| /** Product tree containing branch hierarchy and product relationships. */ | |
| export interface ProductTree { | |
| branches?: Branch[]; | |
| relationships?: Relationship[]; | |
| } |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1061 +/- ##
==========================================
+ Coverage 49.15% 49.22% +0.06%
==========================================
Files 253 254 +1
Lines 5499 5528 +29
Branches 1660 1670 +10
==========================================
+ Hits 2703 2721 +18
- Misses 2521 2532 +11
Partials 275 275
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
echartsandecharts-for-reactdependencies for interactive tree visualizationscollectProducts()flattens recursive branch tree to product ID→name map,collectRelationshipProducts()resolves relationship references to product namesTest plan
npm run lint -w clientpassesnpm run format -w clientpassesnpm run build -w clientsucceedsImplements TC-4598
🤖 Generated with Claude Code
Summary by Sourcery
Introduce CSAF 2.0 data model and utilities to support CSAF visualizer functionality.
New Features:
Enhancements:
Tests: