Skip to content

Add OSV dependency vulnerability scanning#461

Open
Darkroom4364 wants to merge 1 commit into
mainfrom
issue-448-osv-sca
Open

Add OSV dependency vulnerability scanning#461
Darkroom4364 wants to merge 1 commit into
mainfrom
issue-448-osv-sca

Conversation

@Darkroom4364
Copy link
Copy Markdown
Collaborator

@Darkroom4364 Darkroom4364 commented May 27, 2026

Summary

  • add OSV-backed SCA scanning for Cargo.lock, package-lock.json, pnpm-lock.yaml, requirements.txt, poetry.lock, and Pipfile.lock
  • add dependency vulnerability metadata to JSON/SARIF findings plus a registered manifest rule id for overrides/inventory
  • document online, offline, local DB, and cache behavior while keeping PQ manifest rules offline by default

Verification

  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test

Closes #448

Summary by CodeRabbit

  • New Features

    • OSV-backed dependency vulnerability scanning added (new sca command and integrated into regular scans), with flags for offline mode and local DB/cache.
    • Support for multiple lockfile/manifest formats and merging OSV findings into normal scan results.
    • Reports (SARIF/JSON) enriched with dependency metadata and more granular command reporting.
  • Documentation

    • README and docs updated with quick-start, usage, supported files, and offline/cache guidance.
  • Tests

    • New integration tests for offline SCA and SARIF dependency metadata.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 98704b41-250f-4c8b-9079-f15f475f85e8

📥 Commits

Reviewing files that changed from the base of the PR and between 5841160 and 950ce9b.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (34)
  • Cargo.toml
  • README.md
  • docs/dependency-scanning.md
  • src/app.rs
  • src/baseline.rs
  • src/cli.rs
  • src/compliance.rs
  • src/config.rs
  • src/deps.rs
  • src/diff.rs
  • src/engine/coccinelle.rs
  • src/engine/codeql.rs
  • src/github_app/review.rs
  • src/lib.rs
  • src/main.rs
  • src/output/mod.rs
  • src/report/cbom.rs
  • src/report/github_pr.rs
  • src/report/json.rs
  • src/report/sarif.rs
  • src/rules/c.rs
  • src/rules/common.rs
  • src/rules/go.rs
  • src/rules/javascript.rs
  • src/rules/kotlin.rs
  • src/rules/manifest.rs
  • src/rules/mod.rs
  • src/rules/python.rs
  • src/rules/semgrep_compat.rs
  • src/rules/semgrep_taint.rs
  • src/secrets.rs
  • src/tui/tests.rs
  • tests/integration.rs
  • www/src/data/rules.ts
✅ Files skipped from review due to trivial changes (2)
  • README.md
  • src/github_app/review.rs
🚧 Files skipped from review as they are similar to previous changes (29)
  • www/src/data/rules.ts
  • src/rules/c.rs
  • src/rules/common.rs
  • src/rules/kotlin.rs
  • src/diff.rs
  • src/compliance.rs
  • src/report/sarif.rs
  • src/report/github_pr.rs
  • src/rules/semgrep_taint.rs
  • src/report/json.rs
  • src/output/mod.rs
  • src/report/cbom.rs
  • src/lib.rs
  • src/rules/mod.rs
  • src/engine/coccinelle.rs
  • src/secrets.rs
  • src/baseline.rs
  • src/main.rs
  • src/rules/go.rs
  • Cargo.toml
  • src/engine/codeql.rs
  • src/rules/python.rs
  • src/rules/javascript.rs
  • src/app.rs
  • src/cli.rs
  • src/config.rs
  • src/tui/tests.rs
  • tests/integration.rs
  • src/deps.rs

📝 Walkthrough

Walkthrough

Adds OSV-backed SCA: new foxguard sca command, lockfile discovery/parsing for multiple formats, OSV resolution (network/local/cache), enriched findings with dependency metadata, CLI/config wiring, SARIF/JSON reporting updates, manifest rule registration, tests, and docs.

Changes

Dependency Vulnerability Scanning Implementation

Layer / File(s) Summary
Finding struct extension with dependency metadata
src/lib.rs, src/report/sarif.rs, various test helpers
Exports deps module; extends Finding with optional dependency/advisory fields (dep_version, dep_ecosystem, dep_purl, dep_vulnerability_id, dep_fixed_version, dep_source, dep_vulnerability_severity) and dep_path: Vec<String>; SARIF properties include dependency fields.
CLI subcommand and configuration for SCA
src/cli.rs, src/config.rs, src/main.rs
Adds ScaArgs command and conversions; extends ScanArgs/BaselineScanArgs and config with sca, sca_offline, sca_db, sca_cache; resolves configured paths within project boundary and supports sca_only gating.
Core dependency scanning: lockfile parsing, OSV resolution, finding construction
src/deps.rs
New module: lockfile discovery/parsing (Cargo.lock, requirements.txt, poetry.lock, Pipfile.lock, pnpm-lock.yaml, package-lock.json), package normalization/PURL, deduplication, OSV querybatch + local DB/cache fallback, version-range evaluation, severity mapping, finding construction, OSV cache read/write, and unit tests. Exposes OSV_RULE_ID, DependencyScanOptions, DependencyScanResult, and scan_dependency_vulnerabilities.
Scan execution integration & reporting
src/app.rs, src/output/mod.rs, src/report/sarif.rs, src/main.rs
Integrates SCA into main scan flow: constructs DependencyScanOptions, invokes scan_dependency_vulnerabilities, merges/sorts SCA findings/notices, provides SCA-only fast path, adds OSV rule to known-rule filtering, and refines emitted JSON command metadata.
OSV manifest rule registration
src/rules/manifest.rs, src/rules/mod.rs, www/src/data/rules.ts, Cargo.toml
Registers manifest/osv-vulnerable-dep (CWE-937, High) in manifest rules; updates website rule data and makes reqwest non-optional with blocking feature.
Integration tests and test fixture updates
tests/integration.rs, src/tui/tests.rs, many src/* test helpers
Adds 3 SCA integration tests (offline DB matching, SARIF dependency properties, PQ-preservation offline), osv_fixture and assert_sca_finding helpers, and numerous test fixture updates to initialize new Finding dependency fields across test suites.
Documentation and user guide
README.md, docs/dependency-scanning.md
README and new docs page describe foxguard sca usage, supported lockfiles, JSON/SARIF examples, offline mode (--sca-offline), and DB/cache flags (--sca-db, --sca-cache).

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI as foxguard sca
  participant Scanner as scan_dependency_vulnerabilities
  participant Parser as LockfileParser
  participant OSV as OSV Source (DB/Cache/Network)
  participant Reporter as Report Emitter

  User->>CLI: foxguard sca . --sca-db osv.json
  CLI->>Scanner: scan_dependency_vulnerabilities(root, options)
  Scanner->>Parser: discover & parse lockfiles
  Parser->>Scanner: package refs (name, version, spans)
  Scanner->>OSV: resolve vulnerabilities (local DB / cache / querybatch)
  OSV->>Scanner: vulnerabilities for package keys
  Scanner->>Reporter: findings with dep metadata
  Reporter->>User: emit JSON/SARIF with dependency fields
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • 0sec-labs/foxguard#240: Updates Finding construction sites to initialize new dependency-related fields (overlapping test/fixture changes).

Suggested reviewers

  • peaktwilight

Poem

🐰 I parsed the locks at break of day,
hopped through OSV, cache, and clay,
stitched findings with PURLs bright,
fixed versions glowing in moonlight.
A rabbit cheers for safer bytes!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 61.24% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add OSV dependency vulnerability scanning' directly and clearly summarizes the main change: adding OSV-backed SCA capability.
Linked Issues check ✅ Passed The PR fully implements all acceptance criteria from issue #448: supported lockfiles with normalized identities, findings with required metadata, offline/cache behavior, PQ rule isolation, JSON/SARIF dependency fields, and comprehensive test coverage.
Out of Scope Changes check ✅ Passed All changes are scoped to the OSV SCA feature: new deps module, CLI commands, config support, Finding struct extensions, documentation, and comprehensive test coverage. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-448-osv-sca

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/config.rs (1)

253-283: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Compute sca_only after merging effective SCA/no_builtins defaults.

Line 253 computes sca_only before config defaults are applied, so a config-only SCA setup (scan.sca: true + scan.no_builtins: true) can still pull in scan.rules at Lines 254-255. That breaks intended SCA-only behavior.

💡 Proposed fix
 pub fn apply_scan_defaults(scan: &mut ScanArgs, config: Option<&FoxguardConfig>) {
     let Some(config) = config else {
         return;
     };

-    let sca_only = scan.sca && scan.no_builtins && !scan.pq_mode;
-    if scan.rules.is_none() && !sca_only {
-        scan.rules = config.scan.rules.clone();
-    }
     if !scan.no_builtins && config.scan.no_builtins {
         scan.no_builtins = true;
     }
+    if !scan.sca && config.scan.sca {
+        scan.sca = true;
+    }
+    let sca_only = scan.sca && scan.no_builtins && !scan.pq_mode;
+    if scan.rules.is_none() && !sca_only {
+        scan.rules = config.scan.rules.clone();
+    }
     if scan.severity.is_none() {
         scan.severity = config.scan.severity;
     }
@@
-    if !scan.sca && config.scan.sca {
-        scan.sca = true;
-    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/config.rs` around lines 253 - 283, The sca_only flag is computed too
early using pre-merge values (sca_only = scan.sca && scan.no_builtins &&
!scan.pq_mode) which allows config-provided SCA + no_builtins to be treated as
not-SCA-only and thus pull in config.scan.rules; to fix, compute or re-evaluate
sca_only after applying the defaults (the blocks that set scan.sca,
scan.no_builtins, scan.sca_offline, etc.) or change the rules-assignment
condition to check the effective values (e.g., use the merged values of scan.sca
and scan.no_builtins or test config.scan.* combined with current scan.*) so that
when the effective state is SCA-only you do not assign config.scan.rules to
scan.rules.
src/app.rs (1)

351-358: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

No-files warning is misleading in SCA-only mode.

When SCA runs without lockfiles, this branch still emits source-extension guidance (Line 354), which is confusing for dependency scans.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/app.rs` around lines 351 - 358, The "no files found" notice currently
always includes source-file extension guidance even when running SCA-only
(dependency/lockfile) scans; update the branch that checks files_scanned,
coccinelle_candidate_files, codeql_candidate_rules and stats.files_discovered so
that the notices.push(format!(...)) is only executed when we are not in
SCA-only/lockfile-only mode—i.e., add a guard that detects dependency-only runs
(for example by checking the existing lockfile-candidate/lockfile flag or a
sca_only/dependency_scan_only indicator) and skip emitting the
supported-extensions message in that case; modify the if-condition or wrap the
notices.push call (referencing files_scanned, coccinelle_candidate_files,
codeql_candidate_rules, stats.files_discovered, coccinelle_rules, and
notices.push) to implement this behavior.
🧹 Nitpick comments (1)
Cargo.toml (1)

60-60: ⚡ Quick win

Move or relabel reqwest to avoid “optional deps” confusion.

reqwest is now always enabled, but it still sits under the “Optional deps for the GitHub App” comment block. Please move it outside that block (or adjust the comment) so the dependency intent stays clear.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Cargo.toml` at line 60, The reqwest dependency line currently listed as
`reqwest = { version = "0.13.3", default-features = false, features =
["blocking", "json", "rustls"] }` is placed under the “Optional deps for the
GitHub App” comment but is actually always enabled; move that reqwest entry out
of that comment block (or update the comment to reflect it is a non-optional
runtime dependency) so the intent is clear—locate the reqwest dependency in
Cargo.toml and either relocate it above/below the optional-deps section or
change the section heading to indicate it contains both optional and required
deps.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/deps.rs`:
- Around line 1099-1120: The compare_versions implementation misorders
pre-release and complex strings (e.g., "1.0.0-rc1" vs "1.0.0"); replace the
ad-hoc logic by first attempting to parse both strings with a semver-aware
parser (e.g., semver::Version::parse) and, if both parse successfully, compare
the resulting Version values (which correctly treat pre-release as lower
precedence); only if parsing fails for either side fall back to the existing
version_parts/lexical logic in compare_versions (and keep version_parts as the
non-semver fallback). Update compare_versions to try semver parsing first and
use the semver comparison result to drive version_in_range decisions.

---

Outside diff comments:
In `@src/app.rs`:
- Around line 351-358: The "no files found" notice currently always includes
source-file extension guidance even when running SCA-only (dependency/lockfile)
scans; update the branch that checks files_scanned, coccinelle_candidate_files,
codeql_candidate_rules and stats.files_discovered so that the
notices.push(format!(...)) is only executed when we are not in
SCA-only/lockfile-only mode—i.e., add a guard that detects dependency-only runs
(for example by checking the existing lockfile-candidate/lockfile flag or a
sca_only/dependency_scan_only indicator) and skip emitting the
supported-extensions message in that case; modify the if-condition or wrap the
notices.push call (referencing files_scanned, coccinelle_candidate_files,
codeql_candidate_rules, stats.files_discovered, coccinelle_rules, and
notices.push) to implement this behavior.

In `@src/config.rs`:
- Around line 253-283: The sca_only flag is computed too early using pre-merge
values (sca_only = scan.sca && scan.no_builtins && !scan.pq_mode) which allows
config-provided SCA + no_builtins to be treated as not-SCA-only and thus pull in
config.scan.rules; to fix, compute or re-evaluate sca_only after applying the
defaults (the blocks that set scan.sca, scan.no_builtins, scan.sca_offline,
etc.) or change the rules-assignment condition to check the effective values
(e.g., use the merged values of scan.sca and scan.no_builtins or test
config.scan.* combined with current scan.*) so that when the effective state is
SCA-only you do not assign config.scan.rules to scan.rules.

---

Nitpick comments:
In `@Cargo.toml`:
- Line 60: The reqwest dependency line currently listed as `reqwest = { version
= "0.13.3", default-features = false, features = ["blocking", "json", "rustls"]
}` is placed under the “Optional deps for the GitHub App” comment but is
actually always enabled; move that reqwest entry out of that comment block (or
update the comment to reflect it is a non-optional runtime dependency) so the
intent is clear—locate the reqwest dependency in Cargo.toml and either relocate
it above/below the optional-deps section or change the section heading to
indicate it contains both optional and required deps.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6784019d-9cc1-4c0d-b05b-71139bd569ce

📥 Commits

Reviewing files that changed from the base of the PR and between 84f6ae5 and 7eaffb7.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (34)
  • Cargo.toml
  • README.md
  • docs/dependency-scanning.md
  • src/app.rs
  • src/baseline.rs
  • src/cli.rs
  • src/compliance.rs
  • src/config.rs
  • src/deps.rs
  • src/diff.rs
  • src/engine/coccinelle.rs
  • src/engine/codeql.rs
  • src/github_app/review.rs
  • src/lib.rs
  • src/main.rs
  • src/output/mod.rs
  • src/report/cbom.rs
  • src/report/github_pr.rs
  • src/report/json.rs
  • src/report/sarif.rs
  • src/rules/c.rs
  • src/rules/common.rs
  • src/rules/go.rs
  • src/rules/javascript.rs
  • src/rules/kotlin.rs
  • src/rules/manifest.rs
  • src/rules/mod.rs
  • src/rules/python.rs
  • src/rules/semgrep_compat.rs
  • src/rules/semgrep_taint.rs
  • src/secrets.rs
  • src/tui/tests.rs
  • tests/integration.rs
  • www/src/data/rules.ts

Comment thread src/deps.rs
Comment on lines +1099 to +1120
fn compare_versions(left: &str, right: &str) -> Ordering {
let left_parts = version_parts(left);
let right_parts = version_parts(right);
for (left, right) in left_parts.iter().zip(right_parts.iter()) {
let ordering = match (left.parse::<u64>(), right.parse::<u64>()) {
(Ok(left), Ok(right)) => left.cmp(&right),
_ => left.cmp(right),
};
if ordering != Ordering::Equal {
return ordering;
}
}
left_parts.len().cmp(&right_parts.len())
}

fn version_parts(value: &str) -> Vec<String> {
value
.split(|ch: char| !ch.is_ascii_alphanumeric())
.filter(|part| !part.is_empty())
.map(ToString::to_string)
.collect()
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Version ordering is not advisory-accurate for pre-release/complex versions.

The comparator at Line 1099 can mis-order versions like 1.0.0-rc1 and 1.0.0, which directly affects version_in_range matching and can produce incorrect vulnerability findings.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/deps.rs` around lines 1099 - 1120, The compare_versions implementation
misorders pre-release and complex strings (e.g., "1.0.0-rc1" vs "1.0.0");
replace the ad-hoc logic by first attempting to parse both strings with a
semver-aware parser (e.g., semver::Version::parse) and, if both parse
successfully, compare the resulting Version values (which correctly treat
pre-release as lower precedence); only if parsing fails for either side fall
back to the existing version_parts/lexical logic in compare_versions (and keep
version_parts as the non-semver fallback). Update compare_versions to try semver
parsing first and use the semver comparison result to drive version_in_range
decisions.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Cargo.toml`:
- Line 60: The reqwest dependency is currently placed under the "Optional deps
for the GitHub App" block but is not declared optional and not tied to
features.github-app; either move the reqwest = { version = "0.13.3",
default-features = false, features = ["blocking", "json", "rustls"] } line into
the main [dependencies] section to show it is always enabled, or make it
optional by adding optional = true and then add "dep:reqwest" to the
features.github-app entry so features.github-app actually enables reqwest;
update Cargo.toml accordingly to keep placement and feature wiring consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cb871a78-d449-4140-a1e1-50b5ed754335

📥 Commits

Reviewing files that changed from the base of the PR and between 7eaffb7 and 5841160.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (34)
  • Cargo.toml
  • README.md
  • docs/dependency-scanning.md
  • src/app.rs
  • src/baseline.rs
  • src/cli.rs
  • src/compliance.rs
  • src/config.rs
  • src/deps.rs
  • src/diff.rs
  • src/engine/coccinelle.rs
  • src/engine/codeql.rs
  • src/github_app/review.rs
  • src/lib.rs
  • src/main.rs
  • src/output/mod.rs
  • src/report/cbom.rs
  • src/report/github_pr.rs
  • src/report/json.rs
  • src/report/sarif.rs
  • src/rules/c.rs
  • src/rules/common.rs
  • src/rules/go.rs
  • src/rules/javascript.rs
  • src/rules/kotlin.rs
  • src/rules/manifest.rs
  • src/rules/mod.rs
  • src/rules/python.rs
  • src/rules/semgrep_compat.rs
  • src/rules/semgrep_taint.rs
  • src/secrets.rs
  • src/tui/tests.rs
  • tests/integration.rs
  • www/src/data/rules.ts
✅ Files skipped from review due to trivial changes (5)
  • src/rules/python.rs
  • src/compliance.rs
  • src/github_app/review.rs
  • docs/dependency-scanning.md
  • README.md
🚧 Files skipped from review as they are similar to previous changes (27)
  • src/rules/semgrep_taint.rs
  • src/output/mod.rs
  • src/secrets.rs
  • src/rules/mod.rs
  • src/report/sarif.rs
  • src/baseline.rs
  • src/report/cbom.rs
  • src/report/github_pr.rs
  • src/engine/codeql.rs
  • src/rules/kotlin.rs
  • src/rules/manifest.rs
  • src/engine/coccinelle.rs
  • src/rules/javascript.rs
  • src/rules/semgrep_compat.rs
  • src/report/json.rs
  • src/rules/common.rs
  • src/lib.rs
  • src/rules/c.rs
  • src/rules/go.rs
  • src/tui/tests.rs
  • tests/integration.rs
  • src/app.rs
  • src/diff.rs
  • src/main.rs
  • src/config.rs
  • src/deps.rs
  • src/cli.rs

Comment thread Cargo.toml Outdated
Comment thread src/app.rs
)
} else if let Some(files) = targets.as_ref() {
scan_paths_with_root_with_notices(
Path::new(&scan.path),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foxguard · MEDIUM · rs/no-path-traversal (CWE-22)

Path::new called with dynamic path — validate input to prevent path traversal

Comment thread src/app.rs
cache_path: scan.sca_cache.as_ref().map(PathBuf::from),
};
let sca_result = scan_dependency_vulnerabilities(
Path::new(&scan.path),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foxguard · MEDIUM · rs/no-path-traversal (CWE-22)

Path::new called with dynamic path — validate input to prevent path traversal

Comment thread src/deps.rs

#[test]
fn local_advisory_matching_uses_ecosystem_name_and_version() {
let package = parse_package_lock(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foxguard · MEDIUM · rs/no-unwrap-in-lib (CWE-248)

.unwrap() can panic at runtime — use proper error handling with ? or match

Comment thread src/tui/tests.rs
dep_path: vec![],
};

let caret = render_source_context("😀exec(cmd);\n", &finding, 0)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foxguard · MEDIUM · rs/no-unwrap-in-lib (CWE-248)

.expect() can panic at runtime — use proper error handling with ? or match

Comment thread src/tui/tests.rs
dep_path: vec![],
};

let caret = render_source_context("e\u{301}exec(cmd);\n", &finding, 0)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foxguard · MEDIUM · rs/no-unwrap-in-lib (CWE-248)

.expect() can panic at runtime — use proper error handling with ? or match

Comment thread src/tui/tests.rs
dep_path: vec![],
};

let caret = render_source_context("e\u{301}x\n", &finding, 0)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foxguard · MEDIUM · rs/no-unwrap-in-lib (CWE-248)

.expect() can panic at runtime — use proper error handling with ? or match

Comment thread tests/integration.rs

#[test]
fn sca_reports_osv_vulnerabilities_for_supported_lockfiles() {
let dir = TempDir::new().expect("temp dir");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foxguard · MEDIUM · rs/no-unwrap-in-lib (CWE-248)

.expect() can panic at runtime — use proper error handling with ? or match

Comment thread tests/integration.rs
"HIGH"
)
]);
fs::write(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foxguard · MEDIUM · rs/no-unwrap-in-lib (CWE-248)

.expect() can panic at runtime — use proper error handling with ? or match

Comment thread tests/integration.rs
]);
fs::write(
&db_path,
serde_json::to_string_pretty(&advisories).expect("json"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foxguard · MEDIUM · rs/no-unwrap-in-lib (CWE-248)

.expect() can panic at runtime — use proper error handling with ? or match

Comment thread tests/integration.rs
)
.expect("write osv fixture");

let output = foxguard_cmd()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foxguard · MEDIUM · rs/no-unwrap-in-lib (CWE-248)

.expect() can panic at runtime — use proper error handling with ? or match

Comment thread tests/integration.rs
"tests/fixtures/deps",
"--sca-offline",
"--sca-db",
db_path.to_str().expect("utf8 path"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foxguard · MEDIUM · rs/no-unwrap-in-lib (CWE-248)

.expect() can panic at runtime — use proper error handling with ? or match

Comment thread tests/integration.rs

#[test]
fn sca_sarif_includes_dependency_properties() {
let dir = TempDir::new().expect("temp dir");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foxguard · MEDIUM · rs/no-unwrap-in-lib (CWE-248)

.expect() can panic at runtime — use proper error handling with ? or match

Comment thread tests/integration.rs
"6.5.5",
"HIGH"
)]);
fs::write(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foxguard · MEDIUM · rs/no-unwrap-in-lib (CWE-248)

.expect() can panic at runtime — use proper error handling with ? or match

Comment thread tests/integration.rs
)]);
fs::write(
&db_path,
serde_json::to_string_pretty(&advisories).expect("json"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foxguard · MEDIUM · rs/no-unwrap-in-lib (CWE-248)

.expect() can panic at runtime — use proper error handling with ? or match

Comment thread tests/integration.rs
)
.expect("write osv fixture");

let output = foxguard_cmd()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foxguard · MEDIUM · rs/no-unwrap-in-lib (CWE-248)

.expect() can panic at runtime — use proper error handling with ? or match

Comment thread tests/integration.rs
"tests/fixtures/deps/package-lock.json",
"--sca-offline",
"--sca-db",
db_path.to_str().expect("utf8 path"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foxguard · MEDIUM · rs/no-unwrap-in-lib (CWE-248)

.expect() can panic at runtime — use proper error handling with ? or match

Comment thread tests/integration.rs

#[test]
fn sca_offline_without_db_does_not_disable_pq_manifest_rules() {
let output = foxguard_cmd()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foxguard · MEDIUM · rs/no-unwrap-in-lib (CWE-248)

.expect() can panic at runtime — use proper error handling with ? or match

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add OSV-backed dependency vulnerability scanning alongside PQ manifest rules

1 participant