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
10 changes: 8 additions & 2 deletions src/assail/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7860,7 +7860,9 @@ pub fn safe_get_x() -> Option<String> {
fs::write(tmp.path().join("real.rs"), "fn main() {}").unwrap();
let collected = walk_collects(tmp.path());
assert!(
!collected.iter().any(|p| p.to_string_lossy().contains(".yarn/")),
!collected
.iter()
.any(|p| p.to_string_lossy().contains(".yarn/")),
".yarn/ subtree must be skipped"
);
assert!(
Expand Down Expand Up @@ -7931,7 +7933,11 @@ pub fn safe_get_x() -> Option<String> {
outputs = { self, nixpkgs }: { };
}"#;
let findings = flake_findings(src, "/nonexistent/dir/flake.nix");
assert_eq!(findings.len(), 1, "unpinned flake.nix must produce one finding");
assert_eq!(
findings.len(),
1,
"unpinned flake.nix must produce one finding"
);
assert!(
matches!(findings[0].severity, Severity::Low),
"missing flake.lock alone is mechanically fixable — must be Low severity, got {:?}",
Expand Down
29 changes: 21 additions & 8 deletions src/bridge/classify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ mod tests {
fn test_phantom_declared_recommends_machete_strip() {
// file-soup#50 shape: crate declared in Cargo.toml, no `use` site —
// strip the manifest entry.
let (cls, rationale, action) = classify(&mock_vuln(false, false), &phantom_declared_evidence());
let (cls, rationale, action) =
classify(&mock_vuln(false, false), &phantom_declared_evidence());
assert_eq!(cls, Classification::Informational);
assert!(
action.contains("cargo machete --fix") || action.contains("Strip from Cargo.toml"),
Expand Down Expand Up @@ -403,10 +404,8 @@ mod tests {
fn test_phantom_transitive_unknown_parent_falls_back_gracefully() {
// Best-effort parent identification: if Cargo.lock didn't reveal one,
// we still produce useful output.
let (cls, rationale, action) = classify(
&mock_vuln(false, false),
&phantom_transitive_evidence(None),
);
let (cls, rationale, action) =
classify(&mock_vuln(false, false), &phantom_transitive_evidence(None));
assert_eq!(cls, Classification::Informational);
assert!(
action.contains("an upstream parent dependency"),
Expand Down Expand Up @@ -439,7 +438,8 @@ mod tests {
fn test_phantom_variants_both_classify_informational() {
// Three-way classifier output is unchanged from #47.
let (cls_decl, _, _) = classify(&mock_vuln(false, false), &phantom_declared_evidence());
let (cls_trans, _, _) = classify(&mock_vuln(false, false), &phantom_transitive_evidence(None));
let (cls_trans, _, _) =
classify(&mock_vuln(false, false), &phantom_transitive_evidence(None));
assert_eq!(cls_decl, Classification::Informational);
assert_eq!(cls_trans, Classification::Informational);
}
Expand All @@ -458,7 +458,11 @@ mod tests {
// a naive strip breaks the build.
for name in ["pkg-config", "cc", "bindgen", "cmake", "autocfg", "vcpkg"] {
let (cls, _, action) = classify(&vuln_named(name), &phantom_declared_evidence());
assert_eq!(cls, Classification::Informational, "`{name}` must classify Informational");
assert_eq!(
cls,
Classification::Informational,
"`{name}` must classify Informational"
);
assert!(
action.contains("DO NOT STRIP"),
"`{name}` must NOT recommend strip, got: {action}"
Expand Down Expand Up @@ -516,7 +520,16 @@ mod tests {
#[test]
fn test_phantom_transitive_gtk_family_via_dioxus_parent() {
// Same family check but parent is dioxus-desktop directly.
for name in ["atk", "atk-sys", "gdk", "gdk-sys", "glib", "gtk3-macros", "paste", "fxhash"] {
for name in [
"atk",
"atk-sys",
"gdk",
"gdk-sys",
"glib",
"gtk3-macros",
"paste",
"fxhash",
] {
let (_, rationale, _) = classify(
&vuln_named(name),
&phantom_transitive_evidence(Some("dioxus-desktop")),
Expand Down
9 changes: 7 additions & 2 deletions src/bridge/lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,9 @@ pub fn collect_cargo_parents(
if direct_deps.contains(child) {
continue;
}
parent.entry(child.clone()).or_insert_with(|| direct_norm.clone());
parent
.entry(child.clone())
.or_insert_with(|| direct_norm.clone());
queue.push_back(child.clone());
}
}
Expand Down Expand Up @@ -1018,6 +1020,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"

let parents = collect_cargo_parents(dir.path(), &direct);
// Both spellings must hit the same normalised entry.
assert_eq!(parents.get("serde-derive").map(String::as_str), Some("serde"));
assert_eq!(
parents.get("serde-derive").map(String::as_str),
Some("serde")
);
}
}
49 changes: 14 additions & 35 deletions src/bridge/reachability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,9 @@ mod tests {
let mut declared = HashSet::new();
declared.insert("octocrab".to_string());

let evidence = check_reachability_with_manifest(
tmp.path(),
"octocrab",
&declared,
&HashMap::new(),
)
.unwrap();
let evidence =
check_reachability_with_manifest(tmp.path(), "octocrab", &declared, &HashMap::new())
.unwrap();

assert!(!evidence.is_imported);
assert_eq!(evidence.status, ReachabilityStatus::PhantomDeclared);
Expand All @@ -289,13 +285,8 @@ mod tests {
let mut parents = HashMap::new();
parents.insert("rustls".to_string(), "reqwest".to_string());

let evidence = check_reachability_with_manifest(
tmp.path(),
"rustls",
&declared,
&parents,
)
.unwrap();
let evidence =
check_reachability_with_manifest(tmp.path(), "rustls", &declared, &parents).unwrap();

assert!(!evidence.is_imported);
assert_eq!(evidence.status, ReachabilityStatus::PhantomTransitive);
Expand All @@ -312,13 +303,9 @@ mod tests {
let mut declared = HashSet::new();
declared.insert("serde".to_string());

let evidence = check_reachability_with_manifest(
tmp.path(),
"serde",
&declared,
&HashMap::new(),
)
.unwrap();
let evidence =
check_reachability_with_manifest(tmp.path(), "serde", &declared, &HashMap::new())
.unwrap();

assert!(evidence.is_imported);
assert_eq!(evidence.status, ReachabilityStatus::Reachable);
Expand Down Expand Up @@ -382,13 +369,9 @@ octocrab = "0.32"
"workspace-member declared dep must be in the direct-deps set"
);

let evidence = check_reachability_with_manifest(
tmp.path(),
"octocrab",
&declared,
&HashMap::new(),
)
.unwrap();
let evidence =
check_reachability_with_manifest(tmp.path(), "octocrab", &declared, &HashMap::new())
.unwrap();
assert_eq!(evidence.status, ReachabilityStatus::PhantomDeclared);
}

Expand All @@ -404,13 +387,9 @@ octocrab = "0.32"
let mut declared = HashSet::new();
declared.insert("serde-json".to_string());

let evidence = check_reachability_with_manifest(
tmp.path(),
"serde_json",
&declared,
&HashMap::new(),
)
.unwrap();
let evidence =
check_reachability_with_manifest(tmp.path(), "serde_json", &declared, &HashMap::new())
.unwrap();

assert_eq!(evidence.status, ReachabilityStatus::PhantomDeclared);
}
Expand Down
5 changes: 1 addition & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2513,10 +2513,7 @@ fn run_main() -> Result<()> {
})
.collect();
positional.sort();
let description = sub
.get_about()
.map(|s| s.to_string())
.unwrap_or_default();
let description = sub.get_about().map(|s| s.to_string()).unwrap_or_default();
modes.insert(
name,
serde_json::json!({
Expand Down
Loading