Skip to content

Commit b2e58a9

Browse files
feat(assail): exclude vendored-snapshot dirs from analysis (refile of #72 after force-push race) (#77)
Refile of #72 after a botched rebase pushed the wrong HEAD and auto-closed the original PR. Same intent: exclude .yarn, idaptik-rescript13-staging, rescript-ecosystem from analysis. Resolved conflict in src/assail/analyzer.rs by merge-both (kept #71's Julia *Ext.jl tests + this PR's vendored-snapshot tests). Closes #72 (refiled). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 03fdd9f commit b2e58a9

1 file changed

Lines changed: 72 additions & 0 deletions

File tree

src/assail/analyzer.rs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,11 @@ impl Analyzer {
790790
".dub",
791791
"obj",
792792
"runtime",
793+
// Vendored upstream snapshots — analysing these flags
794+
// findings against code the project does not own.
795+
".yarn",
796+
"idaptik-rescript13-staging",
797+
"rescript-ecosystem",
793798
]
794799
.contains(&name)
795800
{
@@ -859,6 +864,9 @@ impl Analyzer {
859864
"corpus",
860865
"corpora",
861866
"runtime",
867+
// Vendored upstream snapshots — see walk_directory.
868+
"idaptik-rescript13-staging",
869+
"rescript-ecosystem",
862870
]
863871
.contains(&name_str)
864872
{
@@ -7819,6 +7827,70 @@ pub fn safe_get_x() -> Option<String> {
78197827
assert!(
78207828
count_julia_dce(src, "src/dangerous.jl") > 0,
78217829
"non-extension Julia files must still flag eval()"
7830+
// Vendored-snapshot directory skip
7831+
// ---------------------------------------------------------------
7832+
7833+
fn walk_collects(root: &std::path::Path) -> Vec<std::path::PathBuf> {
7834+
let analyzer = Analyzer::new(std::path::Path::new(".")).expect("analyzer construction");
7835+
let mut files = Vec::new();
7836+
analyzer.walk_directory(root, &mut files).expect("walk");
7837+
files
7838+
}
7839+
7840+
#[test]
7841+
fn walk_skips_yarn_releases() {
7842+
let tmp = TempDir::new().expect("tempdir");
7843+
fs::create_dir_all(tmp.path().join(".yarn/releases")).unwrap();
7844+
fs::write(
7845+
tmp.path().join(".yarn/releases/yarn-4.12.0.cjs"),
7846+
"console.log(eval('1'));",
7847+
)
7848+
.unwrap();
7849+
fs::write(tmp.path().join("real.rs"), "fn main() {}").unwrap();
7850+
let collected = walk_collects(tmp.path());
7851+
assert!(
7852+
!collected.iter().any(|p| p.to_string_lossy().contains(".yarn/")),
7853+
".yarn/ subtree must be skipped"
7854+
);
7855+
assert!(
7856+
collected.iter().any(|p| p.ends_with("real.rs")),
7857+
"non-vendored files must still be walked"
7858+
);
7859+
}
7860+
7861+
#[test]
7862+
fn walk_skips_idaptik_rescript_staging() {
7863+
let tmp = TempDir::new().expect("tempdir");
7864+
let staging = tmp.path().join("idaptik-rescript13-staging/src");
7865+
fs::create_dir_all(&staging).unwrap();
7866+
fs::write(staging.join("v.res"), "let unsafe_thing = ()").unwrap();
7867+
fs::write(tmp.path().join("own.rs"), "fn main() {}").unwrap();
7868+
let collected = walk_collects(tmp.path());
7869+
assert!(
7870+
!collected
7871+
.iter()
7872+
.any(|p| p.to_string_lossy().contains("idaptik-rescript13-staging")),
7873+
"vendored idaptik staging snapshot must be skipped"
7874+
);
7875+
assert!(
7876+
collected.iter().any(|p| p.ends_with("own.rs")),
7877+
"first-party files must still be walked"
7878+
);
7879+
}
7880+
7881+
#[test]
7882+
fn walk_skips_rescript_ecosystem() {
7883+
let tmp = TempDir::new().expect("tempdir");
7884+
let staging = tmp.path().join("rescript-ecosystem/inner");
7885+
fs::create_dir_all(&staging).unwrap();
7886+
fs::write(staging.join("v.res"), "let unsafe_thing = ()").unwrap();
7887+
fs::write(tmp.path().join("own.rs"), "fn main() {}").unwrap();
7888+
let collected = walk_collects(tmp.path());
7889+
assert!(
7890+
!collected
7891+
.iter()
7892+
.any(|p| p.to_string_lossy().contains("rescript-ecosystem")),
7893+
"rescript-ecosystem vendored snapshot must be skipped"
78227894
);
78237895
}
78247896
}

0 commit comments

Comments
 (0)