265 Commits

Author SHA1 Message Date
Mike McQuaid
55f65ec375
audit: ensure that official formula and cask names don't conflict.
Co-authored-by: Eric Knibbe <enk3@outlook.com>
2025-06-23 16:08:13 +01:00
Eric Knibbe
ab4acd655a
cask/audit: also check binary for minimum OS 2025-06-16 23:39:38 -04:00
Eric Knibbe
689ff373d8
cask/audit: skip caveats check for Intel-only casks 2025-06-11 15:56:07 -04:00
Eric Knibbe
5027a9d2f2
cask/audit: skip audit_rosetta on Intel-only casks & OSes 2025-05-21 10:14:08 -04:00
Bevan Kay
4852829931
cask/audit: install container deps 2025-04-02 16:34:28 +11:00
Sam Ford
1ac70579eb
Cask: skip livecheck https audit for POST requests
We recently added `POST` request support to livecheck but related cask
checks are failing the `livecheck_https_availability` audit because it
calls `validate_url_for_https_availability` which calls
`Utils::Curl.curl_check_http_content` and that checks the URL using a
`GET` request. Adding `POST` request support to all of those methods
will take some work, so this adds a guard to skip the audit if the
`livecheck` block uses `post_form` or `post_json`. This isn't ideal
but it will allow us to add these `livecheck` blocks in the interim
time.

Co-authored-by: Douglas Eichelberger <d@eic.email>
2025-03-06 12:14:42 -05:00
Douglas Eichelberger
fcf18912fe
Inline use of attr_predicate 2025-03-02 21:36:03 -08:00
Douglas Eichelberger
8763fb6d29 Resolve rubocop violations 2025-02-17 18:56:31 -08:00
Sam Ford
01cb74e525
livecheck: clarify livecheckable language
Formulae, casks, and resources have a `#livecheckable?` method that
indicates whether they contain a `livecheck` block. This is intended
to be read as "has a livecheckable?", not "is livecheckable?" (as
livecheck can find versions for some packages/resources without a
`livecheck` block). Unfortunately, correct understanding of this
method's behavior [outside of documentation] relies on historical
knowledge that few people possess, so this is often confusing to
anyone who hasn't been working on livecheck since 2020.

In the olden days, a "livecheckable" was a Ruby file containing a
`livecheck` block (originally a hash) with a filename that
corresponded to a related formula. The `livecheck` blocks in
livecheckable files were integrated into their respective formulae in
August 2020, so [first-party] livecheckables ceased to exist at that
time. From that point forward, we simply referred to these as
`livecheck` blocks.

With that in mind, this clarifies the situation by replacing
"livecheckable" language. This includes renaming `#livecheckable?` to
`#livecheck_defined?`, replacing usage of "livecheckable" as a noun
with "`livecheck` block", replacing "livecheckable" as a boolean with
"livecheck_defined", and replacing incorrect usage of "livecheckable"
as an adjective with "checkable".
2024-12-02 10:13:03 -05:00
Bevan Kay
4a6644650a
cask/audit: audit deprecate/disable reasons 2024-09-30 23:11:44 +10:00
Bo Anderson
0ae1dbeacf
Add typing for Cask#url and fix detected issues 2024-08-23 16:39:23 +01:00
Bo Anderson
f877fc5058
livecheck: remove module_function 2024-08-23 04:57:28 +01:00
Lukas Eipert
915917f4d2 Rosetta audit: Build full executable path
The method only returned the executable name and not the full path,
leading to a swallowed error, because brew gracefully ignores a
failing lipo command.
2024-08-21 13:19:57 +02:00
Lukas Eipert
8814a492aa Use plist main binary for Rosetta audit
Currently `brew audit` only audits the first binary in a cask.
For example the cask `wiso-steuer-2024` contains multiple binaries in
`Contents/MacOS`:
- `btssysteminfo`
- `whilfe`
- `wmain24`

The first binary (some telemetry tool) is not the main binary and not
a universal binary, but the other two are. Given that `wmain24` is
defined as the main binary in the `Contents/Info.plist`, brew probably
should audit that binary rather than just checking the first one.
2024-08-21 10:01:20 +02: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
6105728c31
Merge pull request #18004 from Homebrew/more-srb-strict 2024-08-12 14:22:00 +01:00
Issy Long
0355f07e0d
utils/shared_audits: Bump to Sorbet typed: strict 2024-08-10 16:43:37 +01:00
Markus Reiter
4a1643e7ad
Refactor condition. 2024-07-30 21:48:59 +02:00
Markus Reiter
40d55f8035
Change type name. 2024-07-30 21:43:30 +02:00
Markus Reiter
3b4e1cb573
Share code between cask token and formula name audits. 2024-07-30 21:41:15 +02:00
Klaus Hipp
d90c5c55d2
cask/audit: handle cask_min_os is nil 2024-07-16 10:35:47 -04:00
Mike McQuaid
c5dbd3ca24
Rearrange requires
This improves the load time of most brew commands. For an example of
one of the simplest commands this speeds up:

Without Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     525.0 ms ±  35.8 ms    [User: 229.9 ms, System: 113.1 ms]
  Range (min … max):   465.3 ms … 576.6 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     383.3 ms ±  25.1 ms    [User: 133.0 ms, System: 72.1 ms]
  Range (min … max):   353.0 ms … 443.6 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.37 ± 0.13 times faster than git checkout master; brew help
```

With Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     386.0 ms ±  30.9 ms    [User: 130.2 ms, System: 93.8 ms]
  Range (min … max):   359.5 ms … 469.3 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     330.2 ms ±  32.4 ms    [User: 93.4 ms, System: 73.0 ms]
  Range (min … max):   302.9 ms … 413.9 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.17 ± 0.15 times faster than git checkout master; brew help
```
2024-07-14 08:49:39 -04:00
Eric Knibbe
3f73f32286
cask/audit: handle on_os range bounded by depends_on 2024-07-01 23:11:26 -04:00
Mike McQuaid
6ca46550d9
Merge pull request #17596 from Homebrew/audit_min_os-arch-specific 2024-06-30 19:32:34 +01:00
Mike McQuaid
3948359aab
Merge pull request #17575 from krehel/update-audit-rosetta 2024-06-30 19:23:24 +01:00
Eric Knibbe
0d3e50d144
cask/audit: handle arch-specific detected min OS 2024-06-30 00:23:45 -04:00
Mike McQuaid
a7b2da0fc4
cask/audit: use select instead of reject.
Co-authored-by: Rylan Polster <rslpolster@gmail.com>
2024-06-28 08:33:20 +01:00
Sean Molenaar
203049b2f5 fix: improve audit for binary stanza 2024-06-28 09:28:55 +02:00
Sean Molenaar
8e570a0e9b feat: check for unknown arch for casks 2024-06-28 08:53:10 +02:00
Justin Krehel
475fc1d281
cask/audit: filter bad artifacts in rosetta audit 2024-06-27 12:25:46 -04:00
Sean Molenaar
5fc3af15c5 feat: check if casks should warn about rosetta 2024-06-27 14:22:03 +02:00
Eric Knibbe
16863f3884
cask/audit: ensure on_os blocks specify a min OS 2024-06-25 22:20:21 -04:00
Eric Knibbe
f627c6331d
cask/audit: support on_os blocks in audit_min_os 2024-06-21 19:25:51 -04:00
Sam Ford
fcc87c901d
Cask::Audit: Align user agents with livecheck
The `#page_headers` and `#page_content` methods in
`Livecheck::Strategy` will fetch a URL using our default user agent
but if the request fails it will retry with the `:browser` user agent.
[For context, it was added as an interim measure to make URLs work
that require a different user agent but I aim to remove it in the
future in favor of specifying the user agent in a `livecheck` block
(so we don't make unnecessary requests that we know will fail).]

`Cask::Audit#audit_livecheck_https_availability` checks the
`livecheck` block URL but it only does so using our default user
agent (i.e., it calls `#validate_url_for_https_availability` which
calls `Utils::Curl#curl_check_http_content` which has a `user_agents:
[:default]` parameter). Due to this behavioral mismatch, it's possible
for a `livecheck` block to work but for this cask audit to fail.

This addresses the issue by adding `user_agents: [:default, :browser]`
to the arguments the audit uses, which aligns its behavior with
livecheck's.
2024-06-14 15:38:24 -04:00
Justin Krehel
700cbd893b
cask/audit: fix nested container extraction
Fixes edge cases where nested containers are used. Extraction for auditing artifacts did not pull the secondary container, which tried to audit the container instead of the contents.
2024-05-29 11:38:25 -04:00
Sam Ford
e2220ecc42
cask/audit: Rework tmpdir removal
I previously introduced a finalizer method in `Cask::Audit` to remove
the created `@tmpdir` once it's no longer needed but the existing
approach produces a `finalizer references object to be finalized`
warning when `brew audit` is run. I didn't see this warning when I
was originally testing it but now it reliably appears.

This reworks the finalizer to define it within the
`#extract_artifacts` method and use `@tmpdir` as the target object.
2024-05-27 13:09:46 -04:00
Mike McQuaid
ed73551cc7
cask/audit: remove debug message. 2024-05-27 08:10:20 +01:00
Aaron Ruan
ae851a7aa4
seperate audit for osdn url 2024-05-27 12:22:48 +08:00
Aaron Ruan
7b21cc1856
fix typecheck 2024-05-27 09:32:54 +08:00
Aaron Ruan
73ead3e5f5
match with url host instead of string 2024-05-27 00:26:35 +08:00
Aaron Ruan
7da9ea07d0
fix style 2024-05-26 17:00:42 +08:00
Aaron Ruan
2fcbff8ee2
disable osdn.jp URL 2024-05-26 16:51:44 +08:00
Sam Ford
5701f92321
Clean up cask audit tmpdir after use
`Cask::Audit#extract_artifacts` is used in the `#audit_signing` and
`#cask_plist_min_os` methods to create a directory in `/tmp` and
extract cask artifacts without duplicating the work if it's already
done. However, due to how this is set up, `tmpdir` isn't removed
afterward and the extracted artifacts will take up disk space until
the `tmp` directory is cleaned up. As a result, running
`brew audit --strict --online` locally can chew through disk space
and it may not be clear to the user where their free space has gone.

This adds a finalizer method to `Cask::Audit` to remove the created
`@tmpdir` (if any) once it's no longer needed. There may be a better
way of addressing the issue but this works for now without having to
restructure how these audits work.
2024-05-24 09:22:12 -04:00
Mike McQuaid
82591d12dc
Merge pull request #17031 from krehel/update-artifact-audit
cask/audit: update signing checks for app, binary, and pkg
2024-05-22 17:39:27 +01:00
Justin Krehel
344a5021d8
cask/audit.rb: update signing checks for app, binary, and pkg 2024-05-22 10:29:47 -04:00
Patrick Linnane
773dbfa92a
docs: update for Homebrew/cask-fonts deprecation
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-05-16 09:21:14 -07:00
Bevan Kay
db4099d977
cask/audit: fix sharding for font-* casks 2024-05-16 11:29:58 +10:00
Justin Krehel
836d819c43
Support font sharding in Homebrew/cask 2024-05-10 11:48:56 -04:00
Mike McQuaid
222fe8ef0b
Homebrew 4.3.0 deprecation/disable/removals.
The usual pass of deprecating/disabling/removing code for the next
minor Homebrew release.
2024-05-07 12:18:04 +01:00
Eric Knibbe
d1d0bfc0ba
cask/audit: tune sourceforge.net URL regex 2024-05-06 22:56:28 -04:00