Skip to content

Commit fb217e9

Browse files
authored
Merge branch 'master' into dougqh/crash-tracking-in-smoke-tests
2 parents cce434b + 224dc1b commit fb217e9

File tree

63 files changed

+1496
-255
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1496
-255
lines changed

.circleci/config.continue.yml.j2

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ jobs:
816816
parameters:
817817
weblog-variant:
818818
type: string
819-
parallelism: 3
819+
parallelism: 4
820820
steps:
821821
- setup_system_tests
822822
@@ -838,11 +838,22 @@ jobs:
838838
no_output_timeout: 5m
839839
command: |
840840
cd system-tests
841+
(
841842
echo "
842843
DEFAULT
843844
APM_TRACING_E2E
844845
APM_TRACING_E2E_SINGLE_SPAN
845-
" | circleci tests split > scenarios.list
846+
"
847+
if ! [[ << parameters.weblog-variant >> =~ .*native ]]; then
848+
echo "
849+
APPSEC_BLOCKING
850+
APPSEC_REQUEST_BLOCKING
851+
APPSEC_RASP
852+
APPSEC_RUNTIME_ACTIVATION
853+
REMOTE_CONFIG_MOCKED_BACKEND_ASM_DD
854+
"
855+
fi
856+
) | circleci tests split > scenarios.list
846857
for scenario in $(<scenarios.list); do
847858
if [[ $scenario =~ .*_E2E.* ]]; then
848859
export DD_SITE=datadoghq.com
@@ -860,6 +871,7 @@ jobs:
860871
command: |
861872
mkdir -p artifacts
862873
cd system-tests
874+
shopt -s nullglob
863875
for log_dir in logs*; do
864876
tar -cvzf ../artifacts/${log_dir}_<< parameters.weblog-variant >>.tar.gz $log_dir
865877
done

buildSrc/call-site-instrumentation-plugin/src/main/java/datadog/trace/plugin/csi/impl/AdviceGeneratorImpl.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,10 @@ private static void writeAdviceMethodCall(
344344
final MethodCallExpr invokeStatic =
345345
new MethodCallExpr()
346346
.setScope(new NameExpr("handler"))
347-
.setName("method")
348-
.addArgument(opCode("INVOKESTATIC"))
347+
.setName("advice")
349348
.addArgument(new StringLiteralExpr(method.getOwner().getInternalName()))
350349
.addArgument(new StringLiteralExpr(method.getMethodName()))
351-
.addArgument(new StringLiteralExpr(method.getMethodType().getDescriptor()))
352-
.addArgument(new BooleanLiteralExpr(false));
350+
.addArgument(new StringLiteralExpr(method.getMethodType().getDescriptor()));
353351
body.addStatement(invokeStatic);
354352
}
355353
if (requiresCast(advice)) {

buildSrc/call-site-instrumentation-plugin/src/test/groovy/datadog/trace/plugin/csi/impl/AdviceGeneratorTest.groovy

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
4747
pointcut('java/security/MessageDigest', 'getInstance', '(Ljava/lang/String;)Ljava/security/MessageDigest;')
4848
statements(
4949
'handler.dupParameters(descriptor, StackDupMode.COPY);',
50-
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$BeforeAdvice", "before", "(Ljava/lang/String;)V", false);',
50+
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$BeforeAdvice", "before", "(Ljava/lang/String;)V");',
5151
'handler.method(opcode, owner, name, descriptor, isInterface);'
5252
)
5353
}
@@ -78,7 +78,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
7878
advices(0) {
7979
pointcut('java/lang/String', 'replaceAll', '(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;')
8080
statements(
81-
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$AroundAdvice", "around", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", false);'
81+
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$AroundAdvice", "around", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");'
8282
)
8383
}
8484
}
@@ -110,7 +110,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
110110
statements(
111111
'handler.dupInvoke(owner, descriptor, StackDupMode.COPY);',
112112
'handler.method(opcode, owner, name, descriptor, isInterface);',
113-
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$AfterAdvice", "after", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", false);',
113+
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$AfterAdvice", "after", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");',
114114
)
115115
}
116116
}
@@ -142,7 +142,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
142142
statements(
143143
'handler.dupParameters(descriptor, StackDupMode.PREPEND_ARRAY_CTOR);',
144144
'handler.method(opcode, owner, name, descriptor, isInterface);',
145-
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$AfterAdviceCtor", "after", "([Ljava/lang/Object;Ljava/net/URL;)Ljava/net/URL;", false);',
145+
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$AfterAdviceCtor", "after", "([Ljava/lang/Object;Ljava/net/URL;)Ljava/net/URL;");',
146146
)
147147
}
148148
}
@@ -208,7 +208,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
208208
statements(
209209
'handler.dupParameters(descriptor, StackDupMode.PREPEND_ARRAY);',
210210
'handler.invokeDynamic(name, descriptor, bootstrapMethodHandle, bootstrapMethodArguments);',
211-
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$InvokeDynamicAfterAdvice", "after", "([Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/String;", false);'
211+
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$InvokeDynamicAfterAdvice", "after", "([Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/String;");'
212212
)
213213
}
214214
}
@@ -297,7 +297,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
297297
'handler.dupParameters(descriptor, StackDupMode.PREPEND_ARRAY);',
298298
'handler.invokeDynamic(name, descriptor, bootstrapMethodHandle, bootstrapMethodArguments);',
299299
'handler.loadConstantArray(bootstrapMethodArguments);',
300-
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$InvokeDynamicWithConstantsAdvice", "after", "([Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;", false);'
300+
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$InvokeDynamicWithConstantsAdvice", "after", "([Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;");'
301301
)
302302
}
303303
}
@@ -393,7 +393,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
393393
statements(
394394
'int[] parameterIndices = new int[] { 0 };',
395395
'handler.dupParameters(descriptor, parameterIndices, owner);',
396-
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$PartialArgumentsBeforeAdvice", "before", "(Ljava/lang/String;)V", false);',
396+
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$PartialArgumentsBeforeAdvice", "before", "(Ljava/lang/String;)V");',
397397
'handler.method(opcode, owner, name, descriptor, isInterface);',
398398
)
399399
}
@@ -402,7 +402,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
402402
statements(
403403
'int[] parameterIndices = new int[] { 1 };',
404404
'handler.dupParameters(descriptor, parameterIndices, null);',
405-
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$PartialArgumentsBeforeAdvice", "before", "([Ljava/lang/Object;)V", false);',
405+
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$PartialArgumentsBeforeAdvice", "before", "([Ljava/lang/Object;)V");',
406406
'handler.method(opcode, owner, name, descriptor, isInterface);',
407407
)
408408
}
@@ -411,7 +411,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
411411
statements(
412412
'int[] parameterIndices = new int[] { 0 };',
413413
'handler.dupInvoke(owner, descriptor, parameterIndices);',
414-
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$PartialArgumentsBeforeAdvice", "before", "(Ljava/lang/String;I)V", false);',
414+
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$PartialArgumentsBeforeAdvice", "before", "(Ljava/lang/String;I)V");',
415415
'handler.method(opcode, owner, name, descriptor, isInterface);',
416416
)
417417
}
@@ -443,7 +443,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
443443
statements(
444444
'handler.dupParameters(descriptor, StackDupMode.PREPEND_ARRAY_CTOR);',
445445
'handler.method(opcode, owner, name, descriptor, isInterface);',
446-
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$SuperTypeReturnAdvice", "after", "([Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", false);',
446+
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$SuperTypeReturnAdvice", "after", "([Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");',
447447
'handler.instruction(Opcodes.CHECKCAST, "java/lang/StringBuilder");'
448448
)
449449
}

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/ProcessHierarchy.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,21 @@ public boolean isChild() {
5050
* not one of the supported build system processes.
5151
*/
5252
public boolean isHeadless() {
53-
return !isChild() && !isParent();
53+
return !isChild() && !isParent() && !isWrapper();
5454
}
5555

5656
private boolean isParent() {
5757
return isMavenParent() || isGradleDaemon();
5858
}
5959

60+
/**
61+
* Determines if current process is a wrapper that starts the build system. In other words a
62+
* process that is not a build system, and not a JVM that runs tests.
63+
*/
64+
private boolean isWrapper() {
65+
return isGradleLauncher();
66+
}
67+
6068
private boolean isMavenParent() {
6169
return System.getProperty("maven.home") != null
6270
&& System.getProperty("classworlds.conf") != null;
@@ -70,6 +78,12 @@ private boolean isGradleDaemon() {
7078
&& System.getProperties().getProperty("org.gradle.internal.worker.tmpdir") == null;
7179
}
7280

81+
private boolean isGradleLauncher() {
82+
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
83+
return contextClassLoader.getResource("org/gradle/launcher/Main.class") != null
84+
|| contextClassLoader.getResource("org/gradle/launcher/GradleMain.class") != null;
85+
}
86+
7387
@Nullable
7488
public InetSocketAddress getSignalServerAddress() {
7589
// System.getProperty is used rather than Config,

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/test/ExecutionStrategy.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,11 @@ public TestRetryPolicy retryPolicy(TestIdentifier test) {
9999
public boolean isEarlyFlakeDetectionLimitReached() {
100100
int detectionsUsed = earlyFlakeDetectionsUsed.get();
101101
Collection<TestIdentifier> knownTests = executionSettings.getKnownTests();
102-
int totalTests = knownTests.size() + detectionsUsed;
102+
if (knownTests == null) {
103+
return false;
104+
}
103105

106+
int totalTests = knownTests.size() + detectionsUsed;
104107
EarlyFlakeDetectionSettings earlyFlakeDetectionSettings =
105108
executionSettings.getEarlyFlakeDetectionSettings();
106109
int threshold =

dd-java-agent/agent-crashtracking/src/main/resources/com/datadog/crashtracking/notify_oome.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,25 @@ fi
2222
# The expected contents are:
2323
# - agent: Path to the agent jar
2424
# - tags: Comma-separated list of tags to be sent with the OOME event; key:value pairs are supported
25-
declare -A config
2625
while IFS="=" read -r key value; do
27-
config["$key"]="$value"
26+
declare "config_$key"="$value"
2827
done < "$configFile"
2928

29+
# Exiting early if configuration is missing
30+
if [ -z "${config_agent}" ] || [ -z "${config_tags}" ]; then
31+
echo "Error: Missing configuration"
32+
exit 1
33+
fi
34+
3035
# Debug: Print the loaded values (Optional)
31-
echo "Agent Jar: ${config[agent]}"
32-
echo "Tags: ${config[tags]}"
36+
echo "Agent Jar: ${config_agent}"
37+
echo "Tags: ${config_tags}"
3338
echo "PID: $PID"
3439

3540
# Execute the Java command with the loaded values
36-
java -Ddd.dogstatsd.start-delay=0 -jar "${config[agent]}" sendOomeEvent "${config[tags]}"
41+
java -Ddd.dogstatsd.start-delay=0 -jar "${config_agent}" sendOomeEvent "${config_tags}"
3742
RC=$?
38-
rm -f ${configFile} # Remove the configuration file
43+
rm -f "${configFile}" # Remove the configuration file
3944

4045
if [ $RC -eq 0 ]; then
4146
echo "OOME Event generated successfully"

dd-java-agent/agent-crashtracking/src/main/resources/com/datadog/crashtracking/upload_crash.sh

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,29 @@ fi
3030
# The expected contents are:
3131
# - agent: Path to the agent jar
3232
# - hs_err: Path to the hs_err log file
33-
declare -A config
3433
while IFS="=" read -r key value; do
35-
config["$key"]="$value"
34+
declare "config_$key"="$value"
3635
done < "$configFile"
3736

37+
# Exiting early if configuration is missing
38+
if [ -z "${config_agent}" ] || [ -z "${config_hs_err}" ]; then
39+
echo "Error: Missing configuration"
40+
exit 1
41+
fi
42+
3843
# Debug: Print the loaded values (Optional)
39-
echo "Agent Jar: ${config[agent]}"
40-
echo "Error Log: ${config[hs_err]}"
44+
echo "Agent Jar: ${config_agent}"
45+
echo "Error Log: ${config_hs_err}"
4146
echo "PID: $PID"
4247

4348
# Execute the Java command with the loaded values
44-
java -jar "${config[agent]}" uploadCrash "${config[hs_err]}"
49+
java -jar "${config_agent}" uploadCrash "${config_hs_err}"
4550
RC=$?
46-
rm -f ${configFile} # Remove the configuration file
51+
rm -f "${configFile}" # Remove the configuration file
4752

4853
if [ $RC -eq 0 ]; then
49-
echo "Error file ${config[hs_err]} was uploaded successfully"
54+
echo "Error file ${config_hs_err} was uploaded successfully"
5055
else
51-
echo "Error: Failed to upload error file ${config[hs_err]}"
56+
echo "Error: Failed to upload error file ${config_hs_err}"
5257
exit $RC
5358
fi

dd-java-agent/agent-iast/src/main/java/com/datadog/iast/propagation/StringModuleImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ public void onStringTrim(@Nonnull final String self, @Nullable final String resu
403403
}
404404

405405
@Override
406-
public void onStringConstructor(@Nonnull String self, @Nonnull String result) {
406+
public void onStringConstructor(@Nonnull CharSequence self, @Nonnull String result) {
407407
if (!canBeTainted(self)) {
408408
return;
409409
}

0 commit comments

Comments
 (0)