Class: Neetob::CLI::MonthlyAudit::Security::Code::YarnAudit
- Inherits:
-
Base
- Object
- Base
- Neetob::CLI::MonthlyAudit::Security::Code::YarnAudit
show all
- Defined in:
- lib/neetob/cli/monthly_audit/security/code/yarn_audit.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
11
12
13
|
# File 'lib/neetob/cli/monthly_audit/security/code/yarn_audit.rb', line 11
def initialize
super()
end
|
Instance Method Details
#is_high_critical_vulnerabilities_found?(severity) ⇒ Boolean
45
46
47
|
# File 'lib/neetob/cli/monthly_audit/security/code/yarn_audit.rb', line 45
def is_high_critical_vulnerabilities_found?(severity)
severity&.include?("High") || severity&.include?("Critical")
end
|
#run ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/neetob/cli/monthly_audit/security/code/yarn_audit.rb', line 15
def run
ui.success("### 1.1.2. Checking whether running `yarn audit` throws any vulnerabilities")
repo_data = [["Repository", "Vulnerabilities Found", "Comments", "Audit Passed"]]
ui.info "\n"
NeetoCompliance::NeetoRepos.products.keys.each do |repo|
ui.info("Checking yarn audit run results for #{repo}", print_to_audit_log: false)
yarn_audit_result = Neetob::CLI::Github::YarnAudit.new([repo]).run
vulnerabilities_found = "No"
audit_passed = "No"
= nil
severity = yarn_audit_result.split("\n").select { |line|
line.include?("Severity:") }.first&.strip&.gsub("|", ",")
if yarn_audit_result && !is_high_critical_vulnerabilities_found?(severity)
audit_passed = "Yes"
else
vulnerabilities_found = "Yes"
vulnerabilities = yarn_audit_result.split("\n").select { |line|
line.include?("vulnerabilities found") }.first&.strip
= "#{vulnerabilities}<br>#{severity}"
issue_url = GithubIssueCreation.new.create_issue(
repo:, title: "Yarn audit: High/Critical vulnerabilities found",
description: )
audit_passed += " #{issue_url}"
end
repo_data << [repo, vulnerabilities_found, , audit_passed]
end
ui.print_table(repo_data)
end
|