legendary 0.1.4 → 0.1.5
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 +4 -4
- data/legendary.gemspec +1 -0
- data/lib/legendary.rb +4 -1
- data/lib/legendary/formatters.rb +3 -0
- data/lib/legendary/formatters/base.rb +13 -0
- data/lib/legendary/formatters/html.rb +11 -0
- data/lib/legendary/info.rb +8 -1
- data/lib/legendary/runner.rb +4 -14
- data/lib/legendary/templates/output.html.haml +48 -0
- data/lib/legendary/version.rb +1 -1
- data/lib/legendary/vulnerabilities.rb +3 -3
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d823b2f7eac5326b6ffb269f1da3343f95a2f9a
|
4
|
+
data.tar.gz: 10e2a5e564af03139a2866c18bfd90a0fe158d3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf62e7922edacd69c3ef78735989a961eed5fc1f80dc88c8086a8f01efed15e477483f14b8653ab8b64cf40861389fd10b4dd74cd3c580cced306b54fd4c97f7
|
7
|
+
data.tar.gz: b0294348c603986f2d553d1e8344193b5c95ff8fca5d418dac02d7ff90dc64b89b017d68b9b2bfada38bb7489af9ad0a789745487b74d776b55e56614d40a3f4
|
data/legendary.gemspec
CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "rspec", "~> 3.1"
|
24
24
|
|
25
25
|
spec.add_dependency "bundler", "~> 1.9"
|
26
|
+
spec.add_dependency "haml", "~> 4.0"
|
26
27
|
spec.add_dependency "activesupport", "~> 4.2"
|
27
28
|
spec.add_dependency "git", "~> 1.2"
|
28
29
|
spec.add_dependency "gems", "~> 0.8"
|
data/lib/legendary.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'bundler'
|
2
2
|
require 'git'
|
3
|
-
require '
|
3
|
+
require 'haml'
|
4
4
|
require 'gems'
|
5
5
|
require 'logger'
|
6
6
|
require 'active_support/core_ext/module/delegation'
|
@@ -24,4 +24,7 @@ require 'legendary/vulnerabilities'
|
|
24
24
|
require 'legendary/repository'
|
25
25
|
require 'legendary/gems'
|
26
26
|
require 'legendary/info'
|
27
|
+
require 'legendary/formatters'
|
28
|
+
require 'legendary/formatters/base'
|
29
|
+
require 'legendary/formatters/html'
|
27
30
|
require 'legendary/runner'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Legendary::Formatters::Base
|
2
|
+
def initialize(infos)
|
3
|
+
@infos = infos
|
4
|
+
end
|
5
|
+
|
6
|
+
def sorted_gems
|
7
|
+
@infos.sort{ |a, b| a.name.downcase <=> b.name.downcase }
|
8
|
+
end
|
9
|
+
|
10
|
+
def template_path
|
11
|
+
File.expand_path(File.join(File.dirname(__FILE__), '../templates/'))
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class Legendary::Formatters::Html < Legendary::Formatters::Base
|
2
|
+
def format
|
3
|
+
@extension = "html"
|
4
|
+
engine = Haml::Engine.new(File.read(output_path))
|
5
|
+
engine.render(self)
|
6
|
+
end
|
7
|
+
|
8
|
+
def output_path
|
9
|
+
File.join(template_path, "output.html.haml")
|
10
|
+
end
|
11
|
+
end
|
data/lib/legendary/info.rb
CHANGED
@@ -2,7 +2,6 @@ module Legendary
|
|
2
2
|
class Info
|
3
3
|
attr_accessor :name, :spec, :version, :gemfile, :dependencies, :definitions
|
4
4
|
|
5
|
-
delegate :homepage_uri, to: :meta
|
6
5
|
delegate :name, to: :spec
|
7
6
|
delegate :version, to: :spec
|
8
7
|
delegate :git_version, to: :spec
|
@@ -24,10 +23,18 @@ module Legendary
|
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
26
|
+
def homepage_uri
|
27
|
+
meta['homepage_uri']
|
28
|
+
end
|
29
|
+
|
27
30
|
def outdated?
|
28
31
|
Gem::Version.new(latest_version) > Gem::Version.new(version)
|
29
32
|
end
|
30
33
|
|
34
|
+
def current?
|
35
|
+
Gem::Version.new(latest_version) == Gem::Version.new(version)
|
36
|
+
end
|
37
|
+
|
31
38
|
def vulnerable?
|
32
39
|
# FIXME: speeds things up, but in theory a
|
33
40
|
# a gem might not have a release, but have vulnerable
|
data/lib/legendary/runner.rb
CHANGED
@@ -2,6 +2,7 @@ module Legendary
|
|
2
2
|
class Runner
|
3
3
|
def initialize(path=nil)
|
4
4
|
Legendary.repository = Repository.new(path)
|
5
|
+
@report = File.join(Dir.pwd, "output.html")
|
5
6
|
end
|
6
7
|
|
7
8
|
def run
|
@@ -10,20 +11,9 @@ module Legendary
|
|
10
11
|
|
11
12
|
Legendary.logger.info("Loading Gems")
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
if gem.outdated?
|
17
|
-
Legendary.logger.info("#{gem.name} is outdated. #{gem.version} -> #{gem.latest_version} (it is #{gem.gemfile ? 'in your gemfile' : 'a dependency'})")
|
18
|
-
end
|
19
|
-
|
20
|
-
if gem.vulnerable?
|
21
|
-
Legendary.logger.info("#{gem.name} is vulnerable.")
|
22
|
-
success = false
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
exit 1 unless success
|
14
|
+
gems = Gems.new.to_a
|
15
|
+
File.write(@report, Legendary::Formatters::Html.new(gems).format)
|
16
|
+
Legendary.logger.info("Report Saved at #{@report}")
|
27
17
|
end
|
28
18
|
end
|
29
19
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
!!!
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%meta{:charset => "utf8"}
|
5
|
+
%title Report
|
6
|
+
%link(href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css' rel='stylesheet' type='text/css')
|
7
|
+
%body
|
8
|
+
.wrapper
|
9
|
+
%h1 Report
|
10
|
+
%p Gems in bold appear in the Gemfile. Other gems appear in Gemfile.lock.
|
11
|
+
%table.table
|
12
|
+
%thead
|
13
|
+
%tr
|
14
|
+
%th Gem Name
|
15
|
+
%th Version
|
16
|
+
%th Latest Version
|
17
|
+
%th Details
|
18
|
+
%th Status
|
19
|
+
%th Links
|
20
|
+
%tbody
|
21
|
+
- sorted_gems.each do |info|
|
22
|
+
- row_class = if info.current?
|
23
|
+
- 'success'
|
24
|
+
- elsif info.outdated?
|
25
|
+
- 'warning'
|
26
|
+
- elsif info.vulnerable?
|
27
|
+
- 'danger'
|
28
|
+
- else
|
29
|
+
- nil
|
30
|
+
%tr{:class => row_class}
|
31
|
+
%td
|
32
|
+
- if info.gemfile
|
33
|
+
%strong= info.name
|
34
|
+
- else
|
35
|
+
= info.name
|
36
|
+
%td= info.version
|
37
|
+
%td= info.latest_version
|
38
|
+
%td= info.vulnerabilities.map(&:to_s) if info.vulnerable?
|
39
|
+
%td
|
40
|
+
- if info.vulnerable?
|
41
|
+
%strong Vulnerable
|
42
|
+
- elsif info.outdated?
|
43
|
+
%strong Out of Date
|
44
|
+
- elsif info.current?
|
45
|
+
Up-to-Date
|
46
|
+
- else
|
47
|
+
Unknown Status
|
48
|
+
%td= info.homepage_uri
|
data/lib/legendary/version.rb
CHANGED
@@ -27,10 +27,10 @@ module Legendary
|
|
27
27
|
Gem::Requirement.new(version.split(',')).satisfied_by?(@info.version)
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
is_affected = (info["patched_versions"] || []).none?(&satisfied_version)
|
31
|
+
not_patched = (info["unaffected_versions"] || []).none?(&satisfied_version)
|
32
32
|
|
33
|
-
if
|
33
|
+
if is_affected && not_patched
|
34
34
|
yield info
|
35
35
|
end
|
36
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: legendary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John D'Agostino
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: haml
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: activesupport
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,11 +129,15 @@ files:
|
|
115
129
|
- exe/legendary
|
116
130
|
- legendary.gemspec
|
117
131
|
- lib/legendary.rb
|
132
|
+
- lib/legendary/formatters.rb
|
133
|
+
- lib/legendary/formatters/base.rb
|
134
|
+
- lib/legendary/formatters/html.rb
|
118
135
|
- lib/legendary/gems.rb
|
119
136
|
- lib/legendary/info.rb
|
120
137
|
- lib/legendary/repository.rb
|
121
138
|
- lib/legendary/rspec.rb
|
122
139
|
- lib/legendary/runner.rb
|
140
|
+
- lib/legendary/templates/output.html.haml
|
123
141
|
- lib/legendary/version.rb
|
124
142
|
- lib/legendary/vulnerabilities.rb
|
125
143
|
homepage: https://github.com/jobready/legendary
|