Skip to content

Commit

Permalink
Merge branch 'ANE-1711-millhone-jar-cli-program' into ANE-1711-integr…
Browse files Browse the repository at this point in the history
…ate-jar-fingerprint-method
  • Loading branch information
csasarak committed Jun 27, 2024
2 parents f9d3a99 + 735c659 commit 172b3d9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion extlib/millhone/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use typed_builder::TypedBuilder;
use walkdir::DirEntry;

pub mod analyze;
pub mod analyze_jars;
pub mod analyze_container;
pub mod commit;
pub mod ingest;
pub mod ping;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn main(opts: Subcommand) -> Result<()> {
let tar_filename = opts.image_tar_file();
let jar_analysis = JarAnalysis {
discovered_jars: jars_in_container(opts.image_tar_file())
.with_context(|| format!("Analyze Jar Archive {:?}", tar_filename))?,
.with_context(|| format!("analyze container: {:?}", tar_filename))?,
};

let mut stdout = BufWriter::new(std::io::stdout());
Expand All @@ -76,7 +76,6 @@ pub fn main(opts: Subcommand) -> Result<()> {
fn jars_in_container(image_path: &PathBuf) -> Result<HashMap<LayerPath, Vec<DiscoveredJar>>> {
// Visit each layer and fingerprint the JARs within.
info!("inspecting container");
// May have to make two copies of this Archive, idk if it can be iterated twice.
let layers = list_container_layers(image_path)?;
let mut discoveries = HashMap::new();

Expand Down Expand Up @@ -124,7 +123,7 @@ fn jars_in_layer(entry: Entry<'_, impl Read>) -> Result<Vec<DiscoveredJar>> {

info_span!("jar", ?path).in_scope(|| -> Result<()> {
debug!("fingerprinting");
let entry = buffer(entry).context("Read jar file")?;
let entry = buffer(entry).context("read jar file")?;

match Combined::from_buffer(entry) {
Ok(fingerprints) => discoveries.push(DiscoveredJar::new(path, fingerprints)),
Expand Down Expand Up @@ -155,7 +154,7 @@ fn list_container_layers(layer_path: &PathBuf) -> Result<HashSet<PathBuf>> {
let path = match entry.path() {
Ok(path) => path,
Err(e) => {
warn!("Entry path {:?}", e);
warn!("Failed to read entry path: {e:?}");
continue;
}
};
Expand Down
4 changes: 2 additions & 2 deletions extlib/millhone/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ enum Commands {
Commit(cmd::commit::Subcommand),

/// Find and fingerprint JAR files.
AnalyzeJars(cmd::analyze_jars::Subcommand),
AnalyzeContainer(cmd::analyze_container::Subcommand),
}

fn main() -> stable_eyre::Result<()> {
Expand Down Expand Up @@ -155,7 +155,7 @@ fn main() -> stable_eyre::Result<()> {
Commands::Ingest(opts) => cmd::ingest::main(&app.direct_endpoint, opts),
Commands::Analyze(opts) => cmd::analyze::main(&app.direct_endpoint, opts),
Commands::Commit(opts) => cmd::commit::main(opts),
Commands::AnalyzeJars(opts) => cmd::analyze_jars::main(opts),
Commands::AnalyzeContainer(opts) => cmd::analyze_container::main(opts),
}
}

Expand Down

0 comments on commit 172b3d9

Please sign in to comment.