Class: Maximus::Brakeman
Overview
Evaluates quality of security on a Rails site
Instance Attribute Summary
Attributes inherited from Lint
Instance Method Summary collapse
-
#result ⇒ Object
Brakeman (requires Rails).
Methods inherited from Lint
Methods included from Helper
#discover_path, #edit_yaml, #file_count, #file_list, #is_middleman?, #is_rails?, #node_module_exists, #path_exists?, #prompt, #reporter_path, #root_dir, #truthy?
Constructor Details
This class inherits a constructor from Maximus::Lint
Instance Method Details
#result ⇒ Object
Brakeman (requires Rails)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/maximus/lints/brakeman.rb', line 8 def result @task = 'brakeman' @path = discover_path return unless is_rails? && temp_config(@task) && path_exists?(@path) tmp = Tempfile.new('brakeman') quietly { `brakeman #{@path} -f json -o #{tmp.path} -q` } brakeman = tmp.read tmp.close tmp.unlink unless brakeman.blank? bjson = JSON.parse(brakeman) basics(bjson) brakeman = {} ['warnings', 'errors'].each do |type| new_brakeman = bjson[type].group_by { |s| s['file'] } new_brakeman.each do |file, errors| next unless file brakeman[file] = errors.map { |e| hash_for_brakeman(e, type) } end end end @output[:files_inspected] ||= files_inspected('rb', ' ') refine brakeman end |