Skip to content

Strict audit does not check for env :std for formulae in the core tap #6737

@dunkmann00

Description

@dunkmann00

Please note we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you repeatedly fail to use the issue template, we will block you from ever submitting issues to Homebrew again.

  • ran brew update and can still reproduce the problem?
  • ran brew doctor, fixed all issues and can still reproduce the problem?
  • ran brew config and brew doctor and included their output with your issue?

What you were trying to do (and why)

Running brew audit --new-formula on a formula I am working on resulted in a completion with no errors. After trying to submit this formula I was told having env :std is not allowed. After then trying to find some documentation to get more info on this I learned that it is deprecated (#1775) and also that it is something that a strict audit (which is one of the flags that is set with --new-formula) should have reported.

What happened (include command output)

The audit completed for my formula with no errors.

Command output

~ % brew audit --new-formula gcc-arm-embedded
~ %

What you expected to happen

The audit should have failed and shown a message that env :std is not allowed in a core formula.

~ % brew audit --new-formula gcc-arm-embedded
gcc-arm-embedded:
  * `env :std` in `core` formulae is deprecated
Error: 1 problem in 1 formula detected
~ %

Step-by-step reproduction instructions (by running brew commands)

brew audit --new-formula gcc-arm-embedded

-or-

brew audit --strict gcc-arm-embedded

Additional

After looking into this, I think it is just a simple problem with the logic flow of the function that performs line audits.

The excerpt below is from def line_problems(line, _lineno) and in it, on line 951, if the regex doesn't find anything it returns. But then the code below it, which includes the env :std check, will never be reached.

if !@core_tap && line =~ /depends_on .+ if build\.with(out)?\?\(?["']\w+["']\)?/
problem "`Use :optional` or `:recommended` instead of `#{Regexp.last_match(0)}`"
end
return unless line =~ %r{share(\s*[/+]\s*)(['"])#{Regexp.escape(formula.name)}(?:\2|/)}
problem "Use pkgshare instead of (share#{Regexp.last_match(1)}\"#{formula.name}\")"
return unless @core_tap
return unless line.include?("env :std")
problem "`env :std` in `core` formulae is deprecated"
end

I have created a pull request that I believe fixes the problem. I'll link it to this issue once I get it setup.

brew config - output

HOMEBREW_VERSION: 2.1.16-62-g6e70c4e
ORIGIN: https://github.com/Homebrew/brew
HEAD: 6e70c4efcd1264bff570ed3b25dc608af9e4450a
Last commit: 48 minutes ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: b99a095
Core tap last commit: 2 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_DEV_CMD_RUN: 1
CPU: dodeca-core 64-bit kabylake
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
Clang: 11.0 build 1100
Git: 2.21.0 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 10.15.1-x86_64
CLT: 11.2.0.0.1.1571444319
Xcode: 11.2
CLT headers: 11.2.0.0.1.1571444319

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedPR was locked due to age

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions