gemsurance 0.4.0 → 0.5.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: ee5e6c4788cfdee5596726a63e3754436543e10d
4
- data.tar.gz: 369e502b049c24f560bae6b9e958a625962589ea
3
+ metadata.gz: 21ea60308499e8aa4d571df3b7da44849bb6ca3a
4
+ data.tar.gz: 2709cf96a02232493c2f7d953df14b034ce95bea
5
5
  SHA512:
6
- metadata.gz: 354aac34c082b8d85e4f344e9fb46eb99d747a8b6a5a9527961cc51e70a2171d1000a7b91a41b9d31022cba9f069464e23b21efbbf7c0a8e2104279eb9203026
7
- data.tar.gz: bc326cda646e12e6bf041091f44ed15d034b16fdef2c5af88c7b037c25603db5933e1e97cba5e977e515426dc6908897a34eb1183f70ac75e0b2d1304cf49895
6
+ metadata.gz: e5c871657448ffceac6e0df83675051757b7e0398bf560293e34fced2ddee1575b3ce7e80e2f4e940b66b5c950c2e10bb4f832815bd488ead78ef750b0d24bd6
7
+ data.tar.gz: 7f683726ad934c169d40836879e08af1e4059290e8c6f77c2c153c2e2877fe02d39d14b4ef692cfe8682290568b72cebbd6e8fb4986f44560466390a5dfbfc79
data/bin/gemsurance CHANGED
@@ -4,4 +4,4 @@ require 'gemsurance'
4
4
  require 'gemsurance/cli'
5
5
 
6
6
  options = Gemsurance::Cli.parse(*ARGV)
7
- Gemsurance::Runner.new(options).run
7
+ Gemsurance::Runner.new(options).run.report
@@ -1,5 +1,7 @@
1
1
  module Gemsurance
2
2
  class Runner
3
+ attr_reader :gem_infos
4
+
3
5
  def initialize(options = {})
4
6
  @formatter = options.delete(:formatter) || :html
5
7
  @output_file = options.delete(:output_file) || "gemsurance_report.#{@formatter}"
@@ -7,18 +9,28 @@ module Gemsurance
7
9
  end
8
10
 
9
11
  def run
10
- bundled_gem_infos = retrieve_bundled_gem_infos
11
-
12
- retrieve_vulnerability_data
13
-
14
- add_vulnerability_data(bundled_gem_infos)
12
+ build_gem_infos
13
+ self
14
+ end
15
15
 
16
- generate_report(bundled_gem_infos)
16
+ def report
17
+ unless @gem_infos_loaded
18
+ puts "Error: gem infos not yet loaded."
19
+ exit 1
20
+ end
17
21
 
18
- exit 1 if bundled_gem_infos.any? { |info| info.vulnerable? }
22
+ generate_report
23
+ exit 1 if @gem_infos.any? { |info| info.vulnerable? }
19
24
  end
20
25
 
21
26
  private
27
+ def build_gem_infos
28
+ @gem_infos = retrieve_bundled_gem_infos
29
+ retrieve_vulnerability_data
30
+ add_vulnerability_data
31
+
32
+ @gem_infos_loaded = true
33
+ end
22
34
 
23
35
  def retrieve_bundled_gem_infos
24
36
  puts "Retrieving gem version information..."
@@ -26,7 +38,7 @@ module Gemsurance
26
38
  bundler = Bundler.load
27
39
  current_specs = bundler.specs
28
40
  dependencies = bundler.dependencies
29
- definition = Bundler.definition(true)
41
+ definition = Bundler.definition(true)
30
42
  definition.resolve_remotely!
31
43
 
32
44
  GemInfoRetriever.new(current_specs, dependencies, definition).retrieve(:pre => @options[:pre])
@@ -34,6 +46,7 @@ module Gemsurance
34
46
 
35
47
  def retrieve_vulnerability_data
36
48
  puts "Retrieving latest vulnerability data..."
49
+
37
50
  if File.exists?('./tmp/vulnerabilities')
38
51
  g = Git.open('./tmp/vulnerabilities')
39
52
  g.pull
@@ -42,9 +55,10 @@ module Gemsurance
42
55
  end
43
56
  end
44
57
 
45
- def add_vulnerability_data(gem_infos, vulnerabilities_directory = './tmp/vulnerabilities/gems')
58
+ def add_vulnerability_data(vulnerabilities_directory = './tmp/vulnerabilities/gems')
46
59
  puts "Reading vulnerability data..."
47
- gem_infos.each do |gem_info|
60
+
61
+ @gem_infos.each do |gem_info|
48
62
  vulnerability_directory = File.join(vulnerabilities_directory, gem_info.name)
49
63
  if File.exists?(vulnerability_directory)
50
64
  Dir.foreach(vulnerability_directory) do |yaml_file|
@@ -67,9 +81,10 @@ module Gemsurance
67
81
  end
68
82
  end
69
83
 
70
- def generate_report(gem_infos)
84
+ def generate_report
71
85
  puts "Generating report..."
72
- output_data = Gemsurance::Formatters.const_get(:"#{@formatter.to_s.capitalize}").new(gem_infos).format
86
+
87
+ output_data = Gemsurance::Formatters.const_get(:"#{@formatter.to_s.capitalize}").new(@gem_infos).format
73
88
 
74
89
  File.open(@output_file, "w+") do |file|
75
90
  file.puts output_data
@@ -1,3 +1,3 @@
1
1
  module Gemsurance
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.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.4.0
4
+ version: 0.5.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: 2015-03-19 00:00:00.000000000 Z
11
+ date: 2015-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.5.9
97
+ - !ruby/object:Gem::Dependency
98
+ name: test-unit
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.9
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.9
97
111
  description: Gem vulnerability and version checker
98
112
  email: jon.kessler@appfolio.com
99
113
  executables:
@@ -125,12 +139,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
139
  requirements:
126
140
  - - ">="
127
141
  - !ruby/object:Gem::Version
128
- version: '0'
142
+ version: 1.9.3
129
143
  required_rubygems_version: !ruby/object:Gem::Requirement
130
144
  requirements:
131
145
  - - ">="
132
146
  - !ruby/object:Gem::Version
133
- version: '0'
147
+ version: 1.8.11
134
148
  requirements: []
135
149
  rubyforge_project:
136
150
  rubygems_version: 2.4.3