Skip to content

Commit c5fe600

Browse files
jbachorikclaude
andcommitted
Replace local JfrScrubber with jafar-tools 0.13.0
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4ae34f0 commit c5fe600

15 files changed

Lines changed: 85 additions & 596 deletions

File tree

NATIVE_IMAGE_FIX_STATUS.md

Lines changed: 0 additions & 148 deletions
This file was deleted.

dd-java-agent/agent-profiling/profiling-controller-openjdk/src/main/java/com/datadog/profiling/controller/openjdk/OpenJdkController.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,7 @@ && isEventEnabled(recordingSettings, "jdk.NativeMethodSample")) {
274274
private static String getJfrRepositoryBase(ConfigProvider configProvider) {
275275
String jfrRepoDefault = System.getProperty("java.io.tmpdir") + "/dd/jfr";
276276
String legacy =
277-
configProvider.getString(
278-
ProfilingConfig.PROFILING_JFR_REPOSITORY_BASE, jfrRepoDefault);
277+
configProvider.getString(ProfilingConfig.PROFILING_JFR_REPOSITORY_BASE, jfrRepoDefault);
279278
if (!legacy.equals(jfrRepoDefault)) {
280279
log.warn(
281280
"The configuration key {} is deprecated. Please use {} instead.",

dd-java-agent/agent-profiling/profiling-scrubber/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ minimumBranchCoverage = 0.0
66
dependencies {
77
api libs.slf4j
88

9-
implementation libs.jafar.parser
9+
implementation(libs.jafar.tools) {
10+
// ASM is only used by jafar's CodeGenerator/Deserializer path which the scrubber does not use
11+
exclude group: 'org.ow2.asm', module: 'asm'
12+
// Agent has its own slf4j binding
13+
exclude group: 'org.slf4j', module: 'slf4j-simple'
14+
}
1015

1116
testImplementation libs.bundles.junit5
1217
testImplementation libs.bundles.mockito

dd-java-agent/agent-profiling/profiling-scrubber/src/main/java/com/datadog/profiling/scrubber/DefaultScrubDefinition.java

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,51 @@
11
package com.datadog.profiling.scrubber;
22

3+
import io.jafar.tools.Scrubber;
34
import java.util.Collections;
45
import java.util.HashMap;
56
import java.util.HashSet;
67
import java.util.List;
78
import java.util.Map;
89
import java.util.Set;
9-
import java.util.function.Function;
1010

1111
/** Provides the default scrub definition targeting sensitive JFR event fields. */
1212
public final class DefaultScrubDefinition {
1313

14-
private static final Map<String, JfrScrubber.ScrubField> DEFAULT_SCRUB_FIELDS;
14+
private static final Map<String, Scrubber.ScrubField> DEFAULT_SCRUB_FIELDS;
1515

1616
static {
17-
Map<String, JfrScrubber.ScrubField> fields = new HashMap<>();
17+
Map<String, Scrubber.ScrubField> fields = new HashMap<>();
1818
// System properties may contain API keys, passwords
19-
fields.put(
20-
"jdk.InitialSystemProperty", new JfrScrubber.ScrubField(null, "value", (k, v) -> true));
19+
fields.put("jdk.InitialSystemProperty", new Scrubber.ScrubField(null, "value", (k, v) -> true));
2120
// JVM args may contain credentials in -D flags
22-
fields.put(
23-
"jdk.JVMInformation", new JfrScrubber.ScrubField(null, "jvmArguments", (k, v) -> true));
21+
fields.put("jdk.JVMInformation", new Scrubber.ScrubField(null, "jvmArguments", (k, v) -> true));
2422
// Env vars may contain secrets
2523
fields.put(
26-
"jdk.InitialEnvironmentVariable",
27-
new JfrScrubber.ScrubField(null, "value", (k, v) -> true));
24+
"jdk.InitialEnvironmentVariable", new Scrubber.ScrubField(null, "value", (k, v) -> true));
2825
// Process command lines may reveal infrastructure
29-
fields.put(
30-
"jdk.SystemProcess", new JfrScrubber.ScrubField(null, "commandLine", (k, v) -> true));
26+
fields.put("jdk.SystemProcess", new Scrubber.ScrubField(null, "commandLine", (k, v) -> true));
3127
DEFAULT_SCRUB_FIELDS = Collections.unmodifiableMap(fields);
3228
}
3329

3430
/**
35-
* Creates a scrub definition function that maps event type names to their scrub field
36-
* definitions.
31+
* Creates a scrubber with the default scrub definition.
3732
*
3833
* @param excludeEventTypes list of event type names to exclude from scrubbing, or null for none
39-
* @return a function mapping event type names to scrub field definitions
34+
* @return a configured {@link JfrScrubber}
4035
*/
41-
public static Function<String, JfrScrubber.ScrubField> create(List<String> excludeEventTypes) {
36+
public static JfrScrubber create(List<String> excludeEventTypes) {
4237
Set<String> excludeSet =
43-
excludeEventTypes != null ? new HashSet<>(excludeEventTypes) : Collections.<String>emptySet();
38+
excludeEventTypes != null
39+
? new HashSet<>(excludeEventTypes)
40+
: Collections.<String>emptySet();
4441

45-
return eventTypeName -> {
46-
if (excludeSet.contains(eventTypeName)) {
47-
return null;
48-
}
49-
return DEFAULT_SCRUB_FIELDS.get(eventTypeName);
50-
};
42+
return new JfrScrubber(
43+
eventTypeName -> {
44+
if (excludeSet.contains(eventTypeName)) {
45+
return null;
46+
}
47+
return DEFAULT_SCRUB_FIELDS.get(eventTypeName);
48+
});
5149
}
5250

5351
private DefaultScrubDefinition() {}

0 commit comments

Comments
 (0)