Update your Datadog Node.js library package to at least version 5.0.0 (for Node 18+) or 4.0.0 (for Node 16+) or 3.10.0 (for Node.js 14+), by running one of these commands:
Use this migration guide to assess any breaking changes if you upgraded your library.
Application Security Management is compatible with Express v4+ and Node.js v14+. For additional information, see Compatibility.
Where you import and initialize the Node.js library for APM, also enable ASM. This might be either in your code or with environment variables. If you initialized APM in code, add {appsec: true} to your init statement:
// This line must come before importing any instrumented module.
consttracer=require('dd-trace').init({appsec:true})
For TypeScript and bundlers that support EcmaScript Module syntax, initialize the tracer in a separate file in order to maintain correct load order.
// server.ts
import'./tracer';// must come before importing any instrumented module.
// tracer.ts
importtracerfrom'dd-trace';tracer.init({appsec: true});// initialized in a different file to avoid hoisting.
exportdefaulttracer;
If the default config is sufficient, or all configuration is done through environment variables, you can also use dd-trace/init, which loads and initializes in one step.
import`dd-trace/init`;
Or if you initialize the APM library on the command line using the --require option to Node.js:
node --require dd-trace/init app.js
Then use environment variables to enable ASM:
DD_APPSEC_ENABLED=true node app.js
How you do this varies depending on where your service runs:
for ((i=1;i<=250;i++)); do # Target existing service’s routes curl https://your-application-url/existing-route -A dd-test-scanner-log; # Target non existing service’s routes curl https://your-application-url/non-existing-route -A dd-test-scanner-log; done