提交 6ffb3b70 编写于 作者: C Clint Gibler

Add test for external checks loading

上级 2808c45c
......@@ -181,4 +181,7 @@ class Brakeman::Checks
end
end
Brakeman::Checks.initialize_checks File.expand_path(File.join(File.dirname(__FILE__), "checks"))
#Load all files in checks/ directory
Dir.glob("#{File.expand_path(File.dirname(__FILE__))}/checks/*.rb").sort.each do |f|
require f.match(/(brakeman\/checks\/.*)\.rb$/)[0]
end
require 'brakeman/checks/base_check'
#Verify that checks external to the checks/ dir are added by the additional_checks_path options flag
class Brakeman::CheckExternalCheckTest < Brakeman::BaseCheck
Brakeman::Checks.add self
@description = "An external check that does nothing, used for testing"
def run_check
end
end
abort "Please run using test/test.rb" unless defined? BrakemanTester
Rails4 = BrakemanTester.run_scan "rails4", "Rails 4"
EXTERNAL_CHECKS_PATH = File.expand_path(File.join(File.dirname(__FILE__), "..", "/apps/rails4/external_checks"))
Rails4 = BrakemanTester.run_scan "rails4", "Rails 4", {additional_checks_path: [EXTERNAL_CHECKS_PATH]}
class Rails4Tests < Test::Unit::TestCase
include BrakemanTester::FindWarning
include BrakemanTester::CheckExpected
def report
Rails4
end
......@@ -581,4 +582,8 @@ class Rails4Tests < Test::Unit::TestCase
:relative_path => "app/controllers/application_controller.rb",
:user_input => nil
end
def test_external_checks
# TODO: check for external check class being loaded here
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册