advisory’s query and pruning functionality#2288
Draft
bxf12315 wants to merge 2 commits intoguacsec:mainfrom
Draft
advisory’s query and pruning functionality#2288bxf12315 wants to merge 2 commits intoguacsec:mainfrom
bxf12315 wants to merge 2 commits intoguacsec:mainfrom
Conversation
Contributor
Reviewer's GuideRefactors common list/prune/delete logic from the SBOM API into a shared Sequence diagram for advisory prune command using shared delete_entriessequenceDiagram
actor User
participant Cli as trustify_binary
participant Cmd as AdvisoryCommands
participant Api as AdvisoryApi
participant Common as CommonModule
participant Client as ApiClient
User->>Cli: run "trustify advisory prune" with flags
Cli->>Cmd: parse args to AdvisoryCommands::Prune
Cmd->>Cmd: build PruneParams from flags
Cmd->>Api: prune(&ctx.client, ¶ms)
Api->>Common: build_prune_query(¶ms)
Common-->>Api: query, ListParams
Api->>Client: get_with_query(ADVISORY_PATH, ListParams)
Client-->>Api: JSON list of advisories
Api->>Api: parse JSON into items Vec
Api->>Api: map items to Vec DeleteEntry
alt params.dry_run == true
Api-->>Cmd: new_delete_result(total)
else params.dry_run == false
Api->>Common: delete_entries(&client, ADVISORY_PATH, entries, params.concurrency)
Common->>Client: delete("/v2/advisory/{id}") for each entry (concurrent)
Client-->>Common: Ok or ApiError for each delete
Common-->>Api: DeleteResult
Api-->>Cmd: DeleteResult
end
Cmd->>Cmd: print summary and optionally write JSON file
Cmd-->>Cli: ExitCode::SUCCESS
Cli-->>User: command completes
Class diagram for shared prune/delete infrastructure and advisory integrationclassDiagram
class ListParams {
+Option~String~ q
+Option~u32~ limit
+Option~u32~ offset
+Option~String~ sort
}
class PruneParams {
+Option~String~ q
+Option~u32~ limit
+Option~DateTime_Local~ published_before
+Option~i64~ older_than
+Option~Vec~String~~ label
+Option~u32~ keep_latest
+bool dry_run
+usize concurrency
}
class DeleteEntry {
+String id
+String identifier
}
class DeleteResult {
+Vec~DeletedResult~ deleted
+u32 deleted_total
+Vec~SkippedResult~ skipped
+u32 skipped_total
+Vec~FailedResult~ failed
+u32 failed_total
+u32 total
}
class DeletedResult {
+String id
+String identifier
}
class SkippedResult {
+String id
+String identifier
}
class FailedResult {
+String id
+String identifier
+String error
}
class CommonModule {
+build_prune_query(params: PruneParams) String,ListParams
+delete_entries(client: ApiClient, base_path: String, entries: Vec~DeleteEntry~, concurrency: usize) DeleteResult
+new_delete_result(total: u32) DeleteResult
}
class ApiClient {
+get_with_query(path: String, params: ListParams) Result~String,ApiError~
+delete(path: String) Result~(),ApiError~
}
class SbomApi {
+const SBOM_PATH: &str
+list(client: ApiClient, params: ListParams) Result~String,ApiError~
+prune(client: ApiClient, params: PruneParams) Result~DeleteResult,ApiError~
+delete_by_query(client: ApiClient, params: ListParams, dry_run: bool, concurrency: usize) Result~DeleteResult,ApiError~
+delete_list(client: ApiClient, entries: Vec~DeleteEntry~, concurrency: usize) Result~DeleteResult,ApiError~
+read_delete_entries_from_file(input_file: String) Result~Vec~DeleteEntry~,ApiError~
+delete_duplicates(client: ApiClient, input_file: String, dry_run: bool, concurrency: usize) Result~DeleteResult,ApiError~
}
class AdvisoryApi {
+const ADVISORY_PATH: &str
+list(client: ApiClient, params: ListParams) Result~String,ApiError~
+prune(client: ApiClient, params: PruneParams) Result~DeleteResult,ApiError~
}
class Commands {
+Sbom command
+Advisory command
+Auth command
+run(ctx: Context) ExitCode
}
class SbomCommands {
+List
+Prune
+run(ctx: Context) ExitCode
}
class AdvisoryCommands {
+List
+Prune
+run(ctx: Context) ExitCode
}
class ListFormat {
+Full
}
class OutputFormat {
+Json
}
CommonModule --> ListParams
CommonModule --> PruneParams
CommonModule --> DeleteEntry
CommonModule --> DeleteResult
DeleteResult --> DeletedResult
DeleteResult --> SkippedResult
DeleteResult --> FailedResult
SbomApi ..> CommonModule : uses
SbomApi --> ListParams
SbomApi --> PruneParams
SbomApi --> DeleteResult
SbomApi --> DeleteEntry
AdvisoryApi ..> CommonModule : uses
AdvisoryApi --> ListParams
AdvisoryApi --> PruneParams
AdvisoryApi --> DeleteResult
AdvisoryApi --> DeleteEntry
CommonModule --> ApiClient
Commands --> SbomCommands
Commands --> AdvisoryCommands
SbomCommands --> ListParams
SbomCommands --> PruneParams
AdvisoryCommands --> ListParams
AdvisoryCommands --> PruneParams
AdvisoryCommands --> ListFormat
AdvisoryCommands --> OutputFormat
AdvisoryCommands --> AdvisoryApi
SbomCommands --> SbomApi
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
Author
|
@ruromero In order to implement operations related to advisories, I refactored the existing code. Please review them. |
ruromero
approved these changes
Mar 16, 2026
Contributor
ruromero
left a comment
There was a problem hiding this comment.
The functional changes look good to me and seems a reasonable refactoring
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Introduce shared deletion and prune utilities and add advisory management CLI commands.
New Features:
Enhancements:
Documentation: