Skip to content

Find the holes before someone else does. A fast, 100% Rust vulnerability scanner: XSS, SQL injection, leaked secrets, dependency CVEs and AI agent setups.

feat(deps): name a binary bun.lockb in the report (#214)

Pranav Aryaa2d74536418b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4e63100..ce1c2b9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
## Unreleased
+- Dependencies: a binary `bun.lockb` (bun before 1.2) is now named in the report
+ (`Not checked, binary lockfile: bun.lockb. Run bun install --save-text-lockfile to write
+ bun.lock.`). It used to be skipped without a word, which read like a clean result.
- Secrets: `secret.openrouter-key` now reports a key that comes right after an escaped newline,
tab or carriage return in a quoted string (`"line\nsk-or-v1-..."`).
- Code: `code.sql-injection` now reports Kotlin string templates in a query
diff --git a/src/deps.rs b/src/deps.rs
index e79dc9c..63cb692 100644
--- a/src/deps.rs
+++ b/src/deps.rs
@@ -107,6 +107,10 @@ fn parser(name: &str) -> Option<Parser> {
})
}
+/// bun's binary lockfile, written before bun 1.2. It cannot be read for
+/// packages, so the scan names it instead of passing over it in silence.
+pub const BUN_BINARY_LOCKFILE: &str = "bun.lockb";
+
/// True for the files `parse_lockfile` reads packages from.
pub fn is_lockfile(file: &FileInfo) -> bool {
parser(&file.name).is_some()
diff --git a/src/engine.rs b/src/engine.rs
index 37c95fb..899eaf5 100644
--- a/src/engine.rs
+++ b/src/engine.rs
@@ -84,6 +84,8 @@ pub struct Scanned {
pub env_files: Vec<String>,
/// Lockfiles left out of the dependency check because they are over `MAX_LOCK_BYTES`.
pub lockfiles_too_large: Vec<String>,
+ /// Binary lockfiles (`bun.lockb`), which cannot be read for packages.
+ pub lockfiles_binary: Vec<String>,
}
pub fn scan_files(root: &Path, include_tests: bool) -> Scanned {
@@ -93,6 +95,7 @@ pub fn scan_files(root: &Path, include_tests: bool) -> Scanned {
packages: Vec::new(),
env_files: Vec::new(),
lockfiles_too_large: Vec::new(),
+ lockfiles_binary: Vec::new(),
});
let single_file = root.is_file();
let base = if single_file {
@@ -136,6 +139,11 @@ pub fn scan_files(root: &Path, include_tests: bool) -> Scanned {
.to_string_lossy()
.replace('\\', "/");
let info = FileInfo::new(&rel);
+ // Named here, before the binary check in `read_text` drops it.
+ if info.name == deps::BUN_BINARY_LOCKFILE {
+ out.lock().unwrap().lockfiles_binary.push(rel);
+ return WalkState::Continue;
+ }
if skipped_by_name(&info) {
return WalkState::Continue;
}
@@ -181,6 +189,7 @@ pub fn scan_files(root: &Path, include_tests: bool) -> Scanned {
scanned.packages.sort();
scanned.packages.dedup();
scanned.lockfiles_too_large.sort();
+ scanned.lockfiles_binary.sort();
scanned
}
diff --git a/src/lib.rs b/src/lib.rs
index 4ba3961..b030cdb 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -178,6 +178,9 @@ pub struct Report {
/// Lockfiles too large to read (over `engine::MAX_LOCK_BYTES`), so their packages were not checked.
#[serde(skip_serializing_if = "Vec::is_empty")]
pub lockfiles_too_large: Vec<String>,
+ /// Binary lockfiles (`bun.lockb`, bun before 1.2), so their packages were not checked.
+ #[serde(skip_serializing_if = "Vec::is_empty")]
+ pub lockfiles_binary: Vec<String>,
pub elapsed_ms: u64,
pub dependency_check: DependencyCheck,
}
@@ -230,6 +233,7 @@ pub fn scan(root: &Path, options: &Options) -> std::io::Result<Report> {
files_scanned: scanned.files,
packages_checked: scanned.packages.len(),
lockfiles_too_large: scanned.lockfiles_too_large,
+ lockfiles_binary: scanned.lockfiles_binary,
findings: scanned.findings,
..Report::default()
};
diff --git a/src/report.rs b/src/report.rs
index d1585d2..a0dc324 100644
--- a/src/report.rs
+++ b/src/report.rs
@@ -120,6 +120,19 @@ pub fn terminal(report: &Report, style: &Style) -> String {
)
);
}
+ if !report.lockfiles_binary.is_empty() {
+ let _ = writeln!(
+ out,
+ "{}",
+ style.paint(
+ "2",
+ &format!(
+ "Not checked, binary lockfile: {}. Run bun install --save-text-lockfile to write bun.lock.",
+ report.lockfiles_binary.join(", ")
+ )
+ )
+ );
+ }
out
}
@@ -149,6 +162,23 @@ mod tests {
terminal(&report, &Style { color: false })
}
+ #[test]
+ fn binary_lockfiles_are_named_after_the_summary() {
+ let report = Report {
+ lockfiles_binary: vec!["bun.lockb".to_string(), "web/bun.lockb".to_string()],
+ dependency_check: DependencyCheck::Done,
+ ..Default::default()
+ };
+ let out = terminal(&report, &Style { color: false });
+ assert!(
+ out.contains(
+ "Not checked, binary lockfile: bun.lockb, web/bun.lockb. Run bun install --save-text-lockfile to write bun.lock."
+ ),
+ "{out}"
+ );
+ assert!(!summary(1, 1).contains("binary lockfile"));
+ }
+
#[test]
fn summary_line_uses_singular_for_one() {
let out = summary(1, 1);
diff --git a/tests/scan.rs b/tests/scan.rs
index ba11229..d1b30b6 100644
--- a/tests/scan.rs
+++ b/tests/scan.rs
@@ -346,6 +346,24 @@ fn large_lockfile_out_of_byte_order_keeps_its_lines() {
assert_eq!(lines, [7 + 5 * 9, 7 + 5 * 10, 7 + 5 * 11_999]);
}
+#[test]
+fn binary_bun_lockfile_is_named() {
+ let root = std::env::temp_dir().join(format!("safe-anything-bun-lockb-{}", std::process::id()));
+ let _ = std::fs::remove_dir_all(&root);
+ std::fs::create_dir_all(root.join("web")).unwrap();
+ for name in ["bun.lockb", "web/bun.lockb"] {
+ std::fs::write(root.join(name), b"\0bun-lockfile").unwrap();
+ }
+ // Another binary file, and a text lockfile, are not named.
+ std::fs::write(root.join("logo.bin"), b"\0\0\0").unwrap();
+ std::fs::write(root.join("web/yarn.lock"), "").unwrap();
+ let report = safe_anything::scan(&root, &safe_anything::Options::offline()).unwrap();
+ let _ = std::fs::remove_dir_all(&root);
+ assert_eq!(report.lockfiles_binary, ["bun.lockb", "web/bun.lockb"]);
+ assert!(report.lockfiles_too_large.is_empty());
+ assert_eq!(report.packages_checked, 0);
+}
+
#[test]
fn lockfile_over_the_limit_is_named() {
let root = std::env::temp_dir().join(format!("safe-anything-huge-lock-{}", std::process::id()));