@@ -74,9 +74,6 @@ public class AppSecRequestContext implements DataBundle, Closeable {
74
74
public static final Set <String > RESPONSE_HEADERS_ALLOW_LIST =
75
75
new TreeSet <>(
76
76
Arrays .asList ("content-length" , "content-type" , "content-encoding" , "content-language" ));
77
- public static final int DD_WAF_RUN_INTERNAL_ERROR = -3 ;
78
- public static final int DD_WAF_RUN_INVALID_OBJECT_ERROR = -2 ;
79
- public static final int DD_WAF_RUN_INVALID_ARGUMENT_ERROR = -1 ;
80
77
81
78
static {
82
79
REQUEST_HEADERS_ALLOW_LIST .addAll (DEFAULT_REQUEST_HEADERS_ALLOW_LIST );
@@ -122,15 +119,15 @@ public class AppSecRequestContext implements DataBundle, Closeable {
122
119
private volatile WafMetrics wafMetrics ;
123
120
private volatile WafMetrics raspMetrics ;
124
121
private final AtomicInteger raspMetricsCounter = new AtomicInteger (0 );
125
- private volatile boolean blocked ;
122
+
123
+ private volatile boolean wafBlocked ;
124
+ private volatile boolean wafErrors ;
125
+ private volatile boolean wafTruncated ;
126
+ private volatile boolean wafRequestBlockFailure ;
127
+ private volatile boolean wafRateLimited ;
128
+
126
129
private volatile int wafTimeouts ;
127
130
private volatile int raspTimeouts ;
128
- private volatile int raspInternalErrors ;
129
- private volatile int raspInvalidObjectErrors ;
130
- private volatile int raspInvalidArgumentErrors ;
131
- private volatile int wafInternalErrors ;
132
- private volatile int wafInvalidObjectErrors ;
133
- private volatile int wafInvalidArgumentErrors ;
134
131
135
132
// keep a reference to the last published usr.id
136
133
private volatile String userId ;
@@ -150,29 +147,6 @@ public class AppSecRequestContext implements DataBundle, Closeable {
150
147
private static final AtomicIntegerFieldUpdater <AppSecRequestContext > RASP_TIMEOUTS_UPDATER =
151
148
AtomicIntegerFieldUpdater .newUpdater (AppSecRequestContext .class , "raspTimeouts" );
152
149
153
- private static final AtomicIntegerFieldUpdater <AppSecRequestContext >
154
- RASP_INTERNAL_ERRORS_UPDATER =
155
- AtomicIntegerFieldUpdater .newUpdater (AppSecRequestContext .class , "raspInternalErrors" );
156
- private static final AtomicIntegerFieldUpdater <AppSecRequestContext >
157
- RASP_INVALID_OBJECT_ERRORS_UPDATER =
158
- AtomicIntegerFieldUpdater .newUpdater (
159
- AppSecRequestContext .class , "raspInvalidObjectErrors" );
160
- private static final AtomicIntegerFieldUpdater <AppSecRequestContext >
161
- RASP_INVALID_ARGUMENT_ERRORS_UPDATER =
162
- AtomicIntegerFieldUpdater .newUpdater (
163
- AppSecRequestContext .class , "raspInvalidArgumentErrors" );
164
-
165
- private static final AtomicIntegerFieldUpdater <AppSecRequestContext > WAF_INTERNAL_ERRORS_UPDATER =
166
- AtomicIntegerFieldUpdater .newUpdater (AppSecRequestContext .class , "wafInternalErrors" );
167
- private static final AtomicIntegerFieldUpdater <AppSecRequestContext >
168
- WAF_INVALID_OBJECT_ERRORS_UPDATER =
169
- AtomicIntegerFieldUpdater .newUpdater (
170
- AppSecRequestContext .class , "wafInvalidObjectErrors" );
171
- private static final AtomicIntegerFieldUpdater <AppSecRequestContext >
172
- WAF_INVALID_ARGUMENT_ERRORS_UPDATER =
173
- AtomicIntegerFieldUpdater .newUpdater (
174
- AppSecRequestContext .class , "wafInvalidArgumentErrors" );
175
-
176
150
// to be called by the Event Dispatcher
177
151
public void addAll (DataBundle newData ) {
178
152
for (Map .Entry <Address <?>, Object > entry : newData ) {
@@ -206,86 +180,60 @@ public AtomicInteger getRaspMetricsCounter() {
206
180
return raspMetricsCounter ;
207
181
}
208
182
209
- public void setBlocked () {
210
- this .blocked = true ;
183
+ public void setWafBlocked () {
184
+ this .wafBlocked = true ;
211
185
}
212
186
213
- public boolean isBlocked () {
214
- return blocked ;
187
+ public boolean isWafBlocked () {
188
+ return wafBlocked ;
215
189
}
216
190
217
- public void increaseWafTimeouts () {
218
- WAF_TIMEOUTS_UPDATER . incrementAndGet ( this ) ;
191
+ public void setWafErrors () {
192
+ this . wafErrors = true ;
219
193
}
220
194
221
- public void increaseRaspTimeouts () {
222
- RASP_TIMEOUTS_UPDATER . incrementAndGet ( this ) ;
195
+ public boolean hasWafErrors () {
196
+ return wafErrors ;
223
197
}
224
198
225
- public void increaseRaspErrorCode (int code ) {
226
- switch (code ) {
227
- case DD_WAF_RUN_INTERNAL_ERROR :
228
- RASP_INTERNAL_ERRORS_UPDATER .incrementAndGet (this );
229
- break ;
230
- case DD_WAF_RUN_INVALID_OBJECT_ERROR :
231
- RASP_INVALID_OBJECT_ERRORS_UPDATER .incrementAndGet (this );
232
- break ;
233
- case DD_WAF_RUN_INVALID_ARGUMENT_ERROR :
234
- RASP_INVALID_ARGUMENT_ERRORS_UPDATER .incrementAndGet (this );
235
- break ;
236
- default :
237
- break ;
238
- }
199
+ public void setWafTruncated () {
200
+ this .wafTruncated = true ;
239
201
}
240
202
241
- public void increaseWafErrorCode (int code ) {
242
- switch (code ) {
243
- case DD_WAF_RUN_INTERNAL_ERROR :
244
- WAF_INTERNAL_ERRORS_UPDATER .incrementAndGet (this );
245
- break ;
246
- case DD_WAF_RUN_INVALID_OBJECT_ERROR :
247
- WAF_INVALID_OBJECT_ERRORS_UPDATER .incrementAndGet (this );
248
- break ;
249
- case DD_WAF_RUN_INVALID_ARGUMENT_ERROR :
250
- WAF_INVALID_ARGUMENT_ERRORS_UPDATER .incrementAndGet (this );
251
- break ;
252
- default :
253
- break ;
254
- }
203
+ public boolean isWafTruncated () {
204
+ return wafTruncated ;
255
205
}
256
206
257
- public int getWafTimeouts () {
258
- return wafTimeouts ;
207
+ public void setWafRequestBlockFailure () {
208
+ this . wafRequestBlockFailure = true ;
259
209
}
260
210
261
- public int getRaspTimeouts () {
262
- return raspTimeouts ;
211
+ public boolean isWafRequestBlockFailure () {
212
+ return wafRequestBlockFailure ;
263
213
}
264
214
265
- public int getRaspError (int code ) {
266
- switch (code ) {
267
- case DD_WAF_RUN_INTERNAL_ERROR :
268
- return raspInternalErrors ;
269
- case DD_WAF_RUN_INVALID_OBJECT_ERROR :
270
- return raspInvalidObjectErrors ;
271
- case DD_WAF_RUN_INVALID_ARGUMENT_ERROR :
272
- return raspInvalidArgumentErrors ;
273
- default :
274
- return 0 ;
275
- }
215
+ public void setWafRateLimited () {
216
+ this .wafRateLimited = true ;
276
217
}
277
218
278
- public int getWafError (int code ) {
279
- switch (code ) {
280
- case DD_WAF_RUN_INTERNAL_ERROR :
281
- return wafInternalErrors ;
282
- case DD_WAF_RUN_INVALID_OBJECT_ERROR :
283
- return wafInvalidObjectErrors ;
284
- case DD_WAF_RUN_INVALID_ARGUMENT_ERROR :
285
- return wafInvalidArgumentErrors ;
286
- default :
287
- return 0 ;
288
- }
219
+ public boolean isWafRateLimited () {
220
+ return wafRateLimited ;
221
+ }
222
+
223
+ public void increaseWafTimeouts () {
224
+ WAF_TIMEOUTS_UPDATER .incrementAndGet (this );
225
+ }
226
+
227
+ public void increaseRaspTimeouts () {
228
+ RASP_TIMEOUTS_UPDATER .incrementAndGet (this );
229
+ }
230
+
231
+ public int getWafTimeouts () {
232
+ return wafTimeouts ;
233
+ }
234
+
235
+ public int getRaspTimeouts () {
236
+ return raspTimeouts ;
289
237
}
290
238
291
239
public WafContext getOrCreateWafContext (WafHandle ctx , boolean createMetrics , boolean isRasp ) {
0 commit comments