Skip to content

Commit 49978b9

Browse files
committed
Rename RequestPatch to RequestSSRFDetectionPatch
1 parent 8b20539 commit 49978b9

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

gemfiles/ruby_3.3_rest_client_latest.gemfile.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/datadog/appsec/contrib/rest_client/patcher.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ def target_version
1717
end
1818

1919
def patch
20-
require_relative 'request_patch'
20+
require_relative 'request_ssrf_detection_patch'
2121

22-
::RestClient::Request.prepend(RequestPatch)
22+
::RestClient::Request.prepend(RequestSSRFDetectionPatch)
2323
end
2424
end
2525
end

lib/datadog/appsec/contrib/rest_client/request_patch.rb lib/datadog/appsec/contrib/rest_client/request_ssrf_detection_patch.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module AppSec
55
module Contrib
66
module RestClient
77
# Module that adds SSRF detection to RestClient::Request#execute
8-
module RequestPatch
8+
module RequestSSRFDetectionPatch
99
def execute(&block)
1010
return super unless AppSec.rasp_enabled? && AppSec.active_context
1111

sig/datadog/appsec/contrib/rest_client/request_patch.rbs sig/datadog/appsec/contrib/rest_client/request_ssrf_detection_patch.rbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Datadog
22
module AppSec
33
module Contrib
44
module RestClient
5-
module RequestPatch
5+
module RequestSSRFDetectionPatch
66
def self?.execute: () -> void
77
end
88
end

spec/datadog/appsec/contrib/rest_client/request_patch_spec.rb spec/datadog/appsec/contrib/rest_client/request_ssrf_detection_patch_spec.rb

+5-7
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
let(:context) { instance_double(Datadog::AppSec::Context, run_rasp: waf_response) }
88
let(:waf_response) { instance_double(Datadog::AppSec::SecurityEngine::Result::Ok, match?: false) }
99

10-
let(:request_url) { 'http://example.com/success' }
11-
1210
before do
1311
Datadog.configure do |c|
1412
c.appsec.enabled = true
@@ -20,7 +18,7 @@
2018
WebMock.disable_net_connect!(allow: agent_url)
2119
WebMock.enable!(allow: agent_url)
2220

23-
stub_request(:get, request_url).to_return(status: 200, body: 'OK')
21+
stub_request(:get, 'http://example.com/success').to_return(status: 200, body: 'OK')
2422
end
2523

2624
after do
@@ -35,7 +33,7 @@
3533
it 'does not call waf when making a request' do
3634
expect(Datadog::AppSec.active_context).not_to receive(:run_rasp)
3735

38-
RestClient.get(request_url)
36+
RestClient.get('http://example.com/success')
3937
end
4038
end
4139

@@ -45,7 +43,7 @@
4543
it 'does not call waf when making a request' do
4644
expect(Datadog::AppSec.active_context).not_to receive(:run_rasp)
4745

48-
RestClient.get(request_url)
46+
RestClient.get('http://example.com/success')
4947
end
5048
end
5149

@@ -64,11 +62,11 @@
6462
)
6563
)
6664

67-
RestClient.get(request_url)
65+
RestClient.get('http://example.com/success')
6866
end
6967

7068
it 'returns the http response' do
71-
response = RestClient.get(request_url)
69+
response = RestClient.get('http://example.com/success')
7270

7371
expect(response.code).to eq(200)
7472
expect(response.body).to eq('OK')

0 commit comments

Comments
 (0)