recent_ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +50 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +78 -0
- data/LICENSE +21 -0
- data/README.md +80 -0
- data/Rakefile +56 -0
- data/bin/console +14 -0
- data/bin/recent_ruby +44 -0
- data/bin/setup +8 -0
- data/lib/recent_ruby/version.rb +3 -0
- data/lib/recent_ruby/xml_ast.rb +55 -0
- data/lib/recent_ruby.rb +80 -0
- data/recent_ruby.gemspec +42 -0
- metadata +172 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 70acf82ea562f877b9336246857d9fa430da031ecce7b2a33177b7466842644c
|
4
|
+
data.tar.gz: 8d7877f3335bc076ed310f466380a81fdca866f4cdad92afba1a2531d60327de
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a04056344a2af842976c31397df0b77e462421afe60b333ed7cb4d286eb8a0ec9d24ea3e57f7411971cdd1289fd8e68ab3ddd9542b50e4ba1a752de403f315c2
|
7
|
+
data.tar.gz: e075082df5ef0d07fec859ee3f168961fbc889c65acfe85f918f784a81da9abb89014dadedb9b5599e8e86847a28dc33f5f4c4fd7d5195b55f4c973e2cdd0362
|
data/.gitignore
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
# Gemfile.lock
|
46
|
+
# .ruby-version
|
47
|
+
# .ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
recent_ruby (0.1.0)
|
5
|
+
methadone (~> 1.9.5)
|
6
|
+
parser
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
aruba (0.14.5)
|
12
|
+
childprocess (>= 0.6.3, < 0.10.0)
|
13
|
+
contracts (~> 0.9)
|
14
|
+
cucumber (>= 1.3.19)
|
15
|
+
ffi (~> 1.9.10)
|
16
|
+
rspec-expectations (>= 2.99)
|
17
|
+
thor (~> 0.19)
|
18
|
+
ast (2.4.0)
|
19
|
+
backports (3.11.3)
|
20
|
+
builder (3.2.3)
|
21
|
+
childprocess (0.9.0)
|
22
|
+
ffi (~> 1.0, >= 1.0.11)
|
23
|
+
coderay (1.1.2)
|
24
|
+
contracts (0.16.0)
|
25
|
+
cucumber (3.1.1)
|
26
|
+
builder (>= 2.1.2)
|
27
|
+
cucumber-core (~> 3.1.0)
|
28
|
+
cucumber-expressions (~> 6.0.0)
|
29
|
+
cucumber-wire (~> 0.0.1)
|
30
|
+
diff-lcs (~> 1.3)
|
31
|
+
gherkin (~> 5.1.0)
|
32
|
+
multi_json (>= 1.7.5, < 2.0)
|
33
|
+
multi_test (>= 0.1.2)
|
34
|
+
cucumber-core (3.1.0)
|
35
|
+
backports (>= 3.8.0)
|
36
|
+
cucumber-tag_expressions (~> 1.1.0)
|
37
|
+
gherkin (>= 5.0.0)
|
38
|
+
cucumber-expressions (6.0.1)
|
39
|
+
cucumber-tag_expressions (1.1.1)
|
40
|
+
cucumber-wire (0.0.1)
|
41
|
+
diff-lcs (1.3)
|
42
|
+
ffi (1.9.25)
|
43
|
+
gherkin (5.1.0)
|
44
|
+
methadone (1.9.5)
|
45
|
+
bundler
|
46
|
+
method_source (0.9.0)
|
47
|
+
multi_json (1.13.1)
|
48
|
+
multi_test (0.1.2)
|
49
|
+
parser (2.5.1.0)
|
50
|
+
ast (~> 2.4.0)
|
51
|
+
power_assert (1.1.2)
|
52
|
+
pry (0.11.3)
|
53
|
+
coderay (~> 1.1.0)
|
54
|
+
method_source (~> 0.9.0)
|
55
|
+
rake (10.5.0)
|
56
|
+
rdoc (6.0.4)
|
57
|
+
rspec-expectations (3.7.0)
|
58
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
59
|
+
rspec-support (~> 3.7.0)
|
60
|
+
rspec-support (3.7.1)
|
61
|
+
test-unit (3.2.8)
|
62
|
+
power_assert
|
63
|
+
thor (0.20.0)
|
64
|
+
|
65
|
+
PLATFORMS
|
66
|
+
ruby
|
67
|
+
|
68
|
+
DEPENDENCIES
|
69
|
+
aruba
|
70
|
+
bundler (~> 1.16)
|
71
|
+
pry
|
72
|
+
rake (~> 10.0)
|
73
|
+
rdoc
|
74
|
+
recent_ruby!
|
75
|
+
test-unit
|
76
|
+
|
77
|
+
BUNDLED WITH
|
78
|
+
1.16.2
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Lucas Luitjes
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# Recent Ruby
|
2
|
+
|
3
|
+
This script takes a Ruby version number, compares it to all available Ruby versions, and throws an error unless the supplied version number contains the latest security patches.
|
4
|
+
|
5
|
+
## Why
|
6
|
+
|
7
|
+
Heroku (and other platforms) use the Gemfile to determine which version of Ruby to use. This means, whenever a Ruby vulnerability is found, you need to personally update your Gemfile in order to be safe. This also means you need to pay close attention to the Ruby security notices. On smaller teams, this is often overlooked.
|
8
|
+
|
9
|
+
For Ruby gems, you can use Brakeman or Hakiri or Github itself to stay up-to-date with security patches. For your Ruby version, you can now use Recent Ruby.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Recent Ruby's installation is pretty standard:
|
14
|
+
|
15
|
+
```
|
16
|
+
$ gem install recent_ruby
|
17
|
+
```
|
18
|
+
|
19
|
+
Or just put it in your Gemfile:
|
20
|
+
|
21
|
+
```
|
22
|
+
gem 'recent_ruby', require: false
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Just add Recent Ruby in your CI/CD build process, wherever you would put Rubocop or Brakeman. Recent Ruby can check either your Gemfile, or whatever is supplied as a command line argument, and checks if that version of Ruby is the most recent TEENY/PATCH release for that minor version. It also makes sure that your minor version is not End-of-Life yet. If your version of Ruby does happen to be out of date and potentially insecure, it exits with status code 1. This means you can simply drop it into your .circle.yml or your Semaphore build step, or wherever you usually put these things.
|
28
|
+
|
29
|
+
## Examples
|
30
|
+
|
31
|
+
Version number supplied on command line (2.3.7 was the latest 2.3 release at the time of this writing):
|
32
|
+
|
33
|
+
```
|
34
|
+
$ recent_ruby --version-string 2.3.1
|
35
|
+
Downloading latest list of Rubies from Github...
|
36
|
+
Comparing version numbers...
|
37
|
+
Current version is 2.3.1, but the latest patch release for 2.3 is 2.3.7!
|
38
|
+
|
39
|
+
$ recent_ruby --version-string 2.3.7
|
40
|
+
Downloading latest list of Rubies from Github...
|
41
|
+
Comparing version numbers...
|
42
|
+
Downloading details for 2.3.7...
|
43
|
+
Checking EOL status...
|
44
|
+
Ruby version check completed successfully.
|
45
|
+
|
46
|
+
$ recent_ruby --version-string 2.0.0-p648
|
47
|
+
Downloading latest list of Rubies from Github...
|
48
|
+
Comparing version numbers...
|
49
|
+
Downloading details for 2.0.0-p648...
|
50
|
+
Checking EOL status...
|
51
|
+
EOL warning found for 2.0.0-p648!
|
52
|
+
```
|
53
|
+
|
54
|
+
Version number specified in Gemfile:
|
55
|
+
|
56
|
+
```
|
57
|
+
$ cat path/to/Gemfile
|
58
|
+
source "https://rubygems.org"
|
59
|
+
|
60
|
+
ruby "2.3.3"
|
61
|
+
|
62
|
+
gem "rbnacl-libsodium"
|
63
|
+
|
64
|
+
$ recent_ruby --gemfile path/to/Gemfile
|
65
|
+
Downloading latest list of Rubies from Github...
|
66
|
+
Comparing version numbers...
|
67
|
+
Current version is 2.3.3, but the latest patch release for 2.3 is 2.3.7!
|
68
|
+
```
|
69
|
+
|
70
|
+
## How
|
71
|
+
|
72
|
+
If `--gemfile` was supplied, we use the parser gem to extract the Ruby version from the Gemfile.
|
73
|
+
|
74
|
+
First, we check that we’re being supplied an MRI stable release. If not, we immediately stop and error with exit code 1. Next, we grab the list of releases from the ruby-build repository and do some comparison to make sure we’re on the latest TEENY/PATCH release. Then we download the build specification from the ruby-build repository, and make sure an End-of-Life warning is not present.
|
75
|
+
|
76
|
+
Since the ruby-build repository is well maintained and used in production by many, it’s a reliable source.
|
77
|
+
|
78
|
+
## Contributing
|
79
|
+
|
80
|
+
Feel free to create issues for any problems you may have. Patches are welcome, especially if they come with a Cucumber scenario.
|
data/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
def dump_load_path
|
2
|
+
puts $LOAD_PATH.join("\n")
|
3
|
+
found = nil
|
4
|
+
$LOAD_PATH.each do |path|
|
5
|
+
next unless File.exist?(File.join(path, 'rspec'))
|
6
|
+
puts "Found rspec in #{path}"
|
7
|
+
if File.exist?(File.join(path, 'rspec', 'core'))
|
8
|
+
puts 'Found core'
|
9
|
+
if File.exist?(File.join(path, 'rspec', 'core', 'rake_task'))
|
10
|
+
puts 'Found rake_task'
|
11
|
+
found = path
|
12
|
+
else
|
13
|
+
puts '!! no rake_task'
|
14
|
+
end
|
15
|
+
else
|
16
|
+
puts '!!! no core'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
if found.nil?
|
20
|
+
puts "Didn't find rspec/core/rake_task anywhere"
|
21
|
+
else
|
22
|
+
puts "Found in #{path}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
require 'bundler'
|
26
|
+
require 'rake/clean'
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
|
30
|
+
require 'cucumber'
|
31
|
+
require 'cucumber/rake/task'
|
32
|
+
gem 'rdoc' # we need the installed RDoc gem, not the system one
|
33
|
+
require 'rdoc/task'
|
34
|
+
|
35
|
+
include Rake::DSL
|
36
|
+
|
37
|
+
Bundler::GemHelper.install_tasks
|
38
|
+
|
39
|
+
Rake::TestTask.new do |t|
|
40
|
+
t.pattern = 'test/tc_*.rb'
|
41
|
+
end
|
42
|
+
|
43
|
+
CUKE_RESULTS = 'results.html'.freeze
|
44
|
+
CLEAN << CUKE_RESULTS
|
45
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
46
|
+
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
|
47
|
+
t.fork = false
|
48
|
+
end
|
49
|
+
|
50
|
+
Rake::RDocTask.new do |rd|
|
51
|
+
rd.main = 'README.rdoc'
|
52
|
+
|
53
|
+
rd.rdoc_files.include('README.rdoc', 'lib/**/*.rb', 'bin/**/*')
|
54
|
+
end
|
55
|
+
|
56
|
+
task default: %i[test features]
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'recent_ruby'
|
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(__FILE__)
|
data/bin/recent_ruby
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'methadone'
|
5
|
+
require 'recent_ruby'
|
6
|
+
require 'net/http'
|
7
|
+
require 'json'
|
8
|
+
require 'parser/current'
|
9
|
+
|
10
|
+
class App
|
11
|
+
include Methadone::Main
|
12
|
+
include Methadone::CLILogging
|
13
|
+
extend RecentRuby
|
14
|
+
|
15
|
+
main do
|
16
|
+
gemfile = options['gemfile']
|
17
|
+
version = options['version-string']
|
18
|
+
|
19
|
+
version_base_url = ENV['VERSION_BASE_URL'] || 'https://raw.githubusercontent.com/rbenv/ruby-build/master/share/ruby-build/'
|
20
|
+
versions_url = ENV['VERSIONS_URL'] || 'https://api.github.com/repos/rbenv/ruby-build/contents/share/ruby-build'
|
21
|
+
|
22
|
+
validate_args(gemfile, version)
|
23
|
+
version = parse_gemfile(gemfile) if gemfile
|
24
|
+
validate_mri_version(version)
|
25
|
+
minor = version.split('.')[0, 2]
|
26
|
+
|
27
|
+
rubies = get_rubies(versions_url)
|
28
|
+
latest = latest_minor_version(rubies, minor)
|
29
|
+
compare_versions(version, latest, minor)
|
30
|
+
|
31
|
+
check_eol(version, version_base_url)
|
32
|
+
|
33
|
+
puts 'Ruby version check completed successfully.'
|
34
|
+
end
|
35
|
+
|
36
|
+
on('--gemfile PATH', 'Path of Gemfile')
|
37
|
+
on('--version-string STRING', 'Ruby version string (e.g. 2.3.1)')
|
38
|
+
|
39
|
+
version RecentRuby::VERSION
|
40
|
+
|
41
|
+
use_log_level_option toggle_debug_on_signal: 'USR1'
|
42
|
+
|
43
|
+
go!
|
44
|
+
end
|
data/bin/setup
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'parser/current'
|
2
|
+
require 'rexml/document'
|
3
|
+
|
4
|
+
module RecentRuby
|
5
|
+
|
6
|
+
# Class comes from: https://medium.com/rubyinside/using-xpath-to-rewrite-ruby-code-with-ease-8f635af65b5b
|
7
|
+
# TODO: turn into a separate gem
|
8
|
+
|
9
|
+
class XMLAST
|
10
|
+
include REXML
|
11
|
+
attr_reader :doc
|
12
|
+
|
13
|
+
def initialize sexp
|
14
|
+
@doc = Document.new "<root></root>"
|
15
|
+
@sexp = sexp
|
16
|
+
root = @doc.root
|
17
|
+
populate_tree(root, sexp)
|
18
|
+
end
|
19
|
+
|
20
|
+
def populate_tree xml, sexp
|
21
|
+
if sexp.is_a?(String) ||
|
22
|
+
sexp.is_a?(Symbol) ||
|
23
|
+
sexp.is_a?(Numeric) ||
|
24
|
+
sexp.is_a?(NilClass)
|
25
|
+
el = Element.new(sexp.class.to_s.downcase + "-val")
|
26
|
+
el.add_attribute 'value', sexp.to_s
|
27
|
+
xml.add_element el
|
28
|
+
else
|
29
|
+
el = Element.new(sexp.type.to_s)
|
30
|
+
el.add_attribute('id', sexp.object_id)
|
31
|
+
|
32
|
+
sexp.children.each{ |n| populate_tree(el, n) }
|
33
|
+
xml.add_element el
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def treewalk sexp=@sexp
|
38
|
+
return sexp unless sexp&.respond_to?(:children)
|
39
|
+
[sexp, sexp.children.map {|n| treewalk(n) }].flatten
|
40
|
+
end
|
41
|
+
|
42
|
+
def xpath path
|
43
|
+
results = XPath.match(doc, path)
|
44
|
+
results.map do |n|
|
45
|
+
if n.respond_to?(:attributes) && n.attributes['id']
|
46
|
+
treewalk.find do |m|
|
47
|
+
m.object_id.to_s == n.attributes['id']
|
48
|
+
end
|
49
|
+
else
|
50
|
+
n
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/recent_ruby.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'recent_ruby/version'
|
2
|
+
require 'recent_ruby/xml_ast'
|
3
|
+
|
4
|
+
module RecentRuby
|
5
|
+
def http_get(url)
|
6
|
+
uri = URI(url)
|
7
|
+
Net::HTTP.start(uri.host, uri.port,
|
8
|
+
use_ssl: uri.scheme == 'https') do |http|
|
9
|
+
request = Net::HTTP::Get.new uri
|
10
|
+
response = http.request request
|
11
|
+
if response.code != '200'
|
12
|
+
puts "Error: received HTTP #{response.code} response from Github:\n\n#{response.body}"
|
13
|
+
exit(2)
|
14
|
+
end
|
15
|
+
response.body
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def validate_args(gemfile, version)
|
20
|
+
if gemfile && version
|
21
|
+
puts 'Please supply only one argument. Run with -h for more information.'
|
22
|
+
exit(1)
|
23
|
+
elsif !gemfile && !version
|
24
|
+
puts 'Please supply either a gemfile path or a version string. Run with -h for more information.'
|
25
|
+
exit(1)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def parse_gemfile(gemfile)
|
30
|
+
ast = Parser::CurrentRuby.parse(File.read(gemfile))
|
31
|
+
xml = RecentRuby::XMLAST.new(ast)
|
32
|
+
version = xml.xpath("//send[symbol-val[@value='ruby']]/str/string-val/@value") || [nil]
|
33
|
+
version = version.first ? version.first.value : nil
|
34
|
+
unless version
|
35
|
+
puts 'Unable to find ruby version in gemfile.'
|
36
|
+
exit(1)
|
37
|
+
end
|
38
|
+
version
|
39
|
+
end
|
40
|
+
|
41
|
+
def validate_mri_version(version)
|
42
|
+
return if version =~ /^(\d+\.\d+\.\d+(-p\d+)?)$/
|
43
|
+
puts 'Only stable release MRI version strings are currently supported. (e.g. 2.3.1 or 2.3.1-p12)'
|
44
|
+
exit(1)
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_rubies(versions_url)
|
48
|
+
puts 'Downloading latest list of Rubies from Github...'
|
49
|
+
JSON.parse(http_get(versions_url))
|
50
|
+
end
|
51
|
+
|
52
|
+
def latest_minor_version(rubies, minor)
|
53
|
+
minor_rubies = rubies.map { |n| n['name'] }.select do |n|
|
54
|
+
n =~ /^\d+\.\d+\.\d+(-p\d+)?$/ &&
|
55
|
+
n.split('.')[0, 2] == minor
|
56
|
+
end
|
57
|
+
|
58
|
+
minor_rubies.max_by do |ruby|
|
59
|
+
a, b, c, d = *ruby.sub('-p', '.').split('.').map(&:to_i)
|
60
|
+
[a, b, c, d || -1]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def check_eol(version, version_base_url)
|
65
|
+
puts "Downloading details for #{version}..."
|
66
|
+
details = http_get("#{version_base_url}#{version}")
|
67
|
+
puts 'Checking EOL status...'
|
68
|
+
|
69
|
+
return unless details =~ / warn_eol /
|
70
|
+
puts "EOL warning found for #{version}!"
|
71
|
+
exit 1
|
72
|
+
end
|
73
|
+
|
74
|
+
def compare_versions(version, latest, minor)
|
75
|
+
puts 'Comparing version numbers...'
|
76
|
+
return if version == latest
|
77
|
+
puts "Current version is #{version}, but the latest patch release for #{minor.join('.')} is #{latest}!"
|
78
|
+
exit 1
|
79
|
+
end
|
80
|
+
end
|
data/recent_ruby.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "recent_ruby/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "recent_ruby"
|
8
|
+
spec.license = "MIT"
|
9
|
+
spec.version = RecentRuby::VERSION
|
10
|
+
spec.authors = ["Lucas Luitjes"]
|
11
|
+
spec.email = ["lucas@luitjes.it"]
|
12
|
+
|
13
|
+
spec.summary = %q{CLI tool for your CI/CD to make sure a recent and secure ruby version is used.}
|
14
|
+
spec.homepage = "https://github.com/lucasluitjes/recent_ruby"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
"public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
# Specify which files should be added to the gem when it is released.
|
26
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
27
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
28
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
29
|
+
end
|
30
|
+
spec.bindir = "bin"
|
31
|
+
spec.executables = "recent_ruby"
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
35
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
36
|
+
spec.add_development_dependency('rdoc')
|
37
|
+
spec.add_development_dependency('pry')
|
38
|
+
spec.add_development_dependency('aruba')
|
39
|
+
spec.add_dependency('methadone', '~> 1.9.5')
|
40
|
+
spec.add_dependency('parser')
|
41
|
+
spec.add_development_dependency('test-unit')
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: recent_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lucas Luitjes
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-21 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.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rdoc
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: aruba
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: methadone
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.9.5
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.9.5
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: parser
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: test-unit
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description:
|
126
|
+
email:
|
127
|
+
- lucas@luitjes.it
|
128
|
+
executables:
|
129
|
+
- recent_ruby
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".gitignore"
|
134
|
+
- Gemfile
|
135
|
+
- Gemfile.lock
|
136
|
+
- LICENSE
|
137
|
+
- README.md
|
138
|
+
- Rakefile
|
139
|
+
- bin/console
|
140
|
+
- bin/recent_ruby
|
141
|
+
- bin/setup
|
142
|
+
- lib/recent_ruby.rb
|
143
|
+
- lib/recent_ruby/version.rb
|
144
|
+
- lib/recent_ruby/xml_ast.rb
|
145
|
+
- recent_ruby.gemspec
|
146
|
+
homepage: https://github.com/lucasluitjes/recent_ruby
|
147
|
+
licenses:
|
148
|
+
- MIT
|
149
|
+
metadata:
|
150
|
+
allowed_push_host: https://rubygems.org
|
151
|
+
post_install_message:
|
152
|
+
rdoc_options: []
|
153
|
+
require_paths:
|
154
|
+
- lib
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
requirements: []
|
166
|
+
rubyforge_project:
|
167
|
+
rubygems_version: 2.7.6
|
168
|
+
signing_key:
|
169
|
+
specification_version: 4
|
170
|
+
summary: CLI tool for your CI/CD to make sure a recent and secure ruby version is
|
171
|
+
used.
|
172
|
+
test_files: []
|