audit: Escape interpolated string in regexp

This avoids issues with names containing special characters like e.g. [

Fixes #1431
This commit is contained in:
Baptiste Fontaine 2016-11-03 18:17:10 +01:00
parent 09f438aecc
commit bfa19b3385

View File

@ -741,7 +741,7 @@ class FormulaAuditor
end end
bin_names.each do |name| bin_names.each do |name|
["system", "shell_output", "pipe_output"].each do |cmd| ["system", "shell_output", "pipe_output"].each do |cmd|
if text =~ /(def test|test do).*#{cmd}[\(\s]+['"]#{name}[\s'"]/m if text =~ /(def test|test do).*#{cmd}[\(\s]+['"]#{Regexp.escape name}[\s'"]/m
problem %(fully scope test #{cmd} calls e.g. #{cmd} "\#{bin}/#{name}") problem %(fully scope test #{cmd} calls e.g. #{cmd} "\#{bin}/#{name}")
end end
end end