Find the holes before someone else does. A fast, 100% Rust vulnerability scanner: XSS, SQL injection, leaked secrets, dependency CVEs and AI agent setups.
Rust ai-agentsclaude-codeclaude-code-pluginclicodexcursordevsecopsmcposvowasprustsastsecret-scanningsecretssecuritysecurity-scannersql-injectionvulnerabilityvulnerability-scannerxss
fix(deps): only look up Gemfile.lock gems from GEM sections (#94)
Onur Ugur1dd1ecec4c15
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d6902a8..1d9041a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -35,6 +35,8 @@- Code: `code.open-redirect` now also matches a status code first, so `res.redirect(301, req.query.next)` is reported; a redirect to a fixed path stays unflagged.- Dependencies: `uv.lock` entries whose `source` is `editable`, `virtual` or `path` (the project itself or alocal package) are no longer counted or looked up on PyPI.+- Dependencies: `Gemfile.lock` gems from `GIT` and `PATH` sections (a git repository or a local folder) are+ no longer counted or looked up on RubyGems. Only gems in `GEM` sections are.- Secrets: `secret.url-credentials` skips a connection string whose password is an angle-bracket placeholdersuch as `mongodb+srv://<username>:<password>@host/db`, the form MongoDB Atlas shows in its docs.- Secrets: `secret.private-key` also finds a key written with `\n` escapes inside a string, the way a Googlediff --git a/src/deps.rs b/src/deps.rsindex def277a..03f54a4 100644--- a/src/deps.rs+++ b/src/deps.rs@@ -220,16 +220,20 @@ fn go_mod(file: &FileInfo, text: &str) -> Vec<Package> {fn gemfile_lock(file: &FileInfo, text: &str) -> Vec<Package> {let mut out = Vec::new();+ // Only a `GEM` section lists gems from a gem server. `GIT` and `PATH`+ // sections list gems built from a git repository or a local folder.+ let mut in_gem = false;let mut in_specs = false;for (i, line) in text.lines().enumerate() {- if line.trim() == "specs:" {- in_specs = true;- continue;- }if !line.starts_with(' ') {+ in_gem = line.trim_end() == "GEM";in_specs = false;continue;}+ if line.trim() == "specs:" {+ in_specs = in_gem;+ continue;+ }if in_specs&& line.starts_with(" ")&& !line.starts_with(" ")diff --git a/tests/fixtures/deps/EXPECTED b/tests/fixtures/deps/EXPECTEDindex 7c48d48..c642bf6 100644--- a/tests/fixtures/deps/EXPECTED+++ b/tests/fixtures/deps/EXPECTED@@ -1,7 +1,7 @@web/package-lock.json:7 dependency.known-vulnerabilityapi/requirements.txt:3 dependency.known-vulnerabilitysvc/go.mod:6 dependency.known-vulnerability-rb/Gemfile.lock:4 dependency.known-vulnerability+rb/Gemfile.lock:19 dependency.known-vulnerabilityrs/Cargo.lock:5 dependency.known-vulnerabilityphp/composer.lock:5 dependency.known-vulnerabilitypnpm/pnpm-lock.yaml:29 dependency.known-vulnerabilitydiff --git a/tests/fixtures/deps/rb/Gemfile.lock b/tests/fixtures/deps/rb/Gemfile.lockindex 9cde239..191b4e5 100644--- a/tests/fixtures/deps/rb/Gemfile.lock+++ b/tests/fixtures/deps/rb/Gemfile.lock@@ -1,3 +1,18 @@+GIT+ remote: https://github.com/example/rails-fork.git+ revision: 0123456789abcdef0123456789abcdef01234567+ branch: main+ specs:+ actionpack (7.2.0.alpha)+ rack (>= 2.2.4)+ activesupport (7.2.0.alpha)++PATH+ remote: engines/billing+ specs:+ billing (0.1.0)+ rails (>= 7.0)+GEMremote: https://rubygems.org/specs:@@ -5,5 +20,21 @@ GEMrails (7.1.0)rack (>= 2.2.4)+GEM+ remote: https://gems.example.com/+ specs:+ acme-auth (1.4.2)+PLATFORMSruby++DEPENDENCIES+ acme-auth!+ actionpack!+ activesupport!+ billing!+ rack (= 2.0.0)+ rails (~> 7.1)++BUNDLED WITH+ 2.5.6diff --git a/tests/scan.rs b/tests/scan.rsindex 408e159..1d82e18 100644--- a/tests/scan.rs+++ b/tests/scan.rs@@ -145,7 +145,9 @@ fn deps() {advisories: Some(Box::new(known)),include_tests: false,};- // The web/yarn.lock fixture contains a `my-app@workspace:.` entry that must be- // skipped (not counted as a dependency). The expected package count stays 24.- check_with("deps", options, Some(24));+ // Entries that are not fetched from a registry must be skipped (not counted+ // as a dependency): the `my-app@workspace:.` entry in web/yarn.lock, and the+ // gems in the `GIT` and `PATH` sections of rb/Gemfile.lock. Only the gems in+ // its two `GEM` sections count.+ check_with("deps", options, Some(25));}