bundler-leak 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/.document +3 -0
  3. data/.gitignore +11 -0
  4. data/.gitmodules +3 -0
  5. data/.rspec +1 -0
  6. data/.travis.yml +13 -0
  7. data/.yardopts +1 -0
  8. data/COPYING.txt +674 -0
  9. data/ChangeLog.md +125 -0
  10. data/Gemfile +15 -0
  11. data/README.md +118 -0
  12. data/Rakefile +57 -0
  13. data/bin/bundle-leak +10 -0
  14. data/bin/bundler-leak +3 -0
  15. data/bundler-leak.gemspec +67 -0
  16. data/data/ruby-mem-advisory-db.ts +1 -0
  17. data/data/ruby-mem-advisory-db/.gitignore +1 -0
  18. data/data/ruby-mem-advisory-db/.rspec +1 -0
  19. data/data/ruby-mem-advisory-db/.travis.yml +12 -0
  20. data/data/ruby-mem-advisory-db/CONTRIBUTING.md +69 -0
  21. data/data/ruby-mem-advisory-db/CONTRIBUTORS.md +40 -0
  22. data/data/ruby-mem-advisory-db/Gemfile +9 -0
  23. data/data/ruby-mem-advisory-db/LICENSE.txt +5 -0
  24. data/data/ruby-mem-advisory-db/README.md +72 -0
  25. data/data/ruby-mem-advisory-db/Rakefile +26 -0
  26. data/data/ruby-mem-advisory-db/gems/celluloid/670.yml +10 -0
  27. data/data/ruby-mem-advisory-db/gems/grape/301.yml +9 -0
  28. data/data/ruby-mem-advisory-db/gems/oj/229.yml +9 -0
  29. data/data/ruby-mem-advisory-db/gems/redcarpet/516.yml +12 -0
  30. data/data/ruby-mem-advisory-db/gems/redis/612.yml +9 -0
  31. data/data/ruby-mem-advisory-db/gems/sidekiq-statistic/73.yml +9 -0
  32. data/data/ruby-mem-advisory-db/gems/sidekiq/2598.yml +9 -0
  33. data/data/ruby-mem-advisory-db/gems/therubyracer/336.yml +13 -0
  34. data/data/ruby-mem-advisory-db/gems/zipruby/PRE-SA-2012-02.yml +9 -0
  35. data/data/ruby-mem-advisory-db/scripts/post-advisories.sh +18 -0
  36. data/data/ruby-mem-advisory-db/spec/advisories_spec.rb +23 -0
  37. data/data/ruby-mem-advisory-db/spec/advisory_example.rb +209 -0
  38. data/data/ruby-mem-advisory-db/spec/gem_example.rb +37 -0
  39. data/data/ruby-mem-advisory-db/spec/library_example.rb +21 -0
  40. data/data/ruby-mem-advisory-db/spec/ruby_example.rb +22 -0
  41. data/data/ruby-mem-advisory-db/spec/spec_helper.rb +1 -0
  42. data/gemspec.yml +14 -0
  43. data/lib/bundler/plumber.rb +20 -0
  44. data/lib/bundler/plumber/advisory.rb +119 -0
  45. data/lib/bundler/plumber/cli.rb +135 -0
  46. data/lib/bundler/plumber/database.rb +249 -0
  47. data/lib/bundler/plumber/scanner.rb +133 -0
  48. data/lib/bundler/plumber/task.rb +49 -0
  49. data/lib/bundler/plumber/version.rb +24 -0
  50. data/spec/advisory_spec.rb +155 -0
  51. data/spec/audit_spec.rb +8 -0
  52. data/spec/bundle/insecure_sources/Gemfile +39 -0
  53. data/spec/bundle/secure/Gemfile +38 -0
  54. data/spec/bundle/unpatched_gems/Gemfile +39 -0
  55. data/spec/cli_spec.rb +99 -0
  56. data/spec/database_spec.rb +138 -0
  57. data/spec/fixtures/not_a_hash.yml +2 -0
  58. data/spec/integration_spec.rb +68 -0
  59. data/spec/scanner_spec.rb +61 -0
  60. data/spec/spec_helper.rb +62 -0
  61. metadata +141 -0
@@ -0,0 +1,40 @@
1
+ ### Acknowledgements
2
+
3
+ This database would not be possible without volunteers willing to submit pull requests. In no particular order, we'd like to thank:
4
+
5
+ * [Postmodern](https://github.com/postmodern/)
6
+ * [Max Veytsman](https://twitter.com/mveytsman)
7
+ * [Pietro Monteiro](https://github.com/pietro)
8
+ * [Eric Hodel](https://github.com/drbrain)
9
+ * [Brendon Murphy](https://github.com/bemurphy)
10
+ * [Oliver Legg](https://github.com/olly)
11
+ * [Larry W. Cashdollar](http://vapid.dhs.org/)
12
+ * [Michael Grosser](https://github.com/grosser)
13
+ * [Sascha Korth](https://github.com/skorth)
14
+ * [David Radcliffe](https://github.com/dwradcliffe)
15
+ * [Jörg Schiller](https://github.com/joergschiller)
16
+ * [Derek Prior](https://github.com/derekprior)
17
+ * [Joel Chippindale](https://github.com/mocoso)
18
+ * [Josef Šimánek](https://github.com/simi)
19
+ * [Amiel Martin](https://github.com/amiel)
20
+ * [Jeremy Olliver](https://github.com/jeremyolliver)
21
+ * [Vasily Vasinov](https://github.com/vasinov)
22
+ * [Phill MV](https://twitter.com/phillmv)
23
+ * [Jon Kessler](https://github.com/jonkessler)
24
+ * [James Harton](https://github.com/jamesotron)
25
+ * [Justin Collins](https://github.com/presidentbeef)
26
+ * [Andy Brody](https://github.com/ab)
27
+ * [Alexey Zapparov](https://github.com/ixti)
28
+ * [Toni Reina](https://github.com/areina)
29
+ * [Bernard Lambeau](https://github.com/blambeau)
30
+ * [Don Morrison](https://github.com/elskwid)
31
+ * [John Poulin](https://github.com/forced-request)
32
+ * [Neal Harris](https://github.com/nealharris)
33
+ * [Justin Bull](https://github.com/f3ndot)
34
+ * [Andrew Selder](https://github.com/aselder)
35
+ * [Vanessa Henderson](https://github.com/VanessaHenderson)
36
+ * [Reed Loden](https://github.com/reedloden)
37
+ * [ecneladis](https://github.com/ecneladis)
38
+ * [Brendan Coles](https://github.com/bcoles)
39
+
40
+ The rubysec.com domain was graciously donated by [Jordi Massaguer](https://github.com/jordimassaguerpla).
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rspec'
4
+ gem 'rake'
5
+
6
+ group :development do
7
+ gem 'pry'
8
+ gem 'nokogiri'
9
+ end
@@ -0,0 +1,5 @@
1
+ If you submit code or data to the ruby-advisory-db that is copyrighted by yourself, upon submission you hereby agree to release it into the public domain.
2
+
3
+ However, not all of the ruby-advisory-db can be considered public domain. The ruby-advisory-db may contain some information copyrighted by the Open Source Vulnerability Database (http://osvdb.org). If you use ruby-advisory-db data to build a product or a service, it is your responsibility to familiarize yourself with the terms of their license: http://www.osvdb.org/osvdb_license
4
+
5
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,72 @@
1
+ # Ruby Advisory Database
2
+
3
+ The Ruby Mem Database is a community effort to compile all memory leaks that are relevant to Ruby gems.
4
+
5
+ You can check your own Gemfile.locks against this database by using [bundler-leak](https://github.com/rubymem/bundler-leak).
6
+
7
+ ## Support Ruby security!
8
+
9
+ Do you know about a memory leak that isn't listed in this database? Open an issue, submit a PR, or [use this form](https://rubymem.com/advisories/new) which will email the maintainers.
10
+
11
+ ## Directory Structure
12
+
13
+ The database is a list of directories that match the names of Ruby libraries on
14
+ [rubygems.org]. Within each directory are one or more files
15
+ for the Ruby library. These files are named using
16
+ the advisories can be named however you want, in this example it is named after the PR number in github.
17
+
18
+ gems/:
19
+ celluloid/:
20
+ 612.yml
21
+
22
+
23
+ ## Format
24
+
25
+ Each file contains the information in [YAML] format:
26
+
27
+ ---
28
+ gem: examplegem
29
+ url: https://github.com/celluloid/celluloid/issues/670
30
+ title: Memory Leak using Examplegem::Future
31
+ date: 2015-08-31
32
+ description: |
33
+ The ExampleGem::Group::Spawner appears to never clean up the completed Threads
34
+ that it creates.
35
+ leaky_versions:
36
+ - "> 0.16.0, < 0.17.2
37
+ patched_versions:
38
+ - "~> 0.17.3"
39
+ unaffected_versions:
40
+ - < 0.16.0
41
+
42
+
43
+ ### Schema
44
+
45
+ * `gem` \[String\]: Name of the affected gem.
46
+ * `framework` \[String\] (optional): Name of the framework which the affected
47
+ gem belongs to.
48
+ * `platform` \[String\] (optional): If this vulnerability is platform-specific, name of platform this vulnerability affects (e.g. jruby)
49
+ * `url` \[String\]: The URL to the full advisory.
50
+ * `title` \[String\]: The title of the advisory or individual vulnerability.
51
+ * `date` \[Date\]: The public disclosure date of the advisory.
52
+ * `description` \[String\]: One or more paragraphs describing the vulnerability.
53
+ * `unaffected_versions` \[Array\<String\>\] (optional): The version requirements for the
54
+ unaffected versions of the Ruby library.
55
+ * `patched_versions` \[Array\<String\>\]: The version requirements for the
56
+ patched versions of the Ruby library.
57
+
58
+ ### Tests
59
+ Prior to submitting a pull request, run the tests:
60
+
61
+ ```
62
+ bundle install
63
+ bundle exec rspec
64
+ ```
65
+
66
+ ## Credits
67
+
68
+ Please see [CONTRIBUTORS.md].
69
+
70
+ [rubygems.org]: https://rubygems.org/
71
+ [YAML]: http://www.yaml.org/
72
+ [CONTRIBUTORS.md]: https://github.com/rubymem/ruby-mem-advisory-db/blob/master/CONTRIBUTORS.md
@@ -0,0 +1,26 @@
1
+ require 'yaml'
2
+
3
+ namespace :lint do
4
+ begin
5
+ require 'rspec/core/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:yaml)
8
+ rescue LoadError => e
9
+ task :spec do
10
+ abort "Please run `gem install rspec` to install RSpec."
11
+ end
12
+ end
13
+
14
+ task :cve do
15
+ Dir.glob('{gems,libraries,rubies}/*/*.yml') do |path|
16
+ advisory = YAML.load_file(path)
17
+
18
+ unless advisory['cve']
19
+ puts "Missing CVE: #{path}"
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ task :lint => ['lint:yaml', 'lint:cve']
26
+ task :default => :lint
@@ -0,0 +1,10 @@
1
+ ---
2
+ gem: celluloid
3
+ url: https://github.com/celluloid/celluloid/issues/670
4
+ title: Memory Leak using Celluloid::Future
5
+ date: 2015-08-31
6
+ description: |
7
+ The Celluloid::Group::Spawner appears to never clean up the completed Threads
8
+ that it creates.
9
+ leaky_versions:
10
+ - "> 0.16.0, < 0.17.2"
@@ -0,0 +1,9 @@
1
+ ---
2
+ gem: grape
3
+ url: https://github.com/ruby-grape/grape/issues/301
4
+ title: Memory leak in formatter middleware
5
+ date: 2012-12-27
6
+ description: |
7
+ The call for .to_sym will leak the symbol since those are never garbage collected. Malicious users can abuse.
8
+ leaky_versions:
9
+ - "< 0.2.5"
@@ -0,0 +1,9 @@
1
+ ---
2
+ gem: oj
3
+ url: https://github.com/ohler55/oj/issues/229
4
+ title: Memory Leak using Oj::Doc.open
5
+ date: 2015-04-18
6
+ description: |
7
+ Oj::Doc.open steadily increases memory usage.
8
+ leaky_versions:
9
+ - "< 2.12.4"
@@ -0,0 +1,12 @@
1
+ ---
2
+ gem: redcarpet
3
+ url: https://github.com/vmg/redcarpet/pull/516
4
+ title: Memory Leak in Redcarpet::Render::Base
5
+ date: 2015-09-11
6
+ description: |
7
+ rb_redcarpet_rbase_alloc used to allocate a struct rb_redcarpet_rndr instance
8
+ which was never freed.
9
+
10
+ This caused 312 leaked bytes (on a 64-bit machine) on every render call
11
+ leaky_versions:
12
+ - "< 3.3.3"
@@ -0,0 +1,9 @@
1
+ ---
2
+ gem: redis
3
+ url: https://github.com/redis/redis-rb/issues/612
4
+ title: Memory Leak using Celluloid::Future
5
+ date: 2016-04-25
6
+ description: |
7
+ write_timeout results in lots of short-lived threads created, since each timeout block creates a separate thread. Now every write to Redis requires the creation of a new Thread.
8
+ leaky_versions:
9
+ - "= 3.3.0"
@@ -0,0 +1,9 @@
1
+ ---
2
+ gem: sidekiq-statistic
3
+ url: https://github.com/davydovanton/sidekiq-statistic/issues/73
4
+ title: Memory Leak since timeslist does not expire
5
+ date: 2015-09-15
6
+ description: |
7
+ The timeslist should be expired after some amount of time and the times aggregated into a much more compact form.
8
+ leaky_versions:
9
+ - "<= 1.2"
@@ -0,0 +1,9 @@
1
+ ---
2
+ gem: sidekiq
3
+ url: https://github.com/mperham/sidekiq/pull/2598
4
+ title: Memory Leak in Sidekiq::Manager#real_thread
5
+ date: 2015-10-09
6
+ description: |
7
+ Before starting to execute the task, Processor does an async call to Manager (real_thread method) to add processor's thread to @threads hash in Manager
8
+ leaky_versions:
9
+ - "< 3.5.1"
@@ -0,0 +1,13 @@
1
+ ---
2
+ gem: therubyracer
3
+ url: https://github.com/cowboyd/therubyracer/pull/336
4
+ title: Memory leak in WeakValueMap
5
+ date: 2015-03-31
6
+ description: |
7
+ Entries were not being cleaned up correctly from the backing store.
8
+ leaky_versions:
9
+ - "< 0.12.2"
10
+ unaffected_versions:
11
+ - "~> 0.12.3"
12
+ patched_versions:
13
+ - "~> 0.12.3"
@@ -0,0 +1,9 @@
1
+ ---
2
+ gem: zipruby
3
+ url: https://packetstormsecurity.com/files/111242/libzip-0.10-Heap-Overflow-Information-Leak.html
4
+ title: Heap overflow, information leak
5
+ date: 2012-03-21
6
+ description: |
7
+ libzip has two vulnerabilities that may lead to a heap overflow or an information leak via corrupted zip files.
8
+ leaky_versions:
9
+ - "<= 0.3.6"
@@ -0,0 +1,18 @@
1
+ #!/bin/bash
2
+
3
+ set -o errexit -o nounset
4
+
5
+ REPO="https://${GH_TOKEN}@github.com/rubysec/rubysec.github.io.git"
6
+ DIR="_site"
7
+
8
+ git clone $REPO $DIR
9
+
10
+ cd $DIR
11
+
12
+ git config user.name "RubySec CI"
13
+ git config user.email "ci@rubysec.com"
14
+
15
+ bundle install --jobs=3 --retry=3
16
+ bundle exec rake advisories
17
+
18
+ git push -q
@@ -0,0 +1,23 @@
1
+ load File.join(File.dirname(__FILE__), 'spec_helper.rb')
2
+ require 'gem_example'
3
+ require 'library_example'
4
+ require 'ruby_example'
5
+
6
+ describe "gems" do
7
+ Dir.glob(File.join(File.dirname(__FILE__), '../gems/*/*')) do |path|
8
+ include_examples 'Gem Advisory', path
9
+ end
10
+ end
11
+
12
+ describe "libraries" do
13
+ Dir.glob(File.join(File.dirname(__FILE__), '../libraries/*/*')) do |path|
14
+ include_examples 'Libraries Advisory', path
15
+ end
16
+ end
17
+
18
+ describe "rubies" do
19
+ Dir.glob(File.join(File.dirname(__FILE__), '../rubies/*/*')) do |path|
20
+ include_examples 'Rubies Advisory', path
21
+ end
22
+ end
23
+
@@ -0,0 +1,209 @@
1
+ load File.join(File.dirname(__FILE__), 'spec_helper.rb')
2
+ require 'yaml'
3
+
4
+ shared_examples_for 'Advisory' do |path|
5
+ advisory = YAML.load_file(path)
6
+
7
+ describe path do
8
+ let(:filename) { File.basename(path) }
9
+
10
+ let(:filename_cve) do
11
+ if filename.start_with?('CVE-')
12
+ filename.gsub('CVE-','')
13
+ end
14
+ end
15
+
16
+ let(:filename_osvdb) do
17
+ if filename.start_with?('OSVDB-')
18
+ filename.gsub('OSVDB-','')
19
+ end
20
+ end
21
+
22
+ it "should be correctly named CVE-XXX or OSVDB-XXX" do
23
+ expect(filename).
24
+ to match(/^(CVE-\d{4}-(0\d{3}|[1-9]\d{3,})|OSVDB-\d+)\.yml$/)
25
+ end
26
+
27
+ it "should have CVE or OSVDB" do
28
+ expect(advisory['cve'] || advisory['osvdb']).not_to be_nil
29
+ end
30
+
31
+ describe "framework" do
32
+ subject { advisory['framework'] }
33
+
34
+ it "may be nil or a String" do
35
+ expect(subject).to be_kind_of(String).or(be_nil)
36
+ end
37
+ end
38
+
39
+ describe "platform" do
40
+ subject { advisory['platform'] }
41
+
42
+ it "may be nil or a String" do
43
+ expect(subject).to be_kind_of(String).or(be_nil)
44
+ end
45
+ end
46
+
47
+ describe "cve" do
48
+ subject { advisory['cve'] }
49
+
50
+ it "may be nil or a String" do
51
+ expect(subject).to be_kind_of(String).or(be_nil)
52
+ end
53
+ it "should be id in filename if filename is CVE-XXX" do
54
+ if filename_cve
55
+ is_expected.to eq(filename_cve.chomp('.yml'))
56
+ end
57
+ end
58
+ end
59
+
60
+ describe "osvdb" do
61
+ subject { advisory['osvdb'] }
62
+
63
+ it "may be nil or a Integer" do
64
+ expect(subject).to be_kind_of(Integer).or(be_nil)
65
+ end
66
+
67
+ it "should be id in filename if filename is OSVDB-XXX" do
68
+ if filename_osvdb
69
+ is_expected.to eq(filename_osvdb.to_i)
70
+ end
71
+ end
72
+ end
73
+
74
+ describe "url" do
75
+ subject { advisory['url'] }
76
+
77
+ it { is_expected.to be_kind_of(String) }
78
+ it { is_expected.not_to be_empty }
79
+ end
80
+
81
+ describe "title" do
82
+ subject { advisory['title'] }
83
+
84
+ it { is_expected.to be_kind_of(String) }
85
+ it { is_expected.not_to be_empty }
86
+ end
87
+
88
+ describe "date" do
89
+ subject { advisory['date'] }
90
+
91
+ it { is_expected.to be_kind_of(Date) }
92
+ end
93
+
94
+ describe "description" do
95
+ subject { advisory['description'] }
96
+
97
+ it { is_expected.to be_kind_of(String) }
98
+ it { is_expected.not_to be_empty }
99
+ end
100
+
101
+ describe "cvss_v2" do
102
+ subject { advisory['cvss_v2'] }
103
+
104
+ it "may be nil or a Float" do
105
+ expect(subject).to be_kind_of(Float).or(be_nil)
106
+ end
107
+
108
+ case advisory['cvss_v2']
109
+ when Float
110
+ context "when a Float" do
111
+ it { expect((0.0)..(10.0)).to include(subject) }
112
+ end
113
+ end
114
+ end
115
+
116
+ describe "cvss_v3" do
117
+ subject { advisory['cvss_v3'] }
118
+
119
+ it "may be nil or a Float" do
120
+ expect(subject).to be_kind_of(Float).or(be_nil)
121
+ end
122
+
123
+ case advisory['cvss_v3']
124
+ when Float
125
+ context "when a Float" do
126
+ it { expect((0.0)..(10.0)).to include(subject) }
127
+ end
128
+ end
129
+
130
+ if advisory['cvss_v2']
131
+ it "should also provide a cvss_v2 score" do
132
+ expect(advisory['cvss_v2']).to_not be_nil
133
+ end
134
+ end
135
+ end
136
+
137
+ describe "patched_versions" do
138
+ subject { advisory['patched_versions'] }
139
+
140
+ it "may be nil or an Array" do
141
+ expect(subject).to be_kind_of(Array).or(be_nil)
142
+ end
143
+
144
+ describe "each patched version" do
145
+ if advisory['patched_versions']
146
+ advisory['patched_versions'].each do |version|
147
+ describe version do
148
+ subject { version.split(', ') }
149
+
150
+ it "should contain valid RubyGem version requirements" do
151
+ expect {
152
+ Gem::Requirement.new(*subject)
153
+ }.not_to raise_error
154
+ end
155
+ end
156
+ end
157
+ end
158
+ end
159
+ end
160
+
161
+ describe "unaffected_versions" do
162
+ subject { advisory['unaffected_versions'] }
163
+
164
+ it "may be nil or an Array" do
165
+ expect(subject).to be_kind_of(Array).or(be_nil)
166
+ end
167
+
168
+ case advisory['unaffected_versions']
169
+ when Array
170
+ advisory['unaffected_versions'].each do |version|
171
+ describe version do
172
+ subject { version.split(', ') }
173
+
174
+ it "should contain valid RubyGem version requirements" do
175
+ expect {
176
+ Gem::Requirement.new(*subject)
177
+ }.not_to raise_error
178
+ end
179
+ end
180
+ end
181
+ end
182
+ end
183
+
184
+ describe "related" do
185
+ subject { advisory['related'] }
186
+
187
+ it "may be nil or a Hash" do
188
+ expect(subject).to be_kind_of(Hash).or(be_nil)
189
+ end
190
+
191
+ case advisory["related"]
192
+ when Hash
193
+ advisory["related"].each_pair do |name, values|
194
+ describe name do
195
+ it "should be either a cve, an osvdb or a url" do
196
+ expect(["cve", "osvdb", "url"]).to include(name)
197
+ end
198
+
199
+ it "should always contain an array" do
200
+ expect(values).to be_kind_of(Array)
201
+ end
202
+ end
203
+ end
204
+ end
205
+ end
206
+
207
+
208
+ end
209
+ end