Class: Neetob::CLI::MonthlyAudit::Security::Code::ChecksForUnusedAssets

Inherits:
Base
  • Object
show all
Defined in:
lib/neetob/cli/monthly_audit/security/code/checks_for_unused_assets.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

#initializeChecksForUnusedAssets

Returns a new instance of ChecksForUnusedAssets.



12
13
14
# File 'lib/neetob/cli/monthly_audit/security/code/checks_for_unused_assets.rb', line 12

def initialize
  super()
end

Instance Method Details

#runObject



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
# File 'lib/neetob/cli/monthly_audit/security/code/checks_for_unused_assets.rb', line 16

def run
  ui.success("### 1.1.5. Checking whether running `unused assets audit` throws any vulnerabilities")
  repo_data = [["Repository", "Unused Assets Found", "Comments", "Audit Passed"]]
  ui.info "\n"

  NeetoCompliance::NeetoRepos.products.keys.each do |repo|
    ui.info("Checking unused assets for #{repo}", print_to_audit_log: false)
    unused_files = Neetob::CLI::Github::UnusedAssetsAudit.new([repo]).run
    if unused_files && unused_files.any?
      unused_assets_found = "Yes"
      audit_passed = "No"
      comments = unused_files.join("<br>")
      issue_url = GithubIssueCreation.new.create_issue(
        repo:, title: "Remove unused assets",
        description: comments)
      audit_passed += " #{issue_url}"
    else
      unused_assets_found = "No"
      audit_passed = "Yes"
      comments = nil
    end

    repo_data << [repo, unused_assets_found, comments, audit_passed]
  end

  ui.print_table(repo_data)
end