Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
1a3d504
Add new function to add endpoint
estringana Aug 18, 2025
2cb2b5d
Aproaching solution
estringana Aug 21, 2025
f556623
Use shared cache instead of local
estringana Aug 22, 2025
80ec6fc
wip
estringana Aug 25, 2025
ef57be2
Used last push endpoints
estringana Aug 26, 2025
3789728
Tests passing
estringana Aug 27, 2025
41587cd
Fix rebase errors
estringana Aug 27, 2025
355938c
wip
estringana Sep 25, 2025
bbe08b8
Update generated files
estringana Sep 25, 2025
5a55489
Make string vectors work
estringana Sep 25, 2025
6e9d6c7
wip
estringana Sep 26, 2025
47e2f9f
Add i32 vector
estringana Sep 29, 2025
67fa2c0
Add authentication vector
estringana Sep 29, 2025
bffa264
Add serde json
estringana Sep 29, 2025
ac34cfb
Remove debugging lines
estringana Sep 29, 2025
55efaf6
Replace char_c for slices
estringana Sep 29, 2025
5196a0d
Amend PR comments
estringana Sep 29, 2025
db01490
Strip invalid utf8 chars
estringana Sep 30, 2025
c18d245
Send Laravel endpoints
estringana Oct 6, 2025
6ac2b9d
Point to latest
estringana Oct 6, 2025
83d668e
Fix add-routes-collection (#3446)
estringana Oct 15, 2025
ca9f4ad
Point to latest libdatadog
estringana Oct 16, 2025
887257b
Remove response_code
estringana Oct 17, 2025
f548454
Remove non used fields
estringana Oct 17, 2025
339396f
Point to latest
estringana Oct 17, 2025
ecd9cb6
Generate cbindgen
estringana Oct 17, 2025
8995507
Test Laravel integration
estringana Oct 21, 2025
c2b1e19
Refactor telemetry collection on appsec integration tests
estringana Oct 21, 2025
2124453
Remove non necessary file
estringana Oct 21, 2025
abd49d1
Update php stub
estringana Oct 21, 2025
6572b7a
Generate common
estringana Oct 22, 2025
4c9166a
Amend laravel compatibility
estringana Oct 22, 2025
eb1d3da
Revert non required changes
estringana Oct 22, 2025
99814d2
Play defensive on Laravel Integration
estringana Oct 22, 2025
a88af9b
Get routes from Symfony
estringana Oct 22, 2025
acc187b
Amend issue with drupal
estringana Oct 22, 2025
46701dd
Add wordpress integration
estringana Oct 24, 2025
87f7224
wip
estringana Oct 24, 2025
6ab590f
Test laravel
estringana Oct 28, 2025
11c140b
Test symfony
estringana Oct 28, 2025
a4bae1b
Fix latest symfony
estringana Oct 29, 2025
9493c3d
Fix old symfony versions tests
estringana Oct 29, 2025
1fd556c
Fix some symfony failing versions
estringana Oct 30, 2025
da4eebc
Fix build
estringana Dec 30, 2025
cab5bec
Point to latest libdatadog
estringana Dec 30, 2025
5799b4c
Remove debugging lines
estringana Jan 2, 2026
a5cf63a
Reduce telemetry heartbeat lapse
estringana Jan 2, 2026
295efe3
Refactor test to avoid duplication
estringana Jan 2, 2026
50f90c8
Test wordpress
estringana Jan 2, 2026
c209525
Fix telemetry
estringana Jan 5, 2026
2734188
Exclude symfony 4 from getting endpoints at startup
estringana Jan 7, 2026
4bdf65f
Fix wordpress tests
estringana Jan 7, 2026
d49f445
Merge branch 'master' into estringana/collect-framework-endpoints-2
estringana Jan 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 48 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions appsec/tests/integration/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ def buildTracerTask = { String version, String variant ->
}

def buildAppSecTask = { String version, String variant ->
def buildType = variant.contains('debug') ? 'Debug' : 'RelWithDebInfo'
buildRunInDockerTask(
baseName: 'buildAppsec',
baseTag: 'php',
Expand All @@ -346,17 +347,17 @@ def buildAppSecTask = { String version, String variant ->
],
command: [
'-e', '-c',
'''
"""
git config --global --add safe.directory '*'
cd /appsec
test -f CMakeCache.txt || \\
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \\
cmake -DCMAKE_BUILD_TYPE=$buildType \\
-DCMAKE_INSTALL_PREFIX=/appsec \\
-DDD_APPSEC_ENABLE_PATCHELF_LIBC=ON \\
-DDD_APPSEC_TESTING=ON /project/appsec
make -j extension ddappsec-helper && \\
touch ddappsec.so libddappsec-helper.so
'''
"""
]
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.datadog.appsec.php

import groovy.transform.Canonical
import java.net.http.HttpRequest
import java.net.http.HttpResponse
import com.datadog.appsec.php.docker.AppSecContainer
import static java.net.http.HttpResponse.BodyHandlers.ofString

/**
* @link https://github.com/DataDog/instrumentation-telemetry-api-docs/blob/main/GeneratedDocumentation/ApiDocs/v2/producing-telemetry.md
Expand All @@ -22,6 +26,29 @@ class TelemetryHelpers {
}
}

static class AppEndpoints {
static names = ['app-endpoints']
List<Endpoint> endpoints

AppEndpoints(Map m) {
endpoints = m.endpoints.collect { new Endpoint(it as Map) }
}
}

static class Endpoint {
String method
String operationName
String path
String resourceName

Endpoint(Map m) {
method = m.method
operationName = m.operation_name
path = m.path
resourceName = m.resource_name
}
}

static class Metric {
String namespace
String name
Expand Down Expand Up @@ -137,4 +164,43 @@ class TelemetryHelpers {
autoEnabled = m.autoEnabled
}
}

public static <T> List<T> waitForTelemetryData(AppSecContainer container, int timeoutSec, Closure<Boolean> cl, Class<T> cls, String path = '/hello.php') {
List<T> messages = []
def deadline = System.currentTimeSeconds() + timeoutSec
def lastHttpReq = System.currentTimeSeconds() - 6
while (System.currentTimeSeconds() < deadline) {
Comment on lines +170 to +172

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Badge Fix nonexistent System.currentTimeSeconds call

System.currentTimeSeconds() is not a Java/Groovy API, so this will throw MissingMethodException at runtime the first time waitForTelemetryData is used. That means the new endpoint telemetry tests that call waitForAppEndpoints/waitForMetrics/… will fail immediately instead of waiting on telemetry. Use System.currentTimeMillis() / 1000 or Instant.now().epochSecond instead.

Useful? React with 👍 / 👎.

if (System.currentTimeSeconds() - lastHttpReq > 5) {
lastHttpReq = System.currentTimeSeconds()
// used to flush global (not request-bound) telemetry metrics
def request = container.buildReq(path).GET().build()
def trace = container.traceFromRequest(request, ofString()) { HttpResponse<String> resp ->
assert resp.body().size() > 0
}
}
def telData = container.drainTelemetry(500)
messages.addAll(
TelemetryHelpers.filterMessages(telData, cls))
if (cl.call(messages)) {
break
}
}
messages
}

public static List<AppEndpoints> waitForAppEndpoints(AppSecContainer container, int timeoutSec, Closure<Boolean> cl, String path = '/') {
waitForTelemetryData(container, timeoutSec, cl, AppEndpoints, path)
}

public static List<GenerateMetrics> waitForMetrics(AppSecContainer container, int timeoutSec, Closure<Boolean> cl) {
waitForTelemetryData(container, timeoutSec, cl, GenerateMetrics)
}

public static List<WithIntegrations> waitForIntegrations(AppSecContainer container, int timeoutSec, Closure<Boolean> cl) {
waitForTelemetryData(container, timeoutSec, cl, WithIntegrations)
}

public static List<Logs> waitForLogs(AppSecContainer container, int timeoutSec, Closure<Boolean> cl) {
waitForTelemetryData(container, timeoutSec, cl, Logs)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import java.net.http.HttpResponse

import static com.datadog.appsec.php.integration.TestParams.getPhpVersion
import static com.datadog.appsec.php.integration.TestParams.getVariant
import com.datadog.appsec.php.TelemetryHelpers
import static java.net.http.HttpResponse.BodyHandlers.ofString

@Testcontainers
Expand Down Expand Up @@ -103,4 +104,28 @@ class Laravel8xTests {
assert span.meta."_dd.appsec.event_rules.version" != ''
assert span.meta."appsec.blocked" == "true"
}

@Test
void 'Endpoints are sended'() {
def trace = container.traceFromRequest('/') { HttpResponse<InputStream> resp ->
assert resp.statusCode() == 200
}

assert trace.traceId != null

List<TelemetryHelpers.Endpoint> endpoints

TelemetryHelpers.waitForAppEndpoints(container, 30, { List<TelemetryHelpers.Endpoint> messages ->
endpoints = messages.collectMany { it.endpoints }
endpoints.size() > 0
})

assert endpoints.size() == 6
assert endpoints.find { it.path == '/' && it.method == 'GET' && it.operationName == 'http.request' && it.resourceName == 'GET /' } != null
assert endpoints.find { it.path == 'authenticate' && it.method == 'GET' && it.operationName == 'http.request' && it.resourceName == 'GET authenticate' } != null
assert endpoints.find { it.path == 'register' && it.method == 'GET' && it.operationName == 'http.request' && it.resourceName == 'GET register' } != null
assert endpoints.find { it.path == 'dynamic-path/{param01}' && it.method == 'GET' && it.operationName == 'http.request' && it.resourceName == 'GET dynamic-path/{param01}' } != null
assert endpoints.find { it.path == 'sanctum/csrf-cookie' && it.method == 'GET' && it.operationName == 'http.request' && it.resourceName == 'GET sanctum/csrf-cookie' } != null
assert endpoints.find { it.path == 'api/user' && it.method == 'GET' && it.operationName == 'http.request' && it.resourceName == 'GET api/user' } != null
}
}
Loading
Loading