17 Commits

Author SHA1 Message Date
Mike McQuaid
dc71b7c8f6
Cleanup extend/ directory usage.
- move some things out of `extend` that don't really fit there e.g.
  `Module`s that are included but not doing any
  overriding/monkeypatching
- move some code into `extend/os` to fix all remaining
  `rubocop:todo Homebrew/MoveToExtendOS`s
- remove some unneeded `bundle` skipper code that doesn't really make
  sense given our current bottling strategy
- extract some `Pathname` extensions to `extend/pathname` for separate
  files
- move a `ENV` `Kernel` extension into `kernel.rb`
- `odeprecate` a seemingly unused backwards compatibility method
- move `readline_nonblock` from a monkeypatch to a
  `ReadlineNonblock.read` method as its only used in one place
- fix up a link in documentation
2025-06-09 19:06:16 +01:00
Patrick Linnane
c6a2fa335d
brew style --fix 2025-05-05 14:35:08 -07:00
Issy Long
45978435e7
rubocop: Use Sorbet/StrictSigil as it's better than comments
- Previously I thought that comments were fine to discourage people from
  wasting their time trying to bump things that used `undef` that Sorbet
  didn't support. But RuboCop is better at this since it'll complain if
  the comments are unnecessary.

- Suggested in https://github.com/Homebrew/brew/pull/18018#issuecomment-2283369501.

- I've gone for a mixture of `rubocop:disable` for the files that can't
  be `typed: strict` (use of undef, required before everything else, etc)
  and `rubocop:todo` for everything else that should be tried to make
  strictly typed. There's no functional difference between the two as
  `rubocop:todo` is `rubocop:disable` with a different name.

- And I entirely disabled the cop for the docs/ directory since
  `typed: strict` isn't going to gain us anything for some Markdown
  linting config files.

- This means that now it's easier to track what needs to be done rather
  than relying on checklists of files in our big Sorbet issue:

```shell
$ git grep 'typed: true # rubocop:todo Sorbet/StrictSigil' | wc -l
    268
```

- And this is confirmed working for new files:

```shell
$ git status
On branch use-rubocop-for-sorbet-strict-sigils
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Library/Homebrew/bad.rb
        Library/Homebrew/good.rb

nothing added to commit but untracked files present (use "git add" to track)

$ brew style
Offenses:

bad.rb:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
^^^^^^^^^^^^^

1340 files inspected, 1 offense detected
```
2024-08-12 15:24:27 +01:00
Mike McQuaid
42a6b59de5
sbom: fix errors, improve reproducibility, tests.
- Remove/change data from bottle SBOM to avoid harming reproduciblity
- Add `schema_validation_errors` method to provide nicer test failures
- Add tests more tests for SBOM when bottling
- Cleanup SBOM tests to use more typical RSpec form and be DRYer
2024-08-08 09:34:32 +01:00
Bo Anderson
6b186f9874
Fix SBOM schema validation 2024-08-08 02:30:42 +01:00
Bo Anderson
040372fafa
Vendor SBOM schema 2024-08-07 18:00:53 +01:00
Mike McQuaid
357e70357c
sbom: don't store runtime dependencies when bottling.
In some cases this prevents `:all` bottles when the recursive
dependencies vary. This SBOM is regenerated correctly at pour time.
2024-08-02 11:42:35 +01:00
Mike McQuaid
a901a9c389
sbom: ensure Homebrew versions are more consistent.
Avoid making bottles non-reproducible by ensuring that the Homebrew
version doesn't include the full commit hash but just a `-dev` suffix.

This is similar to the approach we use for analytics.
2024-07-26 17:37:05 +01:00
Mike McQuaid
6bd0823f7e
sbom: fix dependency bottle information in SBOM.
This breaks the possibility for some `:all` bottle creation if they
reference a non-`:all` bottle as a dependency.

Instead, omit this information in the bottle and generate it only at
install time.
2024-05-26 16:48:48 +01:00
Mike McQuaid
7be26329c5
Apply suggestions from code review 2024-05-26 15:28:53 +01:00
Sean Molenaar
fdb347c35f
Update Library/Homebrew/sbom.rb
Co-authored-by: Ruoyu Zhong <zhongruoyu@outlook.com>
2024-05-26 13:20:04 +02:00
Sean Molenaar
9d75d09a82
fix: allow not validating SBOM 2024-05-26 13:16:43 +02:00
Mike McQuaid
b066ac414c
SBOM: various fixes.
- be a bit stricter with SBOM handling with the test default formula
  flow in CI by making it raise errors if SBOM's aren't generated and
  validated as expected
- fix handling of HEAD installations of formulae so SBOM generation is
  both correct and doesn't raise errors
- make `Formula#bottle_hash` more accepting of edge cases e.g. HEAD-only
  formulae without a stable spec

Fixes #17333
2024-05-20 09:41:29 +01:00
Mike McQuaid
7461bf81a1
SBOM: more fixes.
- Remove use of (unused) `Cachable` module.
- Pass whether we're bottling to determine whether to create
  reproducible SBOM or not. A reproducible SBOM omits the time and
  compiler.
- Remove bottle information when bottling: we cannot know what e.g.
  the checksum (and, with GitHub Packages, therefore also the download
  location) will be before we've created the tarball contents.
- Always write a bottle on installation (unless we're bottling) to
  provide new bottle information or freshen the existing one with the
  information we stripped out for reproducibility e.g. the time and
  compiler.
- Don't need to handle a `nil` `@source_modified_time` as it's always
  set.

Fixes #17281
2024-05-13 07:36:51 +01:00
Sean Molenaar
df0bd4cd73 fix: use UTC for all SBOM times
Issue GH-17281
2024-05-12 10:56:10 +02:00
Mike McQuaid
442aa91704
SBOM improvements
- write a schema when installing formulae (if not already present)
- cache the schema on disk rather than downloading it every time
- make more methods/attributes `private`
- allow validation to be optional, only enable for Homebrew developers
  at installation time
- use the tab for more, correct information
- ensure that dependencies/bottles are written correctly
- use new SBOM 3 schema URL
- improve test coverage
2024-05-09 13:10:37 +01:00
Sean Molenaar
a43b7464c2 feat: add generated SPDX file on bottling 2024-05-07 20:33:22 +02:00