Class: Neetob::CLI::MonthlyAudit::Security::Code::Brakeman

Inherits:
Base
  • Object
show all
Defined in:
lib/neetob/cli/monthly_audit/security/code/brakeman.rb

Constant Summary

Constants inherited from Base

Base::NEETO_APPS_LIST_LINK

Instance Attribute Summary

Attributes inherited from Base

#ui

Instance Method Summary collapse

Methods included from Utils

#camel_case_to_slug, #is_upper?, #symbolize_keys

Constructor Details

#initializeBrakeman

Returns a new instance of Brakeman.



9
10
11
# File 'lib/neetob/cli/monthly_audit/security/code/brakeman.rb', line 9

def initialize
  super()
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/neetob/cli/monthly_audit/security/code/brakeman.rb', line 13

def run
  ui.success("### 1.1.3. Checking whether running `bundle exec brakeman` throws any vulnerabilities")
  repo_data = [["Repository", "Vulnerabilities Found", "Comments", "Audit Passed"]]
  ui.info "\n"
  NeetoCompliance::NeetoRepos.products.keys.each do |repo|
    ui.info("Checking Brakeman run results for #{repo}", print_to_audit_log: false)
    brakeman_run_result = Neetob::CLI::Github::Brakeman.new([repo]).run
    vulnerabilities_found = "No"
    audit_passed = "No"
    comments = nil
    if brakeman_run_result && brakeman_run_result.include?("No warnings found")
      audit_passed = "Yes"
    else
      vulnerabilities_found = "Yes"
      comments = brakeman_run_result.gsub("\n", "<br>")

      issue_url = GithubIssueCreation.new.create_issue(
        repo:, title: "Fix vulnerabilities reported by Brakeman",
        description: comments)
      audit_passed += " #{issue_url}"
    end
    repo_data << [repo, vulnerabilities_found, comments, audit_passed]
  end
  ui.print_table(repo_data)
end