-
Notifications
You must be signed in to change notification settings - Fork 1.2k
esbuild support for IAST in Node.js #32079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
CarlesDD
merged 5 commits into
master
from
carles.capell/iast-nodejs-esbuild-support-cjs
Oct 14, 2025
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
212e7c5
esbuild support for IAST in Node.js
CarlesDD 8b93f98
Fix vale annotations
CarlesDD e721193
Update content/en/security/code_security/iast/setup/nodejs.md
CarlesDD 44ba2fc
Apply suggestions from code review
CarlesDD e957b8f
Update content/en/security/code_security/iast/setup/nodejs.md
CarlesDD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,6 +102,71 @@ Update your ECS task definition JSON file, by adding this in the environment sec | |
|
|
||
| If you need additional assistance, contact [Datadog support][6]. | ||
|
|
||
| ## Bundling with esbuild | ||
|
|
||
| `dd-trace` provides esbuild support in the form of an esbuild plugin. Starting from `[email protected]`, this plugin also provides support for IAST product on CommonJS bundled applications. | ||
|
|
||
| Here's an example of how one might use dd-trace with esbuild: | ||
|
|
||
| ```javascript | ||
| // esbuild/esbuilder.js | ||
|
|
||
| const ddPlugin = require('dd-trace/esbuild') | ||
| const esbuild = require('esbuild') | ||
|
|
||
| esbuild.build({ | ||
| entryPoints: ['app.js'], | ||
| bundle: true, | ||
| outfile: 'out.js', | ||
| sourcemap: true, // required for correct vulnearability location | ||
| plugins: [ddPlugin], | ||
| platform: 'node', // allows built-in modules to be required | ||
| target: ['node18'], | ||
| external: [ | ||
| '@datadog/native-iast-taint-tracking' // required for Datadog IAST features | ||
| ] | ||
| }).catch((err) => { | ||
| console.error(err) | ||
| process.exit(1) | ||
| }) | ||
| ``` | ||
|
|
||
| To enable IAST when running the bundler, set the `DD_IAST_ENABLED` environment variable to `true`: | ||
CarlesDD marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```sh | ||
| DD_IAST_ENABLED=true node esbuild/esbuilder.js | ||
| ``` | ||
|
|
||
| Because the tracer uses native modules, these must be included in the `external` list. Native modules used by `dd-trace` are provided in packages prefixed with `@datadog`. You must also distribute a `node_modules` directory alongside the bundled application. | ||
CarlesDD marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| To generate a minimal `node_modules` directory containing only the required native modules and their dependencies: | ||
CarlesDD marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 1. Determine the required package versions. | ||
|
|
||
| 2. Create a temporary directory for installation. | ||
|
|
||
| 3. Copy the resulting `node_modules` directory to the application's output directory. | ||
CarlesDD marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ```sh | ||
| cd path/to/project | ||
| npm ls @datadog/native-iast-taint-tracking | ||
| # [email protected] | ||
| # └── @datadog/[email protected] | ||
| mkdir temp && cd temp | ||
| npm init -y | ||
| npm install @datadog/[email protected] | ||
| cp -R ./node_modules path/to/bundle | ||
| ``` | ||
|
|
||
| ### Unsupported IAST features | ||
|
|
||
| IAST support for bundled applications has some limitations, which are listed below: | ||
CarlesDD marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - Hardcoded password and Hardcoded secrets vulnerability detection | ||
|
|
||
| - Security Controls feature | ||
CarlesDD marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| ## Further Reading | ||
|
|
||
| {{< partial name="whats-next/whats-next.html" >}} | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.