lockfile_audit 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -1
- data/lib/lockfile_audit/version.rb +1 -1
- data/lib/lockfile_audit/vulnerability_collector.rb +27 -17
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5b293cff106a2d7cdf8214e512965e2d0155ac740d7d26eec9840c8d9634a795
|
|
4
|
+
data.tar.gz: f02bf84ccdd70a87cf2d7bada32ffcba4b343ff553cbc016a7c152df5e7b9f81
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 69158c852ae5786a6181f4df7f871accf34a3d42868a153a818186398bd188aad0f3d5ba7ebdfb1049d1c10692f0e57861f294f3ae6d335d0c5df4c9f88d7772
|
|
7
|
+
data.tar.gz: 3491f0634af4b8caea832f88e7eadfc5b71cf4e4db0dca98ae57a60e27a8c011125b7c42f66e9b2f1f98a8afa782279f4e249d561920e3f0697931f6a9bd6e3b
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.1] - 2026-09-26
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- `VulnerabilityCollector` now invokes `bundle-audit` using the same Ruby
|
|
15
|
+
as the host application (`RbConfig.ruby`) and resolves the exact binary
|
|
16
|
+
path via `Gem.bin_path`, instead of relying on `PATH`. This prevents
|
|
17
|
+
`Bundler::RubyVersionMismatch` errors when the app's Ruby differs from
|
|
18
|
+
the one on `PATH`.
|
|
19
|
+
- Added a missing `raise_not_installed` helper so the collector raises a
|
|
20
|
+
clear `BundlerAuditNotInstalled` error (with stderr detail) instead of
|
|
21
|
+
a `NoMethodError`.
|
|
22
|
+
|
|
10
23
|
## [0.1.0] - 2026-09-26
|
|
11
24
|
|
|
12
25
|
### Added
|
|
@@ -26,5 +39,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
26
39
|
- `LockfileAudit::Errors` namespace with `LockfileNotFound`,
|
|
27
40
|
`BundlerAuditNotInstalled`, and `InvalidAuditJson`.
|
|
28
41
|
|
|
29
|
-
[Unreleased]: https://github.com/Behnam1369/lockfile_audit/compare/v0.1.
|
|
42
|
+
[Unreleased]: https://github.com/Behnam1369/lockfile_audit/compare/v0.1.1...HEAD
|
|
43
|
+
[0.1.1]: https://github.com/Behnam1369/lockfile_audit/compare/v0.1.0...v0.1.1
|
|
30
44
|
[0.1.0]: https://github.com/Behnam1369/lockfile_audit/releases/tag/v0.1.0
|
|
@@ -15,13 +15,9 @@ module LockfileAudit
|
|
|
15
15
|
#
|
|
16
16
|
# When invoking the CLI, the collector runs with a scrubbed environment so
|
|
17
17
|
# the parent process's Bundler state (BUNDLE_*, RUBYOPT, etc.) does not leak
|
|
18
|
-
# into the subprocess.
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
# The CLI is invoked directly (never via `bundle exec` or `gem exec`) so the
|
|
23
|
-
# subprocess stays independent of the parent's Bundler context and does not
|
|
24
|
-
# trigger dependency installation or RDoc generation as a side effect.
|
|
18
|
+
# into the subprocess. It also invokes bundler-audit using the *current*
|
|
19
|
+
# Ruby (RbConfig.ruby) and the exact installed binary path (Gem.bin_path),
|
|
20
|
+
# so the subprocess uses the same Ruby as the host application.
|
|
25
21
|
class VulnerabilityCollector
|
|
26
22
|
# Environment variables that must not leak into the bundler-audit
|
|
27
23
|
# subprocess. These are set by Bundler when the parent process is a
|
|
@@ -76,28 +72,30 @@ module LockfileAudit
|
|
|
76
72
|
private
|
|
77
73
|
|
|
78
74
|
def run_bundler_audit
|
|
79
|
-
stdout, stderr, status = invoke
|
|
75
|
+
stdout, stderr, status = invoke
|
|
80
76
|
return stdout if usable?(stdout, status)
|
|
81
77
|
|
|
78
|
+
raise_not_installed(stderr)
|
|
79
|
+
rescue Gem::Exception
|
|
82
80
|
raise Errors::BundlerAuditNotInstalled,
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"(e.g. `gem install bundler-audit`). " \
|
|
86
|
-
"stderr: #{stderr.to_s.strip}"
|
|
81
|
+
"bundler-audit is not installed for #{RbConfig.ruby} (#{RUBY_VERSION}). " \
|
|
82
|
+
"Install it for this Ruby: gem install bundler-audit"
|
|
87
83
|
rescue Errno::ENOENT
|
|
88
|
-
|
|
89
|
-
"bundle-audit is not installed or not on PATH. " \
|
|
90
|
-
"Install it with `gem install bundler-audit`."
|
|
84
|
+
raise_not_installed(nil)
|
|
91
85
|
end
|
|
92
86
|
|
|
93
|
-
def invoke
|
|
87
|
+
def invoke
|
|
94
88
|
Open3.capture3(
|
|
95
89
|
clean_env,
|
|
96
|
-
|
|
90
|
+
RbConfig.ruby, bundle_audit_path, "check", "--format", "json",
|
|
97
91
|
chdir: File.dirname(File.expand_path(@lockfile_path))
|
|
98
92
|
)
|
|
99
93
|
end
|
|
100
94
|
|
|
95
|
+
def bundle_audit_path
|
|
96
|
+
Gem.bin_path("bundler-audit", "bundle-audit")
|
|
97
|
+
end
|
|
98
|
+
|
|
101
99
|
# Builds an environment hash that removes the inherited Bundler state.
|
|
102
100
|
# Passing nil as the value to Open3 unsets the variable in the child.
|
|
103
101
|
def clean_env
|
|
@@ -116,6 +114,18 @@ module LockfileAudit
|
|
|
116
114
|
false
|
|
117
115
|
end
|
|
118
116
|
|
|
117
|
+
# Raises BundlerAuditNotInstalled with an actionable message that
|
|
118
|
+
# includes stderr when available.
|
|
119
|
+
def raise_not_installed(stderr)
|
|
120
|
+
detail = stderr.to_s.strip
|
|
121
|
+
message = "bundler-audit could not be invoked. " \
|
|
122
|
+
"Ensure the `bundler-audit` gem is installed for this Ruby " \
|
|
123
|
+
"(#{RUBY_VERSION}) and run `bundle-audit update` to fetch the " \
|
|
124
|
+
"advisory database."
|
|
125
|
+
message += " stderr: #{detail}" unless detail.empty?
|
|
126
|
+
raise Errors::BundlerAuditNotInstalled, message
|
|
127
|
+
end
|
|
128
|
+
|
|
119
129
|
# Maps a single bundler-audit finding onto the public schema.
|
|
120
130
|
#
|
|
121
131
|
# bundler-audit has used slightly different key names across versions, so
|