Class: Bundler::Audit::Fix::CLI
- Inherits:
-
Thor
- Object
- Thor
- Bundler::Audit::Fix::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/bundler/audit/fix/cli.rb
Overview
The ‘bundle-audit-fix` command.
Instance Method Summary collapse
Instance Method Details
#update(dir = Dir.pwd) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/bundler/audit/fix/cli.rb', line 46 def update(dir = Dir.pwd) unless File.directory?(dir) say_error "No such file or directory: #{dir}", :red exit 1 end if !Database.exists?([:database]) Bundler::Audit::CLI.new.invoke(:download, [:database]) elsif [:update] Bundler::Audit::CLI.new.invoke(:update, [:database]) end gemfile = [:gemfile_lock].sub(/\.lock$/, '') gemfile_path = File.join(dir, gemfile) # for https://github.com/rubygems/bundler/blob/35be6d9a603084f719fec4f4028c18860def07f6/lib/bundler/shared_helpers.rb#L229 ENV['BUNDLE_GEMFILE'] = gemfile_path database = Database.new([:database]) begin scanner = Scanner.new(dir, [:gemfile_lock], database, [:config]) scanner.scan report = scanner.report(ignore: .ignore) unless report.vulnerable? say 'Nothing to do, exiting.', :green exit 0 end patcher = Patcher.new(dir, report, [:gemfile_lock], [:config]) gems_to_update = patcher.patch Bundler::CLI::Update.new({ gemfile: gemfile_path }, gems_to_update).run rescue Bundler::GemfileNotFound, Bundler::GemfileLockNotFound => e say e., :red exit 1 end end |