Skip to content

Commit

Permalink
ruby 3.4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
noraj committed Jan 25, 2025
1 parent b0c58df commit cb76d13
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['3.3', '3.2', '3.1', '3.0']
ruby-version: ['3.4', '3.3', '3.2', '3.1']
env:
BUNDLE_WITHOUT: docs development # https://bundler.io/v1.5/groups.html
steps:
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ AllCops:
Exclude:
- 'test/*.rb'
SuggestExtensions: false
TargetRubyVersion: '3.0'
TargetRubyVersion: '3.1'
# ~~~ Layout ~~~
Layout/HashAlignment:
Include:
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ruby 3.3.0
ruby 3.4.1
nodejs 16.13.2
9 changes: 6 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ group :runtime, :cli do
end

group :runtime, :all do
gem 'base64', '~> 0.2.0' # for base64 encoding
gem 'cgi', '~> 0.4.1' # url decode / html escape
gem 'uri', '~> 0.13.1' # for argument parsing
gem 'uri', '~> 1.0', '>= 1.0.2' # for url parsing
end

group :development, :install do
Expand All @@ -28,6 +29,8 @@ group :development, :lint do
end

group :development, :docs do
gem 'commonmarker', '~> 0.23' # for markdown support in YARD
gem 'yard', ['>= 0.9.27', '< 0.10']
gem 'commonmarker', '~> 2.0' # for markdown support in YARD
# gem 'yard', ['>= 0.9.27', '< 0.10']
# https://github.com/lsegal/yard/issues/1528
gem 'yard', github: 'ParadoxV5/yard', ref: '9e869c940859570b07b81c5eadd6070e76f6291e', branch: 'commonmarker-1.0'
end
52 changes: 34 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,62 +1,78 @@
GIT
remote: https://github.com/ParadoxV5/yard.git
revision: 9e869c940859570b07b81c5eadd6070e76f6291e
ref: 9e869c940859570b07b81c5eadd6070e76f6291e
branch: commonmarker-1.0
specs:
yard (0.9.36)

PATH
remote: .
specs:
ctf-party (3.0.0)
base64 (~> 0.2.0)
docopt (~> 0.6)
uri (>= 0.12.1, < 0.14.0)
uri (~> 1.0, >= 1.0.2)

GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
base64 (0.2.0)
cgi (0.4.1)
commonmarker (0.23.10)
commonmarker (2.0.4)
rb_sys (~> 0.9)
commonmarker (2.0.4-x86_64-linux)
docopt (0.6.1)
json (2.7.2)
json (2.9.1)
language_server-protocol (3.17.0.3)
minitest (5.25.1)
minitest (5.25.4)
minitest-skip (0.0.3)
minitest (~> 5.0)
parallel (1.26.3)
parser (3.3.5.0)
parser (3.3.7.0)
ast (~> 2.4.1)
racc
racc (1.8.1)
rainbow (3.1.1)
rake (13.2.1)
regexp_parser (2.9.2)
rubocop (1.66.1)
rb_sys (0.9.108)
regexp_parser (2.10.0)
rubocop (1.71.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.36.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.3)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.37.0)
parser (>= 3.3.1.0)
ruby-progressbar (1.13.0)
unicode-display_width (2.5.0)
uri (0.13.1)
yard (0.9.37)
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
uri (1.0.2)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
base64 (~> 0.2.0)
bundler (~> 2.1)
cgi (~> 0.4.1)
commonmarker (~> 0.23)
commonmarker (~> 2.0)
ctf-party!
docopt (~> 0.6)
minitest (~> 5.25)
minitest-skip (~> 0.0)
rake (~> 13.2)
rubocop (~> 1.66)
uri (~> 0.13.1)
yard (>= 0.9.27, < 0.10)
uri (~> 1.0, >= 1.0.2)
yard!

BUNDLED WITH
2.3.6
2.6.2
5 changes: 3 additions & 2 deletions ctf_party.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ Gem::Specification.new do |s|
'rubygems_mfa_required' => 'true'
}

s.required_ruby_version = ['>= 3.0.0', '< 4.0']
s.required_ruby_version = ['>= 3.1.0', '< 4.0']

s.add_runtime_dependency('base64', '~> 0.2.0')
s.add_runtime_dependency('docopt', '~> 0.6')
s.add_runtime_dependency('uri', '>= 0.12.1', '< 0.14.0')
s.add_runtime_dependency('uri', '~> 1.0', '>= 1.0.2')
end
7 changes: 7 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [unreleased]

- **Breaking changes**
- **Drop Ruby 3.0 support** ([EOL](https://www.ruby-lang.org/en/downloads/branches/))
- Chore:
- Add support for Ruby 3.4

## [3.0.0]

- **Breaking changes**
Expand Down
6 changes: 2 additions & 4 deletions lib/ctf_party/base64.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class String
# 'Super lib!'.to_b64 # => "U3VwZXIgbGliIQ=="
def to_b64(opts = {})
opts[:mode] ||= :strict
return Base64.strict_encode64(self) if opts[:mode] == :strict ||
opts[:mode] == :rfc4648
return Base64.strict_encode64(self) if %i[strict rfc4648].include?(opts[:mode])
return Base64.encode64(self) if opts[:mode] == :rfc2045
return Base64.urlsafe_encode64(self) if opts[:mode] == :urlsafe
end
Expand All @@ -40,8 +39,7 @@ def to_b64!(opts = {})
# 'UnVieQ=='.from_b64 # => "Ruby"
def from_b64(opts = {})
opts[:mode] ||= :strict
return Base64.strict_decode64(self) if opts[:mode] == :strict ||
opts[:mode] == :rfc4648
return Base64.strict_decode64(self) if %i[strict rfc4648].include?(opts[:mode])
return Base64.decode64(self) if opts[:mode] == :rfc2045
return Base64.urlsafe_decode64(self) if opts[:mode] == :urlsafe
end
Expand Down
4 changes: 2 additions & 2 deletions lib/ctf_party/cgi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class String
# 'http://vulnerable.site/search.aspx?txt="><script>alert(/Rubyfu/.source)</script>'.urlencode # => "http://vulnerable.site/search.aspx?txt=%22%3E%3Cscript%3Ealert(/Rubyfu/.source)%3C/script%3E"
# "'Stop!' said Fred".urlencode # => "'Stop!'%20said%20Fred"
def urlencode
URI::Parser.new.escape self
URI::RFC2396_PARSER.escape self
end

# URL-encode the string in place as described for {String#urlencode}.
Expand Down Expand Up @@ -41,7 +41,7 @@ def urlencode_data!
# "'Stop!'%20said%20Fred".urldecode # => "'Stop!' said Fred"
# '%27Stop%21%27+said+Fred'.urldecode # => "'Stop!'+said+Fred"
def urldecode
URI::Parser.new.unescape self
URI::RFC2396_PARSER.unescape self
end

# URL-decode the string in place as described for {String#urldecode}.
Expand Down
8 changes: 4 additions & 4 deletions lib/ctf_party/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ def ip?
ipv4? || ipv6?
end

# Is the string a valid URI?
# Is the string a valid (RFC 2396) URI?
# @param opts [Hash] optional parameters
# @option opts [Symbol] :lax Default value: `false`.
# When `lax: false`, only URI matching common protocols (ftp http https ldap ldaps mailto ws wss) are recognized,
# but is still a bit lax (eg. `http://` is seen as valid).
# When `lax: true`, the parser will accept more types of URI (gopher magnet matrix), but will be very lax and accept
# nearly anything including `:`.
# @return [Boolean] `true` if the string is a valid URI, `false` else.
# @return [Boolean] `true` if the string is a valid (RFC 2396) URI, `false` else.
# @example
# 'ftp://ftp.ruby-lang.org/pub/ruby/3.2/ruby-3.2.0.tar.xz'.uri? # => true
# 'a:'.uri? # => false
# 'a:'.uri?(lax: true) # => true
def uri?(opts = {})
opts[:lax] ||= false
strict = URI::DEFAULT_PARSER.make_regexp(%w[ftp http https ldap ldaps mailto ws wss]).match?(self)
lax = URI::DEFAULT_PARSER.make_regexp.match?(self)
strict = URI::RFC2396_PARSER.make_regexp(%w[ftp http https ldap ldaps mailto ws wss]).match?(self)
lax = URI::RFC2396_PARSER.make_regexp.match?(self)
if opts[:lax] == true
strict || lax
else
Expand Down

0 comments on commit cb76d13

Please sign in to comment.