File tree Expand file tree Collapse file tree 5 files changed +25
-6
lines changed
lib/datadog/appsec/configuration
spec/datadog/appsec/contrib Expand file tree Collapse file tree 5 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -319,10 +319,17 @@ def self.add_settings!(base)
319
319
o . default false
320
320
end
321
321
322
+ # NOTE: Unfortunately, we have to go with Float due to other libs
323
+ # setup, even tho we don't plan to support sub-second delays.
324
+ #
325
+ # WARNING: The value will be converted to Integer.
322
326
option :sample_delay do |o |
323
- o . type :int
327
+ o . type :float
324
328
o . env 'DD_API_SECURITY_SAMPLE_DELAY'
325
329
o . default 30
330
+ o . setter do |value |
331
+ value . to_i
332
+ end
326
333
end
327
334
328
335
option :sample_rate do |o |
Original file line number Diff line number Diff line change 173
173
c . appsec . user_id_denylist = appsec_user_id_denylist
174
174
c . appsec . ruleset = appsec_ruleset
175
175
c . appsec . api_security . enabled = api_security_enabled
176
- c . appsec . api_security . sample_rate = api_security_sample
176
+ c . appsec . api_security . sample_delay = api_security_sample . to_i
177
177
178
178
c . remote . enabled = remote_enabled
179
179
end
180
180
end
181
+
182
+ allow_any_instance_of ( Datadog ::Tracing ::Transport ::HTTP ::Client ) . to receive ( :send_request )
183
+ allow_any_instance_of ( Datadog ::Tracing ::Transport ::Traces ::Transport ) . to receive ( :native_events_supported? )
184
+ . and_return ( true )
181
185
end
182
186
183
187
after do
Original file line number Diff line number Diff line change 39
39
let ( :appsec_user_id_denylist ) { [ ] }
40
40
let ( :appsec_ruleset ) { :recommended }
41
41
let ( :api_security_enabled ) { false }
42
- let ( :api_security_sample ) { 0.0 }
42
+ let ( :api_security_sample ) { 0 }
43
43
44
44
let ( :crs_942_100 ) do
45
45
{
104
104
c . appsec . user_id_denylist = appsec_user_id_denylist
105
105
c . appsec . ruleset = appsec_ruleset
106
106
c . appsec . api_security . enabled = api_security_enabled
107
- c . appsec . api_security . sample_rate = api_security_sample
107
+ c . appsec . api_security . sample_delay = api_security_sample . to_i
108
108
end
109
+
110
+ allow_any_instance_of ( Datadog ::Tracing ::Transport ::HTTP ::Client ) . to receive ( :send_request )
111
+ allow_any_instance_of ( Datadog ::Tracing ::Transport ::Traces ::Transport ) . to receive ( :native_events_supported? )
112
+ . and_return ( true )
109
113
end
110
114
111
115
after do
Original file line number Diff line number Diff line change 110
110
c . appsec . user_id_denylist = appsec_user_id_denylist
111
111
c . appsec . ruleset = appsec_ruleset
112
112
c . appsec . api_security . enabled = api_security_enabled
113
- c . appsec . api_security . sample_rate = api_security_sample
113
+ c . appsec . api_security . sample_delay = api_security_sample . to_i
114
114
end
115
+
116
+ allow_any_instance_of ( Datadog ::Tracing ::Transport ::HTTP ::Client ) . to receive ( :send_request )
117
+ allow_any_instance_of ( Datadog ::Tracing ::Transport ::Traces ::Transport ) . to receive ( :native_events_supported? )
118
+ . and_return ( true )
115
119
end
116
120
117
121
after do
Original file line number Diff line number Diff line change 127
127
RSpec . shared_examples 'a trace with AppSec api security tags' do
128
128
context 'with api security enabled' do
129
129
let ( :api_security_enabled ) { true }
130
- let ( :api_security_sample ) { 1. 0 }
130
+ let ( :api_security_sample ) { 0 }
131
131
132
132
it do
133
133
api_security_tags = service_span . send ( :meta ) . select { |key , _value | key . include? ( '_dd.appsec.s' ) }
You can’t perform that action at this time.
0 commit comments