Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/commands/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,17 @@ pub async fn run_report(
}

/// Download the SBOM.
pub async fn run_sbom(client: &AnalyzerClient, scan_id: Uuid, output_path: PathBuf) -> Result<()> {
pub async fn run_sbom(
client: &AnalyzerClient,
scan_id: Uuid,
output_path: PathBuf,
wait: bool,
interval: Duration,
timeout: Duration,
) -> Result<()> {
if wait {
wait_for_completion(client, scan_id, interval, timeout).await?;
}
output::status("Downloading", "SBOM...");
let bytes = client.download_sbom(scan_id).await?;
tokio::fs::write(&output_path, &bytes).await?;
Expand Down
17 changes: 16 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,18 @@ enum ScanCommand {
/// Output file path.
#[arg(short = 'O', long)]
output: PathBuf,

/// Wait for scan completion first.
#[arg(short, long)]
wait: bool,

/// Poll interval when waiting.
#[arg(long, value_parser = humantime::parse_duration, default_value = "2s")]
interval: Duration,

/// Maximum wait time.
#[arg(long, value_parser = humantime::parse_duration, default_value = "10m")]
timeout: Duration,
},

/// Download a compliance report (PDF).
Expand Down Expand Up @@ -435,9 +447,12 @@ async fn run(cli: Cli) -> Result<()> {
scan_id,
object_id,
output,
wait,
interval,
timeout,
} => {
let sid = commands::scan::resolve_scan_id(&client, scan_id, object_id).await?;
commands::scan::run_sbom(&client, sid, output).await
commands::scan::run_sbom(&client, sid, output, wait, interval, timeout).await
}
ScanCommand::ComplianceReport {
scan_id,
Expand Down