Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update user lifecycle tracking to V3 #8108

Merged
merged 6 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 Down Expand Up @@ -99,7 +98,7 @@ private static void doStart(SubscriptionService gw, SharedCommunicationObjects s

Blocking.setBlockingService(new BlockingServiceImpl(REPLACEABLE_EVENT_PRODUCER));

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

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 @@ -195,6 +197,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
Loading