gemsurance 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d3c16ae4516623a0c9bf2aeaf8add57a07596e5
4
- data.tar.gz: 6bc516f6387a5c43f835662ac930326a5f3f8ee7
3
+ metadata.gz: 7b9561a163dcf3504a3893d428cbf75ad8ee3dc5
4
+ data.tar.gz: bff5ed8f6ed9c921079f872972b3f6d3cacf3704
5
5
  SHA512:
6
- metadata.gz: f6ebfef168b36077b26d65c65ea85831fb2de7e2580bc48ea4a2640bb75208193c3461e96df7fa02ed2dde045a11a86a222c58d4764bfb9e999264b8330f81c5
7
- data.tar.gz: 52f4764a8eaf0f77aca266f00c6f063e4184bcb2428ecbe5d7b579a5dc77d3323fb4530458ad9a9b53ba19a38e7698185e676181080fba6be2a9a062ab04133e
6
+ metadata.gz: f4ec81aa78ba0a40201bc1cd1e3c11f8a9254b453dd5bf86118a6ef1e3168eb88b3a7420126975a2523bdea7d58255c9fcf9a5543018d51e45ac915d74d44c2d
7
+ data.tar.gz: d63460b5caa5547153e2b8838dae80b5d788da603f72cf32e0dc8be4db7c383e7e9c210b898a6fef9b15ceef3915f66b485ab3c0c5c354106848808fcc68d866
@@ -25,6 +25,10 @@ module Gemsurance
25
25
  options[:output_file] = file
26
26
  end
27
27
 
28
+ opts.on('--whitelist FILE', 'Read whitelist from file. Defaults to .gemsurance.yml') do |file|
29
+ options[:whitelist_file] = file
30
+ end
31
+
28
32
  opts.on("--format FORMAT", "Output report to given format (html & yml available). Html by default.") do |format|
29
33
  options[:formatter] = format
30
34
  end
@@ -6,6 +6,9 @@ module Gemsurance
6
6
  @formatter = options.delete(:formatter) || :html
7
7
  @output_file = options.delete(:output_file) || "gemsurance_report.#{@formatter}"
8
8
  @options = options
9
+
10
+ whitelist_file = options.delete(:whitelist_file) || '.gemsurance.yml'
11
+ @whitelist = File.exist?(whitelist_file) ? YAML.load_file(whitelist_file) : false
9
12
  end
10
13
 
11
14
  def run
@@ -74,8 +77,15 @@ module Gemsurance
74
77
 
75
78
  current_version_is_affected = (vulnerability.unaffected_versions || []).none?(&current_version_satisfies_requirement)
76
79
  current_version_isnt_patched = (vulnerability.patched_versions || []).none?(&current_version_satisfies_requirement)
80
+ current_version_isnt_whitelisted = if (whitelisted_versions = fetch_whitelisted_versions_for(gem_info.name,
81
+ vulnerability.cve,
82
+ vulnerability.osvdb))
83
+ (whitelisted_versions || []).none?(&current_version_satisfies_requirement)
84
+ else
85
+ true
86
+ end
77
87
 
78
- if current_version_is_affected && current_version_isnt_patched
88
+ if current_version_is_affected && current_version_isnt_patched && current_version_isnt_whitelisted
79
89
  gem_info.add_vulnerability!(vulnerability)
80
90
  end
81
91
  end
@@ -94,6 +104,18 @@ module Gemsurance
94
104
  puts "Generated report #{@output_file}."
95
105
  end
96
106
 
107
+ def fetch_whitelisted_versions_for(gem, cve = nil, osvdb = nil)
108
+ if @whitelist && (whitelisted_gem = @whitelist[gem])
109
+ if cve
110
+ whitelisted_gem["CVE-#{cve}"]
111
+ elsif osvdb
112
+ whitelisted_gem["OSVDB-#{osvdb}"]
113
+ else
114
+ # There are is no CVE or OSVDB for this vulnerability
115
+ end
116
+ end
117
+ end
118
+
97
119
  def resolved_definition
98
120
  # Need to temporarily unfrozen Bundler (when the gems have been installed with --deployment option e.g.)
99
121
  if Bundler.settings[:frozen]
@@ -805,6 +805,8 @@
805
805
  <dl>
806
806
  <dt>CVE</dt>
807
807
  <dd><%= vulnerability.cve %></dd>
808
+ <dt>OSVDB</dt>
809
+ <dd><%= vulnerability.osvdb %></dd>
808
810
  <dt>URL</dt>
809
811
  <dd><a href="<%= vulnerability.url %>">More Info</a></dd>
810
812
  <dt>Patched Versions</dt>
@@ -1,3 +1,3 @@
1
1
  module Gemsurance
2
- VERSION = '0.7.0'
2
+ VERSION = '0.8.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemsurance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Kessler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-02 00:00:00.000000000 Z
11
+ date: 2017-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  version: 1.8.11
148
148
  requirements: []
149
149
  rubyforge_project:
150
- rubygems_version: 2.4.8
150
+ rubygems_version: 2.5.2
151
151
  signing_key:
152
152
  specification_version: 4
153
153
  summary: Your Gem Insurance Policy