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.

fix(deps): only look up Gemfile.lock gems from GEM sections (#94)

Onur Ugur1dd1ecec4c15
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 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 a
local 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 placeholder
such 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 Google
diff --git a/src/deps.rs b/src/deps.rs
index 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/EXPECTED
index 7c48d48..c642bf6 100644
--- a/tests/fixtures/deps/EXPECTED
+++ b/tests/fixtures/deps/EXPECTED
@@ -1,7 +1,7 @@
web/package-lock.json:7 dependency.known-vulnerability
api/requirements.txt:3 dependency.known-vulnerability
svc/go.mod:6 dependency.known-vulnerability
-rb/Gemfile.lock:4 dependency.known-vulnerability
+rb/Gemfile.lock:19 dependency.known-vulnerability
rs/Cargo.lock:5 dependency.known-vulnerability
php/composer.lock:5 dependency.known-vulnerability
pnpm/pnpm-lock.yaml:29 dependency.known-vulnerability
diff --git a/tests/fixtures/deps/rb/Gemfile.lock b/tests/fixtures/deps/rb/Gemfile.lock
index 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)
+
GEM
remote: https://rubygems.org/
specs:
@@ -5,5 +20,21 @@ GEM
rails (7.1.0)
rack (>= 2.2.4)
+GEM
+ remote: https://gems.example.com/
+ specs:
+ acme-auth (1.4.2)
+
PLATFORMS
ruby
+
+DEPENDENCIES
+ acme-auth!
+ actionpack!
+ activesupport!
+ billing!
+ rack (= 2.0.0)
+ rails (~> 7.1)
+
+BUNDLED WITH
+ 2.5.6
diff --git a/tests/scan.rs b/tests/scan.rs
index 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));
}