Skip to content

Commit 8f129db

Browse files
authored
Merge branch 'master' into andrea.marziali/ffm-instrument
2 parents 5f1ccbf + 8185dcf commit 8f129db

92 files changed

Lines changed: 648 additions & 107 deletions

File tree

Some content is hidden

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

.github/workflows/update-smoke-test-latest-versions.yaml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ jobs:
4444
METADATA=$(curl -sf https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/maven-metadata.xml)
4545
# Get all versions, filter out alpha/beta/rc, take the latest
4646
VERSION=$(echo "$METADATA" \
47-
| xmllint --xpath '//versions/version/text()' - 2>/dev/null \
48-
| tr ' ' '\n' \
47+
| grep -o '<version>[^<]*</version>' \
48+
| sed 's/<[^>]*>//g' \
4949
| grep -v -E '(alpha|beta|rc)' \
5050
| sort -V \
5151
| tail -1)
@@ -62,8 +62,8 @@ jobs:
6262
METADATA=$(curl -sf https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/maven-metadata.xml)
6363
# Get all versions, filter out alpha/beta, take the latest
6464
VERSION=$(echo "$METADATA" \
65-
| xmllint --xpath '//versions/version/text()' - 2>/dev/null \
66-
| tr ' ' '\n' \
65+
| grep -o '<version>[^<]*</version>' \
66+
| sed 's/<[^>]*>//g' \
6767
| grep -v -E '(alpha|beta)' \
6868
| sort -V \
6969
| tail -1)
@@ -80,6 +80,11 @@ jobs:
8080
MAVEN_VERSION: ${{ steps.maven.outputs.version }}
8181
SUREFIRE_VERSION: ${{ steps.surefire.outputs.version }}
8282
run: |
83+
echo "Writing resolved versions to properties files:"
84+
echo " Gradle: ${GRADLE_VERSION}"
85+
echo " Maven: ${MAVEN_VERSION}"
86+
echo " Maven Surefire: ${SUREFIRE_VERSION}"
87+
8388
printf '%s\n' \
8489
"# Pinned \"latest\" versions for CI Visibility Gradle smoke tests." \
8590
"# Updated automatically by the update-smoke-test-latest-versions workflow." \
@@ -97,9 +102,14 @@ jobs:
97102
id: check-changes
98103
run: |
99104
if [[ -z "$(git status -s)" ]]; then
100-
echo "No changes to commit."
105+
echo "No changes detected — pinned versions are already up to date."
101106
echo "has_changes=false" >> "$GITHUB_OUTPUT"
102107
else
108+
echo "Changes detected in the following files:"
109+
git status -s
110+
echo ""
111+
echo "Diff:"
112+
git diff
103113
echo "has_changes=true" >> "$GITHUB_OUTPUT"
104114
fi
105115

.gitlab/add_final_status.xsl

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
We're using not-that-ideal XSLT here as this change, because it must be done over 17+ repos.
5+
It's a workaround until this gets integrated into a better place, such as datadog-ci or the backend.
6+
* ticket: https://datadoghq.atlassian.net/browse/APMSP-2610
7+
* RFC: https://docs.google.com/document/d/1OaX_h09fCXWmK_1ADrwvilt8Yt5h4WjC7UUAdS3Y3uw/edit?pli=1&tab=t.0#heading=h.tfy5viz7rz2
8+
-->
9+
10+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
11+
12+
<!-- Identity transform: copy everything as-is by default -->
13+
<xsl:template match="@*|node()">
14+
<xsl:copy>
15+
<xsl:apply-templates select="@*|node()"/>
16+
</xsl:copy>
17+
</xsl:template>
18+
19+
<!-- For testcase elements missing dd_tags[test.final_status] inside their properties block -->
20+
<xsl:template match="testcase[not(properties/property[@name='dd_tags[test.final_status]'])]">
21+
<xsl:copy>
22+
<xsl:apply-templates select="@*"/>
23+
<xsl:variable name="status">
24+
<xsl:choose>
25+
<xsl:when test="failure or error">fail</xsl:when>
26+
<xsl:when test="skipped">skip</xsl:when>
27+
<xsl:otherwise>pass</xsl:otherwise>
28+
</xsl:choose>
29+
</xsl:variable>
30+
<xsl:choose>
31+
<xsl:when test="properties">
32+
<!-- Inject into existing properties block, preserving child order -->
33+
<xsl:for-each select="node()">
34+
<xsl:choose>
35+
<xsl:when test="self::properties">
36+
<properties>
37+
<xsl:apply-templates select="@*|node()"/>
38+
<property name="dd_tags[test.final_status]" value="{$status}"/>
39+
</properties>
40+
</xsl:when>
41+
<xsl:otherwise>
42+
<xsl:apply-templates select="."/>
43+
</xsl:otherwise>
44+
</xsl:choose>
45+
</xsl:for-each>
46+
</xsl:when>
47+
<xsl:otherwise>
48+
<!-- No properties block: create one before other children -->
49+
<properties>
50+
<property name="dd_tags[test.final_status]" value="{$status}"/>
51+
</properties>
52+
<xsl:apply-templates select="node()"/>
53+
</xsl:otherwise>
54+
</xsl:choose>
55+
</xsl:copy>
56+
</xsl:template>
57+
58+
</xsl:stylesheet>

.gitlab/collect_results.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ do
7777
sed -i '/<testcase/ s/@[0-9a-f]\{5,\}/@HASHCODE/g' "$TARGET_DIR/$AGGREGATED_FILE_NAME"
7878
# Replace random port numbers by marker in testcase XML nodes to get stable test names
7979
sed -i '/<testcase/ s/localhost:[0-9]\{2,5\}/localhost:PORT/g' "$TARGET_DIR/$AGGREGATED_FILE_NAME"
80+
81+
# Add dd_tags[test.final_status] property to each testcase
82+
xsl_file="$(dirname "$0")/add_final_status.xsl"
83+
tmp_file="$(mktemp)"
84+
xsltproc --output "$tmp_file" "$xsl_file" "$TARGET_DIR/$AGGREGATED_FILE_NAME"
85+
mv "$tmp_file" "$TARGET_DIR/$AGGREGATED_FILE_NAME"
86+
8087
if cmp -s "$RESULT_XML_FILE" "$TARGET_DIR/$AGGREGATED_FILE_NAME"; then
8188
echo ""
8289
else

dd-java-agent/agent-aiguard/src/main/java/com/datadog/aiguard/AIGuardInternal.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ private static String getToolName(final Message current, final List<Message> mes
205205
}
206206

207207
private boolean isBlockingEnabled(final Options options, final Object isBlockingEnabled) {
208+
if (isBlockingEnabled == null) {
209+
return false;
210+
}
208211
return options.block() && "true".equalsIgnoreCase(isBlockingEnabled.toString());
209212
}
210213

dd-java-agent/agent-aiguard/src/test/groovy/com/datadog/aiguard/AIGuardInternalTests.groovy

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,51 @@ class AIGuardInternalTests extends DDSpecification {
222222
suite << TestSuite.build()
223223
}
224224

225+
void 'test evaluate block defaults to remote is_blocking_enabled'() {
226+
given:
227+
def request
228+
final call = Mock(Call) {
229+
execute() >> {
230+
return mockResponse(
231+
request,
232+
200,
233+
[data: [attributes: [action: 'DENY', reason: 'Nope', tags: ['deny_everything'], is_blocking_enabled: remoteBlocking]]]
234+
)
235+
}
236+
}
237+
final client = Mock(OkHttpClient) {
238+
newCall(_ as Request) >> {
239+
request = (Request) it[0]
240+
return call
241+
}
242+
}
243+
final aiguard = new AIGuardInternal(URL, HEADERS, client)
244+
245+
when:
246+
Throwable error = null
247+
AIGuard.Evaluation eval = null
248+
try {
249+
eval = aiguard.evaluate(TOOL_CALL, options)
250+
} catch (Throwable e) {
251+
error = e
252+
}
253+
254+
then:
255+
if (shouldBlock) {
256+
error instanceof AIGuard.AIGuardAbortError
257+
error.action == DENY
258+
} else {
259+
error == null
260+
eval.action == DENY
261+
}
262+
263+
where:
264+
options | remoteBlocking | shouldBlock
265+
AIGuard.Options.DEFAULT | true | true
266+
AIGuard.Options.DEFAULT | false | false
267+
new AIGuard.Options().block(false) | true | false
268+
}
269+
225270
void 'test evaluate with API errors'() {
226271
given:
227272
final errors = [[status: 400, title: 'Bad request']]

dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/jdbc/JDBCConnectionUrlParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ DBInfo.Builder doParse(final String jdbcUrl, final DBInfo.Builder builder) {
7373
String instanceName = null;
7474
final int hostIndex = jdbcUrl.indexOf("://");
7575

76-
if (hostIndex <= 0) {
76+
if (hostIndex <= 0 || jdbcUrl.length() == 3 + hostIndex) {
7777
return builder;
7878
}
7979

dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/git/tree/GitClientTest.groovy

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ class GitClientTest extends Specification {
8787
8888
def "test is shallow"() {
8989
given:
90-
givenGitRepo("ci/git/shallow/git")
90+
givenGitRepos(["ci/git/shallow_with_origin/origin", "ci/git/shallow_with_origin/repo"])
9191
9292
when:
93-
def gitClient = givenGitClient()
93+
def gitClient = givenGitClient("repo")
9494
def shallow = gitClient.isShallow()
9595
9696
then:
@@ -111,22 +111,22 @@ class GitClientTest extends Specification {
111111
112112
def "test get upstream branch SHA"() {
113113
given:
114-
givenGitRepo("ci/git/shallow/git")
114+
givenGitRepos(["ci/git/shallow_with_origin/origin", "ci/git/shallow_with_origin/repo"])
115115
116116
when:
117-
def gitClient = givenGitClient()
117+
def gitClient = givenGitClient("repo")
118118
def upstreamBranch = gitClient.getUpstreamBranchSha()
119119
120120
then:
121-
upstreamBranch == "98b944cc44f18bfb78e3021de2999cdcda8efdf6"
121+
upstreamBranch == "c76ef954d23f8fdb42dcf2fe956d6af5a31fe7bd"
122122
}
123123
124124
def "test unshallow: sha-#remoteSha"() {
125125
given:
126-
givenGitRepo("ci/git/shallow/git")
126+
givenGitRepos(["ci/git/shallow_with_origin/origin", "ci/git/shallow_with_origin/repo"])
127127
128128
when:
129-
def gitClient = givenGitClient()
129+
def gitClient = givenGitClient("repo")
130130
def shallow = gitClient.isShallow()
131131
def commits = gitClient.getLatestCommits()
132132
@@ -209,11 +209,11 @@ class GitClientTest extends Specification {
209209

210210
def "test get commit info with fetching"() {
211211
given:
212-
givenGitRepo("ci/git/shallow/git")
212+
givenGitRepos(["ci/git/shallow_with_origin/origin", "ci/git/shallow_with_origin/repo"])
213213

214214
when:
215-
def commit = "f4377e97f10c2d58696192b170b2fef2a8464b04"
216-
def gitClient = givenGitClient()
215+
def commit = "6e55a15a35ad46f74e4203dd42f7797173a6edcb"
216+
def gitClient = givenGitClient("repo")
217217
def commitInfo = gitClient.getCommitInfo(commit, false)
218218

219219
then:
@@ -224,13 +224,13 @@ class GitClientTest extends Specification {
224224

225225
then:
226226
commitInfo.sha == commit
227-
commitInfo.author.name == "sullis"
228-
commitInfo.author.email == "github@seansullivan.com"
229-
commitInfo.author.iso8601Date == "2023-05-30T07:07:35-07:00"
230-
commitInfo.committer.name == "GitHub"
231-
commitInfo.committer.email == "noreply@github.com"
232-
commitInfo.committer.iso8601Date == "2023-05-30T07:07:35-07:00"
233-
commitInfo.fullMessage == "brotli4j 1.12.0 (#1592)"
227+
commitInfo.author.name == "Test Author"
228+
commitInfo.author.email == "test-author@example.com"
229+
commitInfo.author.iso8601Date == "2026-03-12T17:02:46+01:00"
230+
commitInfo.committer.name == "Test Author"
231+
commitInfo.committer.email == "test-author@example.com"
232+
commitInfo.committer.iso8601Date == "2026-03-12T17:02:46+01:00"
233+
commitInfo.fullMessage == "Commit message 0"
234234
}
235235

236236
def "test get latest commits"() {

dd-java-agent/agent-ci-visibility/src/test/resources/ci/git/shallow/dummy.txt

Whitespace-only changes.

dd-java-agent/agent-ci-visibility/src/test/resources/ci/git/shallow/git/description

Lines changed: 0 additions & 1 deletion
This file was deleted.
Binary file not shown.

0 commit comments

Comments
 (0)