bundler-audit 0.1.0 → 0.2.0

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.
Files changed (97) hide show
  1. checksums.yaml +7 -0
  2. data/.document +1 -1
  3. data/.gitignore +3 -0
  4. data/.gitmodules +3 -0
  5. data/.travis.yml +4 -0
  6. data/ChangeLog.md +50 -0
  7. data/Gemfile +12 -0
  8. data/README.md +51 -69
  9. data/Rakefile +37 -21
  10. data/bin/bundle-audit +2 -12
  11. data/bundler-audit.gemspec +7 -0
  12. data/data/ruby-advisory-db/.rspec +1 -0
  13. data/data/ruby-advisory-db/CONTRIBUTING.md +6 -0
  14. data/data/ruby-advisory-db/CONTRIBUTORS.md +13 -0
  15. data/data/ruby-advisory-db/Gemfile +3 -0
  16. data/data/ruby-advisory-db/LICENSE.txt +5 -0
  17. data/data/ruby-advisory-db/README.md +86 -0
  18. data/data/ruby-advisory-db/Rakefile +27 -0
  19. data/data/ruby-advisory-db/gems/actionpack/OSVDB-79727.yml +26 -0
  20. data/data/ruby-advisory-db/gems/actionpack/OSVDB-84243.yml +28 -0
  21. data/data/ruby-advisory-db/gems/actionpack/OSVDB-84513.yml +23 -0
  22. data/data/ruby-advisory-db/gems/actionpack/OSVDB-84515.yml +26 -0
  23. data/data/{bundler/audit/rails/2013-0156.yml → ruby-advisory-db/gems/actionpack/OSVDB-89026.yml} +8 -3
  24. data/data/ruby-advisory-db/gems/actionpack/OSVDB-91452.yml +20 -0
  25. data/data/ruby-advisory-db/gems/actionpack/OSVDB-91454.yml +23 -0
  26. data/data/ruby-advisory-db/gems/activerecord/OSVDB-82403.yml +25 -0
  27. data/data/ruby-advisory-db/gems/activerecord/OSVDB-82610.yml +24 -0
  28. data/data/{bundler/audit/rails/2013-0155.yml → ruby-advisory-db/gems/activerecord/OSVDB-89025.yml} +9 -4
  29. data/data/{bundler/audit/rails/2013-0276.yml → ruby-advisory-db/gems/activerecord/OSVDB-90072.yml} +8 -3
  30. data/data/{bundler/audit/rails/2013-0277.yml → ruby-advisory-db/gems/activerecord/OSVDB-90073.yml} +8 -3
  31. data/data/ruby-advisory-db/gems/activerecord/OSVDB-91453.yml +26 -0
  32. data/data/ruby-advisory-db/gems/activesupport/OSVDB-79726.yml +26 -0
  33. data/data/ruby-advisory-db/gems/activesupport/OSVDB-84516.yml +23 -0
  34. data/data/{bundler/audit/rails/2013-0333.yml → ruby-advisory-db/gems/activesupport/OSVDB-89594.yml} +8 -3
  35. data/data/ruby-advisory-db/gems/activesupport/OSVDB-91451.yml +28 -0
  36. data/data/ruby-advisory-db/gems/command_wrap/OSVDB-91450.yml +10 -0
  37. data/data/ruby-advisory-db/gems/crack/OSVDB-90742.yml +17 -0
  38. data/data/ruby-advisory-db/gems/cremefraiche/OSVDB-93395.yml +11 -0
  39. data/data/ruby-advisory-db/gems/curl/OSVDB-91230.yml +12 -0
  40. data/data/ruby-advisory-db/gems/devise/OSVDB-89642.yml +20 -0
  41. data/data/ruby-advisory-db/gems/dragonfly/OSVDB-90647.yml +19 -0
  42. data/data/ruby-advisory-db/gems/enum_column3/OSVDB-94679.yml +9 -0
  43. data/data/ruby-advisory-db/gems/extlib/OSVDB-90740.yml +18 -0
  44. data/data/ruby-advisory-db/gems/fastreader/OSVDB-91232.yml +12 -0
  45. data/data/ruby-advisory-db/gems/fileutils/OSVDB-90715.yml +10 -0
  46. data/data/ruby-advisory-db/gems/fileutils/OSVDB-90716.yml +10 -0
  47. data/data/ruby-advisory-db/gems/fileutils/OSVDB-90717.yml +10 -0
  48. data/data/ruby-advisory-db/gems/flash_tool/OSVDB-90829.yml +9 -0
  49. data/data/ruby-advisory-db/gems/ftpd/OSVDB-90784.yml +18 -0
  50. data/data/ruby-advisory-db/gems/gtk2/OSVDB-40774.yml +20 -0
  51. data/data/ruby-advisory-db/gems/httparty/OSVDB-90741.yml +19 -0
  52. data/data/{bundler/audit/json/2013-0269.yml → ruby-advisory-db/gems/json/OSVDB-90074.yml} +8 -4
  53. data/data/ruby-advisory-db/gems/karteek-docsplit/OSVDB-92117.yml +10 -0
  54. data/data/ruby-advisory-db/gems/kelredd-pruview/OSVDB-92228.yml +10 -0
  55. data/data/ruby-advisory-db/gems/ldoce/OSVDB-91870.yml +10 -0
  56. data/data/ruby-advisory-db/gems/loofah/OSVDB-90945.yml +21 -0
  57. data/data/ruby-advisory-db/gems/mail/OSVDB-70667.yml +21 -0
  58. data/data/ruby-advisory-db/gems/mail/OSVDB-81631.yml +14 -0
  59. data/data/ruby-advisory-db/gems/mail/OSVDB-81632.yml +16 -0
  60. data/data/ruby-advisory-db/gems/md2pdf/OSVDB-92290.yml +10 -0
  61. data/data/ruby-advisory-db/gems/mini_magick/OSVDB-91231.yml +15 -0
  62. data/data/ruby-advisory-db/gems/multi_xml/OSVDB-89148.yml +16 -0
  63. data/data/ruby-advisory-db/gems/newrelic_rpm/OSVDB-90189.yml +17 -0
  64. data/data/ruby-advisory-db/gems/nori/OSVDB-90196.yml +19 -0
  65. data/data/ruby-advisory-db/gems/omniauth-oauth2/OSVDB-90264.yml +16 -0
  66. data/data/ruby-advisory-db/gems/pdfkit/OSVDB-90867.yml +11 -0
  67. data/data/{bundler/audit/rack/2013-0263.yml → ruby-advisory-db/gems/rack/OSVDB-89939.yml} +11 -8
  68. data/data/ruby-advisory-db/gems/rack-cache/OSVDB-83077.yml +18 -0
  69. data/data/ruby-advisory-db/gems/rdoc/OSVDB-90004.yml +27 -0
  70. data/data/ruby-advisory-db/gems/rgpg/OSVDB-95948.yml +13 -0
  71. data/data/ruby-advisory-db/gems/ruby_parser/OSVDB-90561.yml +11 -0
  72. data/data/ruby-advisory-db/gems/spree/OSVDB-91216.yml +10 -0
  73. data/data/ruby-advisory-db/gems/spree/OSVDB-91217.yml +10 -0
  74. data/data/ruby-advisory-db/gems/spree/OSVDB-91218.yml +10 -0
  75. data/data/ruby-advisory-db/gems/spree/OSVDB-91219.yml +10 -0
  76. data/data/ruby-advisory-db/gems/thumbshooter/OSVDB-91839.yml +10 -0
  77. data/data/ruby-advisory-db/lib/scrape.rb +87 -0
  78. data/data/ruby-advisory-db/spec/advisory_example.rb +165 -0
  79. data/data/ruby-advisory-db/spec/gems_spec.rb +8 -0
  80. data/data/ruby-advisory-db/spec/spec_helper.rb +1 -0
  81. data/gemspec.yml +4 -7
  82. data/lib/bundler/audit/advisory.rb +51 -9
  83. data/lib/bundler/audit/cli.rb +33 -12
  84. data/lib/bundler/audit/database.rb +1 -30
  85. data/lib/bundler/audit/scanner.rb +97 -0
  86. data/lib/bundler/audit/version.rb +1 -1
  87. data/spec/advisory_spec.rb +67 -7
  88. data/spec/bundle/insecure_sources/Gemfile +39 -0
  89. data/spec/bundle/secure/Gemfile +38 -0
  90. data/spec/database_spec.rb +1 -32
  91. data/spec/integration_spec.rb +132 -0
  92. data/spec/scanner_spec.rb +74 -0
  93. data/spec/spec_helper.rb +14 -1
  94. metadata +89 -74
  95. data/LICENSE.txt +0 -20
  96. data/spec/bundle/Gemfile.lock +0 -92
  97. /data/spec/bundle/{Gemfile → unpatched_gems/Gemfile} +0 -0
@@ -0,0 +1,14 @@
1
+ ---
2
+ gem: mail
3
+ cve: 2012-2139
4
+ osvdb: 81631
5
+ url: http://www.osvdb.org/show/osvdb/81631
6
+ title: Mail Gem for Ruby File Delivery Method to Parameter Traversal Arbitrary File Manipulation
7
+ date: 2012-03-14
8
+
9
+ description: |
10
+ Mail Gem for Ruby contains a flaw that allows a remote attacker to traverse outside of a restricted path. The issue is due to the program not properly sanitizing user input, specifically directory traversal style attacks (e.g., ../../) supplied via the 'to' parameter within the delivery method. This directory traversal attack would allow the attacker to modify arbitrary files.
11
+
12
+ cvss_v2: 5.0
13
+ patched_versions:
14
+ - ">= 2.4.4"
@@ -0,0 +1,16 @@
1
+ ---
2
+ gem: mail
3
+ cve: 2012-2140
4
+ osvdb: 81632
5
+ url: http://www.osvdb.org/show/osvdb/81632
6
+ title: Mail Gem for Ruby Multiple Delivery Method Remote Shell Command Execution
7
+ date: 2012-03-14
8
+
9
+ description: |
10
+ Mail Gem for Ruby contains a flaw that occurs within the sendmail and exim
11
+ delivery methods, which may allow an attacker to execute arbitrary shell
12
+ commands..
13
+
14
+ cvss_v2: 7.5
15
+ patched_versions:
16
+ - ">= 2.4.4"
@@ -0,0 +1,10 @@
1
+ ---
2
+ gem: md2pdf
3
+ cve: 2013-1948
4
+ osvdb: 92290
5
+ url: http://osvdb.org/show/osvdb/92290
6
+ title: md2pdf Gem for Ruby md2pdf/converter.rb File Name Shell Metacharacter Injection Arbitrary Command Execution
7
+ date: 2013-04-13
8
+ description: md2pdf Gem for Ruby contains a flaw that is due to the program failing to properly sanitize input passed to md2pdf/converter.rb. With a specially crafted file name that contains shell metacharacters, a context-dependent attacker can execute arbitrary commands
9
+ cvss_v2: 10.0
10
+ patched_versions:
@@ -0,0 +1,15 @@
1
+ ---
2
+ gem: mini_magick
3
+ cve: 2013-2616
4
+ osvdb: 91231
5
+ url: http://osvdb.org/show/osvdb/91231
6
+ title: MiniMagick Gem for Ruby URI Handling Arbitrary Command Injection
7
+ date: 2013-03-12
8
+
9
+ description: MiniMagick Gem for Ruby contains a flaw that is triggered during the handling of specially crafted input from an untrusted source passed via a URL that contains a ';' character. This may allow a context-dependent attacker to potentially execute arbitrary commands.
10
+
11
+ cvss_v2: 9.3
12
+
13
+ patched_versions:
14
+ - ">= 3.6.0"
15
+
@@ -0,0 +1,16 @@
1
+ ---
2
+ gem: multi_xml
3
+ cve: 2013-0175
4
+ osvdb: 89148
5
+ url: http://osvdb.org/show/osvdb/89148
6
+ title: multi_xml Gem for Ruby XML Parameter Parsing Remote Command Execution
7
+ date: 2013-01-11
8
+
9
+ description: |
10
+ The multi_xml Gem for Ruby contains a flaw that is triggered when an error
11
+ occurs during the parsing of the 'XML' parameter. With a crafted request
12
+ containing arbitrary symbol and yaml types, a remote attacker can execute
13
+ arbitrary commands.
14
+
15
+ patched_versions:
16
+ - ">= 0.5.2"
@@ -0,0 +1,17 @@
1
+ ---
2
+ gem: newrelic_rpm
3
+ cve: 2013-0284
4
+ osvdb: 90189
5
+ url: http://osvdb.org/show/osvdb/90189
6
+ title: Ruby on Rails newrelic_rpm Gem Discloses Sensitive Information
7
+ date: 2012-12-06
8
+
9
+ description: |
10
+ A bug in the Ruby agent causes database connection information and raw SQL
11
+ statements to be transmitted to New Relic servers. The database connection
12
+ information includes the database IP address, username, and password
13
+
14
+ cvss_v2: 5.0
15
+
16
+ patched_versions:
17
+ - ">= 3.5.3.25"
@@ -0,0 +1,19 @@
1
+ ---
2
+ gem: nori
3
+ cve: 2013-0285
4
+ osvdb: 90196
5
+ url: http://osvdb.org/show/osvdb/90196
6
+ title: Ruby Gem nori Parameter Parsing Remote Code Execution
7
+ date: 2013-01-10
8
+
9
+ description: |
10
+ The Ruby Gem nori has a parameter parsing error that may allow an attacker
11
+ to execute arbitrary code. This vulnerability has to do with type casting
12
+ during parsing, and is related to CVE-2013-0156.
13
+
14
+ cvss_v2: 10.0
15
+
16
+ patched_versions:
17
+ - ~> 1.0.3
18
+ - ~> 1.1.4
19
+ - ">= 2.0.2"
@@ -0,0 +1,16 @@
1
+ ---
2
+ gem: omniauth-oauth2
3
+ cve: 2012-6134
4
+ osvdb: 90264
5
+ url: http://www.osvdb.org/show/osvdb/90264
6
+ title: Ruby on Rails omniauth-oauth2 Gem CSRF vulnerability
7
+ date: 2012-09-08
8
+
9
+ description: |
10
+ The omniauth-oauth2 Ruby Gem contains a flaw that allows an attacker to
11
+ inject values into a user's session through a CSRF attack.
12
+
13
+ cvss_v2: 6.8
14
+
15
+ patched_versions:
16
+ - ">= 1.1.1"
@@ -0,0 +1,11 @@
1
+ ---
2
+ gem: pdfkit
3
+ cve: 2013-1607
4
+ osvdb: 90867
5
+ url: http://osvdb.org/show/osvdb/90867
6
+ title: PDFKit Gem for Ruby PDF File Generation Parameter Handling Remote Code Execution
7
+ date: 2013-02-21
8
+ description: PDFKit Gem for Ruby contains a flaw that is due to the program failing to properly validate input during the handling of parameters when generating PDF files. This may allow a remote attacker to potentially execute arbitrary code via the pdfkit generation options.
9
+ cvss_v2:
10
+ patched_versions:
11
+ - ">= 0.5.3"
@@ -1,7 +1,11 @@
1
- ---
1
+ ---
2
+ gem: rack
3
+ cve: 2013-0263
4
+ osvdb: 89939
2
5
  url: http://osvdb.org/show/osvdb/89939
3
6
  title: |
4
7
  Rack Rack::Session::Cookie Function Timing Attack Remote Code Execution
8
+ date: 2009-12-01
5
9
 
6
10
  description: |
7
11
  Rack contains a flaw that is due to an error in the Rack::Session::Cookie
@@ -11,10 +15,9 @@ description: |
11
15
  latencies are sufficiently low to make the attack viable.
12
16
 
13
17
  cvss_v2: 7.6
14
-
15
- patched_versions:
16
- - ~> 1.1.6
17
- - ~> 1.2.8
18
- - ~> 1.3.10
19
- - ~> 1.4.5
20
- - ">= 1.5.2"
18
+ patched_versions:
19
+ - ~> 1.1.6
20
+ - ~> 1.2.8
21
+ - ~> 1.3.10
22
+ - ~> 1.4.5
23
+ - ">= 1.5.2"
@@ -0,0 +1,18 @@
1
+ ---
2
+ gem: rack-cache
3
+ cve: 2012-2671
4
+ osvdb: 83077
5
+ url: http://osvdb.org/83077
6
+ title: rack-cache Rubygem Sensitive HTTP Header Caching Weakness
7
+ date: 2012-06-06
8
+
9
+ description: |
10
+ Rack::Cache (rack-cache) contains a flaw related to the rubygem caching
11
+ sensitive HTTP headers. This will result in a weakness that may make it
12
+ easier for an attacker to gain access to a user's session via a specially
13
+ crafted header.
14
+
15
+ cvss_v2: 7.5
16
+
17
+ patched_versions:
18
+ - ">= 1.2"
@@ -0,0 +1,27 @@
1
+ ---
2
+ gem: rdoc
3
+ cve: 2013-0256
4
+ osvdb: 90004
5
+ url: http://www.osvdb.org/show/osvdb/90004
6
+ title: RDoc 2.3.0 through 3.12 XSS Exploit
7
+ date: 2013-02-06
8
+
9
+ description: |
10
+ Doc documentation generated by rdoc 2.3.0 through rdoc 3.12 and prereleases
11
+ up to rdoc 4.0.0.preview2.1 are vulnerable to an XSS exploit. This exploit
12
+ may lead to cookie disclosure to third parties.
13
+
14
+ The exploit exists in darkfish.js which is copied from the RDoc install
15
+ location to the generated documentation.
16
+
17
+ RDoc is a static documentation generation tool. Patching the library itself
18
+ is insufficient to correct this exploit.
19
+
20
+ This exploit was discovered by Evgeny Ermakov <corwmh@gmail.com>.
21
+
22
+ cvss_v2: 4.3
23
+
24
+ patched_versions:
25
+ - ~> 3.9.5
26
+ - ~> 3.12.1
27
+ - ">= 4.0"
@@ -0,0 +1,13 @@
1
+ ---
2
+ gem: rgpg
3
+ osvdb: 95948
4
+ url: http://www.osvdb.org/show/osvdb/95948
5
+ title: Ruby rgpg Gem Shell Command Injection Vulnerabilities
6
+ date: 2013-08-02
7
+ description: |
8
+ rgpg Gem for Ruby contains a flaw in the GpgHelper module (lib/rgpg/gpg_helper.rb).
9
+ The issue is due to the program failing to properly sanitize user-supplied input before being used in the system() function for execution.
10
+ This may allow a remote attacker to execute arbitrary commands.
11
+ cvss_v2:
12
+ patched_versions:
13
+ - ">= 0.2.3"
@@ -0,0 +1,11 @@
1
+ ---
2
+ gem: ruby_parser
3
+ cve: 2013-0162
4
+ osvdb: 90561
5
+ url: http://osvdb.org/show/osvdb/90561
6
+ title: RubyGems ruby_parser (RP) Temporary File Symlink Arbitrary File Overwrite
7
+ date: 2013-02-21
8
+ description: RubyGems ruby_parser (RP) contains a flaw as rubygem-ruby_parser creates temporary files insecurely. It is possible for a local attacker to use a symlink attack to cause the program to unexpectedly overwrite an arbitrary file.
9
+ cvss_v2: 2.1
10
+ patched_versions:
11
+ - ">= 3.1.2"
@@ -0,0 +1,10 @@
1
+ ---
2
+ gem: spree
3
+ cve: 2013-1656
4
+ osvdb: 91216
5
+ url: http://osvdb.org/show/osvdb/91216
6
+ title: Spree promotion_actions_controller.rb promotion_action Parameter Arbitrary Ruby Object Instantiation Command Execution
7
+ date: 2013-02-21
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
+ cvss_v2: 4.3
10
+ patched_versions:
@@ -0,0 +1,10 @@
1
+ ---
2
+ gem: spree
3
+ cve: 2013-1656
4
+ osvdb: 91217
5
+ url: http://osvdb.org/show/osvdb/91217
6
+ title: Spree payment_methods_controller.rb payment_method Parameter Arbitrary Ruby Object Instantiation Command Execution
7
+ date: 2013-02-21
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
+ cvss_v2: 4.3
10
+ patched_versions:
@@ -0,0 +1,10 @@
1
+ ---
2
+ gem: spree
3
+ cve: 2013-1656
4
+ osvdb: 91218
5
+ url: http://osvdb.org/show/osvdb/91218
6
+ title: Spree promotions_controller.rb calculator_type Parameter Arbitrary Ruby Object Instantiation Command Execution
7
+ date: 2013-02-21
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
+ cvss_v2: 4.3
10
+ patched_versions:
@@ -0,0 +1,10 @@
1
+ ---
2
+ gem: spree
3
+ cve: 2013-1656
4
+ osvdb: 91219
5
+ url: http://osvdb.org/show/osvdb/91219
6
+ title: Spree promotion_rules_controller.rb promotion_rule Parameter Arbitrary Ruby Object Instantiation Command Execution
7
+ date: 2013-02-21
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
+ cvss_v2: 4.3
10
+ patched_versions:
@@ -0,0 +1,10 @@
1
+ ---
2
+ gem: thumbshooter
3
+ cve: 2013-1898
4
+ osvdb: 91839
5
+ url: http://osvdb.org/show/osvdb/91839
6
+ title: Thumbshooter Gem for Ruby thumbshooter.rb URL Shell Metacharacter Injection Arbitrary Command Execution
7
+ date: 2013-03-26
8
+ description: Thumbshooter Gem for Ruby contains a flaw that is due to the program failing to properly sanitize input passed to thumbshooter.rb. With a specially crafted URL that contains shell metacharacters, a context-dependent attacker can execute arbitrary commands.
9
+ cvss_v2: 7.5
10
+ patched_versions:
@@ -0,0 +1,87 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'pry'
5
+ require 'mechanize'
6
+ require 'yaml'
7
+ require 'date'
8
+
9
+ class OSVDB
10
+ attr_accessor :osvdb, :cve, :title, :description, :date, :cvss_v2, :gem, :url, :patched_versions, :page
11
+ def initialize(url)
12
+ self.url = url
13
+ parse!
14
+ end
15
+
16
+ def parse!
17
+ mech = Mechanize.new
18
+ self.page = mech.get(url)
19
+
20
+ page.search(".show_vuln_table").search("td ul li").each do |li|
21
+ case li.children[0].text.strip
22
+ when "CVE ID:"
23
+ self.cve = li.children[1].text
24
+ when "Vendor URL:"
25
+ self.set_gem(li.children[1].text)
26
+ end
27
+ end
28
+
29
+ self.description = page.search(".show_vuln_table").search("tr td tr .white_content p")[0].text
30
+ self.date = page.search(".show_vuln_table").search("tr td tr .white_content tr td")[0].text
31
+ self.title = page.search("title").text.gsub(/\d+: /, "")
32
+ self.osvdb = page.search("title").text.match(/\d+/)[0]
33
+ if cvss_p = page.search(".show_vuln_table").search("tr td tr .white_content div p")[0]
34
+ self.set_cvss(cvss_p.children[0].text)
35
+ end
36
+ end
37
+
38
+ def set_gem(vendortext)
39
+ ["https://rubygems.org/gems/", "http://rubygems.org/gems/"].each do |str|
40
+ if vendortext.match(str)
41
+ self.gem = vendortext.gsub(str,"")
42
+ end
43
+ end
44
+ end
45
+
46
+ def set_cvss(text)
47
+ self.cvss_v2 = text.strip.gsub("CVSSv2 Base Score = ", "")
48
+ end
49
+
50
+ def date
51
+ Date.parse(@date)
52
+ end
53
+
54
+ def cvss_v2
55
+ @cvss_v2.nil? ? nil : @cvss_v2.to_f
56
+ end
57
+
58
+ def gem
59
+ @gem.nil? ? "unknown" : @gem
60
+ end
61
+
62
+ def to_yaml
63
+ { 'gem' => gem,
64
+ 'cve' => cve,
65
+ 'osvdb' => osvdb.to_i,
66
+ 'url' => url,
67
+ 'title' => title,
68
+ 'date' => date,
69
+ 'description' => description,
70
+ 'cvss_v2' => cvss_v2,
71
+ 'patched_versions' => patched_versions }.to_yaml
72
+ end
73
+
74
+ def filename
75
+ "OSVDB-#{osvdb}.yml"
76
+ end
77
+
78
+ def to_advisory!
79
+ gems_path = File.join(File.dirname(__FILE__), "..", "gems")
80
+ adv_path = File.absolute_path(File.join(gems_path, self.gem))
81
+
82
+ FileUtils.mkdir(adv_path) unless File.exists?(adv_path)
83
+ File.open(File.join(adv_path, filename), "w") do |io|
84
+ io.puts self.to_yaml
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,165 @@
1
+ require 'spec_helper'
2
+ require 'yaml'
3
+
4
+ shared_examples_for 'Advisory' do |path|
5
+ advisory = YAML.load_file(path)
6
+
7
+ describe path do
8
+ let(:gem) { File.basename(File.dirname(path)) }
9
+ let(:filename_cve) do
10
+ if File.basename(path).start_with?('CVE-')
11
+ File.basename(path).gsub('CVE-','').chomp('.yml')
12
+ else
13
+ nil
14
+ end
15
+ end
16
+ let(:filename_osvdb) do
17
+ if File.basename(path).start_with?('OSVDB-')
18
+ File.basename(path).gsub('OSVDB-','').chomp('.yml')
19
+ else
20
+ nil
21
+ end
22
+ end
23
+
24
+ it "should have CVE or OSVDB" do
25
+ (advisory['cve'] || advisory['osvdb']).should_not be_nil
26
+ end
27
+
28
+ describe "gem" do
29
+ subject { advisory['gem'] }
30
+
31
+ it { should be_kind_of(String) }
32
+ it { should == gem }
33
+ end
34
+
35
+ describe "framework" do
36
+ subject { advisory['framework'] }
37
+
38
+ it "may be nil or a String" do
39
+ [NilClass, String].should include(subject.class)
40
+ end
41
+ end
42
+
43
+ describe "platform" do
44
+ subject { advisory['platform'] }
45
+
46
+ it "may be nil or a String" do
47
+ [NilClass, String].should include(subject.class)
48
+ end
49
+ end
50
+
51
+ describe "cve" do
52
+ subject { advisory['cve'] }
53
+
54
+ it "may be nil or a String" do
55
+ [NilClass, String].should include(subject.class)
56
+ end
57
+ it "should be id in filename if filename is CVE-XXX" do
58
+ if filename_cve
59
+ should == filename_cve
60
+ end
61
+ end
62
+ end
63
+
64
+ describe "osvdb" do
65
+ subject { advisory['osvdb'] }
66
+ it "may be nil or a Fixnum" do
67
+ [NilClass, Fixnum].should include(subject.class)
68
+ end
69
+ it "should be id in filename if filename is OSVDB-XXX" do
70
+ if filename_osvdb
71
+ should == filename_osvdb.to_i
72
+ end
73
+ end
74
+ end
75
+
76
+ describe "url" do
77
+ subject { advisory['url'] }
78
+
79
+ it { should be_kind_of(String) }
80
+ it { should_not be_empty }
81
+ end
82
+
83
+ describe "title" do
84
+ subject { advisory['title'] }
85
+
86
+ it { should be_kind_of(String) }
87
+ it { should_not be_empty }
88
+ end
89
+
90
+ describe "date" do
91
+ subject { advisory['date'] }
92
+
93
+ it { should be_kind_of(Date) }
94
+ end
95
+
96
+ describe "description" do
97
+ subject { advisory['description'] }
98
+
99
+ it { should be_kind_of(String) }
100
+ it { should_not be_empty }
101
+ end
102
+
103
+ describe "cvss_v2" do
104
+ subject { advisory['cvss_v2'] }
105
+
106
+ it "may be nil or a Float" do
107
+ [NilClass, Float].should include(subject.class)
108
+ end
109
+
110
+ case advisory['cvss_v2']
111
+ when Float
112
+ context "when a Float" do
113
+ it { ((0.0)..(10.0)).should include(subject) }
114
+ end
115
+ end
116
+ end
117
+
118
+ describe "patched_versions" do
119
+ subject { advisory['patched_versions'] }
120
+
121
+ it "may be nil or an Array" do
122
+ [NilClass, Array].should include(subject.class)
123
+ end
124
+
125
+ describe "each patched version" do
126
+ if advisory['patched_versions']
127
+ advisory['patched_versions'].each do |version|
128
+ describe version do
129
+ subject { version.split(', ') }
130
+
131
+ it "should contain valid RubyGem version requirements" do
132
+ lambda {
133
+ Gem::Requirement.new(*subject)
134
+ }.should_not raise_error(ArgumentError)
135
+ end
136
+ end
137
+ end
138
+ end
139
+ end
140
+ end
141
+
142
+ describe "unaffected_versions" do
143
+ subject { advisory['unaffected_versions'] }
144
+
145
+ it "may be nil or an Array" do
146
+ [NilClass, Array].should include(subject.class)
147
+ end
148
+
149
+ case advisory['unaffected_versions']
150
+ when Array
151
+ advisory['unaffected_versions'].each do |version|
152
+ describe version do
153
+ subject { version.split(', ') }
154
+
155
+ it "should contain valid RubyGem version requirements" do
156
+ lambda {
157
+ Gem::Requirement.new(*subject)
158
+ }.should_not raise_error(ArgumentError)
159
+ end
160
+ end
161
+ end
162
+ end
163
+ end
164
+ end
165
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+ require 'advisory_example'
3
+
4
+ describe "gems" do
5
+ Dir.glob('gems/*/*.yml') do |path|
6
+ include_examples 'Advisory', path
7
+ end
8
+ end
@@ -0,0 +1 @@
1
+ require 'rspec'
data/gemspec.yml CHANGED
@@ -4,12 +4,9 @@ description: bundler-audit provides patch-level verification for Bundled apps.
4
4
  license: GPLv3
5
5
  authors: Postmodern
6
6
  email: postmodern.mod3@gmail.com
7
- homepage: https://github.com/postmodern/bundler-audit#readme
7
+ homepage: https://github.com/rubysec/bundler-audit#readme
8
8
 
9
- dependencies:
10
- bundler: ~> 1.0
9
+ required_rubygems_version: ">= 1.8.0"
11
10
 
12
- development_dependencies:
13
- rspec: ~> 2.4
14
- rubygems-tasks: ~> 0.2
15
- yard: ~> 0.8
11
+ dependencies:
12
+ bundler: ~> 1.2