Skip to content

Commit

Permalink
Update user lifecycle tracking to V3
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-alvarez-alvarez committed Dec 18, 2024
1 parent a19f73a commit 6ea6598
Show file tree
Hide file tree
Showing 17 changed files with 841 additions and 595 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.datadog.appsec.event.ReplaceableEventProducerService;
import com.datadog.appsec.gateway.GatewayBridge;
import com.datadog.appsec.powerwaf.PowerWAFModule;
import com.datadog.appsec.user.AppSecEventTrackerImpl;
import com.datadog.appsec.util.AbortStartupException;
import com.datadog.appsec.util.StandardizedLogging;
import datadog.appsec.api.blocking.Blocking;
Expand All @@ -17,6 +16,7 @@
import datadog.communication.monitor.Monitoring;
import datadog.remoteconfig.ConfigurationPoller;
import datadog.trace.api.Config;
import datadog.trace.api.GlobalTracer;
import datadog.trace.api.ProductActivation;
import datadog.trace.api.appsec.AppSecEventTracker;
import datadog.trace.api.gateway.SubscriptionService;
Expand Down Expand Up @@ -99,7 +99,7 @@ private static void doStart(SubscriptionService gw, SharedCommunicationObjects s

Blocking.setBlockingService(new BlockingServiceImpl(REPLACEABLE_EVENT_PRODUCER));

AppSecEventTracker.setEventTracker(new AppSecEventTrackerImpl());
GlobalTracer.setEventTracker(AppSecEventTracker.getEventTracker());

STARTED.set(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public interface KnownAddresses {

Address<String> USER_ID = new Address<>("usr.id");

Address<String> USER_LOGIN = new Address<>("usr.login");

Address<String> SESSION_ID = new Address<>("usr.session_id");

/** The URL of a network resource being requested (outgoing request) */
Expand Down Expand Up @@ -189,6 +191,8 @@ static Address<?> forName(String name) {
return SERVER_GRAPHQL_ALL_RESOLVERS;
case "usr.id":
return USER_ID;
case "usr.login":
return USER_LOGIN;
case "usr.session_id":
return SESSION_ID;
case "server.io.net.url":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.datadog.appsec.report.AppSecEvent;
import com.datadog.appsec.util.StandardizedLogging;
import datadog.trace.api.Config;
import datadog.trace.api.UserIdCollectionMode;
import datadog.trace.api.http.StoredBodySupplier;
import datadog.trace.api.internal.TraceSegment;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
Expand Down Expand Up @@ -125,6 +126,10 @@ public class AppSecRequestContext implements DataBundle, Closeable {

// keep a reference to the last published usr.id
private volatile String userId;
private volatile UserIdCollectionMode userIdSource;
// keep a reference to the last published usr.login
private volatile String userLogin;
private volatile UserIdCollectionMode userLoginSource;
// keep a reference to the last published usr.session_id
private volatile String sessionId;

Expand Down Expand Up @@ -435,6 +440,30 @@ public void setUserId(String userId) {
this.userId = userId;
}

public UserIdCollectionMode getUserIdSource() {
return userIdSource;
}

public void setUserIdSource(UserIdCollectionMode userIdSource) {
this.userIdSource = userIdSource;
}

public String getUserLogin() {
return userLogin;
}

public void setUserLogin(String userLogin) {
this.userLogin = userLogin;
}

public UserIdCollectionMode getUserLoginSource() {
return userLoginSource;
}

public void setUserLoginSource(UserIdCollectionMode userLoginSource) {
this.userLoginSource = userLoginSource;
}

public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
Expand Down
Loading

0 comments on commit 6ea6598

Please sign in to comment.