52 Commits

Author SHA1 Message Date
Douglas Eichelberger
3abbf4447e Some minor regexp match perf improvements 2023-12-27 13:16:36 -08:00
Douglas Eichelberger
08e46c18cd Add type to Formula attrs 2023-07-24 14:12:36 -07:00
Douglas Eichelberger
7720485f40 Enable types in Formula files 2023-03-25 08:50:06 -07:00
Nanda H Krishna
d9d6a74257
brew style --fix 2023-02-06 13:48:18 -05:00
Rylan Polster
fa4bb7d74a
Refactor audit exception handling 2021-10-21 21:11:05 -04:00
Carlo Cabrera
e8eb781470
mac/formula_cellar_checks: apply suggestions from code review
- Fix missing space
- use `MachO::Utils.fat_magic?`
- call `#flag?` consistently.

Co-authored-by: Bo Anderson <mail@boanderson.me>
2021-10-13 16:54:02 +08:00
Carlo Cabrera
4fbe0a2b1b
Fix false positives in audit
There was a typo that made it so that all libraries were being included
in `flat_namespace_files`.
2021-10-12 15:35:46 +08:00
Carlo Cabrera
7223f8ef74
Fix universal binary handling in check_flat_namespace 2021-10-12 13:49:53 +08:00
Carlo Cabrera
0484bfe820
mac/formula_cellar_checks: check for flat namespace libraries
There are at least five instances where a formula has libraries compiled
with `-flat_namespace` due to a bug in detecting the macOS version (cf.
Homebrew/homebrew-core#87103, Homebrew/homebrew-core#85974,
Homebrew/homebrew-core#85973).

I think it makes sense to check for this more generally. It is
sometimes intentional, so I've added a check for an allowlist for
those instances. Running this on the current `util-linux` bottle
produces

    ❯ brew audit --strict util-linux
    util-linux:
      * Libraries were compiled with a flat namespace.
        This can cause linker errors due to name collisions, and
        is often due to a bug in detecting the macOS version.
          /usr/local/Cellar/util-linux/2.37.2/lib/libblkid.1.dylib
          /usr/local/Cellar/util-linux/2.37.2/lib/libfdisk.1.dylib
          /usr/local/Cellar/util-linux/2.37.2/lib/libsmartcols.1.dylib
          /usr/local/Cellar/util-linux/2.37.2/lib/libuuid.1.dylib
    Error: 1 problem in 1 formula detected

Some things that still need to be done here:
- fix this check for universal binaries
- check if we want to restrict this audit check to newer versions of macOS
- fix false positives (try `brew audit --strict llvm` and compare the
  output of `otool -hV` on the identified files)

While we're here, let's fix the formatting of the output of these other
audits (cf. #12217).
2021-10-12 13:11:23 +08:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Mike McQuaid
b58fa4ebb1
Drop Mavericks support.
Companion to https://github.com/Homebrew/brew/pull/7698.

Provide better, `odeprecated` messaging for
`depends_on :macos => :mavericks` and otherwise just fix up the code
that relied on `:mavericks`.
2020-06-10 10:06:46 +01:00
Issy Long
b78028b9c2
Auto-fix Performance/RegexpMatch offenses 2019-10-13 16:04:26 +01:00
Izaak Beekman
0cf8ec7547
Allow Accelerate linkage, deny veclibfort & lapack
- Accelerate provides more than just BLAS and LAPACK functionality, see
   https://developer.apple.com/documentation/accelerate
 - Veclibfort exists only to wrap Accelerate's BLAS/LAPACK
 - LAPACK is a slow, seldom updated reference implementation
 - Encourage usage of OpenBLAS
 - Reverts PR #6130
2019-05-23 19:07:17 -04:00
Izaak Beekman
056a2d41fd
Add exception for veclibfort linking to Accelerate
- veclibfort exists soley to wrap Apple's accelerate and provide BLAS/LAPACK
   access to Accelerate
 - Improve the help message for that audit to mention veclibfort
2019-05-14 12:04:04 -04:00
Jonathan Chang
35a271e99b audit: check Accelerate linkage for core formulae 2019-05-14 13:37:34 +10:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Markus Reiter
e9b9ea49a1 Update to RuboCop 0.59.1. 2018-09-17 03:45:59 +02:00
Maxim Belkin
4f166ce021
formula_cellar_checks: .dylib and .framework are macOS-specific 2018-08-22 21:25:00 -05:00
Mike McQuaid
5e6c40e28f Make versioned formulae regex more consistent.
Share the regex where possible and otherwise ensure they are identical.
2018-06-18 14:36:51 +01:00
Mike McQuaid
61617a257e linkage_checker: use default use_cache parameter for callers. 2018-06-01 14:05:16 +01:00
Andrew R. McBurney
ddb7f06e9f Fixed rubocop offenses from brew style. 2018-05-22 12:54:54 -04:00
Mike McQuaid
44f5d3ec79 Refactor cache store code. 2018-05-22 14:46:14 +01:00
Andrew R. McBurney
010207b982 Changed cache usage behavior.
1. Running `brew linkage some_package` does not set the cache.
2. Running `brew linkage --cached some_package` when `DatabaseCache.empty?` returns `true` should build the cache.
3. Running `brew linkage --cached some_package` when `DatabaseCache.empty?` returns `false` should use the cache.
2018-05-21 17:36:30 -04:00
Andrew R. McBurney
e93e8f3266 Lazily load db of type DBM instance variable for DatabaseCache so the corresponding database file isn't created in the .use block for a DatabaseCache. 2018-05-18 16:37:01 -04:00
Andrew R. McBurney
cd6f89ca76 Made DatabaseCache.new private, and changes instances in code that call it to use DatabaseCache.use instead. 2018-05-18 10:06:30 -04:00
Andrew R. McBurney
d3120c0206 Use cache if HOMEBREW_LINKAGE_CACHE exists in formula_cellar_checks and formula. Make functions private in LinkageChecker. 2018-05-06 15:55:33 -04:00
AndrewMcBurney
a756af3b32 Fixed style issue offenses from brew style. 2018-04-25 10:27:03 -04:00
AndrewMcBurney
916247b920 Merge remote-tracking branch 'origin/master' into cache-optimization 2018-04-24 16:49:51 -04:00
Mike McQuaid
4a03145c1c linkage: fix --test exit code.
Ensure that a non-zero exit code is set both for missing random dylibs
and random missing dependencies.

Additionally, while we are here, drastically trim down the public
interface for this class to the bare minimum and allow getting the
output from `display_test_output` as a variable.

Fixes issue mentioned by @ilovezfs in:
https://github.com/Homebrew/brew/pull/3940#issuecomment-383794520
2018-04-24 09:52:51 +01:00
AndrewMcBurney
e5eaf57856 Fixed broken test due to changing usage of DatabaseCache to block usage. 2018-04-09 14:19:07 -04:00
AndrewMcBurney
bc76a8afcb Changed default behavior of brew linkage command to build cache instead of using cached output. Cached output may be printed with --cached flag. 2018-03-14 16:36:56 -04:00
AndrewMcBurney
831fcfa5dd Merge remote-tracking branch 'origin/master' into cache-optimization 2018-03-06 11:46:23 -05:00
Shaun Jackman
97932c1abf Move linkage_checker from os/mac to generic 2018-02-28 11:18:27 -08:00
AndrewMcBurney
d7765dd223 Separated os/mac/cache_store.rb into cache_store.rb and os/mac/linkage_cache_store.rb. 2018-02-28 10:39:15 -05:00
AndrewMcBurney
14256faa47 Added flag to flush_cache in LinkageChecker. Format ruby hash as JSON string before storing in dbm. 2018-02-27 13:05:19 -05:00
AndrewMcBurney
4bc6459ed7 Removed redundant documentation, use database_cache as a block, and use symbolic keys over string keys in function calls. 2018-02-25 12:14:11 -05:00
AndrewMcBurney
69b590012d Berkeley db cache optimization for brew linkage command. 2018-02-12 16:31:41 -05:00
Markus Reiter
9bee9ca575 Use “squiggly” heredocs. 2017-10-18 14:39:09 +02:00
Mike McQuaid
93051b27d6 formula_cellar_checks: fix broken dylib spacing. 2017-08-08 11:08:35 +01:00
Mike McQuaid
69799d97b1 formula_cellar_checks: remove stray backtick. 2017-08-07 11:48:45 +01:00
Mike McQuaid
e2070780f1 formula_cellar_checks: reinstall broken bottles.
If we pour from a bottle and then immediately know it’s broken then
we should tell users how to resolve their issue and where to file a
issue to.

Inspired by https://github.com/Homebrew/homebrew-core/issues/16477.
2017-08-07 11:21:55 +01:00
Jan Viljanen
85da376233 audit: add additional php header ignore patterns 2017-08-03 06:13:15 +02:00
Mike McQuaid
3f8722c971 audit: allow skipping audit methods.
Add `--only` and `--except` methods which can be used to selectively
enable or disable audit groups.
2017-04-18 08:17:26 +01:00
Jan Viljanen
80b7d4c1aa Whitelist PHP formulas in shadowed header audit check 2017-01-06 23:43:25 +01:00
Markus Reiter
58e36c7319 Fix Style/GuardClause. 2016-09-24 12:24:35 +02:00
Tim D. Smith
a4b4b9cd90 Catch LibreSSL libtls as well
Update the description to reflect that we may be talking about either crypto library and neither is okay. :)
2016-09-04 16:28:51 -07:00
Tim D. Smith
bf18808930 Catch system libressl in openssl audit as well
The regex didn't match libcrypto.35.dylib, and it should have.
2016-09-03 22:13:09 -07:00
Mike McQuaid
3469f177f0 audit: don't check formula linkage.
This partly reverts commit 0ed673abdb59e2f75f9b8539cce318607924e87f.
2016-07-28 16:53:41 -06:00
Xu Cheng
cd2288a561 audit: only check undeclared deps for standard installations. (#576)
In fact, we don't really care about undeclared dependencies for optional
installations. Because, this is mainly used to help us to detect breakage
for bottles so we can do a revision bump.
2016-07-24 20:18:59 +08:00
Xu Cheng
0ed673abdb
formula_cellar_checks: add check_linkage
This means linkage checks will be invoked during `brew install` and `brew audit`

Closes #470.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-07-14 15:23:34 +08:00