Skip to content

feat(iast): Improve callsite processing on IAST vuln location computing#7509

Merged
CarlesDD merged 4 commits intomasterfrom
ccapell/iast-vuln-location-detection-improve-exculded
Feb 27, 2026
Merged

feat(iast): Improve callsite processing on IAST vuln location computing#7509
CarlesDD merged 4 commits intomasterfrom
ccapell/iast-vuln-location-detection-improve-exculded

Conversation

@CarlesDD
Copy link
Copy Markdown
Contributor

@CarlesDD CarlesDD commented Feb 12, 2026

What does this PR do?

Simplifies IAST stack trace filtering by replacing the manually maintained EXCLUDED_PATH_PREFIXES list with filename.startsWith('node:') to automatically exclude all Node.js built-in modules. Also adds fallback to all processed frames when no client frames are found.

Motivation

Since dd-trace v5 only supports Node.js >= 18, and all built-in modules have the node: prefix in stack traces, we can exclude them automatically. This eliminates maintenance burden when new Node.js modules appear in stack traces.

APPSEC-61435

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.24%. Comparing base (e51c0ec) to head (48d988d).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7509      +/-   ##
==========================================
- Coverage   80.24%   80.24%   -0.01%     
==========================================
  Files         733      733              
  Lines       31663    31662       -1     
==========================================
- Hits        25409    25407       -2     
- Misses       6254     6255       +1     
Flag Coverage Δ
aiguard-macos 38.94% <ø> (-0.10%) ⬇️
aiguard-ubuntu 39.05% <ø> (-0.10%) ⬇️
aiguard-windows 38.79% <ø> (-0.10%) ⬇️
apm-capabilities-tracing-macos 48.51% <8.33%> (-0.01%) ⬇️
apm-capabilities-tracing-ubuntu 48.54% <8.33%> (-0.01%) ⬇️
apm-capabilities-tracing-windows 48.28% <8.33%> (-0.01%) ⬇️
apm-integrations-child-process 38.52% <ø> (-0.10%) ⬇️
apm-integrations-couchbase-18 37.44% <ø> (-0.10%) ⬇️
apm-integrations-couchbase-eol 37.92% <ø> (-0.10%) ⬇️
apm-integrations-oracledb 37.75% <ø> (-0.10%) ⬇️
appsec-express 55.37% <100.00%> (-0.08%) ⬇️
appsec-fastify 51.69% <91.66%> (-0.11%) ⬇️
appsec-graphql 51.87% <91.66%> (-0.11%) ⬇️
appsec-kafka 44.41% <91.66%> (-0.07%) ⬇️
appsec-ldapjs 44.04% <100.00%> (-0.09%) ⬇️
appsec-lodash 43.70% <91.66%> (-0.13%) ⬇️
appsec-macos 58.38% <100.00%> (-0.08%) ⬇️
appsec-mongodb-core 48.75% <100.00%> (-0.19%) ⬇️
appsec-mongoose 49.53% <100.00%> (-0.08%) ⬇️
appsec-mysql 50.90% <100.00%> (-0.08%) ⬇️
appsec-node-serialize 43.21% <91.66%> (-0.13%) ⬇️
appsec-passport 47.67% <ø> (-0.09%) ⬇️
appsec-postgres 50.64% <100.00%> (-0.10%) ⬇️
appsec-sourcing 42.61% <8.33%> (-0.09%) ⬇️
appsec-template 43.38% <91.66%> (-0.13%) ⬇️
appsec-ubuntu 58.46% <100.00%> (-0.08%) ⬇️
appsec-windows 58.22% <100.00%> (-0.10%) ⬇️
instrumentations-instrumentation-bluebird 32.31% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-body-parser 40.49% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-child_process 37.84% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-cookie-parser 34.31% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-express 34.64% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 34.44% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-express-session 40.12% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-fs 31.92% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-generic-pool 29.73% <ø> (ø)
instrumentations-instrumentation-http 39.84% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-knex 32.31% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-mongoose 33.45% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-multer 40.24% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-mysql2 38.31% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-passport 44.03% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-passport-http 43.70% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-passport-local 44.24% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-pg 37.73% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-promise 32.24% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-promise-js 32.25% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-q 32.29% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-url 32.21% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-when 32.26% <ø> (-0.10%) ⬇️
llmobs-ai 41.30% <ø> (-0.10%) ⬇️
llmobs-anthropic 40.31% <ø> (-0.09%) ⬇️
llmobs-bedrock 39.26% <ø> (-0.09%) ⬇️
llmobs-google-genai 39.84% <ø> (-0.09%) ⬇️
llmobs-langchain 39.75% <ø> (-0.08%) ⬇️
llmobs-openai 44.08% <ø> (-0.09%) ⬇️
llmobs-vertex-ai 40.10% <ø> (-0.09%) ⬇️
platform-core 31.53% <ø> (ø)
platform-esbuild 34.48% <ø> (ø)
platform-instrumentations-misc 43.70% <ø> (ø)
platform-shimmer 37.63% <ø> (ø)
platform-unit-guardrails 32.95% <ø> (ø)
plugins-azure-event-hubs 25.59% <ø> (ø)
plugins-azure-service-bus 24.96% <ø> (ø)
plugins-bullmq 43.72% <ø> (-0.10%) ⬇️
plugins-cassandra 37.79% <ø> (-0.10%) ⬇️
plugins-cookie 26.65% <ø> (ø)
plugins-cookie-parser 26.44% <ø> (ø)
plugins-crypto 26.79% <ø> (ø)
plugins-dd-trace-api 38.37% <ø> (-0.10%) ⬇️
plugins-express-mongo-sanitize 26.59% <ø> (ø)
plugins-express-session 26.40% <ø> (ø)
plugins-fastify 42.24% <ø> (-0.09%) ⬇️
plugins-fetch 38.33% <ø> (-0.10%) ⬇️
plugins-fs 38.62% <ø> (-0.10%) ⬇️
plugins-generic-pool 25.63% <ø> (ø)
plugins-google-cloud-pubsub 45.38% <ø> (-0.09%) ⬇️
plugins-grpc 40.94% <ø> (-0.09%) ⬇️
plugins-handlebars 26.63% <ø> (ø)
plugins-hapi 40.13% <ø> (-0.10%) ⬇️
plugins-hono 40.39% <ø> (-0.10%) ⬇️
plugins-ioredis 38.43% <ø> (-0.10%) ⬇️
plugins-knex 26.28% <ø> (ø)
plugins-ldapjs 24.13% <ø> (ø)
plugins-light-my-request 26.00% <ø> (ø)
plugins-limitd-client 32.60% <ø> (-0.10%) ⬇️
plugins-lodash 25.72% <ø> (ø)
plugins-mariadb 39.49% <ø> (-0.10%) ⬇️
plugins-memcached 38.17% <ø> (-0.10%) ⬇️
plugins-microgateway-core 39.17% <ø> (-0.10%) ⬇️
plugins-moleculer 40.51% <ø> (-0.10%) ⬇️
plugins-mongodb 39.20% <ø> (-0.10%) ⬇️
plugins-mongodb-core 39.03% <ø> (-0.10%) ⬇️
plugins-mongoose 38.86% <ø> (-0.10%) ⬇️
plugins-multer 26.40% <ø> (ø)
plugins-mysql 39.17% <ø> (-0.10%) ⬇️
plugins-mysql2 39.27% <ø> (-0.10%) ⬇️
plugins-node-serialize 26.69% <ø> (ø)
plugins-opensearch 37.62% <ø> (-0.10%) ⬇️
plugins-passport-http 26.45% <ø> (ø)
plugins-postgres 35.73% <ø> (-0.09%) ⬇️
plugins-process 26.79% <ø> (ø)
plugins-pug 26.65% <ø> (ø)
plugins-redis 38.75% <ø> (-0.25%) ⬇️
plugins-router 42.97% <ø> (-0.10%) ⬇️
plugins-sequelize 25.23% <ø> (ø)
plugins-test-and-upstream-amqp10 38.35% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-amqplib 43.83% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-apollo 39.03% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-avsc 38.71% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-bunyan 33.88% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-connect 40.79% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-graphql 40.14% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-koa 40.37% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-protobufjs 38.94% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-rhea 44.03% <ø> (-0.10%) ⬇️
plugins-undici 39.11% <ø> (-0.09%) ⬇️
plugins-url 26.79% <ø> (ø)
plugins-valkey 38.09% <ø> (-0.10%) ⬇️
plugins-vm 26.79% <ø> (ø)
plugins-winston 34.07% <ø> (-0.10%) ⬇️
plugins-ws 41.89% <ø> (-0.10%) ⬇️
profiling-macos 39.84% <ø> (-0.10%) ⬇️
profiling-ubuntu 39.96% <ø> (-0.10%) ⬇️
profiling-windows 41.17% <ø> (-0.10%) ⬇️
serverless-azure-functions-client 25.31% <ø> (ø)
serverless-azure-functions-eventhubs 25.31% <ø> (ø)
serverless-azure-functions-servicebus 25.31% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 12, 2026

Overall package size

Self size: 4.84 MB
Deduped: 5.69 MB
No deduping: 5.69 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.6 | 81.92 kB | 816.75 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@CarlesDD CarlesDD marked this pull request as ready for review February 12, 2026 18:16
@CarlesDD CarlesDD requested a review from a team as a code owner February 12, 2026 18:16
Copy link
Copy Markdown
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

Overall LGTM, just left some minor suggestions

Comment on lines +83 to +84
if (filename.startsWith('node:')) {
return true
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ideally, this is moved up into the !filename if statement with an OR. That way there is no additional work done while checking for that.

}

return result
return clientFrames.length > 0 ? clientFrames : allFrames
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need to copy the frames for allFrames? Would it not be fine to just return callSiteFrames?

Suggested change
return clientFrames.length > 0 ? clientFrames : allFrames
return clientFrames.length > 0 ? clientFrames : callSiteFrames

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We can't return callSiteFrames directly because allFrames is a subset of processed frames that have valid file information (only contains frames with a valid filepath - line 61 filter). Frames without filepath are excluded and wouldn't have the path/isInternal properties added.

Comment on lines +23 to +25
* @param {Array} callSiteFrames
* @param {Array} externallyExcludedPaths
* @returns {Array} Client frames if available, otherwise all processed frames
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: define the content of the arrays. That could be defined in the Node.js types already

Comment on lines +38 to +39
const frames = getCallSiteFramesForLocation(callSiteFrames, this._getExcludedPaths())
const location = this._getLocation(value, frames)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: are these underscored properties really meant as internally private? A customer would normally not get hold of them, if I am not mistaken, while we seem to use them across classes.

I am just commenting about it because it would be great to make truly internal methods truly private and keep others accessible (as long as they are not directly accessible for customers).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, they're not meant as internally private. _getLocation is overridden by several subclasses (e.g., CookieAnalyzer, HardcodedBaseAnalyzer, MissingHeaderAnalyzer) and some call super._getLocation()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In that case we should not use the underscore, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The underscore prefix here acts as "protected" in OOP terms: not for external/customer use, but accessible to internal subclasses. This is a consistent pattern across the codebase, not just in appsec:

Changing this naming convention across the codebase would be a larger refactor outside the scope of this PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I understand why it was used but we are currently moving away from that in most code.
Thus, when we touch something, it would be great to change it as well. In this particular case making them non-underscored would in my opinion be the way to go.

I marked it as nit, so it is not something that I expect to be done as part of the PR, while it would be nice.

@CarlesDD CarlesDD force-pushed the ccapell/iast-vuln-location-detection-improve-exculded branch from ccf3e08 to 03854ff Compare February 24, 2026 14:16
@CarlesDD CarlesDD marked this pull request as draft February 24, 2026 14:29
@pr-commenter
Copy link
Copy Markdown

pr-commenter bot commented Feb 24, 2026

Benchmarks

Benchmark execution time: 2026-02-27 06:29:16

Comparing candidate commit 48d988d in PR branch ccapell/iast-vuln-location-detection-improve-exculded with baseline commit e51c0ec in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 232 metrics, 28 unstable metrics.

@CarlesDD CarlesDD marked this pull request as ready for review February 24, 2026 14:54
@CarlesDD CarlesDD merged commit 3913137 into master Feb 27, 2026
878 of 881 checks passed
@CarlesDD CarlesDD deleted the ccapell/iast-vuln-location-detection-improve-exculded branch February 27, 2026 06:59
dd-octo-sts bot pushed a commit that referenced this pull request Feb 27, 2026
…ng (#7509)

* Improve callsite processing on IAST vuln location computing

* Simplify excluding conditional

* Specify array types in getCallSiteFramesForLocation JSDoc
@dd-octo-sts dd-octo-sts bot mentioned this pull request Feb 27, 2026
juan-fernandez pushed a commit that referenced this pull request Mar 5, 2026
…ng (#7509)

* Improve callsite processing on IAST vuln location computing

* Simplify excluding conditional

* Specify array types in getCallSiteFramesForLocation JSDoc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants