提交 c215f621 编写于 作者: S soffolk

refactor list_checks method

上级 23c35630
...@@ -173,11 +173,13 @@ module Brakeman ...@@ -173,11 +173,13 @@ module Brakeman
#Output list of checks (for `-k` option) #Output list of checks (for `-k` option)
def self.list_checks def self.list_checks
require 'brakeman/scanner' require 'brakeman/scanner'
format_length = 30
$stderr.puts "Available Checks:" $stderr.puts "Available Checks:"
$stderr.puts "-" * 30 $stderr.puts "-" * format_length
$stderr.puts Checks.checks.map { |c| Checks.checks.each do |check|
c.to_s.match(/^Brakeman::(.*)$/)[1].ljust(27) << c.description $stderr.printf("%-#{format_length}s%s\n", check.checker_name, check.description)
}.sort.join "\n" end
end end
#Installs Rake task for running Brakeman, #Installs Rake task for running Brakeman,
......
...@@ -12,6 +12,14 @@ class Brakeman::BaseCheck < Brakeman::SexpProcessor ...@@ -12,6 +12,14 @@ class Brakeman::BaseCheck < Brakeman::SexpProcessor
CONFIDENCE = { :high => 0, :med => 1, :low => 2 } CONFIDENCE = { :high => 0, :med => 1, :low => 2 }
Match = Struct.new(:type, :match) Match = Struct.new(:type, :match)
class << self
attr_accessor :checker_name
def inherited(subclass)
subclass.checker_name = subclass.to_s.match(/^Brakeman::(.*)$/)[1]
end
end
#Initialize Check with Checks. #Initialize Check with Checks.
def initialize(app_tree, tracker) def initialize(app_tree, tracker)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册