Skip to content

Commit d7ed872

Browse files
committed
Merge branch 'master' into mario.vidal/expand_support_ssrf_apache
2 parents 5347dd7 + 4df0a01 commit d7ed872

File tree

1,065 files changed

+17035
-6607
lines changed

Some content is hidden

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

1,065 files changed

+17035
-6607
lines changed

.circleci/collect_results.sh

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,32 @@ set -e
77
#Enable '**' support
88
shopt -s globstar
99

10-
TEST_RESULTS_DIR=./results
11-
mkdir -p $TEST_RESULTS_DIR >/dev/null 2>&1
12-
10+
TEST_RESULTS_DIR=results
11+
WORKSPACE_DIR=workspace
1312
mkdir -p $TEST_RESULTS_DIR
13+
mkdir -p $WORKSPACE_DIR
1414

15-
mkdir -p workspace
16-
mapfile -t test_result_dirs < <(find workspace -name test-results -type d)
15+
mapfile -t TEST_RESULT_DIRS < <(find $WORKSPACE_DIR -name test-results -type d)
1716

18-
if [[ ${#test_result_dirs[@]} -eq 0 ]]; then
17+
if [[ ${#TEST_RESULT_DIRS[@]} -eq 0 ]]; then
1918
echo "No test results found"
2019
exit 0
2120
fi
2221

23-
echo "saving test results"
24-
find "${test_result_dirs[@]}" -name \*.xml -exec sh -c '
25-
file=$(echo "$0" | rev | cut -d "/" -f 1,2,5 | rev | tr "/" "_")
26-
cp "$0" "$1/$file"' {} $TEST_RESULTS_DIR \;
22+
echo "Saving test results:"
23+
while IFS= read -r -d '' RESULT_XML_FILE
24+
do
25+
echo -n "- $RESULT_XML_FILE"
26+
AGGREGATED_FILE_NAME=$(echo "$RESULT_XML_FILE" | rev | cut -d "/" -f 1,2,5 | rev | tr "/" "_")
27+
echo -n " as $AGGREGATED_FILE_NAME"
28+
cp "$RESULT_XML_FILE" "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"
29+
# Replace Java Object hashCode by marker in testcase XML nodes to get stable test names
30+
sed -i '/<testcase/ s/@[0-9a-f]\{5,\}/@HASHCODE/g' "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"
31+
# Replace random port numbers by marker in testcase XML nodes to get stable test names
32+
sed -i '/<testcase/ s/localhost:[0-9]\{2,5\}/localhost:PORT/g' "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"
33+
if cmp -s "$RESULT_XML_FILE" "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"; then
34+
echo ""
35+
else
36+
echo -n " (non-stable test names detected)"
37+
fi
38+
done < <(find "${TEST_RESULT_DIRS[@]}" -name \*.xml -print0)

.circleci/config.continue.yml.j2

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ instrumentation_modules: &instrumentation_modules "dd-java-agent/instrumentation
3636
debugger_modules: &debugger_modules "dd-java-agent/agent-debugger|dd-java-agent/agent-bootstrap|dd-java-agent/agent-builder|internal-api|communication|dd-trace-core"
3737
profiling_modules: &profiling_modules "dd-java-agent/agent-profiling"
3838

39-
default_system_tests_commit: &default_system_tests_commit 53d9b2c43876a39e5c0426f4df4dd5fd79d062e8
39+
default_system_tests_commit: &default_system_tests_commit 67fe30ac7504997685859d31feae1782f3527f39
4040

4141
parameters:
4242
nightly:
@@ -816,6 +816,7 @@ jobs:
816816
parameters:
817817
weblog-variant:
818818
type: string
819+
parallelism: 4
819820
steps:
820821
- setup_system_tests
821822
@@ -833,32 +834,50 @@ jobs:
833834
834835
- run:
835836
name: Run
836-
command: |
837-
cd system-tests
838-
DD_API_KEY=$SYSTEM_TESTS_DD_API_KEY ./run.sh
839-
840-
- run:
841-
name: Run APM E2E default tests
842837
# Stop the job after 5m to avoid excessive overhead. Will need adjustment as more tests are added.
843838
no_output_timeout: 5m
844839
command: |
845840
cd system-tests
846-
DD_SITE=datadoghq.com DD_API_KEY=$SYSTEM_TESTS_E2E_DD_API_KEY DD_APPLICATION_KEY=$SYSTEM_TESTS_E2E_DD_APP_KEY ./run.sh APM_TRACING_E2E
841+
(
842+
echo "
843+
DEFAULT
844+
APM_TRACING_E2E
845+
APM_TRACING_E2E_SINGLE_SPAN
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
857+
for scenario in $(<scenarios.list); do
858+
if [[ $scenario =~ .*_E2E.* ]]; then
859+
export DD_SITE=datadoghq.com
860+
export DD_API_KEY=$SYSTEM_TESTS_E2E_DD_API_KEY
861+
export DD_APPLICATION_KEY=$SYSTEM_TESTS_E2E_DD_APP_KEY
862+
else
863+
export DD_API_KEY=$SYSTEM_TESTS_DD_API_KEY
864+
fi
865+
echo "Running scenario $scenario"
866+
./run.sh $scenario
867+
done
847868
848869
- run:
849-
name: Run APM E2E Single Span tests
850-
# Stop the job after 5m to avoid excessive overhead. Will need adjustment as more tests are added.
851-
no_output_timeout: 5m
870+
name: Collect artifacts
852871
command: |
872+
mkdir -p artifacts
853873
cd system-tests
854-
DD_SITE=datadoghq.com DD_API_KEY=$SYSTEM_TESTS_E2E_DD_API_KEY DD_APPLICATION_KEY=$SYSTEM_TESTS_E2E_DD_APP_KEY ./run.sh APM_TRACING_E2E_SINGLE_SPAN
855-
856-
- run:
857-
name: Collect artifacts
858-
command: tar -cvzf logs_java_<< parameters.weblog-variant >>_dev.tar.gz -C system-tests logs logs_apm_tracing_e2e logs_apm_tracing_e2e_single_span
874+
shopt -s nullglob
875+
for log_dir in logs*; do
876+
tar -cvzf ../artifacts/${log_dir}_<< parameters.weblog-variant >>.tar.gz $log_dir
877+
done
859878
860879
- store_artifacts:
861-
path: logs_java_<< parameters.weblog-variant >>_dev.tar.gz
880+
path: artifacts
862881
863882
integrations-system-tests:
864883
machine:

.circleci/upload_ciapp.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ junit_upload() {
3333
./results
3434
}
3535

36+
# Make sure we do not use DATADOG_API_KEY from the environment
37+
unset DATADOG_API_KEY
38+
3639
# Upload test results to production environment like all other CI jobs
3740
junit_upload "$DATADOG_API_KEY_PROD"
3841
# And also upload to staging environment to benefit from the new features not yet released

.github/workflows/analyze-changes.yaml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,7 @@ jobs:
1616
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # 4.1.6
1717
with:
1818
submodules: 'recursive'
19-
- name: Check code meets quality standards (production)
20-
id: datadog-static-analysis
21-
uses: DataDog/datadog-static-analyzer-github-action@c74aff158c8cc1c3e285660713bcaa5f9c6d696e # v1
22-
with:
23-
dd_app_key: ${{ secrets.DATADOG_APP_KEY_PROD }}
24-
dd_api_key: ${{ secrets.DATADOG_API_KEY_PROD }}
25-
dd_site: "datadoghq.com"
26-
dd_service: "dd-trace-java"
27-
dd_env: "ci"
28-
cpu_count: 2
29-
enable_performance_statistics: false
30-
# Also run the static analysis on the staging environment to benefit from the new features not yet released
19+
# Run the static analysis on the staging environment to benefit from the new features not yet released
3120
- name: Check code meets quality standards (staging)
3221
id: datadog-static-analysis-staging
3322
uses: DataDog/datadog-static-analyzer-github-action@c74aff158c8cc1c3e285660713bcaa5f9c6d696e # v1

.github/workflows/check-pull-requests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
const ignoreReleaseNotes = labels.filter(label => label == 'tag: no release notes').length > 0
2828
const hasTypeLabel = labels.filter(label => label.startsWith('type:')).length > 0
2929
const hasComponentLabel = labels.filter(label => label.startsWith('comp:')).length > 0
30-
const hasInstrumentationLabel = labels.filter(label => label.startsWith('instr:')).length > 0
30+
const hasInstrumentationLabel = labels.filter(label => label.startsWith('inst:')).length > 0
3131
const labelsCheckFailed = !ignoreReleaseNotes && (!hasTypeLabel || (!hasComponentLabel && !hasInstrumentationLabel));
3232
if (labelsCheckFailed) {
3333
core.setFailed('Please add at least one type, and one component or instrumentation label to the pull request.')
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"pull_request": {
3+
"number": 7884,
4+
"draft": false,
5+
"labels": [
6+
{
7+
"name": "inst: java"
8+
},
9+
{
10+
"name": "type: bug"
11+
}
12+
],
13+
"title": "Adding some new features"
14+
}
15+
}

.github/workflows/tests/check-pull-requests/test-pull-request.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
source "$(dirname "$0")/../env.sh"
33
testworkflow pull_request && \
4+
testworkflow pull_request instrumentation && \
45
testworkflow pull_request draft && \
56
testworkflow pull_request no-release-notes && \
67
! testworkflow pull_request missing-label && \

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
}

buildSrc/src/main/groovy/InstrumentPlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class InstrumentPlugin implements Plugin<Project> {
3535
InstrumentExtension extension = project.extensions.create('instrument', InstrumentExtension)
3636

3737
project.tasks.matching {
38-
it.name in ['compileJava', 'compileScala', 'compileKotlin'] ||
38+
it.name in ['compileJava', 'compileScala', 'compileKotlin', 'compileGroovy'] ||
3939
it.name =~ /compileMain_.+Java/
4040
}.all {
4141
AbstractCompile compileTask = it as AbstractCompile

0 commit comments

Comments
 (0)