-
Notifications
You must be signed in to change notification settings - Fork 35
feat: introduce a PackageType field in our package table #2163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Reviewer's GuideThis PR introduces a strongly-typed PackageType enum for SBOM packages, persists it on the sbom_package table, wires it through the SBOM ingestor (CycloneDX and SPDX paths), and removes several now-redundant ad‑hoc PackageType/Namespace query result structs. Sequence diagram for package_type flow from CycloneDX component to sbom_package rowsequenceDiagram
actor Ingestor
participant SbomContext
participant ComponentCreator
participant PackageCreator
participant Database
Ingestor->>SbomContext: ingest_cyclonedx(sbom)
SbomContext->>ComponentCreator: new(component, refs)
ComponentCreator->>ComponentCreator: package_type = PackageType::from_str(component.type_)
ComponentCreator->>PackageCreator: create(NodeInfoParam{ package_type, ... })
PackageCreator->>PackageCreator: sbom_package.package_type = NodeInfoParam.package_type
PackageCreator->>Database: insert sbom_package (package_type column)
Database-->>PackageCreator: persisted sbom_package
PackageCreator-->>SbomContext: PackageCreator result
SbomContext-->>Ingestor: updated graph including package_type
ER diagram for sbom_package table with new package_type columnerDiagram
sbom_package {
int id PK
varchar node_id
varchar group
varchar version
int package_type "nullable, maps to PackageType enum"
}
Class diagram for new PackageType enum and updated SBOM package structuresclassDiagram
class Model {
+i32 id
+String node_id
+Option~String~ group
+Option~String~ version
+Option~PackageType~ package_type
}
class PackageType {
<<enumeration>>
Application
Framework
Library
Container
Platform
OperatingSystem
Device
DeviceDriver
Firmware
File
MachineLearningModel
Data
CryptographicAsset
}
class NodeInfoParam {
+String node_id
+String name
+Option~String~ group
+Option~String~ version
+Vec~PackageLicensenInfo~ package_license_info
+Option~PackageType~ package_type
+new() Default
}
class PackageLicensenInfo {
+String license
+Option~String~ license_expression
}
class PackageCreator {
+sbom_package ActiveModel
+sbom_package_purls Vec~sbom_package_purl::ActiveModel~
+sbom_package_licenses Vec~sbom_package_license::ActiveModel~
}
Model --> PackageType : uses
NodeInfoParam --> PackageType : optional
PackageCreator --> Model : populates
NodeInfoParam --> PackageLicensenInfo : contains
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2163 +/- ##
=======================================
Coverage 68.18% 68.19%
=======================================
Files 376 377 +1
Lines 21161 21168 +7
Branches 21161 21168 +7
=======================================
+ Hits 14429 14435 +6
+ Misses 5870 5866 -4
- Partials 862 867 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I'd prefer having an enum type in the database, preventing the case of having to deal with unknown integer values. |
I patterned the |
|
I don't think they are ok. Having proper enums names more sense.
trustify/migration/src/m0000010_init_up.sql Lines 26 to 30 in 8338c24
|
They don't seem to be used, and I want to claim the name, PackageType, for sbom_package.
Fixes guacsec#2162 We're using the CycloneDX types initially, as the SPDX 3 types are still coagulating. Once they're finalized, I expect we'll revisit these.
Fixes #2162
We're using the CycloneDX types initially, as the SPDX 3 types are still coagulating. Once they're finalized, I expect we'll revisit these.
I don't expect we'll need to migrate/reingest existing data as our service layer will treat null values as the default "application" type.
Summary by Sourcery
Add a typed package kind field to SBOM packages and plumb it through ingestion, backed by a DB migration.
New Features:
Enhancements:
Build:
Tests: