bundler-audit 0.8.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug-report.md +44 -0
  3. data/.github/ISSUE_TEMPLATE/feature-request.md +14 -0
  4. data/.github/workflows/ruby.yml +16 -2
  5. data/.rubocop.yml +86 -0
  6. data/COPYING.txt +4 -4
  7. data/ChangeLog.md +51 -0
  8. data/Gemfile +8 -3
  9. data/README.md +58 -26
  10. data/Rakefile +7 -3
  11. data/bundler-audit.gemspec +2 -3
  12. data/gemspec.yml +7 -0
  13. data/lib/bundler/audit/advisory.rb +25 -3
  14. data/lib/bundler/audit/cli/formats/json.rb +17 -3
  15. data/lib/bundler/audit/cli/formats/junit.rb +127 -0
  16. data/lib/bundler/audit/cli/formats/text.rb +13 -9
  17. data/lib/bundler/audit/cli/formats.rb +8 -4
  18. data/lib/bundler/audit/cli.rb +37 -18
  19. data/lib/bundler/audit/configuration.rb +8 -5
  20. data/lib/bundler/audit/database.rb +28 -10
  21. data/lib/bundler/audit/results/insecure_source.rb +5 -2
  22. data/lib/bundler/audit/results/unpatched_gem.rb +7 -3
  23. data/lib/bundler/audit/results.rb +2 -2
  24. data/lib/bundler/audit/scanner.rb +17 -8
  25. data/lib/bundler/audit/task.rb +50 -5
  26. data/lib/bundler/audit/version.rb +3 -3
  27. data/lib/bundler/audit.rb +2 -2
  28. data/spec/advisory_spec.rb +19 -2
  29. data/spec/bundle/insecure_sources/Gemfile.lock +71 -73
  30. data/spec/bundle/secure/Gemfile.lock +60 -62
  31. data/spec/cli/formats/json_spec.rb +1 -0
  32. data/spec/cli/formats/junit_spec.rb +284 -0
  33. data/spec/cli/formats/text_spec.rb +88 -18
  34. data/spec/cli_spec.rb +57 -17
  35. data/spec/database_spec.rb +26 -2
  36. data/spec/fixtures/advisory/CVE-2020-1234.yml +1 -0
  37. data/spec/fixtures/lib/bundler/audit/cli/formats/bad.rb +0 -2
  38. data/spec/fixtures/lib/bundler/audit/cli/formats/good.rb +0 -2
  39. data/spec/results/unpatched_gem_spec.rb +2 -2
  40. data/spec/scanner_spec.rb +25 -1
  41. data/spec/spec_helper.rb +5 -1
  42. metadata +29 -8
@@ -0,0 +1,127 @@
1
+ #
2
+ # Copyright (c) 2013-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
3
+ #
4
+ # bundler-audit is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # bundler-audit is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with bundler-audit. If not, see <https://www.gnu.org/licenses/>.
16
+ #
17
+
18
+ require 'thor'
19
+ require 'cgi'
20
+
21
+ module Bundler
22
+ module Audit
23
+ class CLI < ::Thor
24
+ module Formats
25
+ module Junit
26
+ #
27
+ # Prints any findings as an XML junit report.
28
+ #
29
+ # @param [Report] report
30
+ # The results from the {Scanner}.
31
+ #
32
+ # @param [IO, File] output
33
+ # Optional output stream.
34
+ #
35
+ def print_report(report, output=$stdout)
36
+ original_stdout = $stdout
37
+ $stdout = output
38
+
39
+ print_xml_testsuite(report) do
40
+ report.each do |result|
41
+ print_xml_testcase(result)
42
+ end
43
+ end
44
+
45
+ $stdout = original_stdout
46
+ end
47
+
48
+ private
49
+
50
+ def say_xml(*lines)
51
+ say(lines.join($/))
52
+ end
53
+
54
+ def print_xml_testsuite(report)
55
+ say_xml(
56
+ %{<?xml version="1.0" encoding="UTF-8" ?>},
57
+ %{<testsuites id="#{Time.now.to_i}" name="Bundle Audit">},
58
+ %{ <testsuite id="Gemfile" name="Ruby Gemfile" failures="#{report.count}">}
59
+ )
60
+
61
+ yield
62
+
63
+ say_xml(
64
+ %{ </testsuite>},
65
+ %{</testsuites>}
66
+ )
67
+ end
68
+
69
+ def xml(string)
70
+ CGI.escapeHTML(string.to_s)
71
+ end
72
+
73
+ def print_xml_testcase(result)
74
+ case result
75
+ when Results::InsecureSource
76
+ say_xml(
77
+ %{ <testcase id="#{xml(result.source)}" name="Insecure Source URI found: #{xml(result.source)}">},
78
+ %{ <failure message="Insecure Source URI found: #{xml(result.source)}" type="Unknown"></failure>},
79
+ %{ </testcase>}
80
+ )
81
+ when Results::UnpatchedGem
82
+ say_xml(
83
+ %{ <testcase id="#{xml(result.gem.name)}" name="#{xml(bundle_title(result))}">},
84
+ %{ <failure message="#{xml(result.advisory.title)}" type="#{xml(result.advisory.criticality)}">},
85
+ %{ Name: #{xml(result.gem.name)}},
86
+ %{ Version: #{xml(result.gem.version)}},
87
+ %{ Advisory: #{xml(advisory_ref(result.advisory))}},
88
+ %{ Criticality: #{xml(advisory_criticality(result.advisory))}},
89
+ %{ URL: #{xml(result.advisory.url)}},
90
+ %{ Title: #{xml(result.advisory.title)}},
91
+ %{ Solution: #{xml(advisory_solution(result.advisory))}},
92
+ %{ </failure>},
93
+ %{ </testcase>}
94
+ )
95
+ end
96
+ end
97
+
98
+ def bundle_title(result)
99
+ "#{advisory_criticality(result.advisory).upcase} #{result.gem.name}(#{result.gem.version}) #{result.advisory.title}"
100
+ end
101
+
102
+ def advisory_solution(advisory)
103
+ unless advisory.patched_versions.empty?
104
+ "upgrade to #{advisory.patched_versions.map { |v| "'#{v}'" }.join(', ')}"
105
+ else
106
+ "remove or disable this gem until a patch is available!"
107
+ end
108
+ end
109
+
110
+ def advisory_criticality(advisory)
111
+ if advisory.criticality
112
+ advisory.criticality.to_s.capitalize
113
+ else
114
+ "Unknown"
115
+ end
116
+ end
117
+
118
+ def advisory_ref(advisory)
119
+ advisory.identifiers.join(" ")
120
+ end
121
+
122
+ Formats.register :junit, Junit
123
+ end
124
+ end
125
+ end
126
+ end
127
+ end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2013-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2013-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # bundler-audit is free software: you can redistribute it and/or modify
5
5
  # it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
12
12
  # GNU General Public License for more details.
13
13
  #
14
14
  # You should have received a copy of the GNU General Public License
15
- # along with bundler-audit. If not, see <http://www.gnu.org/licenses/>.
15
+ # along with bundler-audit. If not, see <https://www.gnu.org/licenses/>.
16
16
  #
17
17
 
18
18
  require 'thor'
@@ -21,6 +21,9 @@ module Bundler
21
21
  module Audit
22
22
  class CLI < ::Thor
23
23
  module Formats
24
+ #
25
+ # The plain-text output format.
26
+ #
24
27
  module Text
25
28
  #
26
29
  # Prints any findings as plain-text.
@@ -78,10 +81,12 @@ module Bundler
78
81
 
79
82
  say "Criticality: ", :red
80
83
  case advisory.criticality
81
- when :low then say "Low"
82
- when :medium then say "Medium", :yellow
83
- when :high then say "High", [:red, :bold]
84
- else say "Unknown"
84
+ when :none then say "None"
85
+ when :low then say "Low"
86
+ when :medium then say "Medium", :yellow
87
+ when :high then say "High", [:red, :bold]
88
+ when :critical then say "Critical", [:red, :bold]
89
+ else say "Unknown"
85
90
  end
86
91
 
87
92
  say "URL: ", :red
@@ -91,7 +96,7 @@ module Bundler
91
96
  say "Description:", :red
92
97
  say
93
98
 
94
- print_wrapped advisory.description, :indent => 2
99
+ print_wrapped advisory.description, indent: 2
95
100
  say
96
101
  else
97
102
  say "Title: ", :red
@@ -100,7 +105,7 @@ module Bundler
100
105
 
101
106
  unless advisory.patched_versions.empty?
102
107
  say "Solution: upgrade to ", :red
103
- say advisory.patched_versions.join(', ')
108
+ say advisory.patched_versions.map { |v| "'#{v}'" }.join(', ')
104
109
  else
105
110
  say "Solution: ", :red
106
111
  say "remove or disable this gem until a patch is available!", [:red, :bold]
@@ -108,7 +113,6 @@ module Bundler
108
113
 
109
114
  say
110
115
  end
111
-
112
116
  end
113
117
 
114
118
  Formats.register :text, Text
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2013-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2013-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # bundler-audit is free software: you can redistribute it and/or modify
5
5
  # it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
12
12
  # GNU General Public License for more details.
13
13
  #
14
14
  # You should have received a copy of the GNU General Public License
15
- # along with bundler-audit. If not, see <http://www.gnu.org/licenses/>.
15
+ # along with bundler-audit. If not, see <https://www.gnu.org/licenses/>.
16
16
  #
17
17
 
18
18
  require 'thor'
@@ -126,15 +126,19 @@ module Bundler
126
126
  #
127
127
  def self.load(name)
128
128
  name = name.to_s
129
+ path = File.join(DIR,File.basename(name))
129
130
 
130
131
  begin
131
- require File.join(DIR,File.basename(name))
132
+ require path
132
133
  rescue LoadError
133
134
  raise(FormatNotFound,"could not load format #{name.inspect}")
134
135
  end
135
136
 
136
- return self[name] || \
137
+ unless (format = self[name])
137
138
  raise(FormatNotFound,"unknown format #{name.inspect}")
139
+ end
140
+
141
+ return format
138
142
  end
139
143
  end
140
144
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2013-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2013-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # bundler-audit is free software: you can redistribute it and/or modify
5
5
  # it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
12
12
  # GNU General Public License for more details.
13
13
  #
14
14
  # You should have received a copy of the GNU General Public License
15
- # along with bundler-audit. If not, see <http://www.gnu.org/licenses/>.
15
+ # along with bundler-audit. If not, see <https://www.gnu.org/licenses/>.
16
16
  #
17
17
 
18
18
  require 'bundler/audit/scanner'
@@ -25,21 +25,26 @@ require 'bundler'
25
25
 
26
26
  module Bundler
27
27
  module Audit
28
+ #
29
+ # The `bundle-audit` command.
30
+ #
28
31
  class CLI < ::Thor
29
32
 
30
33
  default_task :check
31
34
  map '--version' => :version
32
35
 
33
36
  desc 'check [DIR]', 'Checks the Gemfile.lock for insecure dependencies'
34
- method_option :quiet, :type => :boolean, :aliases => '-q'
35
- method_option :verbose, :type => :boolean, :aliases => '-v'
36
- method_option :ignore, :type => :array, :aliases => '-i'
37
- method_option :update, :type => :boolean, :aliases => '-u'
38
- method_option :database, :type => :string, :aliases => '-D', :default => Database::USER_PATH
39
- method_option :format, :type => :string, :default => 'text',
40
- :aliases => '-F'
41
- method_option :gemfile_lock, :type => :string, :aliases => '-G', :default => 'Gemfile.lock'
42
- method_option :output, :type => :string, :aliases => '-o'
37
+ method_option :quiet, type: :boolean, aliases: '-q'
38
+ method_option :verbose, type: :boolean, aliases: '-v'
39
+ method_option :ignore, type: :array, aliases: '-i'
40
+ method_option :update, type: :boolean, aliases: '-u'
41
+ method_option :database, type: :string, aliases: '-D',
42
+ default: Database::USER_PATH
43
+ method_option :format, type: :string, default: 'text', aliases: '-F'
44
+ method_option :config, type: :string, aliases: '-c', default: '.bundler-audit.yml'
45
+ method_option :gemfile_lock, type: :string, aliases: '-G',
46
+ default: 'Gemfile.lock'
47
+ method_option :output, type: :string, aliases: '-o'
43
48
 
44
49
  def check(dir=Dir.pwd)
45
50
  unless File.directory?(dir)
@@ -62,15 +67,18 @@ module Bundler
62
67
 
63
68
  database = Database.new(options[:database])
64
69
  scanner = begin
65
- Scanner.new(dir,options[:gemfile_lock],database)
70
+ Scanner.new(dir,options[:gemfile_lock],database, options[:config])
66
71
  rescue Bundler::GemfileLockNotFound => exception
67
72
  say exception.message, :red
68
73
  exit 1
69
74
  end
70
- report = scanner.report(:ignore => options.ignore)
71
75
 
72
- output = if options[:output] then File.new(options[:output],'w')
73
- else $stdout
76
+ report = scanner.report(ignore: options.ignore)
77
+
78
+ output = if options[:output]
79
+ File.new(options[:output],'w')
80
+ else
81
+ $stdout
74
82
  end
75
83
 
76
84
  print_report(report,output)
@@ -81,7 +89,7 @@ module Bundler
81
89
  end
82
90
 
83
91
  desc 'stats', 'Prints ruby-advisory-db stats'
84
- method_option :quiet, :type => :boolean, :aliases => '-q'
92
+ method_option :quiet, type: :boolean, aliases: '-q'
85
93
 
86
94
  def stats(path=Database.path)
87
95
  database = Database.new(path)
@@ -89,10 +97,14 @@ module Bundler
89
97
  puts "ruby-advisory-db:"
90
98
  puts " advisories:\t#{database.size} advisories"
91
99
  puts " last updated:\t#{database.last_updated_at}"
100
+
101
+ if (commit_id = database.commit_id)
102
+ puts " commit:\t#{commit_id}"
103
+ end
92
104
  end
93
105
 
94
106
  desc 'download', 'Downloads ruby-advisory-db'
95
- method_option :quiet, :type => :boolean, :aliases => '-q'
107
+ method_option :quiet, type: :boolean, aliases: '-q'
96
108
 
97
109
  def download(path=Database.path)
98
110
  if Database.exists?(path)
@@ -113,7 +125,7 @@ module Bundler
113
125
  end
114
126
 
115
127
  desc 'update', 'Updates the ruby-advisory-db'
116
- method_option :quiet, :type => :boolean, :aliases => '-q'
128
+ method_option :quiet, type: :boolean, aliases: '-q'
117
129
 
118
130
  def update(path=Database.path)
119
131
  unless Database.exists?(path)
@@ -150,6 +162,13 @@ module Bundler
150
162
 
151
163
  protected
152
164
 
165
+ #
166
+ # @note Silence deprecation warnings from Thor.
167
+ #
168
+ def self.exit_on_failure?
169
+ true
170
+ end
171
+
153
172
  #
154
173
  # @abstract
155
174
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2013-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2013-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # bundler-audit is free software: you can redistribute it and/or modify
5
5
  # it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
12
12
  # GNU General Public License for more details.
13
13
  #
14
14
  # You should have received a copy of the GNU General Public License
15
- # along with bundler-audit. If not, see <http://www.gnu.org/licenses/>.
15
+ # along with bundler-audit. If not, see <https://www.gnu.org/licenses/>.
16
16
  #
17
17
 
18
18
  require 'yaml'
@@ -26,14 +26,17 @@ module Bundler
26
26
  # @since 0.8.0
27
27
  #
28
28
  class Configuration
29
- class InvalidConfigurationError < StandardError; end
30
- class FileNotFound < StandardError; end
29
+ class InvalidConfigurationError < StandardError
30
+ end
31
+
32
+ class FileNotFound < StandardError
33
+ end
31
34
 
32
35
  #
33
36
  # A constructor method for loading configuration from a YAML file.
34
37
  #
35
38
  # @param [String] file_path
36
- # Path to the yaml file holding the configuration.
39
+ # Path to the YAML file holding the configuration.
37
40
  #
38
41
  # @raise [FileNotFound]
39
42
  # Will raise a file not found error when the path to the
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2013-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2013-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # bundler-audit is free software: you can redistribute it and/or modify
5
5
  # it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
12
12
  # GNU General Public License for more details.
13
13
  #
14
14
  # You should have received a copy of the GNU General Public License
15
- # along with bundler-audit. If not, see <http://www.gnu.org/licenses/>.
15
+ # along with bundler-audit. If not, see <https://www.gnu.org/licenses/>.
16
16
  #
17
17
 
18
18
  require 'bundler/audit/advisory'
@@ -34,18 +34,20 @@ module Bundler
34
34
  class UpdateFailed < RuntimeError
35
35
  end
36
36
 
37
- # Git URL of the ruby-advisory-db
37
+ # Git URL of the ruby-advisory-db.
38
38
  URL = 'https://github.com/rubysec/ruby-advisory-db.git'
39
39
 
40
- # Path to the user's copy of the ruby-advisory-db
40
+ # Path to the user's copy of the ruby-advisory-db.
41
41
  USER_PATH = File.expand_path(File.join(Gem.user_home,'.local','share','ruby-advisory-db'))
42
42
 
43
- # Default path to the ruby-advisory-db
43
+ # Default path to the ruby-advisory-db.
44
44
  #
45
45
  # @since 0.8.0
46
- DEFAULT_PATH = ENV['BUNDLER_AUDIT_DB'] || USER_PATH
46
+ DEFAULT_PATH = ENV.fetch('BUNDLER_AUDIT_DB',USER_PATH)
47
47
 
48
- # The path to the advisory database
48
+ # The path to the advisory database.
49
+ #
50
+ # @return [String]
49
51
  attr_reader :path
50
52
 
51
53
  #
@@ -82,7 +84,7 @@ module Bundler
82
84
  # The given path of the database to check.
83
85
  #
84
86
  # @return [Boolean]
85
- #
87
+ #
86
88
  # @since 0.8.0
87
89
  #
88
90
  def self.exists?(path=DEFAULT_PATH)
@@ -119,7 +121,7 @@ module Bundler
119
121
 
120
122
  path = options.fetch(:path,DEFAULT_PATH)
121
123
 
122
- command = %w(git clone)
124
+ command = %w[git clone]
123
125
  command << '--quiet' if options[:quiet]
124
126
  command << URL << path
125
127
 
@@ -199,7 +201,7 @@ module Bundler
199
201
  def update!(options={})
200
202
  if git?
201
203
  Dir.chdir(@path) do
202
- command = %w(git pull)
204
+ command = %w[git pull]
203
205
  command << '--quiet' if options[:quiet]
204
206
  command << 'origin' << 'master'
205
207
 
@@ -212,6 +214,22 @@ module Bundler
212
214
  end
213
215
  end
214
216
 
217
+ #
218
+ # The last commit ID of the repository.
219
+ #
220
+ # @return [String, nil]
221
+ # The commit hash or `nil` if the database is not a git repository.
222
+ #
223
+ # @since 0.9.0
224
+ #
225
+ def commit_id
226
+ if git?
227
+ Dir.chdir(@path) do
228
+ `git rev-parse HEAD`.chomp
229
+ end
230
+ end
231
+ end
232
+
215
233
  #
216
234
  # Determines the time when the database was last updated.
217
235
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2013-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2013-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # bundler-audit is free software: you can redistribute it and/or modify
5
5
  # it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
12
12
  # GNU General Public License for more details.
13
13
  #
14
14
  # You should have received a copy of the GNU General Public License
15
- # along with bundler-audit. If not, see <http://www.gnu.org/licenses/>.
15
+ # along with bundler-audit. If not, see <https://www.gnu.org/licenses/>.
16
16
  #
17
17
 
18
18
  require 'bundler/audit/results/result'
@@ -20,6 +20,9 @@ require 'bundler/audit/results/result'
20
20
  module Bundler
21
21
  module Audit
22
22
  module Results
23
+ #
24
+ # Represents an insecure gem source (ex: `git://...` or `http://...`).
25
+ #
23
26
  class InsecureSource < Result
24
27
 
25
28
  # The insecure `git://` or `http://` URI.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2013-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2013-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # bundler-audit is free software: you can redistribute it and/or modify
5
5
  # it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
12
12
  # GNU General Public License for more details.
13
13
  #
14
14
  # You should have received a copy of the GNU General Public License
15
- # along with bundler-audit. If not, see <http://www.gnu.org/licenses/>.
15
+ # along with bundler-audit. If not, see <https://www.gnu.org/licenses/>.
16
16
  #
17
17
 
18
18
  require 'bundler/audit/results/result'
@@ -22,6 +22,10 @@ require 'uri'
22
22
  module Bundler
23
23
  module Audit
24
24
  module Results
25
+ #
26
+ # Represents a gem version that has known vulnerabilities and needs to be
27
+ # upgraded.
28
+ #
25
29
  class UnpatchedGem < Result
26
30
 
27
31
  # The specification of the vulnerable gem.
@@ -73,7 +77,7 @@ module Bundler
73
77
  end
74
78
 
75
79
  #
76
- # Converts the unpached gem to a Hash.
80
+ # Converts the unpatched gem to a Hash.
77
81
  #
78
82
  # @return [Hash{Symbol => Object}]
79
83
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2013-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2013-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # bundler-audit is free software: you can redistribute it and/or modify
5
5
  # it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
12
12
  # GNU General Public License for more details.
13
13
  #
14
14
  # You should have received a copy of the GNU General Public License
15
- # along with bundler-audit. If not, see <http://www.gnu.org/licenses/>.
15
+ # along with bundler-audit. If not, see <https://www.gnu.org/licenses/>.
16
16
  #
17
17
 
18
18
  require 'bundler/audit/results/insecure_source'
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2013-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2013-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # bundler-audit is free software: you can redistribute it and/or modify
5
5
  # it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
12
12
  # GNU General Public License for more details.
13
13
  #
14
14
  # You should have received a copy of the GNU General Public License
15
- # along with bundler-audit. If not, see <http://www.gnu.org/licenses/>.
15
+ # along with bundler-audit. If not, see <https://www.gnu.org/licenses/>.
16
16
  #
17
17
 
18
18
  require 'bundler'
@@ -31,9 +31,12 @@ require 'yaml'
31
31
 
32
32
  module Bundler
33
33
  module Audit
34
+ #
35
+ # Scans a `Gemfile.lock` for security issues.
36
+ #
34
37
  class Scanner
35
38
 
36
- # The advisory database
39
+ # The advisory database.
37
40
  #
38
41
  # @return [Database]
39
42
  attr_reader :database
@@ -41,12 +44,13 @@ module Bundler
41
44
  # Project root directory
42
45
  attr_reader :root
43
46
 
44
- # The parsed `Gemfile.lock` from the project
47
+ # The parsed `Gemfile.lock` from the project.
45
48
  #
46
49
  # @return [Bundler::LockfileParser]
47
50
  attr_reader :lockfile
48
51
 
49
- # The configuration loaded from the `.bundler-audit.yml` file from the project
52
+ # The configuration loaded from the `.bundler-audit.yml` file from the
53
+ # project.
50
54
  #
51
55
  # @return [Hash]
52
56
  attr_reader :config
@@ -63,6 +67,9 @@ module Bundler
63
67
  # @param [Database] database
64
68
  # The database to scan against.
65
69
  #
70
+ # @param [String] config_dot_file
71
+ # The file name of the bundler-audit config file.
72
+ #
66
73
  # @raise [Bundler::GemfileLockNotFound]
67
74
  # The `gemfile_lock` file could not be found within the `root`
68
75
  # directory.
@@ -79,7 +86,7 @@ module Bundler
79
86
 
80
87
  @lockfile = LockfileParser.new(File.read(gemfile_lock_path))
81
88
 
82
- config_dot_file_full_path = File.join(@root,config_dot_file)
89
+ config_dot_file_full_path = File.absolute_path(config_dot_file, @root)
83
90
 
84
91
  @config = if File.exist?(config_dot_file_full_path)
85
92
  Configuration.load(config_dot_file_full_path)
@@ -211,8 +218,10 @@ module Bundler
211
218
  def scan_specs(options={})
212
219
  return enum_for(__method__,options) unless block_given?
213
220
 
214
- ignore = if options[:ignore] then Set.new(options[:ignore])
215
- else config.ignore
221
+ ignore = if options[:ignore]
222
+ Set.new(options[:ignore])
223
+ else
224
+ config.ignore
216
225
  end
217
226
 
218
227
  @lockfile.specs.each do |gem|