package-audit 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a9f8b791f93ef77f2eecb40a1d0bacaebf40c94a06e938ef7528f26281ac30b
4
- data.tar.gz: e9a24f0114518ba97deaa1687ca5c786fee0ba54dd868cbaec48c4d6d183be7b
3
+ metadata.gz: f5f9a3b6c50fcbebe1832c0559eddcd5a4e99c94779d1a251ad00c540df6c6b6
4
+ data.tar.gz: 84c02793f8d4b6a07099179fa5deee0ee473541668eb4b9212ea62b0e61d37d5
5
5
  SHA512:
6
- metadata.gz: e106be4632777be3433e572bb60b34a9b8fa4f7e038f4be86b1d9744ffcaf2e709804bcd4ffffd2b001ee82887ea70cbb7234d2df37a4033224f155ac84b4b88
7
- data.tar.gz: 400eb639d4f16d4671bc10b1e0b76ad7e49f7f3991239c8f3c5a7dbee5138fcc46d3ae819bcb06021d45a3d46e4ca2cff8e755760dda387976b2fd67d8c8aa03
6
+ metadata.gz: 197beea22db4bdc21106d235e6bf0d360d61c396498d516a1fbd8aa8cca2342348aa4bcdacbd08376199ad0ff0a0555f0e145a9d2d19d4a6e1e4f29a684c6a4f
7
+ data.tar.gz: 8540a1858d4ad3a094f20d77c174dafcbffe1b3af1fc1a9ead5806443efb314a7bbbcb77d7fb3ccc764aed0f921de9e71b588ea82283b06a4cf4bb1dfb3fc414
data/README.md CHANGED
@@ -10,8 +10,6 @@ A useful tool for patch management and prioritization, `package-audit` produces
10
10
 
11
11
  Supports **Ruby 2.6 → latest**, with the full Ruby matrix tested daily in CI.
12
12
 
13
- [!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png)](https://www.buymeacoffee.com/vkononov)
14
-
15
13
  ## Supported Technologies
16
14
 
17
15
  * Ruby
@@ -169,6 +167,8 @@ package-audit help [COMMAND]
169
167
 
170
168
  The `package-audit` gem automatically searches for `.package-audit.yml` in the current directory or in the specified `DIR` if available. However, you have the option to override the default configuration file location by using the `--config` (or `-c`) flag.
171
169
 
170
+ When `--technology` is specified, stale exclusions are cleaned up only for the selected technologies. Configuration entries for other technologies are preserved.
171
+
172
172
  #### Below is an example of a configuration file:
173
173
 
174
174
  ```YAML
@@ -3,7 +3,7 @@ module Package
3
3
  module Const
4
4
  module Cmd
5
5
  BUNDLE_AUDIT = 'bundle-audit check --update'
6
- BUNDLE_AUDIT_JSON = 'bundle-audit check --update --quiet --format json "%s" 2>/dev/null'
6
+ BUNDLE_AUDIT_JSON = %w[bundle-audit check --update --quiet --format json].freeze
7
7
 
8
8
  NPM_AUDIT = 'npm audit'
9
9
  end
@@ -14,7 +14,7 @@ module Package
14
14
  BULK_ADVISORY_URL = 'https://registry.npmjs.org/-/npm/v1/security/advisories/bulk'
15
15
  BATCH_SIZE = 100
16
16
  TIMEOUT = 30
17
- VERSION_LINE = /^\s+"?version"?\s+"([^"]+)"/
17
+ VERSION_LINE = /^\s+"?version"?(?::\s*|\s+)["']?([^"'\s]+)["']?\s*$/
18
18
 
19
19
  def initialize(dir, pkgs)
20
20
  @dir = dir
@@ -105,14 +105,13 @@ module Package
105
105
  uri = URI(BULK_ADVISORY_URL)
106
106
  response = make_request(uri, versions_by_name.to_json)
107
107
  unless response.is_a?(Net::HTTPSuccess)
108
- warn "Warning: Unable to fetch npm advisories (#{response.code} #{response.message})."
109
- return {}
108
+ raise "Unable to fetch npm advisories (#{response.code} #{response.message})"
110
109
  end
111
110
 
112
- JSON.parse(response.body)
113
- rescue StandardError => e
114
- warn "Warning: Error while fetching npm advisories: #{e.message}"
115
- {}
111
+ advisories = JSON.parse(response.body)
112
+ raise 'Invalid npm advisory response' unless advisories.is_a?(Hash)
113
+
114
+ advisories
116
115
  end
117
116
 
118
117
  def make_request(uri, body)
@@ -17,7 +17,7 @@ module Package
17
17
  def initialize(dir, pkgs)
18
18
  @dir = dir
19
19
  @pkgs = pkgs
20
- @gem_hash = {}
20
+ @gem_hash = @pkgs.to_h { |pkg| [pkg.name, pkg] }
21
21
  end
22
22
 
23
23
  def fetch
@@ -11,7 +11,9 @@ module Package
11
11
  end
12
12
 
13
13
  def run
14
- json_result = `#{format(Const::Cmd::BUNDLE_AUDIT_JSON, @dir)}`
14
+ json_result = IO.popen(
15
+ [*Const::Cmd::BUNDLE_AUDIT_JSON, @dir.to_s], err: File::NULL, &:read
16
+ )
15
17
  vulnerability_json_array = JSON.parse(json_result, symbolize_names: true)[:results]
16
18
  vulnerability_json_array.each do |vulnerability_json|
17
19
  update_meta_data(vulnerability_json)
@@ -62,7 +62,10 @@ module Package
62
62
  cleaned
63
63
  end
64
64
 
65
- def clean_packages_for_technology(technology, packages)
65
+ def clean_packages_for_technology(technology, packages) # rubocop:disable Metrics/MethodLength
66
+ technologies = @options[Enum::Option::TECHNOLOGY]
67
+ return packages if technologies && !technologies.include?(technology)
68
+
66
69
  return {} unless packages.is_a?(Hash)
67
70
 
68
71
  current_packages = current_packages_for_technology(technology)
@@ -1,5 +1,5 @@
1
1
  module Package
2
2
  module Audit
3
- VERSION = '0.9.0'
3
+ VERSION = '0.9.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: package-audit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vadim Kononov
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []
120
- rubygems_version: 4.0.10
120
+ rubygems_version: 4.0.20
121
121
  specification_version: 4
122
122
  summary: CLI that reports outdated, deprecated and vulnerable dependencies in a project
123
123
  test_files: []