bauditor 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7f53e52d93dc0ae2ff905960a4dda662e1e383b2
4
+ data.tar.gz: 3e695a0ec8a309e3bf11021c3f5dbdb00d46abf0
5
+ SHA512:
6
+ metadata.gz: 1acc61e4cbacbcb1bf3a9cc9a91f7b6e76e09474a72253dcdeeaf192e4193d64d47f7767070442a3e00fc4db59f40e7b5a609aa676e37ab4c76512868ea8b7bf
7
+ data.tar.gz: e142e8352fa36286d0e1532ccd57f44b394690e90e9510d94b847b82388fc4e28b18ad4775cd4a4d0570b71be177b5f9972705f2894cb5e80a0c01e9de126287
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at leklund@fastly.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bauditor.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Lukas Eklund
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,120 @@
1
+ # Bauditor
2
+
3
+ Run [bundler-audit](https://github.com/rubysec/bundler-audit) on multiple repositories at once.
4
+
5
+ If you manage many ruby applications it can be a hassle to keep them all up-to-date and audited. This gem can aid in running bundle-audit on many repositories at once. It will do the following:
6
+
7
+ * create a directory in `/tmp/bauditor` (TODO: make this configurable)
8
+ * fetch a list of repos with `git clone repo --branch master --single-branch`
9
+ * run `bundle-audit` on the repositories `Gemfile.lock` and print the output
10
+ * Print a summary reports
11
+ * `rm -rf /tmp/bauditor`
12
+
13
+ ## Installation
14
+
15
+ ```
16
+ $ gem install bauditor
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```
22
+ $ bauditor help audit
23
+
24
+ Usage:
25
+ bauditor audit
26
+
27
+ Options:
28
+ r, [--repos=list of repositories]
29
+ c, [--config=CONFIG_FILE]
30
+
31
+ run bundle-audit on multiple repositories
32
+ ```
33
+
34
+ Repositories must be in a format that can passed to git clone. Currently this only works on the master branch.
35
+
36
+ `audit` is the only command and is the default so `bauditor` can be invoked without a command.
37
+ ### Example
38
+
39
+ ```
40
+ $ cat config
41
+
42
+ git@github.com:leklund/chopped_ingredients.git
43
+ git@github.com:leklund/bitbucket-irc-notification.git
44
+
45
+ $ bauditor -c=config -r=git@github.com:wistia/nsq-ruby.git
46
+ OR
47
+ $ bauditor audit -c=config -r=git@github.com:wistia/nsq-ruby.git
48
+
49
+ [BAUDITOR] Updating the bundle-audit database
50
+ Updating ruby-advisory-db ...
51
+ From https://github.com/rubysec/ruby-advisory-db
52
+ * branch master -> FETCH_HEAD
53
+ Already up-to-date.
54
+ Updated ruby-advisory-db
55
+ ruby-advisory-db: 273 advisories
56
+ ---------------------------------------------------
57
+ [BAUDITOR] fetching and auditing nsq-ruby
58
+ ---------------------------------------------------
59
+ Insecure Source URI found: http://rubygems.org/
60
+ Vulnerabilities found!
61
+ ---------------------------------------------------
62
+ [BAUDITOR] fetching and auditing chopped_ingredients
63
+ ---------------------------------------------------
64
+ No vulnerabilities found
65
+ ---------------------------------------------------
66
+ [BAUDITOR] fetching and auditing bitbucket-irc-notification
67
+ ---------------------------------------------------
68
+ Name: rack
69
+ Version: 1.5.2
70
+ Advisory: CVE-2015-3225
71
+ Criticality: Unknown
72
+ URL: https://groups.google.com/forum/#!topic/ruby-security-ann/gcUbICUmKMc
73
+ Title: Potential Denial of Service Vulnerability in Rack
74
+ Solution: upgrade to >= 1.6.2, ~> 1.5.4, ~> 1.4.6
75
+
76
+ Name: rest-client
77
+ Version: 1.6.7
78
+ Advisory: CVE-2015-1820
79
+ Criticality: Unknown
80
+ URL: https://github.com/rest-client/rest-client/issues/369
81
+ Title: rubygem-rest-client: session fixation vulnerability via Set-Cookie headers in 30x redirection responses
82
+ Solution: upgrade to >= 1.8.0
83
+
84
+ Name: rest-client
85
+ Version: 1.6.7
86
+ Advisory: CVE-2015-3448
87
+ Criticality: Unknown
88
+ URL: http://www.osvdb.org/show/osvdb/117461
89
+ Title: Rest-Client Gem for Ruby logs password information in plaintext
90
+ Solution: upgrade to >= 1.7.3
91
+
92
+ Vulnerabilities found!
93
+ ---------------------------------------------------
94
+ [BAUDITOR] summary report:
95
+ ____________________________________________
96
+ | Repo | Vulnerable? |
97
+ --------------------------------------------
98
+ | nsq-ruby | YES |
99
+ | chopped_ingredients | No |
100
+ | bitbucket-irc-notification | YES |
101
+ --------------------------------------------
102
+
103
+ ```
104
+
105
+ ## Development
106
+
107
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
108
+
109
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
110
+
111
+ ## Contributing
112
+
113
+ Bug reports and pull requests are welcome on GitHub at https://github.com/leklund/bauditor. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
114
+
115
+
116
+ ## License
117
+
118
+ Copyright (c) 2017 Lukas Eklund
119
+
120
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
data/bauditor.gemspec ADDED
@@ -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 'bauditor/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'bauditor'
8
+ spec.version = Bauditor::VERSION
9
+ spec.authors = ['Lukas Eklund']
10
+ spec.email = ['lukas@eklund.io']
11
+
12
+ spec.summary = %q{Run bundler-audit on multiple repositories}
13
+ spec.homepage = 'https://github.com/leklund/bauditor'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = 'exe'
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'thor'
22
+ spec.add_dependency 'bundler-audit'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.12'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'minitest', '~> 5.0'
27
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bauditor"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/bauditor ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
6
+ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
7
+
8
+ require 'bauditor'
9
+
10
+ Bauditor::CLI.start
@@ -0,0 +1,134 @@
1
+ require 'thor'
2
+ require 'fileutils'
3
+
4
+ module Bauditor
5
+ class CLI < ::Thor
6
+ default_task :audit
7
+
8
+ desc 'audit', 'run bundle-audit on multiple repositories'
9
+
10
+ method_option :repos, type: :array, aliases: 'r'
11
+ method_option :config, type: :string, aliases: 'c'
12
+
13
+ def audit
14
+ if options[:repos].nil? && options[:config].nil?
15
+ puts 'Please provide either a list of repos (--repos=one two)'
16
+ puts 'or a configuraiton file --config=repos.cfg'
17
+ exit 1
18
+ end
19
+
20
+ update_db
21
+ set_repos
22
+
23
+ setup_dirs
24
+
25
+ self.summary = {}
26
+ audit_repos
27
+
28
+ summary_report
29
+ ensure
30
+ teardown
31
+ end
32
+
33
+ private
34
+
35
+ attr_accessor :repos, :summary
36
+
37
+ def add_repos_from_config
38
+ self.repos += File.readlines(options[:config]).map(&:chomp)
39
+ end
40
+
41
+ def audit_repos
42
+ repos.each do |repo|
43
+ Dir.chdir repo_path
44
+ unless repo.match(/([^\/]+)\.git$/)
45
+ hr
46
+ say "[BAUDITOR] #{repo} does not appear to be a git repo", :red
47
+ next
48
+ end
49
+ name = $1
50
+ hr
51
+ say "[BAUDITOR] fetching and auditing #{name}", :yellow
52
+ hr
53
+
54
+ git = `git clone #{repo} --branch master --single-branch #{name} 2>&1`
55
+ unless $?.success?
56
+ say "[BAUDITOR] error fetching git repo #{name}", :red
57
+ puts git
58
+ next
59
+ end
60
+
61
+ Dir.chdir name
62
+
63
+ success = system 'bundle-audit'
64
+
65
+ self.summary[name] = success
66
+ end
67
+ hr
68
+ end
69
+
70
+ def repo_path
71
+ options.fetch(:repo_path, '/tmp/bauditor')
72
+ end
73
+
74
+ def hr
75
+ say "---------------------------------------------------", :blue
76
+ end
77
+
78
+ def set_repos
79
+ self.repos = options.fetch(:repos, [])
80
+
81
+ add_repos_from_config if options[:config]
82
+
83
+ self.repos.uniq!
84
+
85
+ if repos.empty?
86
+ puts 'No repositories found'
87
+ exit 1
88
+ end
89
+ end
90
+
91
+ def setup_dirs
92
+ unless File.exist?(repo_path)
93
+ Dir.mkdir(repo_path)
94
+ @dir_created = true
95
+ end
96
+ end
97
+
98
+ def summary_report
99
+ say '[BAUDITOR] summary report:', [:green, :bold]
100
+
101
+ long_name = summary.keys.max_by(&:length)
102
+ pad = long_name.length
103
+
104
+ h = sprintf("| %-#{pad}s | Vulnerable? |", 'Repo')
105
+ say '_' * h.length, :cyan
106
+ say h, :cyan
107
+ say '-' * h.length, :cyan
108
+
109
+ summary.each do |name, status|
110
+ say '| ', :cyan
111
+ say sprintf("%-#{pad}s ", name), :yellow
112
+ say '| ', :cyan
113
+ if status
114
+ say sprintf(' %-9s', 'No '), :green
115
+ else
116
+ say sprintf(' %-9s', 'YES '), [:red, :bold]
117
+ end
118
+ say '|', :cyan
119
+ end
120
+ say '-' * h.length, :cyan
121
+ end
122
+
123
+ def teardown
124
+ Dir.chdir File.dirname(__FILE__)
125
+ return unless @dir_created
126
+ FileUtils.rm_rf repo_path
127
+ end
128
+
129
+ def update_db
130
+ say '[BAUDITOR] Updating the bundle-audit database', :yellow
131
+ system 'bundle exec bundle-audit update'
132
+ end
133
+ end
134
+ end
@@ -0,0 +1,3 @@
1
+ module Bauditor
2
+ VERSION = '0.1.0'
3
+ end
data/lib/bauditor.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'bauditor/version'
2
+ require 'bauditor/cli'
3
+
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bauditor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Lukas Eklund
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-01-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler-audit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.12'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.12'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.0'
83
+ description:
84
+ email:
85
+ - lukas@eklund.io
86
+ executables:
87
+ - bauditor
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".travis.yml"
93
+ - CODE_OF_CONDUCT.md
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bauditor.gemspec
99
+ - bin/console
100
+ - bin/setup
101
+ - exe/bauditor
102
+ - lib/bauditor.rb
103
+ - lib/bauditor/cli.rb
104
+ - lib/bauditor/version.rb
105
+ homepage: https://github.com/leklund/bauditor
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.6.8
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Run bundler-audit on multiple repositories
129
+ test_files: []