Commit Graph
51001 Commits
Author SHA1 Message Date
Andrew NesbittandGitHub 6bd951d96e Merge pull request #23115 from Homebrew/vulns-osv-export-archaeology
generate-vulns-advisories: derive initial fixed via FormulaVersions
6.0.11
2026-07-14 22:39:17 +00:00
Mike McQuaidandGitHub 0b4b55e3af Merge pull request #23108 from Homebrew/bootsnap-prewarm
Prewarm Bootsnap caches after `brew update`
2026-07-14 22:35:00 +00:00
Mike McQuaidandGitHub 22f8b50f83 Merge pull request #23107 from Homebrew/download-queue-wakeups
download_queue: wake on completed downloads
2026-07-14 22:34:42 +00:00
Mike McQuaidandGitHub 915cb8d088 Merge pull request #23105 from Homebrew/start-bottle-downloads-earlier
Start bottle downloads before dependency fetches
2026-07-14 22:34:24 +00:00
Patrick LinnaneandGitHub 9fd4e814a3 Merge pull request #23113 from Homebrew/test_bot-restrict-portable-ruby-tests
test_bot/formulae: only run subset of `brew tests` for portable Ruby
2026-07-14 21:10:46 +00:00
Andrew Nesbitt 4130be563c generate-vulns-advisories: derive initial fixed via FormulaVersions
For records with no existing file, walk homebrew-core git history
(newest-first) via FormulaVersions and use the pkg_version at the oldest
revision where the CVE still appears in resolved_ids as the `fixed`
boundary, instead of the current pkg_version. Existing records preserve
their on-disk ranges (per the merge behaviour in the previous commit),
so this only fires once per newly-annotated (formula, CVE) pair.

The FormulaVersions instance and its rev_list output are cached per
formula so subsequent CVEs for the same formula reuse the ~90s
path-filtered git rev-list and per-revision formula loads. OsvExport.run
now runs inside the SimulateSystem block so historical loads are
runner-OS-independent. Historical revisions are evaluated under the base
simulation only; a resolves inside on_linux/on_intel falls through to
the current pkg_version (documented; no such annotation exists in core
today).

Spot-checked against real homebrew-core: unzip CVE-2014-8139 -> 6.0_6
(current is 6.0_8), CVE-2022-0529 -> 6.0_8; libquicktime CVE-2016-2399
-> 1.2.4_5 (the resolves-added-later case; hand-correct to _4).
2026-07-14 14:09:30 -07:00
Andrew NesbittandGitHub 945b48cb9f Merge pull request #23112 from Homebrew/vulns-osv-export-merge
vulns/osv_export: merge into existing records instead of overwriting
2026-07-14 20:49:07 +00:00
Michael Cho d243e63ca5 test_bot/formulae: only run subset of brew tests for portable Ruby
Currently tests fail on all runners (Tier 1 Linux and Tier 3 macOS). It
is difficult to align the setups used between Homebrew/brew and
Homebrew/core so can limit to basic sanity of the cask and formula
tests.
2026-07-14 16:12:06 -04:00
Andrew NesbittandGitHub 70c621ff71 Merge branch 'main' into vulns-osv-export-merge 2026-07-14 12:38:48 -07:00
Andrew Nesbitt bea143bf74 vulns/osv_export: backfill published from modified; drop T.cast
When migrating a record written before `published` existed, fall back to
its `modified` timestamp rather than today's so first-rewrite doesn't
jump the publication date forward.

Narrow the upstream cache value with `is_a?(Hash)` at the call site
instead of `T.cast`, and collapse the failed-fetch guard to a single
`next if` now that reassignment isn't needed.
2026-07-14 12:37:18 -07:00
Andrew Nesbitt 8f9122b974 vulns/osv_export: merge into existing records instead of overwriting
Records now carry `published` and `database_specific: {source:
"generated"}`. `.run` reads any existing `<id>.json`, preserves its
`published` timestamp and `affected[].ranges` (so the `fixed` boundary
reflects when the annotation was first observed rather than drifting to
the current pkg_version), and only writes when the remaining content has
changed. Records for annotations no longer in core are simply not
visited, so they persist on the default branch.

A transient OSV.dev failure leaves an existing enriched record untouched
rather than stripping its summary/severity/references. The unchanged
comparison uses parsed hashes so key ordering in a hand-formatted
existing file does not cause spurious rewrites.
2026-07-14 12:23:19 -07:00
Bo AndersonandGitHub 38acf7eeda Merge pull request #23110 from Homebrew/embedded-patch-ohai
Show application of file and data patches
2026-07-14 19:04:39 +00:00
Mike McQuaidandGitHub 95eeda5a7b Merge pull request #23111 from Homebrew/cleanup-scrub-keep-current-package-api
Keep the current internal package API file on `brew cleanup -s`
2026-07-14 18:58:15 +00:00
Mike McQuaidandGitHub de842715e9 Merge pull request #23106 from Homebrew/vulns-osv-export
dev-cmd/generate-vulns-advisories: OSV advisory export for homebrew-advisory-database
2026-07-14 18:42:55 +00:00
Patrick Linnane 11b2e39566 Keep the current internal package API file on brew cleanup -s
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2026-07-14 11:30:36 -07:00
Bo Anderson e500d91b93 Show application of file and data patches 2026-07-14 19:20:11 +01:00
Andrew Nesbitt 714494585b vulns/osv_export: link OSV schema and tighten patch_ref return type
Add a pointer to ossf.github.io/osv-schema above SCHEMA_VERSION and note
where the Homebrew ecosystem/prefix were registered. patch_ref now
returns T::Hash[Symbol, T.any(String, T::Array[String])] via a PatchRef
alias; the input side stays T.untyped to match Formula#serialized_patches.
2026-07-14 10:20:00 -07:00
Mike McQuaid faa5bf676c Prewarm Bootsnap caches after brew update
- Bootsnap compiles Ruby files into instruction sequence and YAML
  caches on first load, so an update that changes files leaves the
  next command to recompile them at startup, on the user's time.
- The cost is largest for updates under `Library/Homebrew/vendor`:
  portable Ruby bumps rotate the whole cache key (it hashes the
  Ruby version and gem directory listing), cold-starting every
  file at once, and vendored gem bumps rewrite entire gem trees,
  much of which `update-report`'s own run never loads and so
  cannot recompile as a side effect.
- Loading the `brew install` and `brew fetch` command graph with a
  fully cold cache took 0.91s vs 0.56s warm on an M-series Mac in
  this checkout, so ~350ms of pure cache compilation; the gap is a
  multiple of that on older machines.
- After an explicit `brew update` that changed
  `Library/Homebrew/vendor`, `update-report` now spawns a detached
  background Ruby that requires `global`, `cmd/install`,
  `cmd/fetch` and `cmd/upgrade`, recompiling the caches for the
  most common next commands while the user reads the update
  report.
- Code-only updates skip the prewarm: `update-report` has already
  recompiled most of what the next command loads (the residual
  was ~20-40ms here), so a background process is not worth it.
- Auto-update runs also skip it: the command that triggered them
  loads the same files immediately afterwards, so a parallel
  prewarm would only duplicate its work.
- `Homebrew::Bootsnap.prewarm!` reuses the existing `enabled?`
  gate, is skipped under `HOMEBREW_TESTS` and spawns the
  interpreter from `HOMEBREW_RUBY_EXEC_ARGS` with the parent's
  `$LOAD_PATH`, stdio on `/dev/null` and its own process group,
  then detaches, so the update exits immediately and a prewarm
  failure cannot break it.
- Verified: across a vendored gem bump a detached child appears
  once `update-report` exits and compiles whatever its run did
  not load (736 -> 1055 cache files after a minimal report run),
  while code-only updates, auto-update runs and
  `HOMEBREW_NO_BOOTSNAP=1` spawn no child.
2026-07-14 18:03:03 +01:00
Andrew NesbittandGitHub c0966f6ddb Merge pull request #23103 from andrew/vulns-non-forge-head
vulns/scanner: fall back to verbatim head URL for non-forge repos
2026-07-14 16:57:02 +00:00
Andrew NesbittandGitHub a9f6cad1ad Merge branch 'main' into vulns-osv-export 2026-07-14 09:56:36 -07:00
Andrew Nesbitt d4470b95a2 vulns/osv_export: memoize upstream fetch per vuln id
When multiple formulae resolve the same CVE, fetch it from OSV.dev once
per run rather than once per (formula, id) pair. Uses Hash#fetch with a
block so a nil (fetch-failed) result is also cached.
2026-07-14 09:52:52 -07:00
Mike McQuaid 851f6bdf2d download_queue: wake on completed downloads
- The parallel fetch loop paused a fixed 50ms per iteration, even
  when every download had already finished: `Kernel#sleep` was 27%
  of wall samples (~100ms) in `brew prof --stackprof fetch` for an
  already-cached formula, the largest single frame ahead of
  `Kernel#require`.
- Warm-cache downloads resolve in microseconds, so almost all of
  that sleeping was wasted on every `brew fetch`, `brew install`
  and `brew upgrade`, interactive or scripted, and even the final
  iteration slept after the last download had finished.
- Warm-cache `brew fetch` of a cached formula drops from
  0.63-0.70s to 0.45-0.52s (~200ms, ~25-30%), measured both on a
  TTY and piped, and `Kernel#sleep` disappears from its profile
  entirely.
- Completed downloads are reported as they finish instead of on
  the next 50ms poll tick.
- Skip the end-of-iteration pause entirely when the partition left
  no downloads pending; previously even the final iteration slept.
- Wait on a `Concurrent::Event` signalled by an `on_resolution!`
  callback on every download future instead of sleeping, so warm
  caches never pay a poll interval.
- On animated TTYs the wait times out after 50ms, purely to keep
  redrawing the spinner and progress bars at a steady cadence
  while downloads are in flight; otherwise after 1s as a safety
  net.
- The event is reset before each wait and the remaining futures
  are re-checked in between, so a download resolving between the
  partition and the reset cannot cause a lost wakeup.
2026-07-14 17:41:02 +01:00
Andrew NesbittandGitHub c78d1a43fa Merge branch 'main' into vulns-non-forge-head 2026-07-14 09:38:07 -07:00
Andrew Nesbitt d09f70139c dev-cmd/generate-vulns-advisories: entry point for OsvExport
Replaces the tap's brew-vulns --osv-export DIR with a hidden dev-cmd
following the generate-formula-api pattern. Iterates homebrew/core under
with_no_api_env + SimulateSystem, unions each formula's serialized_patches
across all OS/arch variations from to_hash_with_variations so
platform-gated resolves annotations are not silently dropped, and hands
[formula, patches] pairs to Homebrew::Vulns::OsvExport.

--dry-run lists record ids without writing or querying OSV.dev.
Consumed by Homebrew/homebrew-advisory-database's regenerate workflow.
2026-07-14 09:35:34 -07:00
Andrew Nesbitt aa746060d6 vulns: add OsvExport for Homebrew-ecosystem OSV records
Ports the OSV record exporter from Homebrew/homebrew-brew-vulns. Emits
one BREW-<formula>-<CVE> record per security id declared in a formula's
patch resolves list, under the registered Homebrew ecosystem with
pkg:brew purls, marking the currently shipped pkg_version as the fixed
boundary. Upstream summary/severity/references are copied from OSV.dev
where available.

This is the generator for Homebrew/homebrew-advisory-database; the
dev-cmd entry point follows in the next commit.
2026-07-14 09:35:34 -07:00
Andrew Nesbitt 22d03a1650 vulns/scanner: hoist stable repo_url/tag derivation
Compute stable_repo_url and stable_tag once at the top of build_target
and reuse them in both the installed and non-installed branches, rather
than repeating the same target_repo_url/tag chain twice.
2026-07-14 09:17:11 -07:00
Andrew NesbittandGitHub 19a23e1f3d Merge pull request #23104 from andrew/deps-brewfile
cmd/deps: accept --brewfile as an input source
2026-07-14 16:05:16 +00:00
Mike McQuaidandGitHub 6e21a1a0bb Merge pull request #23100 from Homebrew/nested-container-staging
Preserve cask container metadata
2026-07-14 16:02:46 +00:00
Mike McQuaid 32059d607e Start bottle downloads before dependency fetches
- Start the requested bottle after `prelude` checks but before
  recursive dependency enqueueing so network I/O overlaps Ruby work.
- Reuse the cached-location future in `DownloadQueue` and defer
  staging until dependency enqueueing completes, avoiding duplicate
  transfers and early extraction.
- Preserve direct fetch ordering and existing attestation, source, local
  bottle and only-dependencies paths.
- This favours cold parallel downloads; warm or serial downloads gain
  little and later dependency failures can waste bandwidth.
2026-07-14 16:17:46 +01:00
Andrew Nesbitt 4b423089c6 cmd/deps: merge --brewfile inputs with named arguments
Previously --brewfile silently replaced any named arguments; combine
them instead so `brew deps foo --brewfile` includes foo alongside the
Brewfile entries, and dedupe the merged list.
2026-07-14 07:48:07 -07:00
Andrew Nesbitt 1d4cad75a4 Extract target_repo_url and cover the SBOM fallback path
Move the verbatim source/head URL fallback into a Scanner.target_repo_url
class method so build_target's three call sites share one implementation
written in the ||= style suggested in review, and add a spec for the
installed-keg SBOM branch where the SBOM downloadLocation host is not a
supported forge.
2026-07-14 07:30:54 -07:00
Andrew Nesbitt 4c904dc1d5 cmd/deps: accept --brewfile as an input source
Read brew and cask entries from a Brewfile and treat them as if they
had been passed as named arguments, so --brewfile composes with --tree,
--graph, --for-each, --union and the default flat listing. --formula and
--cask filter which entry types are loaded. A bare --brewfile reads
./Brewfile and --brewfile=<path> reads a specific file, matching
brew vulns.
2026-07-14 07:20:49 -07:00
Mike McQuaid 055a22740c Preserve cask container metadata
- Retain nested paths and explicit types for API-backed downloads.
- Ensure queued staging extracts the declared nested container.
2026-07-14 15:05:44 +01:00
Andrew Nesbitt 719e9562f3 vulns/scanner: fall back to verbatim head URL for non-forge repos
repo_url only normalises GitHub, GitLab and Codeberg, so formulae whose
stable, head and homepage URLs are all hosted elsewhere (bash, gmp,
gnu-tar, go, make, openconnect, zsh) were skipped outright. Restore the
tap's last-resort fallback: query OSV with the source URL verbatim when
its path yielded a tag, otherwise the head URL verbatim. OSV's GIT
ecosystem returns nothing for these hosts today, so this is parity with
the tap and future-proofing rather than a detection change.

Follow-up to #23080.
2026-07-14 06:56:57 -07:00
Mike McQuaidandGitHub 32f23a9813 Merge pull request #23099 from Homebrew/tests-without-sorbet-runtime
Test without Sorbet runtime
2026-07-14 12:36:41 +00:00
Mike McQuaid 6578002869 Test without Sorbet runtime 2026-07-14 13:17:32 +01:00
Mike McQuaidandGitHub dd6b7d1054 Merge pull request #23047 from Homebrew/test-ruby-macho-pr-997
Use RubyMacho 6.0.0
2026-07-14 11:40:03 +00:00
Mike McQuaidandGitHub 0916a6ecf9 Merge pull request #23097 from Homebrew/cask-path-uninstall-regression
Test uninstalling casks
2026-07-14 10:07:24 +00:00
Mike McQuaid ded27ae459 Test uninstalling casks by path 2026-07-14 09:43:38 +01:00
Ruoyu ZhongandGitHub f40cb3ec19 Merge pull request #23098 from Homebrew/23096-donation-link
Fix donation link
2026-07-14 08:32:06 +00:00
github-actions[bot] d434da42cd Update RBI files for test-ruby-macho-pr.
Autogenerated by the [vendor-gems](https://github.com/Homebrew/brew/blob/HEAD/.github/workflows/vendor-gems.yml) workflow.
2026-07-14 08:20:11 +00:00
github-actions[bot] 8da4830c46 Update RubyGems licence metadata for test-ruby-macho-pr.
Autogenerated by the [vendor-gems](https://github.com/Homebrew/brew/blob/HEAD/.github/workflows/vendor-gems.yml) workflow.
2026-07-14 08:19:53 +00:00
Mike McQuaid 344ae40c58 Use ruby-macho 6.0
- Use the released `ruby-macho` gem now that the code signing API
  is available in `6.0.0`.
- Vendor the released runtime files so `brew` can load `macho`
  without relying on the PR git checkout.
- Keep `MachO.codesign!` for patched keg binaries to avoid the
  `codesign` signing path this branch is replacing.
2026-07-14 09:14:36 +01:00
Mike McQuaid 213c8b90d7 Fix donation link 2026-07-14 09:08:47 +01:00
Mike McQuaidandGitHub a3ef52c7e9 Merge pull request #23095 from Homebrew/api-deadcode
Remove dead API methods and move generated_hash! to tests
2026-07-14 07:06:29 +00:00
Mike McQuaidandGitHub 0022e7ff30 Merge pull request #23080 from andrew/vulns-cmd
Add brew vulns command
2026-07-14 07:06:04 +00:00
Douglas Eichelberger 83eb38c7f6 Remove dead API methods and move generated_hash! to tests
Extracted from the typecheck-deadcode branch (Homebrew/brew#22733 was the
first extraction), which uses Spoom to find code with no static callers.

Remove four methods with no callers:

- Homebrew::API.cached_formula_json_file_path
- Homebrew::API::Cask.all_renames
- Homebrew::API::Formula.all_renames
- APIHashable#generated_hash!

Renames are resolved through Homebrew::API.formula_renames and
Homebrew::API.cask_renames, which read the internal API, so the
all_renames pair on the JSON API classes is unused. The only remaining
references were vestigial RSpec stubs, so drop those too.

APIHashable#generated_hash! reverts the global monkeypatches applied by
generating_hash!. The generate-*-api commands exit once they are done and
never call it, so it is only needed to stop tests leaking global state.
Move it to a test helper rather than keeping it in production code.
2026-07-13 22:52:42 -07:00
Michael ChoandGitHub 199d35fe46 Merge pull request #23088 from Homebrew/test-fixes-2
Fix more test failures
2026-07-14 02:16:16 +00:00
Douglas EichelbergerandGitHub e322eeffc2 Merge pull request #23091 from Homebrew/revert-23078-shared-type-instance
Revert "Return a shared type instance from type constructors when runtime checking is disabled"
2026-07-14 01:18:45 +00:00
Michael Cho fbc6e31092 test/cmd/exec_spec: use temporary cellar 2026-07-13 20:53:04 -04:00