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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c98968f6509b0551b595706cc23591bf2741626a472dcccda17e107c2e7788d0
4
- data.tar.gz: 61c7ea8687934092a74aca4f0358e2565ce9eec53fe0713198bd1eadd5e2ae31
3
+ metadata.gz: 762980c9b274b19e477ee0be0ae021e452a1e7d63796ceb6da0d667de704dad9
4
+ data.tar.gz: 3e0fae808a027e677f3d218949c092d8189fc124bb34f61b57fdf982b5ffd6b1
5
5
  SHA512:
6
- metadata.gz: 3a10a9071b08c8781c33db982d9d72929c63c2ec3ce69839cf93186bcd47775e8483fe397cf9b05363f13c785757f9b7cb3dfef2bced8085f9913c38553d6714
7
- data.tar.gz: 4789e6c07340509b1e08218b6f9b2e16fcc40f24f42476ca92fe530171b2035bab209984b324783bf387758c9262d3fce724ceb0f76cdc0e78c967109112431d
6
+ metadata.gz: faa37304223ab40fd5678b6a4fcc1f9edb6d112c418c3a80a38aff6dbfbfacd416481f32f402998ece370d4646fe416e8f9453a5cec98d634845ff7bfd1abc6f
7
+ data.tar.gz: 7fbd39c761fdee364266207e4f0b52be6347b480b8447d31688428b8d3b5337c7f7403142ef0b2da0bc293ddfbe1ea5df93750b3a70be3920eff37af1d6a7884
@@ -0,0 +1,44 @@
1
+ ---
2
+ name: Bug Report
3
+ about: Report a bug
4
+ title: ''
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+ <!--
10
+ **Double Check**
11
+
12
+ - Did you update to the latest bundler-audit? (ex: `bundle update bundler-audit` or `gem update bundler-audit`)
13
+ - Did you update the ruby-advisory-db? (ex: `bundler-audit update`)
14
+ -->
15
+
16
+ ## Description
17
+
18
+ <!-- A clear and concise description of what the bug is. -->
19
+
20
+ ## Steps To Reproduce
21
+
22
+ Steps to reproduce the bug:
23
+ 1. `$ bundle-audit ...`
24
+ 2. ???
25
+
26
+ ## Expected Behavior
27
+
28
+ <!-- What should happen. -->
29
+
30
+ ## Actual Behavior
31
+
32
+ <!-- The error message or backtrace. -->
33
+ ```
34
+ ```
35
+
36
+ ## Environment
37
+
38
+ $ bundler-audit --version
39
+ ...
40
+ $ bundle --version
41
+ ...
42
+ $ ruby --version
43
+ ...
44
+
@@ -0,0 +1,14 @@
1
+ ---
2
+ name: Feature Request
3
+ about: Request a new Feature
4
+ title: ''
5
+ labels: feature
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ ## Description
11
+
12
+ <!-- Explain how the desired feature would work. -->
13
+ <!-- Explain why the desired feature is needed. -->
14
+ <!-- Explain who would use the desired feature. -->
@@ -9,11 +9,11 @@ jobs:
9
9
  fail-fast: false
10
10
  matrix:
11
11
  ruby:
12
- - 2.4
13
12
  - 2.5
14
13
  - 2.6
15
14
  - 2.7
16
- - 3.0
15
+ - '3.0'
16
+ - 3.1
17
17
  - jruby
18
18
  - truffleruby-head
19
19
  name: Ruby ${{ matrix.ruby }}
@@ -27,3 +27,17 @@ jobs:
27
27
  run: bundle install --jobs 4 --retry 3
28
28
  - name: Run tests
29
29
  run: bundle exec rake test
30
+
31
+ # rubocop linting
32
+ rubocop:
33
+ runs-on: ubuntu-latest
34
+ steps:
35
+ - uses: actions/checkout@v2
36
+ - name: Set up Ruby
37
+ uses: ruby/setup-ruby@v1
38
+ with:
39
+ ruby-version: 2.7
40
+ - name: Install dependencies
41
+ run: bundle install --jobs 4 --retry 3
42
+ - name: Run rubocop
43
+ run: bundle exec rubocop --parallel
data/.rubocop.yml ADDED
@@ -0,0 +1,86 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ SuggestExtensions: false
4
+ TargetRubyVersion: 2.7
5
+ Exclude:
6
+ - 'spec/bundle/**/*'
7
+ - 'spec/fixtures/database/**/*'
8
+ - 'vendor/**/*'
9
+
10
+ #
11
+ # Style
12
+ #
13
+ Layout/FirstArrayElementIndentation: { EnforcedStyle: consistent }
14
+ Layout/FirstHashElementIndentation: { EnforcedStyle: consistent }
15
+ Layout/SpaceAroundEqualsInParameterDefault: { EnforcedStyle: no_space }
16
+ Style/SymbolArray: { EnforcedStyle: brackets }
17
+ Style/PercentLiteralDelimiters:
18
+ Enabled: true
19
+ PreferredDelimiters:
20
+ default: '{}'
21
+ '%i': '[]'
22
+ '%I': '[]'
23
+ '%w': '[]'
24
+ '%W': '[]'
25
+
26
+ #
27
+ # Rules that conflict with my style.
28
+ #
29
+ Metrics: { Enabled: false }
30
+ Layout/BeginEndAlignment: { Enabled: false } # Offense count: 1
31
+ Layout/BlockAlignment: { Enabled: false } # Offense count: 1
32
+ Layout/EmptyLinesAroundClassBody: { Enabled: false } # Offense count: 15
33
+ Layout/ExtraSpacing: { Enabled: false } # Offense count: 9
34
+ Layout/HashAlignment: { Enabled: false } # Offense count: 3
35
+ Layout/SpaceAfterComma: { Enabled: false } # Offense count: 122
36
+ Layout/SpaceInsideHashLiteralBraces: { Enabled: false } # Offense count: 8
37
+ Lint/MissingSuper: { Enabled: false } # Offense count: 3
38
+ Lint/ShadowingOuterLocalVariable: { Enabled: false }
39
+ Lint/ConstantDefinitionInBlock: { Exclude: ['spec/cli/formats_spec.rb'] }
40
+ Lint/SuppressedException: { Exclude: ['spec/cli_spec.rb'] }
41
+ Lint/UnusedBlockArgument: { Enabled: false } # Offense count: 4
42
+ Lint/UnusedMethodArgument: { Enabled: false } # Offense count: 6
43
+ Naming/RescuedExceptionsVariableName: { Enabled: false } # Offense count: 2
44
+ Style/BlockDelimiters: { Enabled: false } # Offense count: 20
45
+ Style/CaseEquality: { Exclude: ['lib/bundler/audit/advisory.rb'] }
46
+ Style/ClassCheck: { Enabled: false } # Offense count: 4
47
+ Style/Documentation: { Enabled: false } # Offense count: 12
48
+ Style/GuardClause: { Enabled: false } # Offense count: 1
49
+ Style/HashSyntax:
50
+ Exclude:
51
+ - 'Rakefile'
52
+ - 'lib/bundler/audit/task.rb'
53
+ Style/IfUnlessModifier: { Enabled: false } # Offense count: 14
54
+ Style/MethodCallWithoutArgsParentheses: { Enabled: false } # Offense count: 1
55
+ Style/MultilineBlockChain: { Exclude: ['spec/**/*'] } # Offense count: 6
56
+ Style/MutableConstant: { Enabled: false } # Offense count: 4
57
+ Style/ParenthesesAroundCondition: { Enabled: false } # Offense count: 1
58
+ Style/RedundantBegin: { Exclude: ['spec/cli_spec.rb'] } # Offense count: 1
59
+ Style/RedundantReturn: { Enabled: false } # Offense count: 6
60
+ Style/SpecialGlobalVars: { Enabled: false } # Offense count: 5
61
+ Style/StringLiterals: { Enabled: false } # Offense count: 333
62
+ Style/StructInheritance: { Enabled: false } # Offense count: 1
63
+ Style/UnlessElse: { Enabled: false } # Offense count: 1
64
+ Style/WordArray: { Enabled: false } # Offense count: 1
65
+ Style/Lambda: { Enabled: false } # Offense count: 2
66
+ Style/SafeNavigation: { Enabled: false } # Offense count: 2
67
+ Lint/IneffectiveAccessModifier: { Enabled: false } # Offense count: 1
68
+ Gemspec/DuplicatedAssignment:
69
+ Exclude:
70
+ - 'bundler-audit.gemspec'
71
+
72
+ #
73
+ # Rules that may be disabled in the future.
74
+ #
75
+ # Layout/SpaceInsideParens: { Enabled: false }
76
+ # Layout/TrailingWhitespace: { Enabled: false }
77
+
78
+ #
79
+ # Rules that I want to fully enabled in the future.
80
+ #
81
+ Style/DoubleNegation: { Exclude: ['spec/spec_helper.rb'] } # Offense count: 1
82
+ Style/EmptyMethod: { Exclude: ['spec/cli/formats_spec.rb'] } # Offense count: 2
83
+ Style/ExpandPathArguments: { Enabled: false } # Offense count: 5
84
+ Style/FrozenStringLiteralComment: { Enabled: false } # Offense count: 42
85
+ Style/MixinUsage: { Exclude: ['spec/spec_helper.rb'] } # Offense count: 1
86
+ Layout/LineLength: { Enabled: false }
data/COPYING.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  GNU GENERAL PUBLIC LICENSE
2
2
  Version 3, 29 June 2007
3
3
 
4
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
5
  Everyone is permitted to copy and distribute verbatim copies
6
6
  of this license document, but changing it is not allowed.
7
7
 
@@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
645
645
  GNU General Public License for more details.
646
646
 
647
647
  You should have received a copy of the GNU General Public License
648
- along with this program. If not, see <http://www.gnu.org/licenses/>.
648
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
649
649
 
650
650
  Also add information on how to contact you by electronic and paper mail.
651
651
 
@@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
664
664
  You should also get your employer (if you work as a programmer) or school,
665
665
  if any, to sign a "copyright disclaimer" for the program, if necessary.
666
666
  For more information on this, and how to apply and follow the GNU GPL, see
667
- <http://www.gnu.org/licenses/>.
667
+ <https://www.gnu.org/licenses/>.
668
668
 
669
669
  The GNU General Public License does not permit incorporating your program
670
670
  into proprietary programs. If your program is a subroutine library, you
671
671
  may consider it more useful to permit linking proprietary applications with
672
672
  the library. If this is what you want to do, use the GNU Lesser General
673
673
  Public License instead of this License. But first, please read
674
- <http://www.gnu.org/philosophy/why-not-lgpl.html>.
674
+ <https://www.gnu.org/philosophy/why-not-lgpl.html>.
data/ChangeLog.md CHANGED
@@ -1,3 +1,54 @@
1
+ ### 0.9.1 / 2022-05-19
2
+
3
+ #### CLI
4
+
5
+ * Improve the readability of the suggested gem versions to upgrade to
6
+ (pull #331).
7
+
8
+ #### Rake Task
9
+
10
+ * Fixed a regression introduced in 0.9.0 where the `bundler:audit` rake task
11
+ was not exiting with an error status code if vulnerabilities were found.
12
+ Now when the `bundler-audit` command fails, the rake task will also exit with
13
+ the `bundler-audit` command's error code.
14
+ * If the `bundler-audit` command could not be found for some reason raise the
15
+ {Bundler::Audit::Task::CommandNotFound} exception.
16
+
17
+ ### 0.9.0.1 / 2021-08-31
18
+
19
+ * Add a workaround for Psych < 3.1.0 to support running on Ruby < 2.6.
20
+ (issue #319)
21
+ * Although, Ruby 2.5 and prior have all reached [End-of-Life] and
22
+ are no longer receiving security updates. It is strongly advised that you
23
+ should upgrade to a currently supported version of Ruby.
24
+
25
+ [End-of-Life]: https://www.ruby-lang.org/en/downloads/branches/
26
+
27
+ ### 0.9.0 / 2021-08-31
28
+
29
+ * Load advisory metadata using `YAML.safe_load`. (issue #302)
30
+ * Explicitly permit the `Date` class for Psych >= 4.0.0 and Ruby >= 3.1.0.
31
+ * Added {Bundler::Audit::Advisory#to_h}. (pull #310)
32
+ * Added {Bundler::Audit::Database#commit_id}.
33
+
34
+ #### CLI
35
+
36
+ * Added the `--config` option. (pull #306)
37
+ * Added the `junit` output format (ex: `--format junit`). (pull #314)
38
+ * Add missing output for CVSSv3 criticality information. (pull #302)
39
+ * Include criticality information in the JSON output as well. (pull #310)
40
+ * `bundle-audit stats` now prints the commit ID of the ruby-advisory-db.
41
+ * Fixed a deprecation warning from Thor. (issue #317)
42
+
43
+ #### Rake Task
44
+
45
+ * Add the `bundle:audit:update` task for updating the [ruby-advisory-db].
46
+ (pull #296)
47
+ * Aliased `bundle:audit` to `bundle:audit:check`.
48
+ * Aliased `bundler:audit:*` to `bundle:audit:*`.
49
+ * Rake tasks now execute `bundle-audit` command as a subprocess to ensure
50
+ isolation.
51
+
1
52
  ### 0.8.0 / 2021-03-10
2
53
 
3
54
  * No longer vendor [ruby-advisory-db].
data/Gemfile CHANGED
@@ -4,10 +4,15 @@ gemspec
4
4
 
5
5
  group :development do
6
6
  gem 'rake'
7
- gem 'kramdown', '~> 2.0'
8
-
9
7
  gem 'rubygems-tasks', '~> 0.2'
8
+
9
+ gem 'rubocop', '~> 1.18'
10
+
10
11
  gem 'rspec', '~> 3.0'
12
+ gem 'simplecov', '~> 0.7', require: false
13
+
14
+ gem 'kramdown', '~> 2.0'
15
+ gem 'redcarpet', platform: :mri
11
16
  gem 'yard', '~> 0.9'
12
- gem 'simplecov', '~> 0.7', :require => false
17
+ gem 'yard-spellcheck', require: false
13
18
  end
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # bundler-audit
2
+
2
3
  [![CI](https://github.com/rubysec/bundler-audit/actions/workflows/ruby.yml/badge.svg)](https://github.com/rubysec/bundler-audit/actions/workflows/ruby.yml)
3
4
  [![Code Climate](https://codeclimate.com/github/rubysec/bundler-audit.svg)](https://codeclimate.com/github/rubysec/bundler-audit)
5
+ [![Gem Version](https://badge.fury.io/rb/bundler-audit.svg)](https://badge.fury.io/rb/bundler-audit)
4
6
 
5
7
  * [Homepage](https://github.com/rubysec/bundler-audit#readme)
6
8
  * [Issues](https://github.com/rubysec/bundler-audit/issues)
@@ -13,7 +15,7 @@ Patch-level verification for [bundler].
13
15
  ## Features
14
16
 
15
17
  * Checks for vulnerable versions of gems in `Gemfile.lock`.
16
- * Checks for insecure gem sources (`http://`).
18
+ * Checks for insecure gem sources (`http://` and `git://`).
17
19
  * Allows ignoring certain advisories that have been manually worked around.
18
20
  * Prints advisory information.
19
21
  * Does not require a network connection.
@@ -109,35 +111,48 @@ Update the [ruby-advisory-db] that `bundle audit` uses:
109
111
 
110
112
  Update the [ruby-advisory-db] and check `Gemfile.lock` (useful for CI runs):
111
113
 
112
- $ bundle-audit check --update
114
+ ```shell
115
+ $ bundle-audit check --update
116
+ ```
113
117
 
114
118
  Checking the `Gemfile.lock` without updating the [ruby-advisory-db]:
115
119
 
116
- $ bundle-audit check --no-update
120
+ ```shell
121
+ $ bundle-audit check --no-update
122
+ ```
117
123
 
118
124
  Ignore specific advisories:
119
125
 
120
- $ bundle-audit check --ignore OSVDB-108664
126
+ ```shell
127
+ $ bundle-audit check --ignore OSVDB-108664
128
+ ```
121
129
 
122
130
  Checking a custom `Gemfile.lock` file:
123
131
 
124
- $ bundle-audit check --gemfile Gemfile.custom.lock
132
+ ```shell
133
+ $ bundle-audit check --gemfile-lock Gemfile.custom.lock
134
+ ```
125
135
 
126
136
  Output the audit's results in JSON:
127
137
 
128
- $ bundle-audit check --format json
138
+ ```shell
139
+ $ bundle-audit check --format json
140
+ ```
129
141
 
130
142
  Output the audit's results in JSON, to a file:
131
143
 
132
- $ bundle-audit check --format json --output bundle-audit.json
144
+ ```shell
145
+ $ bundle-audit check --format json --output bundle-audit.json
146
+ ```
133
147
 
134
- Rake task:
148
+ ## Rake Tasks
135
149
 
136
- ```ruby
137
- require 'bundler/audit/task'
138
- Bundler::Audit::Task.new
150
+ Bundler-audit provides Rake tasks for checking the code and for updating
151
+ its vulnerability database:
139
152
 
140
- task default: 'bundle:audit'
153
+ ```bash
154
+ rake bundle:audit
155
+ rake bundle:audit:update
141
156
  ```
142
157
 
143
158
  ## Configuration File
@@ -146,13 +161,21 @@ bundler-audit also supports a per-project configuration file:
146
161
 
147
162
  `.bundler-audit.yml`:
148
163
 
149
- ---
150
- ignore:
151
- - CVE-YYYY-XXXX
152
- - ...
164
+ ```yaml
165
+ ---
166
+ ignore:
167
+ - CVE-YYYY-XXXX
168
+ - ...
169
+ ```
153
170
 
154
171
  * `ignore:` \[Array\<String\>\] - A list of advisory IDs to ignore.
155
172
 
173
+ You can provide a path to a config file using the `--config` flag:
174
+
175
+ ```shell
176
+ $ bundle-audit check --config bundler-audit.custom.yaml
177
+ ```
178
+
156
179
  ## Requirements
157
180
 
158
181
  * [git]
@@ -163,32 +186,42 @@ bundler-audit also supports a per-project configuration file:
163
186
 
164
187
  ## Install
165
188
 
166
- $ [sudo] gem install bundler-audit
189
+ ```shell
190
+ $ [sudo] gem install bundler-audit
191
+ ```
167
192
 
168
193
  ### Git
169
194
 
170
195
  * Debian / Ubuntu:
171
196
 
172
- $ sudo apt install git
197
+ ```shell
198
+ $ sudo apt install git
199
+ ```
173
200
 
174
201
  * RedHat / Fedora:
175
202
 
176
- $ sudo dnf install git
203
+ ```shell
204
+ $ sudo dnf install git
205
+ ```
177
206
 
178
207
  * Alpine Linux:
179
208
 
180
- $ apk add git
209
+ ```shell
210
+ $ apk add git
211
+ ```
181
212
 
182
213
  * macOS:
183
214
 
184
- $ brew install git
215
+ ```shell
216
+ $ brew install git
217
+ ```
185
218
 
186
219
  ## Contributing
187
220
 
188
221
  1. https://github.com/rubysec/bundler-audit/fork
189
222
  2. `git clone YOUR_FORK_URI`
190
223
  3. `cd bundler-audit/`
191
- 4. `budle install`
224
+ 4. `bundle install`
192
225
  5. `bundle exec rake spec`
193
226
  6. `git checkout -b YOUR_FEATURE`
194
227
  7. Make your changes
@@ -198,7 +231,7 @@ bundler-audit also supports a per-project configuration file:
198
231
 
199
232
  ## License
200
233
 
201
- Copyright (c) 2013-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
234
+ Copyright (c) 2013-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
202
235
 
203
236
  bundler-audit is free software: you can redistribute it and/or modify
204
237
  it under the terms of the GNU General Public License as published by
@@ -211,14 +244,13 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
211
244
  GNU General Public License for more details.
212
245
 
213
246
  You should have received a copy of the GNU General Public License
214
- along with bundler-audit. If not, see <http://www.gnu.org/licenses/>.
247
+ along with bundler-audit. If not, see <https://www.gnu.org/licenses/>.
215
248
 
216
249
  [git]: https://git-scm.com
217
250
  [ruby]: https://ruby-lang.org
218
251
  [rubygems]: https://rubygems.org
219
252
  [thor]: http://whatisthor.com/
220
- [bundler]: https://github.com/carlhuda/bundler#readme
221
- [git]: https://github.com/git/git
253
+ [bundler]: https://bundler.io
222
254
 
223
255
  [OSVDB]: http://osvdb.org/
224
256
  [ruby-advisory-db]: https://github.com/rubysec/ruby-advisory-db
data/Rakefile CHANGED
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'rubygems'
4
2
 
5
3
  begin
@@ -36,5 +34,11 @@ task :test => :spec
36
34
  task :default => :spec
37
35
 
38
36
  require 'yard'
39
- YARD::Rake::YardocTask.new
37
+ YARD::Rake::YardocTask.new
40
38
  task :doc => :yard
39
+
40
+ require 'bundler/audit/task'
41
+ Bundler::Audit::Task.new
42
+
43
+ require 'rubocop/rake_task'
44
+ RuboCop::RakeTask.new
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'yaml'
4
2
 
5
3
  Gem::Specification.new do |gem|
@@ -32,7 +30,7 @@ Gem::Specification.new do |gem|
32
30
  gem.default_executable = gem.executables.first if Gem::VERSION < '1.7.'
33
31
 
34
32
  gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
35
- gem.test_files = glob[gemspec['test_files'] || '{test/{**/}*_test.rb']
33
+ gem.test_files = glob[gemspec['test_files'] || 'spec/{**/}*_spec.rb']
36
34
  gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
37
35
 
38
36
  gem.require_paths = Array(gemspec.fetch('require_paths') {
@@ -57,4 +55,5 @@ Gem::Specification.new do |gem|
57
55
  gem.add_development_dependency(name,split[versions])
58
56
  end
59
57
  end
58
+ gem.metadata['rubygems_mfa_required'] = 'true'
60
59
  end
data/gemspec.yml CHANGED
@@ -6,6 +6,13 @@ authors: Postmodern
6
6
  email: postmodern.mod3@gmail.com
7
7
  homepage: https://github.com/rubysec/bundler-audit#readme
8
8
 
9
+ metadata:
10
+ documentation_uri: https://rubydoc.info/gems/bundler-audit
11
+ source_code_uri: https://github.com/rubysec/bundler-audit.rb
12
+ bug_tracker_uri: https://github.com/rubysec/bundler-audit.rb/issues
13
+ changelog_uri: https://github.com/rubysec/bundler-audit.rb/blob/master/ChangeLog.md
14
+ rubygems_mfa_required: 'true'
15
+
9
16
  required_ruby_version: ">= 2.0.0"
10
17
  required_rubygems_version: ">= 1.8.0"
11
18
 
@@ -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,13 +12,17 @@
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
+ require 'date'
18
19
  require 'yaml'
19
20
 
20
21
  module Bundler
21
22
  module Audit
23
+ #
24
+ # Represents an advisory loaded from the {Database}.
25
+ #
22
26
  class Advisory < Struct.new(:path,
23
27
  :id,
24
28
  :url,
@@ -45,7 +49,14 @@ module Bundler
45
49
  #
46
50
  def self.load(path)
47
51
  id = File.basename(path).chomp('.yml')
48
- data = YAML.load_file(path)
52
+ data = File.open(path) do |yaml|
53
+ if Psych::VERSION >= '3.1.0'
54
+ YAML.safe_load(yaml, permitted_classes: [Date])
55
+ else
56
+ # XXX: psych < 3.1.0 YAML.safe_load calling convention
57
+ YAML.safe_load(yaml, [Date])
58
+ end
59
+ end
49
60
 
50
61
  unless data.kind_of?(Hash)
51
62
  raise("advisory data in #{path.dump} was not a Hash")
@@ -200,6 +211,17 @@ module Bundler
200
211
  id == other.id
201
212
  end
202
213
 
214
+ #
215
+ # Converts the advisory to a Hash.
216
+ #
217
+ # @return [Hash{Symbol => Object}]
218
+ #
219
+ def to_h
220
+ super.merge({
221
+ criticality: criticality
222
+ })
223
+ end
224
+
203
225
  alias to_s id
204
226
 
205
227
  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'
@@ -22,6 +22,9 @@ module Bundler
22
22
  module Audit
23
23
  class CLI < ::Thor
24
24
  module Formats
25
+ #
26
+ # The JSON output format.
27
+ #
25
28
  module JSON
26
29
  #
27
30
  # Outputs the report as JSON. Will pretty-print JSON if `output`
@@ -37,11 +40,22 @@ module Bundler
37
40
  hash = report.to_h
38
41
 
39
42
  if output.tty?
40
- output.puts ::JSON.pretty_generate(hash)
43
+ output.puts(::JSON.pretty_generate(hash))
41
44
  else
42
45
  output.write(::JSON.generate(hash))
43
46
  end
44
47
  end
48
+
49
+ def criticality_label(advisory)
50
+ case advisory.criticality
51
+ when :none then "none"
52
+ when :low then "low"
53
+ when :medium then "medium"
54
+ when :high then "high"
55
+ when :critical then "critical"
56
+ else "unknown"
57
+ end
58
+ end
45
59
  end
46
60
 
47
61
  Formats.register :json, JSON