feat(sbom): add lightweight SBOM lookup endpoint for CLI delete utility#2313
feat(sbom): add lightweight SBOM lookup endpoint for CLI delete utility#2313bxf12315 wants to merge 2 commits intoguacsec:mainfrom
Conversation
Reviewer's GuideAdds a new lightweight SBOM lookup API and corresponding Rust service/model plumbing to support efficient bulk CLI prune/delete operations by querying only sbom and source_document and returning just sbom_id and document_id in a paginated format. Sequence diagram for the new lightweight SBOM lookup APIsequenceDiagram
actor CliTool
participant SbomApi as SbomLookupEndpoint
participant SbomService
participant Database
CliTool->>SbomApi: GET /v2/sbom/lookup?q=...&offset=...&limit=...
SbomApi->>SbomService: fetch_sbom_lookups(search, paginated, connection)
SbomService->>Database: BEGIN READ TRANSACTION
SbomService->>Database: SELECT sbom_id, document_id
activate Database
Database-->>SbomService: PaginatedResults<SbomLookup>
deactivate Database
SbomService-->>SbomApi: PaginatedResults<SbomLookup>
SbomApi-->>CliTool: 200 OK (JSON with items[sbom_id, document_id])
Class diagram for the SbomLookup model and service changesclassDiagram
class SbomLookup {
<<data>>
+Uuid sbom_id
+Option_String document_id
}
class PaginatedResults_SbomLookup {
<<data>>
+int64 total
+SbomLookup[] items
}
class SbomService {
+fetch_sbom_lookups(search Query, paginated Paginated, connection ConnectionTrait) PaginatedResults_SbomLookup
}
class Query
class Paginated {
+int64 offset
+int64 limit
}
class ConnectionTrait
PaginatedResults_SbomLookup "*" o-- SbomLookup : items
SbomService ..> PaginatedResults_SbomLookup : returns
SbomService ..> Query : uses
SbomService ..> Paginated : uses
SbomService ..> ConnectionTrait : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Add GET /v2/sbom/lookup endpoint that returns only sbom_id and document_id by joining only the sbom and source_document tables. This avoids the 15+ table joins of the full SBOM search endpoint, providing efficient bulk lookups for CLI prune/delete operations. Implements TC-4003 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add three tests covering the /v2/sbom/lookup endpoint: - lookup_sboms: basic response validation with sbom_id and document_id - lookup_sboms_search: search filtering across multiple SBOMs - lookup_sboms_pagination: limit/offset pagination Implements TC-4003 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2313 +/- ##
==========================================
+ Coverage 67.62% 67.71% +0.08%
==========================================
Files 436 436
Lines 24835 24858 +23
Branches 24835 24858 +23
==========================================
+ Hits 16795 16832 +37
+ Misses 7151 7128 -23
- Partials 889 898 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ctron
left a comment
There was a problem hiding this comment.
I am against adding a random use case without having a clear picture how we want to manage the API. Just adding a new endpoint, out of pattern with the rest, ignoring the ongoing change of the API will only create more clutter, make the code more complex.
There is a new v3 "list SBOMs" endpoint, which wasn't release yet. So we can break it's API. This has to be coordinated with the UI. The possible deficiencies of this endpoint can be worked on. Which serves everyone.
Add GET /v2/sbom/lookup endpoint that returns only sbom_id and document_id by joining only the sbom and source_document tables. This avoids the 15+ table joins of the full SBOM search endpoint, providing efficient bulk lookups for CLI prune/delete operations.
Implements TC-4003
Summary by Sourcery
Add a lightweight SBOM lookup API for efficient bulk retrieval of SBOM and document identifiers.
New Features:
Enhancements: