Skip to content

Commit

Permalink
chore: Update file paths in launch.json and fix file formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
djschleen authored Sep 13, 2024
1 parent 5e2c18d commit b6ef252
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
20 changes: 10 additions & 10 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
},
"args": [
"./test/_TESTDATA_/railsgoat.cyclonedx.json"
"./tests/_TESTDATA_/railsgoat.cyclonedx.json"
],
"cwd": "${workspaceFolder}"
},
Expand All @@ -41,7 +41,7 @@
}
},
"args": [
"./test/_TESTDATA_/railsgoat.cyclonedx.json"
"./tests/_TESTDATA_/railsgoat.cyclonedx.json"
],
"cwd": "${workspaceFolder}"
},
Expand All @@ -61,7 +61,7 @@
}
},
"args": [
"./test/_TESTDATA_/juiceshop.cyclonedx.json"
"./tests/_TESTDATA_/juiceshop.cyclonedx.json"
],
"cwd": "${workspaceFolder}"
},
Expand All @@ -82,7 +82,7 @@
},
"args": [
"--output-file=output/trustier.json",
"./test/_TESTDATA_/juiceshop.cyclonedx.json"
"./tests/_TESTDATA_/juiceshop.cyclonedx.json"
],
"cwd": "${workspaceFolder}"
},
Expand All @@ -103,7 +103,7 @@
}
},
"args": [
"./test/_TESTDATA_/juiceshop.cyclonedx.json"
"./tests/_TESTDATA_/juiceshop.cyclonedx.json"
],
"cwd": "${workspaceFolder}"
},
Expand All @@ -123,7 +123,7 @@
}
},
"args": [
"./test/_TESTDATA_/trustier.cyclonedx.json"
"./tests/_TESTDATA_/trustier.cyclonedx.json"
],
"cwd": "${workspaceFolder}"
},
Expand All @@ -144,7 +144,7 @@
},
"args": [
"--output-file=output/trustier.json",
"./test/_TESTDATA_/trustier.cyclonedx.json"
"./tests/_TESTDATA_/trustier.cyclonedx.json"
],
"cwd": "${workspaceFolder}"
},
Expand All @@ -165,7 +165,7 @@
}
},
"args": [
"./test/_TESTDATA_/trustier.cyclonedx.json"
"./tests/_TESTDATA_/trustier.cyclonedx.json"
],
"cwd": "${workspaceFolder}"
},
Expand All @@ -186,7 +186,7 @@
},
"args": [
"--output-file=output/trustier.json",
"./test/_TESTDATA_/trustier.small.cyclonedx.json"
"./tests/_TESTDATA_/trustier.small.cyclonedx.json"
],
"cwd": "${workspaceFolder}"
},
Expand All @@ -207,7 +207,7 @@
}
},
"args": [
"./test/_TESTDATA_/trustier.small.cyclonedx.json"
"./tests/_TESTDATA_/trustier.small.cyclonedx.json"
],
"cwd": "${workspaceFolder}"
}
Expand Down
17 changes: 8 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use colored::*;
use cyclonedx_bom::prelude::*;
use models::TrustyResponse;
use packageurl::PackageUrl;
use serde_json;
use std::{fs, str::FromStr};
use surf;
use serde_json;

#[derive(Debug, Parser)]
#[command(author, version, about)]
Expand Down Expand Up @@ -62,7 +62,7 @@ fn main() {
}
if let Err(err) = task::block_on(process_sbom(&bom, args.output_file, args.ratelimit)) {
eprintln!("Error processing SBOM (process_sbom): {}", err);
}
}

println!("{}", "DONE!".green().bold());
}
Expand All @@ -82,7 +82,6 @@ fn print_ascii_header() {
);
}


async fn process_sbom(
bom: &Bom,
output_file: Option<String>,
Expand All @@ -94,6 +93,7 @@ async fn process_sbom(
.iter()
.filter_map(|component| component.purl.as_ref().map(|purl| purl.to_string()))
.collect::<Vec<_>>()
//TODO: may have to dedupe
} else {
Vec::new()
};
Expand Down Expand Up @@ -132,7 +132,7 @@ async fn process_sbom(
}
}
fs::write(of_clone, json).expect("Failed to write JSON to file");
println!("* JSON written to file: {}", of);
println!("\n* JSON written to file: {}\n", of);
} else {
let json = serde_json::to_string_pretty(&responses).unwrap();
println!("{}", json);
Expand All @@ -159,19 +159,18 @@ async fn fetch_purl_bodies(
println!("* Fetching trust information for {}:", p);

let body = surf::get(url).await?.body_string().await?;

// eprintln!("* Response: {}", body);

match serde_json::from_str::<TrustyResponse>(&body) {
Ok(resp) => {
//println!("Success: {:?}", resp);
responses.push(resp);
},
}
Err(e) => {
eprintln!("Failed to parse JSON: {}", e);
},
}
}


task::sleep(std::time::Duration::from_millis(rate_limit_ms)).await;
}
Expand Down

0 comments on commit b6ef252

Please sign in to comment.