Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions lib/bundler/audit/scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ class Scanner
InsecureSource = Struct.new(:source)

# Represents a gem that is covered by an Advisory
UnpatchedGem = Struct.new(:gem, :advisory)
UnpatchedGem = Struct.new(:gem, :advisory) do
alias_method :rubygem, :gem
end

# The advisory database
#
Expand All @@ -30,15 +32,18 @@ class Scanner
#
# Initializes a scanner.
#
# @param [String] root
# The path to the project root.
# @param [String, #read] path_io
# The path to a directory with a Gemfile.lock, or an IO representation of Gemfile.lock
#
def initialize(root=Dir.pwd)
@root = File.expand_path(root)
def initialize(path_io=Dir.pwd)
@database = Database.new
@lockfile = LockfileParser.new(
File.read(File.join(@root,'Gemfile.lock'))
)
@lockfile = if path_io.respond_to?(:read)
@root = nil
LockfileParser.new(path_io.read)
else
@root = path_io
LockfileParser.new File.read(File.join(@root,'Gemfile.lock'))
end
end

#
Expand Down