Skip to content

Commit

Permalink
Capitalize the names of all technologies for output only.
Browse files Browse the repository at this point in the history
  • Loading branch information
vkononov authored Mar 5, 2024
1 parent 1e409a2 commit 4ab853b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 36 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ serviceworker-rails 0.6.0 0.6.0 2019-07-09 m
turbolinks 5.2.1 5.2.1 2019-09-18 medium no updates by author in over 2 years
3 vulnerable (7 vulnerabilities), 6 outdated, 9 deprecated.
Found a total of 14 ruby packages.
Found a total of 14 Ruby packages.
To get more information about the ruby gem vulnerabilities run:
> bundle-audit check --update
Expand Down Expand Up @@ -71,7 +71,7 @@ simple-plist 1.3.0 1.3.1 2022-03-31 critical(1) hi
urijs 1.19.7 1.19.11 2022-04-03 high(1) moderate(4) high security vulnerability
10 vulnerable (61 vulnerabilities), 11 outdated, 7 deprecated.
Found a total of 18 node packages.
Found a total of 18 Node packages.
To get more information about the node module vulnerabilities run:
> yarn audit
Expand Down
13 changes: 7 additions & 6 deletions lib/package/audit/util/summary_printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ def self.deprecated

def self.vulnerable(technology, cmd)
printf("%<info>s\n%<cmd>s\n\n",
info: Util::BashColor.blue("To get more information about the #{technology} vulnerabilities run:"),
info: Util::BashColor.blue("For more information about #{technology.capitalize} vulnerabilities run:"),
cmd: Util::BashColor.magenta(" > #{cmd}"))
end

def self.total(technology, report, pkgs, ignored_pkgs)
if ignored_pkgs.any?
puts Util::BashColor.cyan("Found a total of #{pkgs.length} #{technology} packages " \
puts Util::BashColor.cyan("Found a total of #{pkgs.length} #{technology.capitalize} packages " \
"(#{ignored_pkgs.length} ignored).\n")
elsif pkgs.any?
puts Util::BashColor.cyan("Found a total of #{pkgs.length} #{technology} packages.\n")
puts Util::BashColor.cyan("Found a total of #{pkgs.length} #{technology.capitalize} packages.\n")
else
puts Util::BashColor.green("There are no #{report} #{technology} packages!\n")
puts Util::BashColor.green("There are no #{report} #{technology.capitalize} packages!\n")
end
end

Expand Down Expand Up @@ -66,10 +66,11 @@ def self.statistics(format, technology, report, pkgs, ignored_pkgs)
print status_message(stats)
print Util::BashColor.cyan(' \\') if format == Enum::Format::MARKDOWN
puts
puts Util::BashColor.green("There are no deprecated, outdated or vulnerable #{technology} " \
puts Util::BashColor.green("There are no deprecated, outdated or vulnerable #{technology.capitalize} " \
"packages (#{ignored_pkgs.length} ignored)!\n")
else
puts Util::BashColor.green("There are no deprecated, outdated or vulnerable #{technology} packages!\n")
puts Util::BashColor.green("There are no deprecated, outdated or vulnerable #{technology.capitalize} " \
"packages!\n")
end
end

Expand Down
8 changes: 4 additions & 4 deletions test/package/audit/test_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ def test_that_unknown_commands_give_an_appropriate_error
def test_that_that_config_option_works
output = `bundle exec package-audit test/files/gemfile/empty --config test/files/config/.package-audit.yml`

assert_match 'There are no deprecated, outdated or vulnerable ruby packages!', output
assert_match 'There are no deprecated, outdated or vulnerable Ruby packages!', output
end

def test_that_that_config_option_alias_works
output = `bundle exec package-audit test/files/gemfile/empty -c test/files/config/.package-audit.yml`

assert_match 'There are no deprecated, outdated or vulnerable ruby packages!', output
assert_match 'There are no deprecated, outdated or vulnerable Ruby packages!', output
end

def test_that_that_config_option_returns_an_appropriate_error
Expand All @@ -58,13 +58,13 @@ def test_that_that_config_option_returns_an_appropriate_error
def test_that_that_include_ignored_option_works
output = `bundle exec package-audit test/files/gemfile/empty --include-ignored`

assert_match 'There are no deprecated, outdated or vulnerable ruby packages!', output
assert_match 'There are no deprecated, outdated or vulnerable Ruby packages!', output
end

def test_that_that_exclude_headers_option_works
output = `bundle exec package-audit test/files/gemfile/empty --exclude-headers`

assert_match 'There are no deprecated, outdated or vulnerable ruby packages!', output
assert_match 'There are no deprecated, outdated or vulnerable Ruby packages!', output
end

def test_that_that_format_option_works
Expand Down
12 changes: 6 additions & 6 deletions test/package/audit/test_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,42 @@ def test_that_no_group_produces_expected_output
output = `bundle exec package-audit test/files/gemfile/groups`

%w[irb minitest rack reline tzinfo yard].each { |pkg| assert_match pkg, output }
assert_match 'Found a total of 6 ruby packages.', output
assert_match 'Found a total of 6 Ruby packages.', output
end

def test_that_default_group_produces_expected_output
output = `bundle exec package-audit test/files/gemfile/groups -g default`

%w[irb rack reline].each { |pkg| assert_match pkg, output }
assert_match 'Found a total of 3 ruby packages.', output
assert_match 'Found a total of 3 Ruby packages.', output
end

def test_that_development_group_produces_expected_output
output = `bundle exec package-audit test/files/gemfile/groups -g development`

%w[irb rack reline yard].each { |pkg| assert_match pkg, output }
assert_match 'Found a total of 4 ruby packages.', output
assert_match 'Found a total of 4 Ruby packages.', output
end

def test_that_test_group_produces_expected_output
output = `bundle exec package-audit test/files/gemfile/groups -g test`

%w[irb minitest rack reline].each { |pkg| assert_match pkg, output }
assert_match 'Found a total of 4 ruby packages.', output
assert_match 'Found a total of 4 Ruby packages.', output
end

def test_that_production_group_produces_expected_output
output = `bundle exec package-audit test/files/gemfile/groups -g production`

%w[irb rack reline tzinfo].each { |pkg| assert_match pkg, output }
assert_match 'Found a total of 4 ruby packages.', output
assert_match 'Found a total of 4 Ruby packages.', output
end

def test_that_multiple_groups_produces_expected_output
output = `bundle exec package-audit test/files/gemfile/groups -g test -g production`

%w[irb minitest rack reline tzinfo].each { |pkg| assert_match pkg, output }
assert_match 'Found a total of 5 ruby packages.', output
assert_match 'Found a total of 5 Ruby packages.', output
end
end
end
Expand Down
36 changes: 18 additions & 18 deletions test/package/test_audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,39 @@ def test_that_it_has_a_version_number
def test_that_there_is_a_success_message_when_report_is_empty
output = `bundle exec package-audit test/files/gemfile/empty`

assert_match 'There are no deprecated, outdated or vulnerable ruby packages!', output
assert_match 'There are no deprecated, outdated or vulnerable Ruby packages!', output
end

def test_that_there_is_a_success_with_ignored_packages_message_when_report_is_empty
output = `bundle exec package-audit test/files/gemfile/ignored_empty`

assert_match '0 vulnerable, 0 outdated, 0 deprecated (1 ignored).', output
assert_match 'There are no deprecated, outdated or vulnerable ruby packages (1 ignored)!', output
assert_match 'There are no deprecated, outdated or vulnerable Ruby packages (1 ignored)!', output
end

def test_that_there_is_a_success_with_ignored_packages_message_when_report_is_not_empty
output = `bundle exec package-audit test/files/gemfile/ignored`

assert_match '0 vulnerable, 1 outdated, 0 deprecated (1 ignored).', output
assert_match 'Found a total of 1 ruby packages (1 ignored).', output
assert_match 'Found a total of 1 Ruby packages (1 ignored).', output
end

def test_that_there_is_a_success_message_when_everything_is_up_to_date
output = `bundle exec package-audit outdated test/files/gemfile/empty`

assert_match 'There are no outdated ruby packages!', output
assert_match 'There are no outdated Ruby packages!', output
end

def test_that_there_is_a_success_message_when_there_are_no_vulnerabilities
output = `bundle exec package-audit vulnerable test/files/gemfile/empty`

assert_match 'There are no vulnerable ruby packages!', output
assert_match 'There are no vulnerable Ruby packages!', output
end

def test_that_there_is_a_success_message_when_there_are_no_deprecations
output = `bundle exec package-audit deprecated test/files/gemfile/empty`

assert_match 'There are no deprecated ruby packages!', output
assert_match 'There are no deprecated Ruby packages!', output
end

def test_that_the_exit_code_is_0_when_report_is_empty
Expand All @@ -59,56 +59,56 @@ def test_that_the_exit_code_is_1_when_report_is_not_empty
def test_that_there_is_a_report_of_gems
output = `bundle exec package-audit test/files/gemfile/report`

assert_match 'Found a total of 3 ruby packages.', output
assert_match 'Found a total of 3 Ruby packages.', output
assert_match '1 vulnerable (11 vulnerabilities), 2 outdated, 1 deprecated.', output
end

def test_that_there_is_a_message_about_outdated_gems
output = `bundle exec package-audit outdated test/files/gemfile/outdated`

assert_match 'Found a total of 1 ruby packages.', output
assert_match 'Found a total of 1 Ruby packages.', output
end

def test_that_there_is_a_message_about_deprecated_gems
output = `bundle exec package-audit deprecated test/files/gemfile/deprecated`

assert_match 'Found a total of 1 ruby packages.', output
assert_match 'Found a total of 1 Ruby packages.', output
end

def test_that_there_is_a_message_about_vulnerable_gems
output = `bundle exec package-audit vulnerable test/files/gemfile/vulnerable`

assert_match 'Found a total of 1 ruby packages.', output
assert_match 'Found a total of 1 Ruby packages.', output
end

def test_that_there_is_a_report_of_node_modules_with_no_dependencies
output = `bundle exec package-audit test/files/yarn/empty`

assert_match 'There are no deprecated, outdated or vulnerable node packages!', output
assert_match 'There are no deprecated, outdated or vulnerable Node packages!', output
end

def test_that_there_is_a_report_of_node_modules_formatted_by_npm_with_no_dependencies
output = `bundle exec package-audit test/files/yarn/npm`

assert_match 'Found a total of 1 node packages.', output
assert_match 'Found a total of 1 Node packages.', output
end

def test_that_there_is_a_success_message_when_node_modules_are_up_to_date
output = `bundle exec package-audit outdated test/files/yarn/empty`

assert_match 'There are no outdated node packages!', output
assert_match 'There are no outdated Node packages!', output
end

def test_that_there_is_a_success_message_when_node_modules_have_no_vulnerabilities
output = `bundle exec package-audit vulnerable test/files/yarn/empty`

assert_match 'There are no vulnerable node packages!', output
assert_match 'There are no vulnerable Node packages!', output
end

def test_that_there_is_a_success_message_when_node_modules_have_no_deprecations
output = `bundle exec package-audit deprecated test/files/yarn/empty`

assert_match 'There are no deprecated node packages!', output
assert_match 'There are no deprecated Node packages!', output
end

def test_that_there_is_a_report_of_node_modules
Expand All @@ -120,19 +120,19 @@ def test_that_there_is_a_report_of_node_modules
def test_that_there_is_a_message_about_outdated_node_modules
output = `bundle exec package-audit outdated test/files/yarn/outdated`

assert_match 'Found a total of 3 node packages.', output
assert_match 'Found a total of 3 Node packages.', output
end

def test_that_there_is_a_message_about_deprecated_node_modules
output = `bundle exec package-audit deprecated test/files/yarn/deprecated`

assert_match 'Found a total of 1 node packages.', output
assert_match 'Found a total of 1 Node packages.', output
end

def test_that_there_is_a_message_about_vulnerable_node_modules
output = `bundle exec package-audit outdated test/files/yarn/vulnerable`

assert_match 'Found a total of 1 node packages.', output
assert_match 'Found a total of 1 Node packages.', output
end
end
end

0 comments on commit 4ab853b

Please sign in to comment.