Publish data/advisories.json indexed by formula name - #30
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a generated, formula-indexed advisory corpus file (data/advisories.json) and automation to keep it up-to-date, enabling consumers (notably Homebrew/brew) to fetch advisory data in a single request rather than per-record lookups.
Changes:
- Introduces
AdvisoryIndexto concatenateadvisories/*.jsonintodata/advisories.json, grouped by formula and sorted deterministically. - Adds
rake advisories:concatand wires it into the existingRegenerateworkflow. - Adds a test suite covering grouping/sorting, error handling, and output formatting for the new index.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
lib/advisory_index.rb |
Implements the build/write logic for the new formula-indexed advisory JSON output. |
Rakefile |
Adds advisories:concat task to generate/update data/advisories.json. |
.github/workflows/regenerate.yml |
Runs the new concat rake task after regenerating advisory records. |
test/advisory_index_test.rb |
Adds coverage for AdvisoryIndex behavior and output format. |
data/advisories.json |
Commits the initial generated corpus so it’s immediately available to consumers post-merge. |
Comments suppressed due to low confidence (1)
lib/advisory_index.rb:43
schema_versions.compact.maxcompares schema versions as plain strings, which can pick the wrong “highest” version lexicographically (e.g. "1.10.0" sorts before "1.9.0"). UseGem::Versionfor numeric semantic version comparison and then convert back to a string for the JSON output.
{
"meta" => {
"count" => by_formula.each_value.sum(&:size),
"schema_version" => schema_versions.compact.max,
},
"advisories" => by_formula.transform_values { |records| records.sort_by { |r| r.fetch("id") } }
.sort.to_h,
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Jul 28, 2026
p-linnane
approved these changes
Jul 28, 2026
kmarekspartz
left a comment
There was a problem hiding this comment.
No strong opinions here, just thought I'd take a look since you've been a great feedback provider!
andrew
force-pushed
the
concat-advisories
branch
from
July 31, 2026 11:52
8360f14 to
e5252f1
Compare
andrew
force-pushed
the
concat-advisories
branch
from
July 31, 2026 11:54
e5252f1 to
8a67f1a
Compare
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.
Concatenates every
advisories/*.jsonrecord intodata/advisories.json, grouped byaffected[0].package.nameand sorted byid, so consumers can fetch the whole corpus in one request. Shape:{ "meta": {"count": N, "schema_version": "..."}, "advisories": {"<formula>": [{<record>}, ...], ...} }rake advisories:concatbuilds it;regenerate.ymlruns it afterbrew generate-vulns-advisoriesand the existinggit add advisories/ data/picks it up. The initial file (44 records, 10 formulae, ~150KB) is committed sohttps://raw.githubusercontent.com/Homebrew/advisory-database/main/data/advisories.jsonis live on merge.This unblocks the
generate-formula-apichange in Homebrew/brew that reads this file (instead of querying OSV live per API build) and attaches avulnerabilitiesfield to each formula's API JSON. #29 will need the samerake advisories:concatstep before itsgit add; happy to add that here or on #29's branch.