Repository navigation
Sync: end an older release line where the next vulnerable range starts - #1330
Merged
Merged
Conversation
"~> <first patched>" stops at the next minor, so a later minor of an older major is flagged although it has the fix. Use the start of the next vulnerable range instead, and sort release lines as versions so 2.10 comes after 2.9.
An adversarial review of the first commit found that it ignored vulnerable ranges without a fix, widened backported four-segment fixes that later releases can predate (cgi 0.1.1 and 0.1.0.2), and raised on a version RubyGems cannot parse. Keep the plain "~>" in each of those cases, and sort the vulnerable ranges as versions too, so unaffected_versions starts at the oldest range.
Paul-Bob
marked this pull request as draft
November 20, 2026 12:53
Member
|
Reviewed above
|
Two more adversarial passes left these on constructed input. A range start RubyGems cannot parse was printed into unaffected_versions, and two starts that are equal but spelled differently sorted in node order. Such a start now means nothing is listed as unaffected, and ">" sorts after ">=" and "=". Every guard in the rule has an example that fails without it.
Paul-Bob
marked this pull request as ready for review
November 21, 2026 11:06
simi
approved these changes
Nov 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The sync stops flagging a later minor of an older major that has the fix, and it flags 344 vulnerable releases it used to miss.
The script wrote
~> <first patched>for every release line except the newest, so avo3.34.1was flagged after a fix in3.33.1. #1265 and #1329 corrected that by hand. It also sorted versions as text, so2.10came before2.9and vulnerable releases were marked as patched or unaffected.I replayed the old and the new script over GitHub's data, 106,526 checks against every released version.
No vulnerable version loses its flag, on the replay or on 80,000 generated inputs. The rule went through three adversarial review passes. Four-segment fixes such as Rails
8.0.5.1keep the plain~>on purpose, because a later release can predate a backport (cgi0.1.1and0.1.0.2).Some context. A user on avo
3.34.1was flagged bybundler-auditfor two advisories with fixes in3.33.1and3.33.2. I had my agent trace it and write this change. It ran in Claude Code, on Claude Opus 5.5 for the diagnosis and Claude Fable 5.2 for the change, its reviews and the replay.For AI agents
Where
lib/github_advisory_sync.rb,patched_versions_for. Called fromcreateandupdate.updatefillspatched_versionsonly when the saved file has none, so no existing file changes.patched_until_next_range, withstarts_after?,ends_by?andminor_line_ending_at. The rule for every release line except the newest.range_order. The sort key ofvulnerable_version_ranges_for, which decides whatunaffected_versions_forreturns.spec/github_advisory_sync_spec.rb. 22 new examples, built with thegeneratedhelper.Why this shape
For an older line with fix
p, the code takes the lowest vulnerable range startsabovep, from every range of the gem, with or without a fix.sis3.33.1, next range>= 4.0.0.beta.1~> 3.33.1~> 3.33, >= 3.33.1~> pcovers2.2.10, next range>= 2.2.11~> 2.2.10>= 2.2.10, < 2.2.112.3.18, next range>= 3.1.0~> 2.3.18~> 2.3.18~> pis the answer whenever the data is unclear: another range overlaps the fix, no range starts above it, or a version does not parse.Gem::Version.newraises on a bad string, and one of those would abort a whole sync run.= 3.40.0between avo3.33.1and4.0) lost its flag.8.0.5.1to~> 8.0.5, >= 8.0.5.1, the shape of Fix activestorage CVE-2026-66066 patched_versions #1191) was tried and taken out. On the replay it clears 536 more releases, and also cgi0.1.1, released 2021-11-24, a year before the backported fix0.1.0.2of 2022-11-22. GitHub's range for that advisory is< 0.1.0.2, so nothing in the data tells the two shapes apart. Release dates would.>= p, < sfor every line was tried and taken out.< 4.0.0matches4.0.0.rc1, so it cleared 1,158 prereleases of the next line, and it cleared release lines GitHub lists no fix for (activerecord3.0.xbetween2.3.18and3.1.12).unaffected_versionsstarts below the lowest range start by version. A range with no lower bound, or with a start RubyGems cannot parse, means nothing is listed as unaffected. At equal starts>sorts after>=and=, so the start itself stays vulnerable.>= newest, as before.Invariants
patched_versionsandunaffected_versionstogether.spec/versions_example.rbrequires.Verify
bundle exec rspec spec/github_advisory_sync_spec.rbgives 25 examples, 0 failures. Onmaster, 7 of the 22 new examples fail. The other 15 hold the conservative cases.masterand from this branch into separate modules, buildsGitHubAdvisoryobjects fromsecurityVulnerabilities(ecosystem: RUBYGEMS)(1,976 nodes and 1,196 advisory and gem pairs on 2026-11-20), and for the 393 pairs with more than one release line compares what each output flags with GitHub's ranges, for every version inhttps://rubygems.org/api/v1/versions/<gem>.json.masteragainst this branch: 60,000 inputs shaped like GitHub's and 20,000 malformed ones. No vulnerable version loses a flag, and nothing raises that did not raise before.gems/avo/CVE-2026-55518.ymlremoved,bundle exec rake "sync_github_advisories[avo]"writes~> 3.32, >= 3.32.1for it.Follow-ups
3.0.0.pre1to3.0.0.pre12in CVE-2023-34102 and CVE-2023-34103, where an unfixed range sits above the newest fix. Unchanged by this PR.= X) inside the span~> pcovers gives>= p, < X, so later releases of that minor are flagged. Today's data has no such case.>= 3) now gives< 3where the text sort gave another range's start. In 21 of the 80,000 fuzz inputs that output failed the lint rules where the old one passed, each time on a one-segment bound (< 3or<= 3). Today's data has no such start.Written with coexist