Testing External Security Check Integration in Brakeman
This test suite validates the functionality of external checks integration in the Brakeman security scanner. It verifies that custom security checks located outside the main checks directory can be properly loaded and executed using the additional_checks_path option flag.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
presidentbeef/brakeman
test/apps/rails4/external_checks/check_external_check_test.rb
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_optional self
@description = "An external check that does nothing, used for testing"
def run_check
tracker.find_call(target: nil, method: :call_shady_method).each do |result|
if user_input = has_immediate_user_input?(result[:call].first_arg)
warn result: result,
warning_type: "Shady Call",
warning_code: :custom_check,
message: "Called something shady!",
confidence: :high,
user_input: user_input,
:cwe_id => [-1]
end
end
end
end