still_active 3.0.0.rc5 → 3.0.0.rc6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23f5514e3d64b78d82b0812eece16e13325045841fdd0b253acff4f7c5e31dae
4
- data.tar.gz: b9d8907b6699755744639cc00e31135cf45991416c222990dc79247ae4c2d88f
3
+ metadata.gz: 56cc5a97641e59d9c11683f736609c52de9818aa90c8eeebec4c64909cbc1981
4
+ data.tar.gz: c50ae5f85c0e258f0a3620159c05c4aaf131e9c25556ed940494d1fd90b829db
5
5
  SHA512:
6
- metadata.gz: 4d571b1a3788960da4f6ae9fb04466c00ab6c3c6dcd1bd2051b4d6244aaf8e14248aeb3acc1c4d2179db33d8d18f98e320182ab0cb15635290e1be795c5509f9
7
- data.tar.gz: 7071c08ca0bb94ff85edee290d6d55d47247093863f5599a8c56c2899871ef80e424daac09142e2c9978e0efbd5020d493c88abadc28c5a3bd5b303ffcea6003
6
+ metadata.gz: a067ca8d8e55a0d796efd76d88f95e1081ab520cbd6bd7496aec1791d2bf85e621a82edaca2bb458a758c82a04acdc9c4e6e4f2c2dd3456adf61386cec41652a
7
+ data.tar.gz: bb99f7070a1c9c0c938df5deb1573ea400f608e4cf9a680cb06879c873a67589fcd3b2fda0a33d5cee14d8191515451bff37c6c0b72a6341a318919b9b3c80f1
data/CHANGELOG.md CHANGED
@@ -34,6 +34,7 @@ The new `--fail-if-poison[=TIER]` and `--fail-if-language-ceiling[=TIER]` gates
34
34
 
35
35
  ### Fixed
36
36
 
37
+ - **A patched version is no longer reported vulnerable while an advisory's backport fixes are still propagating.** deps.dev's per-version `advisoryKeys`, the discovery source for every cross-ecosystem advisory (and the second source on the native Ruby path), mirrors OSV/GHSA data with an ingestion lag. Advisories are routinely *amended* after publication: a CVE lands with a fix on the current release line, maintainers backport to the older supported lines, and the advisory is then amended to carry those branch ranges. Until deps.dev re-ingests, it keeps serving the pre-amendment record, whose broader range still covers versions the amendment has since marked patched. Live receipt: `GHSA-mh99-v99m-4gvg` was published 2026-07-24 as a single `introduced 0 / fixed 5.0.8` range and amended 2026-07-31 to carry the 1.1.17, 2.1.3 and 3.0.3 branches; hours after the amendment deps.dev still answered from the old record, so `--sbom` reported the fully patched `brace-expansion` 1.1.18 and 2.1.4 as `status: "vulnerable"` where `npm audit` correctly reported none. still_active now confirms each deps.dev-discovered advisory against OSV's own `/v1/query`, deps.dev's upstream, which applies the declared ranges per ecosystem and reflects an amendment immediately, and drops the ones OSV says do not apply to the audited version. The window reopens with every backported fix, so this is a standing correction rather than a workaround for one stale record. A dropped advisory is named on stderr, so the one path that can turn a red run green always leaves a trace. (It is lag, not a parsing defect on deps.dev's part: 341 multi-branch advisories across npm/rubygems/pypi/cargo were compared against OSV over 589 version checks, and every one agreed.) Dropping a finding is the one direction this tool must never get wrong, so it needs positive contradiction on every count: the advisory came from deps.dev alone (a ruby-advisory-db verdict is never overruled, it matches versions itself and is the Ruby authority), OSV served a record for it that names the package under that exact ecosystem and spelling, and the query for that exact version succeeded without listing it. A failed query, an unmapped ecosystem, a name OSV spells differently, a record holding no version data for the package, or an answer that isn't readable end to end all keep the advisory. That last one matters more than it sounds: OSV's genuine all-clear is a bare `{}` with no positive marker of its own, and OSV paginates once a query exceeds 20 seconds (a latency trigger, so it can land on any package under load), so a truncated page is treated as "we don't know", never as "clean". Costs one request per advisory-bearing package.
37
38
  - **A private-source gem is no longer linked to the public rubygems.org page.** `ruby_gems_url` was set to `rubygems.org/gems/<name>` for any gem with versions, including one resolving from a private source, where that URL is a public name collision (for `sidekiq-pro`, the `0.0.3` squat-warning decoy) rather than the gem the user installs. It is now set only for a gem that actually lives on public rubygems.org, the same #43 guard the repository-URL substitution already applies.
38
39
  - **An Artifactory-sourced gem is no longer reported `(YANKED)` when its real host is a legacy private registry.** Artifactory's `/api/v1/versions/<gem>.json` merges metadata from a virtual repo's member remotes; when a member (a legacy host like Contribsys) can't answer it, the merge returns only whatever rubygems.org holds for the name, which for `sidekiq-pro` is a `0.0.3` squat-warning placeholder. still_active read that endpoint first, so the installed version was absent from the list and looked yanked. It now reads the RubyGems compact index (`/info/<gem>`, what Bundler resolves through) instead, listing exactly the versions the repo can resolve, with the versions API demoted to dating those versions and AQL kept only as a last resort for hosts serving no compact index (and no longer presenting its cache timestamp as a release date). A side benefit: the compact index's per-version Ruby requirement and dependency constraints let the runtime-ceiling and poison-pill checks work on Artifactory sources for the first time.
39
40
  - **SARIF `tool.driver` version fields are populated and spec-correct.** `version` was null, so a consumer reading `tool.driver.version` (rather than `semanticVersion`) saw nothing, and `semanticVersion` carried the RubyGems version verbatim (`3.0.0.rc4`), which is not valid SemVer 2.0.0 for a prerelease. Now `version` carries the free-form gem version and `semanticVersion` the SemVer form (`3.0.0-rc4`); final releases like `3.0.0` were already valid.
@@ -76,7 +76,9 @@ module StillActive
76
76
  vulnerabilities = vulnerabilities_for(info)
77
77
  # Enrich with OSV: a real GHSA severity label (deps.dev can't score a CVSS-4-only
78
78
  # advisory) and the fixed-version ranges the "capped below the fix" signal needs.
79
- OsvClient.enrich(vulnerabilities, ecosystem: ecosystem, name: name)
79
+ # Passing the version also lets OSV confirm the advisory actually applies to it,
80
+ # correcting deps.dev's lag on an advisory amended with backport fixes.
81
+ vulnerabilities = OsvClient.enrich(vulnerabilities, ecosystem: ecosystem, name: name, version: version)
80
82
  scorecard = DepsDevClient.project_scorecard(project_id: project_id)
81
83
  repo = repo_signals(project_id)
82
84
 
@@ -15,8 +15,13 @@ module StillActive
15
15
  # poison cap's ceiling.
16
16
  #
17
17
  # Enrichment is best-effort: any failure (missing record, transport error, odd
18
- # shape) leaves the advisory exactly as deps.dev produced it. It must never drop
19
- # an advisory the audit already found, so it only ever ADDS fields.
18
+ # shape) leaves the advisory exactly as deps.dev produced it.
19
+ #
20
+ # OSV is also the ARBITER of whether a deps.dev-discovered advisory really applies
21
+ # to the audited version (see reject_unaffected), which is the one place this module
22
+ # removes rather than adds. That direction is the dangerous one -- a wrongly dropped
23
+ # advisory reads a vulnerable dependency as clean -- so every degrade path here must
24
+ # resolve to "keep", and only an unambiguous OSV contradiction may drop.
20
25
  module OsvClient
21
26
  extend self
22
27
 
@@ -45,25 +50,24 @@ module StillActive
45
50
  TYPE_VERSIONS = {"CVSS_V4" => "4.0", "CVSS_V3" => "3.1", "CVSS_V2" => "2.0"}.freeze
46
51
 
47
52
  # Enrich each advisory in place with the OSV severity label and the fixed
48
- # versions for the audited package. A missing/failed lookup is a no-op on that
49
- # advisory (it keeps whatever deps.dev gave it), never a raise.
50
- def enrich(advisories, ecosystem:, name:)
51
- advisories.each do |advisory|
52
- record = detail(advisory_id: advisory[:id])
53
- next if record.nil?
54
-
55
- advisory[:osv_severity] = record[:severity_label]
56
- advisory[:osv_cvss_score] = record[:cvss_score]
57
- advisory[:cvss_version] = record[:cvss_version]
58
- advisory[:cvss_vector] = record[:cvss_vector]
59
- advisory[:fixed_versions] = fixed_versions(record, ecosystem: ecosystem, name: name)
60
- rescue => e
61
- # Enrichment is additive and best-effort. An unexpected OSV shape must never
62
- # raise out through the workflow's per-gem rescue, which would DROP the whole
63
- # gem and read a known-vulnerable dependency as clean. Leave the advisory
64
- # exactly as deps.dev produced it.
65
- warn("warning: OSV enrichment for #{advisory[:id]} failed: #{e.class} (#{e.message}); leaving advisory unchanged")
53
+ # versions for the audited package, and return the advisories that survive
54
+ # version confirmation (see reject_unaffected). A missing/failed lookup is a
55
+ # no-op on that advisory (it keeps whatever deps.dev gave it), never a raise.
56
+ def enrich(advisories, ecosystem:, name:, version: nil)
57
+ # Each eligible advisory is paired with OSV's own identifiers for it, which the
58
+ # confirmation match needs alongside deps.dev's (see detail).
59
+ backed = advisories.filter_map do |advisory|
60
+ osv_ids = apply_record(advisory, ecosystem: ecosystem, name: name)
61
+ [advisory, osv_ids] if osv_ids
66
62
  end
63
+ reject_unaffected(advisories, backed, ecosystem: ecosystem, name: name, version: version)
64
+ rescue => e
65
+ # The confirmation pass runs outside apply_record's per-advisory rescue, and an
66
+ # escape from here would hit the workflow's per-gem rescue and strip the gem of
67
+ # ALL its signals -- reading a known-vulnerable dependency as clean, the very
68
+ # thing this module exists to prevent. Keep every advisory instead.
69
+ warn("warning: OSV version confirmation for #{name} failed: #{e.class} (#{e.message}); keeping every advisory")
70
+ advisories
67
71
  end
68
72
 
69
73
  # Fetch and parse one OSV record by advisory id (GHSA/CVE). Returns
@@ -79,6 +83,11 @@ module StillActive
79
83
 
80
84
  cvss = best_cvss(body)
81
85
  {
86
+ # OSV's own identity for the advisory, unioned into the match against a query
87
+ # result. Asking for a CVE returns the GHSA record (OSV resolves aliases), so
88
+ # deps.dev's id alone can miss the id the query answers with, and reading a
89
+ # listed advisory as absent would drop a real finding.
90
+ identifiers: [body["id"], *Array(body["aliases"])].grep(String),
82
91
  severity_label: body.dig("database_specific", "severity"),
83
92
  cvss_score: cvss[:score],
84
93
  cvss_version: cvss[:version],
@@ -89,6 +98,158 @@ module StillActive
89
98
 
90
99
  private
91
100
 
101
+ # Applies one OSV record to one advisory, in place. Returns OSV's identifiers for
102
+ # the advisory when it is eligible for the version confirmation below (only OSV
103
+ # data may overrule OSV-derived data), or nil when it is not and must be kept
104
+ # whatever the query says.
105
+ def apply_record(advisory, ecosystem:, name:)
106
+ record = detail(advisory_id: advisory[:id])
107
+ return if record.nil?
108
+
109
+ advisory[:osv_severity] = record[:severity_label]
110
+ advisory[:osv_cvss_score] = record[:cvss_score]
111
+ advisory[:cvss_version] = record[:cvss_version]
112
+ advisory[:cvss_vector] = record[:cvss_vector]
113
+ advisory[:fixed_versions] = fixed_versions(record, ecosystem: ecosystem, name: name)
114
+ record[:identifiers] if names_package?(record, ecosystem: ecosystem, name: name)
115
+ rescue => e
116
+ # Enrichment is additive and best-effort. An unexpected OSV shape must never
117
+ # raise out through the workflow's per-gem rescue, which would DROP the whole
118
+ # gem and read a known-vulnerable dependency as clean. Leave the advisory
119
+ # exactly as deps.dev produced it, and hold it (nil) rather than risk
120
+ # dropping it on a record we couldn't read.
121
+ warn("warning: OSV enrichment for #{advisory[:id]} failed: #{e.class} (#{e.message}); leaving advisory unchanged")
122
+ nil
123
+ end
124
+
125
+ # Drops the advisories that OSV's own version matching says don't apply to the
126
+ # audited version. deps.dev is the discovery source, but it MIRRORS OSV/GHSA data
127
+ # with an ingestion lag, and advisories get AMENDED after publication: the usual
128
+ # shape is a CVE published with a fix on the current release line, then backports
129
+ # to the older supported lines, then an amendment adding those branch ranges. Until
130
+ # deps.dev re-ingests, it keeps serving the pre-amendment record, whose broader
131
+ # range still covers versions the amendment has since marked patched.
132
+ #
133
+ # Receipt (2026-07-31): GHSA-mh99-v99m-4gvg was published 07-24 with a single
134
+ # range, introduced 0 / fixed 5.0.8. Backports 3.0.3, 2.1.3 and 1.1.17 shipped
135
+ # 07-27 to 07-29, and the advisory was amended 07-31 19:39Z to carry all four
136
+ # branches. Hours later deps.dev still answered from the 07-24 record, reporting
137
+ # the patched 1.1.17/1.1.18/2.1.3/2.1.4/3.0.3 as vulnerable.
138
+ #
139
+ # This is lag, NOT a parsing defect: 341 multi-branch advisories across
140
+ # npm/rubygems/pypi/cargo were compared against OSV over 589 version checks, and
141
+ # every one agreed. So the correction has to be a live re-check, not a local range
142
+ # fix. We
143
+ # ask OSV's /v1/query, deps.dev's own upstream, which applies the declared ranges
144
+ # under each ecosystem's semantics and reflects an amendment immediately. It also
145
+ # saves reimplementing cross-ecosystem version ordering.
146
+ #
147
+ # The window reopens with every backported fix, so this is structural, not a
148
+ # one-off worth waiting out.
149
+ #
150
+ # Removing a finding is the one direction this tool must never get wrong, so a drop
151
+ # needs positive contradiction on every count: the advisory came from deps.dev ALONE
152
+ # (ruby-advisory-db does its own version matching and is the Ruby authority, so its
153
+ # verdict stands), OSV served a record for it that names this package under this
154
+ # ecosystem and spelling, and the query for this exact version succeeded without
155
+ # listing it. Anything unknown -- no version, unmapped ecosystem, failed query --
156
+ # keeps the advisory.
157
+ def reject_unaffected(advisories, backed, ecosystem:, name:, version:)
158
+ candidates = backed.select { |advisory, _osv_ids| advisory[:source] == "deps.dev" }
159
+ return advisories if candidates.empty? || version.to_s.empty?
160
+
161
+ affected = affected_identifiers(ecosystem: ecosystem, name: name, version: version)
162
+ return advisories if affected.nil?
163
+
164
+ unaffected = candidates
165
+ .reject { |advisory, osv_ids| (identifiers(advisory) | osv_ids).intersect?(affected) }
166
+ .map(&:first)
167
+ # Say so when a finding is removed. This is the only path that can turn a red run
168
+ # green, and a silent drop leaves no way to tell "OSV cleared it" from "the audit
169
+ # missed it". Matches the per-gem stderr notes the severity gates already emit.
170
+ unaffected.each { |advisory| warn("still_active: #{name}@#{version} is not affected by #{advisory[:id]} per OSV; deps.dev listed it, dropping") }
171
+ advisories - unaffected
172
+ end
173
+
174
+ # Every advisory identifier OSV reports as affecting this exact package version,
175
+ # or nil when the question can't be asked or answered (unmapped ecosystem, failed
176
+ # request, unusable body). An EMPTY array is a real answer -- "nothing affects this
177
+ # version" -- and must stay distinct from the nil, which means "we don't know".
178
+ #
179
+ # That distinction is the whole safety of the drop, so an empty array is only ever
180
+ # returned for a body that positively IS an empty OSV result. OSV's genuine all-clear
181
+ # is a bare `{}` (verified live, and identical to what an unknown package name
182
+ # returns), which gives a malformed or truncated body no distinguishing marker of
183
+ # its own: read loosely, every unparseable 200 would fabricate an all-clear.
184
+ def affected_identifiers(ecosystem:, name:, version:)
185
+ osv_ecosystem = ECOSYSTEM_NAMES[ecosystem || :rubygems]
186
+ return if osv_ecosystem.nil?
187
+
188
+ query = {version: version, package: {name: name, ecosystem: osv_ecosystem}}
189
+ body = HttpHelper.post_json(BASE_URI, "/v1/query", body: JSON.generate(query))
190
+ return unless body.is_a?(Hash)
191
+
192
+ identifiers_from(body)
193
+ rescue => e
194
+ warn("warning: OSV version confirmation for #{name}@#{version} failed: #{e.class} (#{e.message}); keeping every advisory")
195
+ nil
196
+ end
197
+
198
+ # The identifiers in one /v1/query body, or nil when the body isn't a complete,
199
+ # readable answer. A truncated answer is not an answer: OSV paginates past 1000
200
+ # vulnerabilities OR once a query exceeds 20 seconds, and documents that a page can
201
+ # carry ONLY a next_page_token. That second trigger is latency, not package size, so
202
+ # it can land on any package on a slow day; reading it as "nothing affects this
203
+ # version" would drop real findings at random. We decline to filter rather than
204
+ # walk the pages, since the pass only ever removes false positives.
205
+ def identifiers_from(body)
206
+ return if body["next_page_token"] || body["nextPageToken"]
207
+ # A bare `{}` is OSV's genuine "nothing affects this version" (verified live). It
208
+ # has to be matched exactly, not as "no vulns key": an error envelope served with a
209
+ # 200 (`{"code":3,"message":...}`) has no vulns key either, and reading that as an
210
+ # all-clear would drop every advisory on the package.
211
+ return [] if body.empty?
212
+
213
+ vulns = body["vulns"]
214
+ return unless vulns.is_a?(Array)
215
+ # EVERY entry has to be readable, not just one of them. Skipping the unreadable
216
+ # ones would silently shorten the list, and a short list is indistinguishable from
217
+ # OSV not listing that advisory at all: the one it named but we couldn't parse
218
+ # would be dropped as unaffected. `all?` holds on an empty array, so OSV's other
219
+ # genuine all-clear shape, `{"vulns": []}`, still answers.
220
+ return unless vulns.all? { |vuln| vuln.is_a?(Hash) && vuln["id"].is_a?(String) }
221
+
222
+ vulns.flat_map { |vuln| [vuln["id"], *vuln["aliases"]] }.grep(String)
223
+ end
224
+
225
+ # An advisory's own id plus its aliases, mirroring VulnerabilityHelper's merge
226
+ # identity: OSV keys a record by GHSA while deps.dev may hand us the CVE (or the
227
+ # reverse), so matching on the primary id alone would read a listed advisory as
228
+ # absent and drop a real finding.
229
+ def identifiers(advisory)
230
+ [advisory[:id], *advisory[:aliases]].compact.map(&:to_s)
231
+ end
232
+
233
+ # Does this record carry version data for the audited package, under the exact
234
+ # ecosystem and spelling we're querying with? Both halves guard a fabricated
235
+ # all-clear, because OSV answers an unknown package and a patched version with the
236
+ # same bare `{}`:
237
+ #
238
+ # NAME -- registry name normalization differs by ecosystem (PyPI folds case and
239
+ # -/_/.), so a spelling mismatch would turn a missed lookup into "not affected".
240
+ # Exact equality is stricter than OSV's own matching, which costs us the fix on a
241
+ # case-divergent name; that's the safe direction to be wrong in.
242
+ #
243
+ # VERSIONED -- an affected entry with no ranges and no version list (or one whose
244
+ # window lives somewhere /v1/query can't match on, like a GIT range) is OSV having
245
+ # no opinion on versions at all. The query can then never return that record for
246
+ # ANY version, so treating its silence as contradiction would drop the advisory
247
+ # permanently, for every user, while deps.dev still asserts the version is affected.
248
+ def names_package?(record, ecosystem:, name:)
249
+ osv_ecosystem = ECOSYSTEM_NAMES[ecosystem || :rubygems]
250
+ record[:affected].any? { |a| a[:name] == name && a[:ecosystem] == osv_ecosystem && a[:versioned] }
251
+ end
252
+
92
253
  # The highest-version CVSS vector the record carries, as { score:, version:,
93
254
  # vector: } (a computed base score, the "3.1"/"4.0" version, and the raw string),
94
255
  # or all-nil. deps.dev has no v4 score, so this is what gives a CVSS-4-only
@@ -132,12 +293,21 @@ module StillActive
132
293
  package = entry["package"]
133
294
  return unless package.is_a?(Hash) && package["name"]
134
295
 
135
- fixed = Array(entry["ranges"]).flat_map do |range|
136
- next [] unless range.is_a?(Hash)
296
+ ranges = Array(entry["ranges"]).select { |range| range.is_a?(Hash) }
297
+ fixed = ranges.flat_map { |range| Array(range["events"]).filter_map { |event| event["fixed"] if event.is_a?(Hash) } }
298
+ {ecosystem: package["ecosystem"], name: package["name"], fixed: fixed, versioned: version_matchable?(entry, ranges)}
299
+ end
137
300
 
138
- Array(range["events"]).filter_map { |event| event["fixed"] if event.is_a?(Hash) }
139
- end
140
- {ecosystem: package["ecosystem"], name: package["name"], fixed: fixed}
301
+ # Range types /v1/query can resolve a VERSION against. A GIT range is commit-graph
302
+ # data a version query never matches, so a record carrying only those has no version
303
+ # opinion to contradict deps.dev with. A range missing its type reads the same way.
304
+ VERSION_RANGE_TYPES = ["SEMVER", "ECOSYSTEM"].freeze
305
+
306
+ # Does this affected entry hold data a version query could match on -- an explicit
307
+ # version list, or a version-ordered range? See names_package? for why the absence
308
+ # of it has to block a drop rather than permit one.
309
+ def version_matchable?(entry, ranges)
310
+ !Array(entry["versions"]).empty? || ranges.any? { |range| VERSION_RANGE_TYPES.include?(range["type"]) }
141
311
  end
142
312
 
143
313
  def encode(value)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StillActive
4
- VERSION = "3.0.0.rc5"
4
+ VERSION = "3.0.0.rc6"
5
5
  end
@@ -384,8 +384,9 @@ module StillActive
384
384
  vulnerabilities = VulnerabilityHelper.merge_advisories(deps_dev: deps_dev_vulns, ruby_advisory_db: radb_vulns)
385
385
  # Enrich with OSV: a real GHSA severity label (deps.dev can't score a CVSS-4-only
386
386
  # advisory) and the fixed-version ranges the "capped below the fix" signal needs.
387
- # Native path is rubygems.
388
- OsvClient.enrich(vulnerabilities, ecosystem: :rubygems, name: gem_name)
387
+ # Native path is rubygems. The version also lets OSV confirm a deps.dev-only
388
+ # advisory applies to it; a ruby-advisory-db verdict is never overruled.
389
+ vulnerabilities = OsvClient.enrich(vulnerabilities, ecosystem: :rubygems, name: gem_name, version: version)
389
390
  {
390
391
  scorecard_score: scorecard&.dig(:score),
391
392
  scorecard_maintained: scorecard&.dig(:maintained),
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: still_active
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.rc5
4
+ version: 3.0.0.rc6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Floyd