File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed
appsec/src/test/groovy/com/datadog/appsec/user
instrumentation/spring-security-5/src/main/java/datadog/trace/instrumentation/springsecurity5
internal-api/src/main/java/datadog/trace/api/appsec Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -268,6 +268,15 @@ class AppSecEventTrackerSpecification extends DDSpecification {
268
268
thrown(BlockingException)
269
269
}
270
270
271
+ void ' should not fail on null callback' () {
272
+ when:
273
+ tracker.onUserEvent(UserIdCollectionMode.IDENTIFICATION, ' test- user' )
274
+
275
+ then:
276
+ noExceptionThrown()
277
+ provider.getCallback(EVENTS.user()) >> null
278
+ }
279
+
271
280
private static class ActionFlow<T> implements Flow<T> {
272
281
273
282
private Action action
Original file line number Diff line number Diff line change 1
1
package datadog .trace .instrumentation .springsecurity5 ;
2
2
3
3
import java .util .function .Supplier ;
4
+ import org .slf4j .Logger ;
5
+ import org .slf4j .LoggerFactory ;
4
6
import org .springframework .security .core .context .SecurityContext ;
5
7
6
8
public class AppSecDeferredContext implements Supplier <SecurityContext > {
7
9
10
+ private static final Logger LOGGER = LoggerFactory .getLogger (AppSecDeferredContext .class );
11
+
8
12
private final Supplier <SecurityContext > delegate ;
9
13
10
14
public AppSecDeferredContext (final Supplier <SecurityContext > delegate ) {
@@ -15,7 +19,11 @@ public AppSecDeferredContext(final Supplier<SecurityContext> delegate) {
15
19
public SecurityContext get () {
16
20
SecurityContext context = delegate .get ();
17
21
if (context != null ) {
18
- SpringSecurityUserEventDecorator .DECORATE .onUser (context .getAuthentication ());
22
+ try {
23
+ SpringSecurityUserEventDecorator .DECORATE .onUser (context .getAuthentication ());
24
+ } catch (Throwable e ) {
25
+ LOGGER .debug ("Error handling user event" , e );
26
+ }
19
27
}
20
28
return context ;
21
29
}
Original file line number Diff line number Diff line change @@ -142,6 +142,9 @@ private <T> void dispatch(
142
142
return ;
143
143
}
144
144
final T callback = cbp .getCallback (event );
145
+ if (callback == null ) {
146
+ return ;
147
+ }
145
148
final Flow <Void > flow = consumer .apply (ctx , callback );
146
149
if (flow == null ) {
147
150
return ;
You can’t perform that action at this time.
0 commit comments