Class: Bundler::Patch::Scanner
- Inherits:
-
Boson::Runner
- Object
- Boson::Runner
- Bundler::Patch::Scanner
- Defined in:
- lib/bundler/patch/scanner.rb
Instance Method Summary collapse
-
#initialize ⇒ Scanner
constructor
A new instance of Scanner.
-
#patch(options = {}) ⇒ Object
TODO: Revamp the commands now that we’ve broadened into security specific and generic.
-
#scan(options = {}) ⇒ Object
TODO: Revamp the commands now that we’ve broadened into security specific and generic.
-
#update(options = {}) ⇒ Object
TODO: Revamp the commands now that we’ve broadened into security specific and generic.
Constructor Details
#initialize ⇒ Scanner
Returns a new instance of Scanner.
6 7 8 |
# File 'lib/bundler/patch/scanner.rb', line 6 def initialize = 'No known vulnerabilities to update.' end |
Instance Method Details
#patch(options = {}) ⇒ Object
TODO: Revamp the commands now that we’ve broadened into security specific and generic
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/bundler/patch/scanner.rb', line 32 def patch(={}) # TODO: Revamp the commands now that we've broadened into security specific and generic header gem_patches, warnings = AdvisoryConsolidator.new().patch_gemfile_and_get_gem_specs_to_patch unless warnings.empty? warnings.each do |gp| # TODO: Bundler.ui puts "* Could not attempt upgrade for #{gp.gem_name} from #{gp.old_version} to any patched versions " \ + "#{gp.patched_versions.join(', ')}. Most often this is because a major version increment would be " \ + "required and it's safer for a major version increase to be done manually." end end if gem_patches.empty? puts else gem_patches.each do |gp| puts "Attempting #{gp.gem_name}: #{gp.old_version} => #{gp.new_version}" # TODO: Bundler.ui end puts "Updating '#{gem_patches.map(&:gem_name).join(' ')}' to address vulnerabilities" conservative_update(gem_patches, .merge(patching: true)) end end |
#scan(options = {}) ⇒ Object
TODO: Revamp the commands now that we’ve broadened into security specific and generic
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bundler/patch/scanner.rb', line 13 def scan(={}) # TODO: Revamp the commands now that we've broadened into security specific and generic header gem_patches = AdvisoryConsolidator.new().vulnerable_gems if gem_patches.empty? puts else puts # extra line to separate from advisory db update text puts 'Detected vulnerabilities:' puts '-------------------------' puts gem_patches.map(&:to_s).uniq.sort.join("\n") end end |
#update(options = {}) ⇒ Object
TODO: Revamp the commands now that we’ve broadened into security specific and generic
65 66 67 68 69 |
# File 'lib/bundler/patch/scanner.rb', line 65 def update(={}) # TODO: Revamp the commands now that we've broadened into security specific and generic header gem_patches = (.delete(:gems_to_update) || []).map { |gem_name| GemPatch.new(gem_name: gem_name) } conservative_update(gem_patches, .merge(updating: true)) end |