Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat[patch]: support for patch verb #38

Merged
merged 14 commits into from
Aug 6, 2021
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ response.body

### API reference

`SsrfFilter.get/.put/.post/.delete/.head(url, options = {}, &block)`
`SsrfFilter.get/.put/.post/.delete/.head/.patch(url, options = {}, &block)`

Fetches the requested url using a get/put/post/delete/head request, respectively.
Fetches the requested url using a get/put/post/delete/head/patch request, respectively.

Params:
- `url` — the url to fetch.
Expand Down
5 changes: 3 additions & 2 deletions lib/ssrf_filter/ssrf_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def self.prefixlen_from_ipaddr(ipaddr)
put: ::Net::HTTP::Put,
post: ::Net::HTTP::Post,
delete: ::Net::HTTP::Delete,
head: ::Net::HTTP::Head
head: ::Net::HTTP::Head,
patch: ::Net::HTTP::Patch
}.freeze

FIBER_LOCAL_KEY = :__ssrf_filter_hostname
Expand All @@ -100,7 +101,7 @@ class TooManyRedirects < Error
class CRLFInjection < Error
end

%i[get put post delete head].each do |method|
%i[get put post delete head patch].each do |method|
define_singleton_method(method) do |url, options = {}, &block|
::SsrfFilter::Patch::SSLSocket.apply!
::SsrfFilter::Patch::HTTPGenericRequest.apply!
Expand Down
2 changes: 2 additions & 0 deletions ssrf_filter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Gem::Specification.new do |gem|

gem.add_development_dependency('bundler-audit', '~> 0.6.1')
gem.add_development_dependency('coveralls', '~> 0.8.22')
gem.add_development_dependency('psych', '< 4')
gem.add_development_dependency('rspec', '~> 3.8.0')
gem.add_development_dependency('webmock', '>= 3.5.1')
gem.add_development_dependency('webrick') if major >= 3
Expand All @@ -31,6 +32,7 @@ Gem::Specification.new do |gem|
# ssrf_filter doesn't use public_suffix directly, it's required by `addressable` which is required
# by `webmock`. We need to set this requirement here to pin a version that is compatible with ruby 2.0
gem.add_development_dependency('public_suffix', '2.0.5')
gem.add_development_dependency('rexml', '3.2.4')
gem.add_development_dependency('rubocop', '~> 0.50.0')
end
end