mrjoy-bundler-audit 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +2 -0
- data/ChangeLog.md +18 -0
- data/Gemfile +1 -1
- data/README.md +5 -2
- data/Rakefile +15 -22
- data/data/ruby-advisory-db/CONTRIBUTORS.md +10 -0
- data/data/ruby-advisory-db/gems/actionpack/OSVDB-100524.yml +20 -0
- data/data/ruby-advisory-db/gems/actionpack/OSVDB-100525.yml +21 -0
- data/data/ruby-advisory-db/gems/actionpack/OSVDB-100526.yml +27 -0
- data/data/ruby-advisory-db/gems/actionpack/OSVDB-100527.yml +24 -0
- data/data/ruby-advisory-db/gems/actionpack/OSVDB-100528.yml +22 -0
- data/data/ruby-advisory-db/gems/actionpack/OSVDB-103439.yml +24 -0
- data/data/ruby-advisory-db/gems/actionpack/OSVDB-103440.yml +22 -0
- data/data/ruby-advisory-db/gems/activerecord/OSVDB-103438.yml +23 -0
- data/data/ruby-advisory-db/gems/arabic-prawn/OSVDB-104365.yml +15 -0
- data/data/ruby-advisory-db/gems/cocaine/OSVDB-98835.yml +2 -2
- data/data/ruby-advisory-db/gems/crack/OSVDB-90742.yml +1 -1
- data/data/ruby-advisory-db/gems/curl/OSVDB-91230.yml +1 -1
- data/data/ruby-advisory-db/gems/echor/OSVDB-102129.yml +11 -0
- data/data/ruby-advisory-db/gems/echor/OSVDB-102130.yml +10 -0
- data/data/ruby-advisory-db/gems/gitlab-grit/OSVDB-99370.yml +14 -0
- data/data/ruby-advisory-db/gems/httparty/OSVDB-90741.yml +3 -8
- data/data/ruby-advisory-db/gems/i18n/OSVDB-100528.yml +17 -0
- data/data/ruby-advisory-db/gems/nokogiri/OSVDB-101179.yml +12 -0
- data/data/ruby-advisory-db/gems/nokogiri/OSVDB-101458.yml +15 -0
- data/data/ruby-advisory-db/gems/nori/OSVDB-90196.yml +1 -1
- data/data/ruby-advisory-db/gems/omniauth-facebook/OSVDB-99693.yml +22 -0
- data/data/ruby-advisory-db/gems/omniauth-facebook/OSVDB-99888.yml +17 -0
- data/data/ruby-advisory-db/gems/paperclip/OSVDB-103151.yml +13 -0
- data/data/ruby-advisory-db/gems/paratrooper-newrelic/OSVDB-101839.yml +12 -0
- data/data/ruby-advisory-db/gems/paratrooper-pingdom/OSVDB-101847.yml +13 -0
- data/data/ruby-advisory-db/gems/rack/OSVDB-89939.yml +1 -1
- data/data/ruby-advisory-db/gems/rbovirt/OSVDB-104080.yml +20 -0
- data/data/ruby-advisory-db/gems/rgpg/OSVDB-95948.yml +2 -1
- data/data/ruby-advisory-db/gems/spree/OSVDB-91216.yml +3 -2
- data/data/ruby-advisory-db/gems/spree/OSVDB-91217.yml +3 -2
- data/data/ruby-advisory-db/gems/spree/OSVDB-91218.yml +3 -2
- data/data/ruby-advisory-db/gems/spree/OSVDB-91219.yml +3 -2
- data/data/ruby-advisory-db/gems/sprout/OSVDB-100598.yml +14 -0
- data/data/ruby-advisory-db/gems/webbynode/OSVDB-100920.yml +11 -0
- data/data/ruby-advisory-db/gems/will_paginate/OSVDB-101138.yml +15 -0
- data/data/ruby-advisory-db/spec/advisory_example.rb +3 -3
- data/data/ruby-advisory-db/spec/gems_spec.rb +3 -4
- data/data/ruby-advisory-db.ts +1 -0
- data/gemspec.yml +2 -1
- data/lib/bundler/audit/cli.rb +7 -8
- data/lib/bundler/audit/database.rb +7 -5
- data/lib/bundler/audit/task.rb +45 -0
- data/lib/bundler/audit/version.rb +1 -1
- data/spec/advisory_spec.rb +14 -7
- data/spec/bundle/secure/Gemfile +1 -1
- data/spec/database_spec.rb +23 -1
- data/spec/integration_spec.rb +44 -29
- data/spec/rake_task_spec.rb +35 -0
- data/spec/spec_helper.rb +11 -3
- metadata +76 -33
- data/lib/bundler/audit/vendored_time.rb +0 -9
@@ -1,6 +1,7 @@
|
|
1
1
|
---
|
2
2
|
gem: rgpg
|
3
3
|
osvdb: 95948
|
4
|
+
cve: 2013-4203
|
4
5
|
url: http://www.osvdb.org/show/osvdb/95948
|
5
6
|
title: Ruby rgpg Gem Shell Command Injection Vulnerabilities
|
6
7
|
date: 2013-08-02
|
@@ -8,6 +9,6 @@ description: |
|
|
8
9
|
rgpg Gem for Ruby contains a flaw in the GpgHelper module (lib/rgpg/gpg_helper.rb).
|
9
10
|
The issue is due to the program failing to properly sanitize user-supplied input before being used in the system() function for execution.
|
10
11
|
This may allow a remote attacker to execute arbitrary commands.
|
11
|
-
cvss_v2:
|
12
|
+
cvss_v2: 7.5
|
12
13
|
patched_versions:
|
13
14
|
- ">= 0.2.3"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
---
|
1
|
+
---
|
2
2
|
gem: spree
|
3
3
|
cve: 2013-1656
|
4
4
|
osvdb: 91216
|
@@ -7,4 +7,5 @@ title: Spree promotion_actions_controller.rb promotion_action Parameter Arbitrar
|
|
7
7
|
date: 2013-02-21
|
8
8
|
description: Spree contains a flaw that is triggered when handling input passed via the 'promotion_action' parameter to promotion_actions_controller.rb. This may allow a remote authenticated attacker to instantiate arbitrary Ruby objects and potentially execute arbitrary commands.
|
9
9
|
cvss_v2: 4.3
|
10
|
-
patched_versions:
|
10
|
+
patched_versions:
|
11
|
+
- ">= 2.0.0"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
---
|
1
|
+
---
|
2
2
|
gem: spree
|
3
3
|
cve: 2013-1656
|
4
4
|
osvdb: 91217
|
@@ -7,4 +7,5 @@ title: Spree payment_methods_controller.rb payment_method Parameter Arbitrary Ru
|
|
7
7
|
date: 2013-02-21
|
8
8
|
description: Spree contains a flaw that is triggered when handling input passed via the 'payment_method' parameter to payment_methods_controller.rb. This may allow a remote authenticated attacker to instantiate arbitrary Ruby objects and potentially execute arbitrary commands.
|
9
9
|
cvss_v2: 4.3
|
10
|
-
patched_versions:
|
10
|
+
patched_versions:
|
11
|
+
- ">= 2.0.0"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
---
|
1
|
+
---
|
2
2
|
gem: spree
|
3
3
|
cve: 2013-1656
|
4
4
|
osvdb: 91218
|
@@ -7,4 +7,5 @@ title: Spree promotions_controller.rb calculator_type Parameter Arbitrary Ruby O
|
|
7
7
|
date: 2013-02-21
|
8
8
|
description: Spree contains a flaw that is triggered when handling input passed via the 'calculator_type' parameter to promotions_controller.rb. This may allow a remote authenticated attacker to instantiate arbitrary Ruby objects and potentially execute arbitrary commands.
|
9
9
|
cvss_v2: 4.3
|
10
|
-
patched_versions:
|
10
|
+
patched_versions:
|
11
|
+
- ">= 2.0.0"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
---
|
1
|
+
---
|
2
2
|
gem: spree
|
3
3
|
cve: 2013-1656
|
4
4
|
osvdb: 91219
|
@@ -7,4 +7,5 @@ title: Spree promotion_rules_controller.rb promotion_rule Parameter Arbitrary Ru
|
|
7
7
|
date: 2013-02-21
|
8
8
|
description: Spree contains a flaw that is triggered when handling input passed via the 'promotion_rule' parameter to promotion_rules_controller.rb. This may allow a remote authenticated attacker to instantiate arbitrary Ruby objects and potentially execute arbitrary commands.
|
9
9
|
cvss_v2: 4.3
|
10
|
-
patched_versions:
|
10
|
+
patched_versions:
|
11
|
+
- ">= 2.0.0"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
gem: sprout
|
3
|
+
cve: 2013-6421
|
4
|
+
osvdb: 100598
|
5
|
+
url: http://www.osvdb.org/show/osvdb/100598
|
6
|
+
title: Sprout Gem for Ruby contains a flaw
|
7
|
+
date: 2013-12-02
|
8
|
+
description: sprout Gem for Ruby contains a flaw in the unpack_zip() function in archive_unpacker.rb.
|
9
|
+
The issue is due to the program failing to properly sanitize input passed via the 'zip_file', 'dir',
|
10
|
+
'zip_name', and 'output' parameters. This may allow a context-dependent attacker to execute arbitrary code.
|
11
|
+
cvss_v2: 7.5
|
12
|
+
patched_versions:
|
13
|
+
unaffected_versions:
|
14
|
+
- '< 0.7.246'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
---
|
2
|
+
gem: webbynode
|
3
|
+
osvdb: 100920
|
4
|
+
url: http://osvdb.org/show/osvdb/100920
|
5
|
+
title: Webbynode Gem for Ruby contains a flaw
|
6
|
+
date: 2013-12-12
|
7
|
+
description: Webbynode Gem for Ruby contains a flaw in notify.rb that is triggered
|
8
|
+
when handling a specially crafted growlnotify message. This may allow a
|
9
|
+
context-dependent attacker to execute arbitrary commands.
|
10
|
+
cvss_v2: 7.5
|
11
|
+
patched_versions:
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
gem: will_paginate
|
3
|
+
osvdb: 101138
|
4
|
+
cve: 2013-6459
|
5
|
+
url: http://osvdb.org/show/osvdb/101138
|
6
|
+
title: will_paginate Gem for Ruby Generated Pagination Link Unspecified XSS
|
7
|
+
date: 2013-09-19
|
8
|
+
description: will_paginate Gem for Ruby contains a flaw that allows a cross-site scripting (XSS) attack.
|
9
|
+
This flaw exists because the application does not validate certain unspecified input related to
|
10
|
+
generated pagination links before returning it to the user. This may allow an attacker to create
|
11
|
+
a specially crafted request that would execute arbitrary script code in a users browser within the
|
12
|
+
trust relationship between their browser and the server.
|
13
|
+
cvss_v2: 4.3
|
14
|
+
patched_versions:
|
15
|
+
- ">= 3.0.5"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
load File.join(File.dirname(__FILE__), 'spec_helper.rb')
|
2
2
|
require 'yaml'
|
3
3
|
|
4
4
|
shared_examples_for 'Advisory' do |path|
|
@@ -131,7 +131,7 @@ shared_examples_for 'Advisory' do |path|
|
|
131
131
|
it "should contain valid RubyGem version requirements" do
|
132
132
|
lambda {
|
133
133
|
Gem::Requirement.new(*subject)
|
134
|
-
}.should_not raise_error
|
134
|
+
}.should_not raise_error
|
135
135
|
end
|
136
136
|
end
|
137
137
|
end
|
@@ -155,7 +155,7 @@ shared_examples_for 'Advisory' do |path|
|
|
155
155
|
it "should contain valid RubyGem version requirements" do
|
156
156
|
lambda {
|
157
157
|
Gem::Requirement.new(*subject)
|
158
|
-
}.should_not raise_error
|
158
|
+
}.should_not raise_error
|
159
159
|
end
|
160
160
|
end
|
161
161
|
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
load File.join(File.dirname(__FILE__), 'spec_helper.rb')
|
2
|
+
load File.join(File.dirname(__FILE__), 'advisory_example.rb')
|
4
3
|
describe "gems" do
|
5
|
-
Dir.glob('gems/*/*.yml') do |path|
|
4
|
+
Dir.glob(File.join(File.dirname(__FILE__), '../gems/*/*.yml')) do |path|
|
6
5
|
include_examples 'Advisory', path
|
7
6
|
end
|
8
7
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
2014-04-10 19:47:28 UTC
|
data/gemspec.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
name: mrjoy-bundler-audit
|
2
2
|
summary: Patch-level verification for Bundler
|
3
|
-
description: bundler-audit provides patch-level verification for Bundled apps
|
3
|
+
description: An improved version of bundler-audit provides patch-level verification for Bundled apps
|
4
4
|
license: GPLv3
|
5
5
|
authors:
|
6
6
|
- Postmodern
|
@@ -13,4 +13,5 @@ homepage: https://github.com/MrJoy/mrjoy-bundler-audit#readme
|
|
13
13
|
required_rubygems_version: ">= 1.8.0"
|
14
14
|
|
15
15
|
dependencies:
|
16
|
+
thor: ~> 0.18
|
16
17
|
bundler: ~> 1.2
|
data/lib/bundler/audit/cli.rb
CHANGED
@@ -20,12 +20,13 @@
|
|
20
20
|
require 'bundler/audit/scanner'
|
21
21
|
require 'bundler/audit/version'
|
22
22
|
|
23
|
+
require 'thor'
|
23
24
|
require 'bundler'
|
24
25
|
require 'bundler/vendored_thor'
|
25
26
|
|
26
27
|
module Bundler
|
27
28
|
module Audit
|
28
|
-
class CLI < Thor
|
29
|
+
class CLI < ::Thor
|
29
30
|
|
30
31
|
default_task :check
|
31
32
|
map '--version' => :version
|
@@ -74,9 +75,9 @@ module Bundler
|
|
74
75
|
|
75
76
|
protected
|
76
77
|
|
77
|
-
def say(
|
78
|
+
def say(message="", color=nil)
|
78
79
|
color = nil unless $stdout.tty?
|
79
|
-
super(
|
80
|
+
super(message.to_s, color)
|
80
81
|
end
|
81
82
|
|
82
83
|
def print_warning(message)
|
@@ -90,7 +91,7 @@ module Bundler
|
|
90
91
|
say advisory.id
|
91
92
|
|
92
93
|
say "Criticality: ", :red
|
93
|
-
say *CRITICALITY_MAP[advisory.criticality]
|
94
|
+
say *(CRITICALITY_MAP[advisory.criticality] || "Unknown")
|
94
95
|
|
95
96
|
say "URL: ", :red
|
96
97
|
say advisory.url
|
@@ -133,13 +134,11 @@ module Bundler
|
|
133
134
|
end
|
134
135
|
end
|
135
136
|
|
136
|
-
CRITICALITY_MAP =
|
137
|
+
CRITICALITY_MAP = {
|
137
138
|
:low => ["Low"],
|
138
139
|
:medium => ["Medium", :yellow],
|
139
140
|
:high => ["High", [:red, :bold]],
|
140
|
-
}
|
141
|
-
"Unknown"
|
142
|
-
end
|
141
|
+
}
|
143
142
|
end
|
144
143
|
end
|
145
144
|
end
|
@@ -17,12 +17,11 @@
|
|
17
17
|
# along with mrjoy-bundler-audit. If not, see <http://www.gnu.org/licenses/>.
|
18
18
|
#
|
19
19
|
|
20
|
+
require 'bundler/audit/advisory'
|
21
|
+
|
20
22
|
require 'time'
|
21
23
|
require 'yaml'
|
22
24
|
|
23
|
-
require 'bundler/audit/advisory'
|
24
|
-
require 'bundler/audit/vendored_time'
|
25
|
-
|
26
25
|
module Bundler
|
27
26
|
module Audit
|
28
27
|
#
|
@@ -37,8 +36,11 @@ module Bundler
|
|
37
36
|
# Default path to the ruby-advisory-db
|
38
37
|
VENDORED_PATH = File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','data','ruby-advisory-db'))
|
39
38
|
|
39
|
+
# Timestamp for when the database was last updated
|
40
|
+
VENDORED_TIMESTAMP = Time.parse(File.read("#{VENDORED_PATH}.ts")).utc
|
41
|
+
|
40
42
|
# Path to the user's copy of the ruby-advisory-db
|
41
|
-
USER_PATH = File.join(
|
43
|
+
USER_PATH = File.expand_path(File.join(ENV['HOME'],'.local','share','ruby-advisory-db'))
|
42
44
|
|
43
45
|
# The path to the advisory database
|
44
46
|
attr_reader :path
|
@@ -69,7 +71,7 @@ module Bundler
|
|
69
71
|
def self.path
|
70
72
|
if File.directory?(USER_PATH)
|
71
73
|
t1 = Dir.chdir(USER_PATH) { Time.parse(`git log --pretty="%cd" -1`) }
|
72
|
-
t2 =
|
74
|
+
t2 = VENDORED_TIMESTAMP
|
73
75
|
|
74
76
|
if t1 >= t2 then USER_PATH
|
75
77
|
else VENDORED_PATH
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
require 'bundler/audit/scanner'
|
4
|
+
require 'bundler/audit/cli'
|
5
|
+
|
6
|
+
module Bundler
|
7
|
+
module Audit
|
8
|
+
class Task < ::Rake::TaskLib
|
9
|
+
attr_accessor :name
|
10
|
+
attr_accessor :options
|
11
|
+
attr_accessor :block
|
12
|
+
attr_accessor :verbose
|
13
|
+
attr_accessor :ignore
|
14
|
+
|
15
|
+
def initialize(*args, &block)
|
16
|
+
@options = args || []
|
17
|
+
@block = block if block
|
18
|
+
@verbose = false
|
19
|
+
|
20
|
+
define
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
def define
|
25
|
+
desc "Run Bundler-audit" unless ::Rake.application.last_comment
|
26
|
+
@name = options.shift || :audit
|
27
|
+
|
28
|
+
task @name, *options do |_, task_args|
|
29
|
+
RakeFileUtils.send(:verbose, @verbose) do
|
30
|
+
block.call(self) if block
|
31
|
+
run
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def run
|
37
|
+
t = ['check']
|
38
|
+
t << '-v' if verbose
|
39
|
+
t << '-i' << ignore if ignore
|
40
|
+
Bundler::Audit::CLI.start t
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/spec/advisory_spec.rb
CHANGED
@@ -8,13 +8,20 @@ describe Bundler::Audit::Advisory do
|
|
8
8
|
let(:id) { 'OSVDB-84243' }
|
9
9
|
let(:path) { File.join(root,'gems',gem,"#{id}.yml") }
|
10
10
|
let(:an_unaffected_version) do
|
11
|
-
Advisory.load(path).
|
12
|
-
|
13
|
-
|
14
|
-
requirements.
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
Bundler::Audit::Advisory.load(path).unaffected_versions.map { |version_rule|
|
12
|
+
# For all the rules, get the individual constraints out and see if we
|
13
|
+
# can find a suitable one...
|
14
|
+
version_rule.requirements.select { |(constraint, gem_version)|
|
15
|
+
# We only want constraints where the version number specified is
|
16
|
+
# one of the unaffected version. I.E. we don't want ">", "<", or if
|
17
|
+
# such a thing exists, "!=" constraints.
|
18
|
+
['~>', '>=', '=', '<='].include?(constraint)
|
19
|
+
}.map { |(constraint, gem_version)|
|
20
|
+
# Fetch just the version component, which is a Gem::Version,
|
21
|
+
# and extract the string representation of the version.
|
22
|
+
gem_version.version
|
23
|
+
}
|
24
|
+
}.flatten.first
|
18
25
|
end
|
19
26
|
|
20
27
|
describe "load" do
|
data/spec/bundle/secure/Gemfile
CHANGED
data/spec/database_spec.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'bundler/audit/database'
|
3
3
|
require 'tmpdir'
|
4
|
+
require 'rake/file_list'
|
4
5
|
|
5
6
|
describe Bundler::Audit::Database do
|
7
|
+
let(:vendored_advisories) do
|
8
|
+
Rake::FileList[File.join(Bundler::Audit::Database::VENDORED_PATH, '**/*.yml')].sort
|
9
|
+
end
|
10
|
+
|
6
11
|
describe "path" do
|
7
12
|
subject { described_class.path }
|
8
13
|
|
@@ -101,7 +106,18 @@ describe Bundler::Audit::Database do
|
|
101
106
|
end
|
102
107
|
|
103
108
|
describe "#size" do
|
104
|
-
it { subject.size.
|
109
|
+
it { expect(subject.size).to eq vendored_advisories.count }
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "#advisories" do
|
113
|
+
it "should return a list of all advisories." do
|
114
|
+
actual_advisories = Bundler::Audit::Database.new.
|
115
|
+
advisories.
|
116
|
+
map(&:path).
|
117
|
+
sort
|
118
|
+
|
119
|
+
expect(actual_advisories).to eq vendored_advisories
|
120
|
+
end
|
105
121
|
end
|
106
122
|
|
107
123
|
describe "#to_s" do
|
@@ -109,4 +125,10 @@ describe Bundler::Audit::Database do
|
|
109
125
|
subject.to_s.should == subject.path
|
110
126
|
end
|
111
127
|
end
|
128
|
+
|
129
|
+
describe "#inspect" do
|
130
|
+
it "should produce a Ruby-ish instance descriptor" do
|
131
|
+
expect(Bundler::Audit::Database.new.inspect).to eq("#<Bundler::Audit::Database:#{Bundler::Audit::Database::VENDORED_PATH}>")
|
132
|
+
end
|
133
|
+
end
|
112
134
|
end
|
data/spec/integration_spec.rb
CHANGED
@@ -1,66 +1,81 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "CLI" do
|
4
|
-
|
4
|
+
include Helpers
|
5
5
|
|
6
|
-
|
6
|
+
let(:command) do
|
7
|
+
File.expand_path(File.join(File.dirname(__FILE__),'..','bin','bundle-audit'))
|
8
|
+
end
|
9
|
+
|
10
|
+
context "when auditing a bundle with unpatched gems" do
|
7
11
|
let(:bundle) { 'unpatched_gems' }
|
12
|
+
let(:directory) { File.join('spec','bundle',bundle) }
|
13
|
+
|
14
|
+
subject do
|
15
|
+
Dir.chdir(directory) { sh(command, :fail => true) }
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should print a warning" do
|
19
|
+
subject.should include("Unpatched versions found!")
|
20
|
+
end
|
8
21
|
|
9
22
|
it "should print advisory information for the vulnerable gems" do
|
10
|
-
output = audit_in_directory "", directory, :fail => true
|
11
|
-
# Doing this so we can get an exact count on the number of
|
12
|
-
# vulnerabilities we should match with the regex below.
|
13
|
-
vuln_count = output.split(/Name:/).length - 1 # Less one for the
|
14
|
-
# zero-width prefix before
|
15
|
-
# the first match.
|
16
|
-
|
17
|
-
# Note the "{vuln_count}" below indicates the minimum number of
|
18
|
-
# advisories that we should see matches for -- as a particular version of
|
19
|
-
# code will never
|
20
23
|
advisory_pattern = /(Name: [^\n]+
|
21
|
-
Version: \d
|
24
|
+
Version: \d+.\d+.\d+
|
22
25
|
Advisory: OSVDB-\d+
|
23
26
|
Criticality: (High|Medium)
|
24
|
-
URL: http:\/\/(direct
|
25
|
-
Title: [^\n]
|
26
|
-
Solution: upgrade to ((
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
expect(output).to match(advisory_pattern)
|
31
|
-
expect(output).to include("Unpatched versions found!")
|
27
|
+
URL: http:\/\/(direct|www\.)?osvdb.org\/show\/osvdb\/\d+
|
28
|
+
Title: [^\n]*?
|
29
|
+
Solution: upgrade to ((~>|=>) \d+.\d+.\d+, )*(~>|=>) \d+.\d+.\d+[\s\n]*?)+/
|
30
|
+
|
31
|
+
expect(subject).to match(advisory_pattern)
|
32
|
+
expect(subject).to include("Unpatched versions found!")
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
35
36
|
context "when auditing a bundle with ignored gems" do
|
36
37
|
let(:bundle) { 'unpatched_gems' }
|
38
|
+
let(:directory) { File.join('spec','bundle',bundle) }
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
+
let(:command) do
|
41
|
+
File.expand_path(File.join(File.dirname(__FILE__),'..','bin','bundle-audit -i OSVDB-89026'))
|
42
|
+
end
|
40
43
|
|
41
|
-
|
44
|
+
subject do
|
45
|
+
Dir.chdir(directory) { sh(command, :fail => true) }
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should not print advisory information for ignored gem" do
|
49
|
+
subject.should_not include("OSVDB-89026")
|
42
50
|
end
|
43
51
|
end
|
44
52
|
|
45
53
|
context "when auditing a bundle with insecure sources" do
|
46
54
|
let(:bundle) { 'insecure_sources' }
|
55
|
+
let(:directory) { File.join('spec','bundle',bundle) }
|
56
|
+
|
57
|
+
subject do
|
58
|
+
Dir.chdir(directory) { sh(command, :fail => true) }
|
59
|
+
end
|
47
60
|
|
48
61
|
it "should print warnings about insecure sources" do
|
49
|
-
|
50
|
-
expect(output).to include(%{
|
62
|
+
subject.should include(%{
|
51
63
|
Insecure Source URI found: git://github.com/rails/jquery-rails.git
|
52
64
|
Insecure Source URI found: http://rubygems.org/
|
53
65
|
}.strip)
|
54
66
|
end
|
55
67
|
end
|
56
68
|
|
57
|
-
|
58
69
|
context "when auditing a secure bundle" do
|
59
70
|
let(:bundle) { 'secure' }
|
71
|
+
let(:directory) { File.join('spec','bundle',bundle) }
|
72
|
+
|
73
|
+
subject do
|
74
|
+
Dir.chdir(directory) { sh(command) }
|
75
|
+
end
|
60
76
|
|
61
77
|
it "should print nothing when everything is fine" do
|
62
|
-
|
63
|
-
expect(output.strip).to eq "No unpatched versions found"
|
78
|
+
subject.strip.should == "No unpatched versions found"
|
64
79
|
end
|
65
80
|
end
|
66
81
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'bundler/audit/task'
|
2
|
+
|
3
|
+
describe Bundler::Audit::Task do
|
4
|
+
let(:task) { Bundler::Audit::Task.new }
|
5
|
+
|
6
|
+
context "default options" do
|
7
|
+
it "runs bundle-audit check" do
|
8
|
+
task = Bundler::Audit::Task.new(:audit_task)
|
9
|
+
expect(Bundler::Audit::CLI).to receive(:start)
|
10
|
+
task.send(:run)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "creates task name" do
|
14
|
+
task = Bundler::Audit::Task.new(:audit_task)
|
15
|
+
expect(task.name).to eq(:audit_task)
|
16
|
+
expect(task).to receive(:run) { true }
|
17
|
+
Rake.application.invoke_task("audit_task")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "can fail" do
|
21
|
+
task = Bundler::Audit::Task.new(:failed_audit)
|
22
|
+
Rake.application.invoke_task("failed_audit")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "verbose" do
|
27
|
+
it "correctly adds verbose to the command" do
|
28
|
+
task = Bundler::Audit::Task.new(:audit_test_1) do |r|
|
29
|
+
r.verbose = true
|
30
|
+
end
|
31
|
+
expect(Bundler::Audit::CLI).to receive(:start).with ['check', '-v']
|
32
|
+
Rake.application.invoke_task("audit_test_1")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.require(:default, :development, :test)
|
4
|
+
|
5
|
+
version = RUBY_VERSION.split(/\./).map(&:to_i)
|
6
|
+
if((version[0] == 1 && version[1] >= 9) || (version[0] >= 2))
|
7
|
+
require 'simplecov'
|
8
|
+
require 'json'
|
9
|
+
SimpleCov.start
|
10
|
+
end
|
4
11
|
|
5
12
|
require 'rspec'
|
13
|
+
require 'bundler/audit'
|
6
14
|
require 'bundler/audit/version'
|
7
15
|
|
8
16
|
module Helpers
|