Skip to content

Commit dc48fa1

Browse files
committed
Add new APPSEC_HEADER_COLLECTION_REDACTION_ENABLED config
1 parent 0dcd979 commit dc48fa1

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

dd-java-agent/appsec/src/main/java/com/datadog/appsec/gateway/GatewayBridge.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,11 @@ private NoopFlow onRequestEnded(RequestContext ctx_, IGSpanInfo spanInfo) {
704704
traceSeg.setDataTop("appsec", wrapper);
705705

706706
// Report collected request and response headers based on allow list
707-
boolean collectAll = Config.get().isAppSecCollectAllHeaders();
707+
boolean collectAll =
708+
Config.get().isAppSecCollectAllHeaders()
709+
// Until redaction is defined we don't want to collect all headers due to risk of
710+
// leaking sensitive data
711+
&& !Config.get().isAppSecHeaderCollectionRedactionEnabled();
708712
writeRequestHeaders(
709713
traceSeg, REQUEST_HEADERS_ALLOW_LIST, ctx.getRequestHeaders(), collectAll);
710714
writeResponseHeaders(

dd-smoke-tests/appsec/springboot/src/test/groovy/datadog/smoketest/appsec/ExtendedDataCollectionSmokeTest.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class ExtendedDataCollectionSmokeTest extends AbstractAppSecServerSmokeTest {
1515
command.addAll(defaultJavaProperties)
1616
command.addAll(defaultAppSecProperties)
1717
command.add('-Ddd.appsec.collect.all.headers=true')
18+
command.add('-Ddd.appsec.header.collection.redaction.enabled=false')
1819
command.addAll((String[]) ["-jar", springBootShadowJar, "--server.port=${httpPort}"])
1920

2021
ProcessBuilder processBuilder = new ProcessBuilder(command)

dd-trace-api/src/main/java/datadog/trace/api/config/AppSecConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public final class AppSecConfig {
4545
"appsec.max.stacktrace.depth"; // old non-standard as a fallback alias
4646
public static final String APPSEC_COLLECT_ALL_HEADERS = "appsec.collect.all.headers";
4747
public static final String APPSEC_MAX_COLLECTED_HEADERS = "appsec.max.collected.headers";
48+
public static final String APPSEC_HEADER_COLLECTION_REDACTION_ENABLED =
49+
"appsec.header.collection.redaction.enabled";
4850

4951
private AppSecConfig() {}
5052
}

internal-api/src/main/java/datadog/trace/api/Config.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ public static String getHostName() {
292292
private final int appSecMaxStackTraces;
293293
private final int appSecMaxStackTraceDepth;
294294
private final boolean appSecCollectAllHeaders;
295+
private final boolean appSecHeaderCollectionRedactionEnabled;
295296
private final int appSecMaxCollectedHeaders;
296297
private final boolean apiSecurityEnabled;
297298
private final float apiSecuritySampleDelay;
@@ -1386,6 +1387,8 @@ PROFILING_DATADOG_PROFILER_ENABLED, isDatadogProfilerSafeInCurrentEnvironment())
13861387
DEFAULT_APPSEC_MAX_STACK_TRACE_DEPTH,
13871388
APPSEC_MAX_STACKTRACE_DEPTH_DEPRECATED);
13881389
appSecCollectAllHeaders = configProvider.getBoolean(APPSEC_COLLECT_ALL_HEADERS, false);
1390+
appSecHeaderCollectionRedactionEnabled =
1391+
configProvider.getBoolean(APPSEC_HEADER_COLLECTION_REDACTION_ENABLED, true);
13891392
appSecMaxCollectedHeaders =
13901393
configProvider.getInteger(
13911394
APPSEC_MAX_COLLECTED_HEADERS, DEFAULT_APPSEC_MAX_COLLECTED_HEADERS);
@@ -4198,6 +4201,10 @@ public boolean isAppSecCollectAllHeaders() {
41984201
return appSecCollectAllHeaders;
41994202
}
42004203

4204+
public boolean isAppSecHeaderCollectionRedactionEnabled() {
4205+
return appSecHeaderCollectionRedactionEnabled;
4206+
}
4207+
42014208
public int getAppsecMaxCollectedHeaders() {
42024209
return appSecMaxCollectedHeaders;
42034210
}

0 commit comments

Comments
 (0)