Skip to content

Commit

Permalink
audit: check more unscoped test calls.
Browse files Browse the repository at this point in the history
Also check `def test`, `shell_output`, `pipe_output` and method calls
using parentheses.
  • Loading branch information
MikeMcQuaid committed Nov 2, 2016
1 parent 89fd34b commit 7aa26f7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Library/Homebrew/dev-cmd/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -734,8 +734,10 @@ def audit_text
bin_names += dir.children.map(&:basename).map(&:to_s)
end
bin_names.each do |name|
if text =~ /test do.*system\s+['"]#{name}/m
problem %(fully scope test system calls e.g. system "\#{bin}/#{name}")
["system", "shell_output", "pipe_output"].each do |cmd|
if text =~ /(def test|test do).*#{cmd}[\(\s]+['"]#{name}/m
problem %(fully scope test #{cmd} calls e.g. #{cmd} "\#{bin}/#{name}")
end
end
end

Expand Down

0 comments on commit 7aa26f7

Please sign in to comment.