ruby-advisory-db-check 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d3f2195662ec7eeeece46bb036349237db636ed8
4
+ data.tar.gz: 083b5b45a24685077b01bce4b4e559a7c0d8c708
5
+ SHA512:
6
+ metadata.gz: c0411dbb637187e7873a1bdcfa09b6f324a1bdb58627f0feaf71bba327786177a49fadded2ebfa79cfef5c432b7e834b1faf76b44b62b980f439869823e0501f
7
+ data.tar.gz: ff0b911700b3b2375b076a008ca05cea9ea0461c631a61f770a2d867b6c54cbedcb12af548d70560f864737f84d95b630e3a0f8592cc76707838050ae93eb2ca
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea/
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ gem 'bundler', '~> 1.5'
5
+ gem 'rubyzip', '~> 1.1.6'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Torsten Braun
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Ruby::Advisory::Db::Check
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ruby-advisory-db-check'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ruby-advisory-db-check
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( http://github.com/<my-github-username>/ruby-advisory-db-check/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,4 @@
1
+ require 'rake'
2
+ require 'ruby_advisory_db_check/version'
3
+
4
+ load 'tasks/ruby_advisory_db_check.rake'
@@ -0,0 +1,3 @@
1
+ module RubyAdvisoryDbCheck
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,69 @@
1
+ require 'open-uri'
2
+ require 'zip'
3
+ require 'yaml'
4
+ require 'bundler'
5
+ require 'rubygems'
6
+
7
+ DATABASE_FILE = 'https://github.com/rubysec/ruby-advisory-db/archive/master.zip'
8
+ TEMP_DIR = 'tmp/check_advisory_db'
9
+ TEMP_FILE = "#{TEMP_DIR}/master.zip"
10
+
11
+ namespace :check_advisory_db do
12
+ desc 'Check the Gems for advisories.'
13
+ task :check => :environment do
14
+ global_result = true
15
+
16
+ # Download the database
17
+ FileUtils::mkdir_p TEMP_DIR
18
+ File.open(TEMP_FILE, 'wb') do |file|
19
+ file.write open(DATABASE_FILE).read
20
+ end
21
+
22
+ # Extract all the advisory YAML files for each Gem
23
+ Zip::File.open("#{TEMP_DIR}/master.zip") do |zipfile|
24
+ zipfile.each do |file|
25
+ if /^ruby-advisory-db-master\/gems\/.*\.yml$/ =~ file.name
26
+ file_path = "#{TEMP_DIR}/#{file.name.gsub(/ruby-advisory-db-master\/gems\//, '')}"
27
+ FileUtils.mkdir_p File.dirname(file_path)
28
+ zipfile.extract(file, file_path)
29
+ end
30
+ end
31
+ end
32
+ FileUtils.remove(TEMP_FILE)
33
+
34
+ # Check all Gem versions for advisories and output them
35
+ Bundler.load.specs.each do |spec|
36
+ spec_dir = "#{TEMP_DIR}/#{spec.name}"
37
+
38
+ if File.directory?(spec_dir)
39
+ Dir["#{spec_dir}/*.yml"].each do |advisory_file|
40
+ result = false
41
+ good_versions = []
42
+ advisory = YAML.load_file(advisory_file)
43
+ advisory['unaffected_versions'].each {|i| good_versions << i} if advisory['unaffected_versions']
44
+ advisory['patched_versions'].each {|i| good_versions << i} if advisory['patched_versions']
45
+
46
+ good_versions.each do |version|
47
+ result |= Gem::Dependency.new('', version).match?('', spec.version) rescue result |= false
48
+ end
49
+
50
+ unless result
51
+ global_result = false
52
+
53
+ puts '------------------------------------------------------------------------'
54
+ puts "#{spec.name} - #{advisory['title']}"
55
+ puts "See: #{advisory['url']}"
56
+ puts ''
57
+ puts advisory['description']
58
+ puts '------------------------------------------------------------------------'
59
+ puts ''
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ # clean the temp files and fail if there was an advisory
66
+ FileUtils.rm_rf(TEMP_DIR)
67
+ fail('One or more Gems have an advisory!') unless global_result
68
+ end
69
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ruby_advisory_db_check/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'ruby-advisory-db-check'
8
+ spec.version = RubyAdvisoryDbCheck::VERSION
9
+ spec.authors = ['Torsten Braun']
10
+ spec.email = ['tbraun@tnt-web-solutions.de']
11
+ spec.summary = %q{Automatically check the ruby-advisory-db Database for advisories in your installed Gems.}
12
+ spec.description = %q{
13
+ This Gem automatically downloads and extracts the ruby-advisory-db Database from Github.
14
+ Than it uses bundler and rubygems to check for advisories in your installed Gems by
15
+ executing a rake task.
16
+ }
17
+ spec.homepage = 'https://github.com/tbraun89/ruby-advisory-db-check'
18
+ spec.license = 'MIT'
19
+
20
+ spec.files = `git ls-files`.split($/)
21
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.add_development_dependency 'bundler', '~> 1.5'
26
+ spec.add_development_dependency 'rake', '~> 0'
27
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-advisory-db-check
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Torsten Braun
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: "\n This Gem automatically downloads and extracts
42
+ the ruby-advisory-db Database from Github.\n Than it uses
43
+ bundler and rubygems to check for advisories in your installed Gems by\n executing
44
+ a rake task.\n "
45
+ email:
46
+ - tbraun@tnt-web-solutions.de
47
+ executables: []
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - ".gitignore"
52
+ - Gemfile
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - lib/ruby_advisory_db_check.rb
57
+ - lib/ruby_advisory_db_check/version.rb
58
+ - lib/tasks/ruby_advisory_db_check.rake
59
+ - ruby-advisory-db-check.gemspec
60
+ homepage: https://github.com/tbraun89/ruby-advisory-db-check
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.2.2
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Automatically check the ruby-advisory-db Database for advisories in your
84
+ installed Gems.
85
+ test_files: []