Class: Bundler::Plumber::Scanner
- Inherits:
-
Object
- Object
- Bundler::Plumber::Scanner
- Defined in:
- lib/bundler/plumber/scanner.rb
Defined Under Namespace
Classes: UnpatchedGem
Instance Attribute Summary collapse
-
#database ⇒ Database
readonly
The advisory database.
-
#lockfile ⇒ Bundler::LockfileParser
readonly
The parsed
Gemfile.lock
from the project. -
#root ⇒ Object
readonly
Project root directory.
Instance Method Summary collapse
-
#initialize(root = Dir.pwd, gemfile_lock = 'Gemfile.lock') ⇒ Scanner
constructor
Initializes a scanner.
-
#scan(options = {}) {|result| ... } ⇒ Enumerator
Scans the project for issues.
-
#scan_specs(options = {}) {|result| ... } ⇒ Enumerator
Scans the gem sources in the lockfile.
Constructor Details
#initialize(root = Dir.pwd, gemfile_lock = 'Gemfile.lock') ⇒ Scanner
Initializes a scanner.
57 58 59 60 61 62 63 |
# File 'lib/bundler/plumber/scanner.rb', line 57 def initialize(root=Dir.pwd,gemfile_lock='Gemfile.lock') @root = File.(root) @database = Database.new @lockfile = LockfileParser.new( File.read(File.join(@root,gemfile_lock)) ) end |
Instance Attribute Details
#database ⇒ Database (readonly)
The advisory database
38 39 40 |
# File 'lib/bundler/plumber/scanner.rb', line 38 def database @database end |
#lockfile ⇒ Bundler::LockfileParser (readonly)
The parsed Gemfile.lock
from the project
46 47 48 |
# File 'lib/bundler/plumber/scanner.rb', line 46 def lockfile @lockfile end |
#root ⇒ Object (readonly)
Project root directory
41 42 43 |
# File 'lib/bundler/plumber/scanner.rb', line 41 def root @root end |
Instance Method Details
#scan(options = {}) {|result| ... } ⇒ Enumerator
Scans the project for issues.
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/bundler/plumber/scanner.rb', line 80 def scan(={},&block) return enum_for(__method__, ) unless block ignore = Set[] ignore += [:ignore] if [:ignore] scan_specs(, &block) return self end |
#scan_specs(options = {}) {|result| ... } ⇒ Enumerator
Scans the gem sources in the lockfile.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/bundler/plumber/scanner.rb', line 113 def scan_specs(={}) return enum_for(__method__, ) unless block_given? ignore = Set[] ignore += [:ignore] if [:ignore] @lockfile.specs.each do |gem| @database.check_gem(gem) do |advisory| # TODO this logic should be modified for rubymem #unless (ignore.include?(advisory.cve_id) || ignore.include?(advisory.osvdb_id)) # yield UnpatchedGem.new(gem,advisory) #end yield UnpatchedGem.new(gem, advisory) end end end |