diff --git a/content/en/security/application_security/setup/aws/fargate/_index.md b/content/en/security/application_security/setup/aws/fargate/_index.md index 891c72cf3a1c7..fc2c75fb4f939 100644 --- a/content/en/security/application_security/setup/aws/fargate/_index.md +++ b/content/en/security/application_security/setup/aws/fargate/_index.md @@ -28,7 +28,7 @@ Learn how to set up App and API Protection (AAP) on your AWS Fargate tasks by se {{< appsec-integrations >}} {{< appsec-integration name="Python" avatar="python" link="/security/application_security/setup/python" >}} - {{< appsec-integration name="Node.js" avatar="node" link="/security/application_security/setup/nodejs" >}} + {{< appsec-integration name="Node.js" avatar="node" link="/security/application_security/setup/nodejs/aws-fargate" >}} {{< appsec-integration name="Java" avatar="java" link="/security/application_security/setup/java/aws-fargate" >}} {{< appsec-integration name="Go" avatar="go" link="/security/application_security/setup/go" >}} {{< appsec-integration name="Ruby" avatar="ruby" link="/security/application_security/setup/ruby" >}} diff --git a/content/en/security/application_security/setup/docker/_index.md b/content/en/security/application_security/setup/docker/_index.md index a0f6f08b36db2..ab75c7f97820e 100644 --- a/content/en/security/application_security/setup/docker/_index.md +++ b/content/en/security/application_security/setup/docker/_index.md @@ -28,7 +28,7 @@ Learn how to set up App and API Protection (AAP) on your Docker containers by se {{< appsec-integrations >}} {{< appsec-integration name="Python" avatar="python" link="/security/application_security/setup/python" >}} - {{< appsec-integration name="Node.js" avatar="node" link="/security/application_security/setup/nodejs" >}} + {{< appsec-integration name="Node.js" avatar="node" link="/security/application_security/setup/nodejs/docker" >}} {{< appsec-integration name="Java" avatar="java" link="/security/application_security/setup/java/docker" >}} {{< appsec-integration name="Go" avatar="go" link="/security/application_security/setup/go" >}} {{< appsec-integration name="Ruby" avatar="ruby" link="/security/application_security/setup/ruby" >}} diff --git a/content/en/security/application_security/setup/kubernetes/_index.md b/content/en/security/application_security/setup/kubernetes/_index.md index 1290a1b0851ac..41642a6469235 100644 --- a/content/en/security/application_security/setup/kubernetes/_index.md +++ b/content/en/security/application_security/setup/kubernetes/_index.md @@ -28,7 +28,7 @@ Learn how to set up App and API Protection (AAP) on your Kubernetes services by {{< appsec-integrations >}} {{< appsec-integration name="Python" avatar="python" link="/security/application_security/setup/python" >}} - {{< appsec-integration name="Node.js" avatar="node" link="/security/application_security/setup/nodejs" >}} + {{< appsec-integration name="Node.js" avatar="node" link="/security/application_security/setup/nodejs/kubernetes" >}} {{< appsec-integration name="Java" avatar="java" link="/security/application_security/setup/java/kubernetes" >}} {{< appsec-integration name="Go" avatar="go" link="/security/application_security/setup/go" >}} {{< appsec-integration name="Ruby" avatar="ruby" link="/security/application_security/setup/ruby" >}} diff --git a/content/en/security/application_security/setup/linux/_index.md b/content/en/security/application_security/setup/linux/_index.md index 9ca9b1ac127a8..7ac926844b611 100644 --- a/content/en/security/application_security/setup/linux/_index.md +++ b/content/en/security/application_security/setup/linux/_index.md @@ -28,7 +28,7 @@ Learn how to set up App and API Protection (AAP) on your Linux services by selec {{< appsec-integrations >}} {{< appsec-integration name="Python" avatar="python" link="/security/application_security/setup/python" >}} - {{< appsec-integration name="Node.js" avatar="node" link="/security/application_security/setup/nodejs" >}} + {{< appsec-integration name="Node.js" avatar="node" link="/security/application_security/setup/nodejs/linux" >}} {{< appsec-integration name="Java" avatar="java" link="/security/application_security/setup/java/linux" >}} {{< appsec-integration name="Go" avatar="go" link="/security/application_security/setup/go" >}} {{< appsec-integration name="Ruby" avatar="ruby" link="/security/application_security/setup/ruby" >}} diff --git a/content/en/security/application_security/setup/macos/_index.md b/content/en/security/application_security/setup/macos/_index.md index 06ea34c79fa80..a9804cf383e6c 100644 --- a/content/en/security/application_security/setup/macos/_index.md +++ b/content/en/security/application_security/setup/macos/_index.md @@ -28,7 +28,7 @@ Learn how to set up App and API Protection (AAP) on your macOS services by selec {{< appsec-integrations >}} {{< appsec-integration name="Python" avatar="python" link="/security/application_security/setup/python" >}} - {{< appsec-integration name="Node.js" avatar="node" link="/security/application_security/setup/nodejs" >}} + {{< appsec-integration name="Node.js" avatar="node" link="/security/application_security/setup/nodejs/macos" >}} {{< appsec-integration name="Java" avatar="java" link="/security/application_security/setup/java/macos" >}} {{< appsec-integration name="Go" avatar="go" link="/security/application_security/setup/go" >}} {{< appsec-integration name="Ruby" avatar="ruby" link="/security/application_security/setup/ruby" >}} diff --git a/content/en/security/application_security/setup/nodejs.md b/content/en/security/application_security/setup/nodejs.md deleted file mode 100644 index e167df856058d..0000000000000 --- a/content/en/security/application_security/setup/nodejs.md +++ /dev/null @@ -1,174 +0,0 @@ ---- -title: Enabling AAP for Node.js -code_lang: nodejs -type: multi-code-lang -code_lang_weight: 50 -aliases: - - /security_platform/application_security/getting_started/nodejs - - /security/application_security/getting_started/nodejs - - /security/application_security/enabling/tracing_libraries/threat_detection/nodejs/ - - /security/application_security/threats/setup/threat_detection/nodejs - - /security/application_security/threats_detection/nodejs - - /security/application_security/setup/aws/fargate/nodejs -further_reading: - - link: "/security/application_security/add-user-info/" - tag: "Documentation" - text: "Adding user information to traces" - - link: 'https://github.com/DataDog/dd-trace-js' - tag: "Source Code" - text: 'Node.js Datadog library source code' - - link: "/security/default_rules/?category=cat-application-security" - tag: "Documentation" - text: "OOTB App and API Protection Rules" - - link: "/security/application_security/troubleshooting" - tag: "Documentation" - text: "Troubleshooting App and API Protection" ---- - -You can monitor App and API Protection for Node.js apps running in Docker, Kubernetes, Amazon ECS, and AWS Fargate. - -{{% appsec-getstarted %}} - -## Enabling threat detection -### Get started - -1. **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: - ```shell - npm install dd-trace@^5 - npm install dd-trace@^4 - npm install dd-trace@^3.10.0 - ``` - Use this [migration guide][1] to assess any breaking changes if you upgraded your library. - - App and API Protection is compatible with Express v4+ and Node.js v14+. For additional information, see [Compatibility][2]. - -2. **Where you import and initialize the Node.js library for APM, also enable AAP.** This might be either in your code or with environment variables. If you initialized APM in code, add `{appsec: true}` to your init statement: - {{< tabs >}} -{{% tab "In JavaScript code" %}} - -```js -// This line must come before importing any instrumented module. -const tracer = require('dd-trace').init({ - appsec: true -}) -``` - -{{% /tab %}} -{{% tab "In TypeScript code" %}} - -For TypeScript and bundlers that support EcmaScript Module syntax, initialize the tracer in a separate file in order to maintain correct load order. -```typescript -// server.ts -import './tracer'; // must come before importing any instrumented module. - -// tracer.ts -import tracer from 'dd-trace'; -tracer.init({ - appsec: true -}); // initialized in a different file to avoid hoisting. -export default tracer; -``` -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. -```typescript -import `dd-trace/init`; -``` -{{% /tab %}} - -{{< /tabs >}} - - **Or** if you initialize the APM library on the command line using the `--require` option to Node.js: - ```shell - node --require dd-trace/init app.js - ``` - Then use environment variables to enable AAP: - ```shell - DD_APPSEC_ENABLED=true node app.js - ``` - How you do this varies depending on where your service runs: - {{< tabs >}} -{{% tab "Docker CLI" %}} - -Update your configuration container for APM by adding the following argument in your `docker run` command: - -```shell -docker run [...] -e DD_APPSEC_ENABLED=true [...] -``` - -{{% /tab %}} -{{% tab "Dockerfile" %}} - -Add the following environment variable value to your container Dockerfile: - -```Dockerfile -ENV DD_APPSEC_ENABLED=true -``` - -{{% /tab %}} -{{% tab "Kubernetes" %}} - -Update your configuration yaml file container for APM and add the AppSec env variable: - -```yaml -spec: - template: - spec: - containers: - - name: - image: / - env: - - name: DD_APPSEC_ENABLED - value: "true" -``` - -{{% /tab %}} -{{% tab "Amazon ECS" %}} - -Update your ECS task definition JSON file, by adding this in the environment section: - -```json -"environment": [ - ..., - { - "name": "DD_APPSEC_ENABLED", - "value": "true" - } -] -``` - -{{% /tab %}} -{{% tab "AWS Fargate" %}} - -Initialize AAP in your code or set `DD_APPSEC_ENABLED` environment variable to `true` in your service invocation: -```shell -DD_APPSEC_ENABLED=true node app.js -``` - -{{% /tab %}} -{{< /tabs >}} - -{{% appsec-getstarted-2-plusrisk %}} - -{{< img src="/security/application_security/appsec-getstarted-threat-and-vuln_2.mp4" alt="Video showing Signals explorer and details, and Vulnerabilities explorer and details." video="true" >}} - - -If you need additional assistance, contact [Datadog support][6]. - -## Using AAP without APM tracing - -If you want to use Application & API Protection without APM tracing functionality, you can deploy with tracing disabled: - -1. Configure your tracing library with the `DD_APM_TRACING_ENABLED=false` environment variable in addition to the `DD_APPSEC_ENABLED=true` environment variable. -2. This configuration will reduce the amount of APM data sent to Datadog to the minimum required by App and API Protection products. - -For more details, see [Standalone App and API Protection][standalone_billing_guide]. -[standalone_billing_guide]: /security/application_security/guide/standalone_application_security/ - -## Further Reading - -{{< partial name="whats-next/whats-next.html" >}} - -[1]: https://github.com/DataDog/dd-trace-js/blob/master/MIGRATING.md -[2]: /security/application_security/setup/compatibility/nodejs -[4]: /agent/versions/upgrade_between_agent_minor_versions/ -[5]: https://app.datadoghq.com/security/appsec/vm -[6]: /help diff --git a/content/en/security/application_security/setup/nodejs/_index.md b/content/en/security/application_security/setup/nodejs/_index.md new file mode 100644 index 0000000000000..7069dfe269db3 --- /dev/null +++ b/content/en/security/application_security/setup/nodejs/_index.md @@ -0,0 +1,51 @@ +--- +title: Enabling App and API Protection for Node.js +aliases: + - /security_platform/application_security/getting_started/nodejs + - /security/application_security/getting_started/nodejs + - /security/application_security/enabling/tracing_libraries/threat_detection/nodejs/ + - /security/application_security/threats/setup/threat_detection/nodejs + - /security/application_security/threats_detection/nodejs + - /security/application_security/setup/aws/fargate/nodejs +further_reading: + - link: "/security/application_security/add-user-info/" + tag: "Documentation" + text: "Adding user information to traces" + - link: 'https://github.com/DataDog/dd-trace-js' + tag: "Source Code" + text: 'Node.js Datadog library source code' + - link: "/security/default_rules/?category=cat-application-security" + tag: "Documentation" + text: "OOTB App and API Protection Rules" + - link: "/security/application_security/troubleshooting" + tag: "Documentation" + text: "Troubleshooting App and API Protection" +--- +{{< partial name="app_and_api_protection/callout.html" >}} + +{{% aap/aap_and_api_protection_nodejs_overview showSetup="false" %}} + +## Environments + +### Hosts +{{< appsec-integrations >}} +{{< appsec-integration name="Linux" avatar="linux" link="./linux" >}} +{{< appsec-integration name="macOS" avatar="apple" link="./macos" >}} +{{< appsec-integration name="Windows" avatar="windows" link="./windows" >}} +{{< /appsec-integrations >}} + +### Cloud and Container Platforms +{{< appsec-integrations >}} +{{< appsec-integration name="Docker" avatar="docker" link="./docker" >}} +{{< appsec-integration name="Kubernetes" avatar="kubernetes" link="./kubernetes" >}} +{{< /appsec-integrations >}} + +### AWS +{{< appsec-integrations >}} +{{< appsec-integration name="AWS Fargate" avatar="aws-fargate" link="./aws-fargate" >}} +{{< /appsec-integrations >}} + +## Additional Resources + +- [Troubleshooting Guide](./troubleshooting) +- [Compatibility Information](./compatibility) diff --git a/content/en/security/application_security/setup/nodejs/aws-fargate.md b/content/en/security/application_security/setup/nodejs/aws-fargate.md new file mode 100644 index 0000000000000..945b1a0e44b6a --- /dev/null +++ b/content/en/security/application_security/setup/nodejs/aws-fargate.md @@ -0,0 +1,169 @@ +--- +code_lang: aws-fargate +type: multi-code-lang +code_lang_weight: 60 +title: Set up App and API Protection for Node.js on AWS Fargate +further_reading: +- link: "/security/application_security/how-it-works/" + tag: "Documentation" + text: "How App and API Protection Works" +- link: "/security/default_rules/?category=cat-application-security" + tag: "Documentation" + text: "OOTB App and API Protection Rules" +- link: "/security/application_security/troubleshooting" + tag: "Documentation" + text: "Troubleshooting App and API Protection" +--- + +{{% aap/aap_and_api_protection_nodejs_overview %}} + +## Prerequisites + +- AWS Fargate environment +- Node.js application containerized with Docker +- AWS CLI configured with appropriate permissions +- Your Datadog API key +- Datadog Node.js tracing library (see [version requirements][1]) + +## 1. Installing the Datadog Agent + +Install the Datadog Agent in your Fargate task definition: + +```json +{ + "containerDefinitions": [ + { + "name": "datadog-agent", + "image": "public.ecr.aws/datadog/agent:latest", + "environment": [ + { + "name": "DD_API_KEY", + "value": "" + }, + { + "name": "DD_APM_ENABLED", + "value": "true" + }, + { + "name": "DD_APM_NON_LOCAL_TRAFFIC", + "value": "true" + } + ] + } + ] +} +``` + +## 2. Enabling App and API Protection monitoring + +{{% aap/aap_and_api_protection_nodejs_navigation_menu %}} + +{{% aap/aap_and_api_protection_nodejs_remote_config_activation %}} + +### Manually enabling App and API Protection monitoring + +Ensure your Dockerfile includes the Datadog Node.js library: + +```dockerfile +FROM node:18-alpine + +# Install the Datadog Node.js library +RUN npm install dd-trace + +# Copy your application files +COPY package*.json ./ +COPY . . +RUN npm install + +# Start the application with the Datadog tracer +CMD ["node", "--require", "dd-trace/init", "app.js"] +``` + +{{% collapse-content title="APM Tracing Enabled" level="h4" %}} + +Update your task definition to include the Node.js application container with App and API Protection configuration: + +```json +{ + "containerDefinitions": [ + { + "name": "your-nodejs-app", + "image": "your-nodejs-app-image", + "environment": [ + { + "name": "DD_APPSEC_ENABLED", + "value": "true" + }, + { + "name": "DD_SERVICE", + "value": "" + }, + { + "name": "DD_ENV", + "value": "" + } + ] + } + ] +} +``` + +{{% /collapse-content %}} + +{{% collapse-content title="APM Tracing Disabled" level="h4" %}} +To disable APM tracing while keeping App and API Protection enabled, you must set the APM tracing variable to false. + +Update your task definition to include the Node.js application container with App and API Protection configuration: + +```json +{ + "containerDefinitions": [ + { + "name": "your-nodejs-app", + "image": "your-nodejs-app-image", + "environment": [ + { + "name": "DD_APPSEC_ENABLED", + "value": "true" + }, + { + "name": "DD_APM_TRACING_ENABLED", + "value": "false" + }, + { + "name": "DD_SERVICE", + "value": "" + }, + { + "name": "DD_ENV", + "value": "" + } + ] + } + ] +} +``` + +{{% /collapse-content %}} + +## 3. Run your application + +Deploy your Fargate task with the updated configuration: + +```bash +aws ecs register-task-definition --cli-input-json file://task-definition.json +aws ecs run-task --cluster your-cluster --task-definition your-task-definition +``` + +{{% aap/aap_and_api_protection_nodejs_verify_setup %}} + +## Troubleshooting + +If you encounter issues while setting up App and API Protection for your Node.js application, see the [Node.js App and API Protection troubleshooting guide][2]. + +## Further Reading + +{{< partial name="whats-next/whats-next.html" >}} + +[1]: /security/application_security/setup/nodejs/compatibility +[2]: /security/application_security/setup/nodejs/troubleshooting diff --git a/content/en/security/application_security/setup/nodejs/compatibility.md b/content/en/security/application_security/setup/nodejs/compatibility.md new file mode 100644 index 0000000000000..7cbb83574d6ad --- /dev/null +++ b/content/en/security/application_security/setup/nodejs/compatibility.md @@ -0,0 +1,165 @@ +--- +title: Node.js Compatibility Requirements +code_lang: nodejs +type: multi-code-lang +code_lang_weight: 50 +aliases: + - /security/application_security/threats/setup/compatibility/nodejs +--- + +## App and API Protection capabilities + +The following App and API Protection capabilities are supported in the Node.js library, for the specified tracer version: + +| App and API Protection capability | Minimum Node.js tracer version | +|----------------------------------------|--------------------------------------------------| +| Threat Detection | 4.0.0 | +| Threat Protection | 4.0.0 | +| Customize response to blocked requests | 4.1.0 | +| Automatic user activity event tracking | 4.4.0 | +| API Security | 4.30.0 | + +The minimum tracer version to get all supported App and API Protection capabilities for Node.js is 4.30.0. + +**Note**: +- Threat Protection requires enabling [Remote Configuration][2], which is included in the listed minimum tracer version. + +### Supported deployment types + +| Type | Threat Detection support | +|-------------|--------------------------| +| Docker | {{< X >}} | +| Kubernetes | {{< X >}} | +| Amazon ECS | {{< X >}} | +| AWS Fargate | {{< X >}} | +| AWS Lambda | {{< X >}} | + + +## Language and framework compatibility + +### Node.js Version Support + +When the Node.js project drops support for an LTS major release line (when it goes End of Life), support for it is dropped in the next major version of `dd-trace`. +The last major supporting release line of `dd-trace` library supports that EOL version of Node.js for at least another year on a maintenance mode basis. + +Some issues cannot be solved in `dd-trace` and instead must be solved in Node.js. When this happens and the Node.js release in question is EOL, it's not possible to solve the issue without moving to another non-EOL release. +Datadog does not make new releases of `dd-trace` to provide specific support for non-LTS Node.js major release lines (odd numbered versions). + +For the best level of support, always run the latest LTS release of Node.js, and the latest major version of `dd-trace`. Whatever release line of Node.js you use, also use the latest version of Node.js on that release line, to ensure you have the latest security fixes. + +For more information about Node.js release, see the [official Node.js documentation][4]. + +### Operating system support + +The following operating systems are officially supported by `dd-trace`. Any operating system not listed is still likely to work, but with some features missing, for example App and API Protection capabilities, profiling, and runtime metrics. Generally speaking, operating systems that are actively maintained at the time of initial release for a major version are supported. + +| Operating System | Architectures | Minimum Versions | +|------------------|---------------|------------------------------------------| +| Linux (glibc) | arm64, x64 | CentOS 7, Debian 9, RHEL 7, Ubuntu 14.04 | +| Linux (musl) | arm64, x64 | Alpine 3.13 | +| macOS | arm64, x64 | Catalina (10.15) | +| Windows | x64 | Windows 8.1, Windows Server 2012 | + +### Web framework compatibility + +- Attacker source HTTP request details +- Tags for the HTTP request (status code, method, etc) +- Distributed Tracing to see attack flows through your applications + +##### App and API Protection Capability Notes + +Although Threat Protection is available for express >= 4 versions, the blocking of payloads on the body is only supported for applications using either the [`body-parser`][45] or [`multer`][46] libraries. + +| Framework | Versions | Threat Detection supported? | Threat Protection supported? | +|-----------|----------|-----------------------------|------------------------------| +| express | `>=4` | {{< X >}} | {{< X >}} | +| fastify | `>=2` | {{< X >}} | {{< X >}} | +| nextjs | `>=11.1` | {{< X >}} | | + +
If you would like to see support added for any of the unsupported capabilities or for your Node.js framework, let us know! Fill out this short form to send details.
+ +### Networking framework compatibility + +**Networking tracing provides:** + +- Distributed tracing through your applications +- Request-based blocking + +##### App and API Protection Capability Notes + +| Framework | Threat Detection supported? | Threat Protection supported? | +|-----------|-----------------------------|------------------------------| +| http | {{< X >}} | {{< X >}} | +| https | {{< X >}} | {{< X >}} | + + +
If you don't see your framework of choice listed, let us know! Fill out this short form to send details.
+ +### Data store compatibility + +**Datastore tracing provides:** + +- Timing request to response +- Query info (for example, a sanitized query string) +- Error and stacktrace capturing + +##### App and API Protection Capability Notes + +- **Threat Protection** also works at the HTTP request (input) layer, and so works for all databases by default, even those not listed in the table below. + +| Framework | Versions | Threat Detection supported? | Threat Protection supported? | +|--------------------------|-----------|-----------------------------|------------------------------| +| [@apollo/server][43] | `>=4` | {{< X >}} | {{< X >}} | +| [apollo-server-core][44] | `>=3` | {{< X >}} | {{< X >}} | +| [cassandra-driver][28] | `>=3` | {{< X >}} | {{< X >}} | +| [couchbase][29] | `^2.4.2` | {{< X >}} | {{< X >}} | +| [elasticsearch][30] | `>=10` | {{< X >}} | {{< X >}} | +| [ioredis][31] | `>=2` | {{< X >}} | {{< X >}} | +| [knex][32] | `>=0.8` | {{< X >}} | {{< X >}} | +| [mariadb][5] | `>=3` | {{< X >}} | {{< X >}} | +| [memcached][33] | `>=2.2` | {{< X >}} | {{< X >}} | +| [mongodb-core][34] | `>=2` | {{< X >}} | {{< X >}} | +| [mysql][35] | `>=2` | {{< X >}} | {{< X >}} | +| [mysql2][36] | `>=1` | {{< X >}} | {{< X >}} | +| [oracledb][37] | `>=5` | {{< X >}} | {{< X >}} | +| [pg][38] | `>=4` | {{< X >}} | {{< X >}} | +| [redis][39] | `>=0.12` | {{< X >}} | {{< X >}} | +| [sharedb][40] | `>=1` | {{< X >}} | {{< X >}} | +| [tedious][41] | `>=1` | {{< X >}} | {{< X >}} | +| [sequelize][42] | `>=4` | {{< X >}} | {{< X >}} | + +### User Authentication Frameworks compatibility + +**Integrations to User Authentication Frameworks provide:** + +- User login events, including the user IDs +- The Account Takeover detection monitoring the user login events + +| Framework | Minimum Framework Version | +|-----------------|---------------------------| +| passport-local | 1.0.0 | +| passport-http | 0.3.0 | + +[1]: /tracing/trace_collection/compatibility/nodejs/ +[2]: /agent/remote_config/#enabling-remote-configuration +[4]: https://github.com/nodejs/release#release-schedule +[5]: https://github.com/mariadb-corporation/mariadb-connector-nodejs +[28]: https://github.com/datastax/nodejs-driver +[29]: https://github.com/couchbase/couchnode +[30]: https://github.com/elastic/elasticsearch-js +[31]: https://github.com/luin/ioredis +[32]: https://knexjs.org +[33]: https://github.com/3rd-Eden/memcached +[34]: https://www.mongodb.com/docs/drivers/node/current/ +[35]: https://github.com/mysqljs/mysql +[36]: https://github.com/sidorares/node-mysql2 +[37]: https://oracle.github.io/node-oracledb/ +[38]: https://node-postgres.com +[39]: https://github.com/NodeRedis/node_redis +[40]: https://share.github.io/sharedb/ +[41]: http://tediousjs.github.io/tedious +[42]: https://github.com/sequelize/sequelize +[43]: https://github.com/apollographql/apollo-server +[44]: https://www.npmjs.com/package/apollo-server-core +[45]: https://www.npmjs.com/package/body-parser +[46]: https://www.npmjs.com/package/multer diff --git a/content/en/security/application_security/setup/nodejs/docker.md b/content/en/security/application_security/setup/nodejs/docker.md new file mode 100644 index 0000000000000..b509670fcfee8 --- /dev/null +++ b/content/en/security/application_security/setup/nodejs/docker.md @@ -0,0 +1,122 @@ +--- +title: Set up App and API Protection for Node.js in Docker +code_lang: docker +type: multi-code-lang +code_lang_weight: 10 +further_reading: +- link: "/security/application_security/how-it-works/" + tag: "Documentation" + text: "How App and API Protection Works" +- link: "/security/default_rules/?category=cat-application-security" + tag: "Documentation" + text: "OOTB App and API Protection Rules" +- link: "/security/application_security/troubleshooting" + tag: "Documentation" + text: "Troubleshooting App and API Protection" +--- +{{% aap/aap_and_api_protection_nodejs_setup_options platform="docker" %}} + +{{% aap/aap_and_api_protection_nodejs_overview %}} + +## Prerequisites + +- Docker installed on your host +- Node.js application containerized with Docker +- Your Datadog API key +- Datadog Node.js tracing library (see [version requirements][1]) + +## 1. Installing the Datadog Agent + +Install the Datadog Agent by following the [setup instructions for Docker](/agent/?tab=cloud_and_container). + +## 2. Enabling App and API Protection monitoring + +{{% aap/aap_and_api_protection_nodejs_navigation_menu %}} +{{% aap/aap_and_api_protection_nodejs_remote_config_activation %}} + +### Manually enabling App and API Protection monitoring + +{{% collapse-content title="APM Tracing Enabled" level="h4" %}} + +Add the Datadog Node.js library to your Dockerfile and configure environment variables: + +```dockerfile +FROM node:18-alpine + +# Install the Datadog Node.js library +RUN npm install dd-trace + +# Copy your application files +COPY package*.json ./ +COPY . . + +# Install dependencies +RUN npm install + +# Set environment variables +ENV DD_APPSEC_ENABLED=true +ENV DD_SERVICE= +ENV DD_ENV= + +# Start the application with the Datadog tracer +CMD ["node", "--require", "dd-trace/init", "app.js"] +``` + +{{% /collapse-content %}} + +{{% collapse-content title="APM Tracing Disabled" level="h4" %}} +To disable APM tracing while keeping App and API Protection enabled, you must set the APM tracing variable to false. + +Add the Datadog Node.js library to your Dockerfile and configure environment variables: + +```dockerfile +FROM node:18-alpine + +# Install the Datadog Node.js library +RUN npm install dd-trace + +# Copy your application files +COPY package*.json ./ +COPY . . + +# Install dependencies +RUN npm install + +# Set environment variables +ENV DD_APPSEC_ENABLED=true +ENV DD_APM_TRACING_ENABLED=false +ENV DD_SERVICE= +ENV DD_ENV= + +# Start the application with the Datadog tracer +CMD ["node", "--require", "dd-trace/init", "app.js"] +``` + +{{% /collapse-content %}} + +## 3. Run your application + +Build your image and then run your container. + +When running your container, make sure to: +1. Connect it to the same Docker network as the Datadog Agent. +2. Set the required environment variables. + +```bash +docker run -d \ + --name your-nodejs-app \ + your-nodejs-app-image +``` + +{{% aap/aap_and_api_protection_nodejs_verify_setup %}} + +## Troubleshooting + +If you encounter issues while setting up App and API Protection for your Node.js application, see the [Node.js App and API Protection troubleshooting guide][2]. + +## Further Reading + +{{< partial name="whats-next/whats-next.html" >}} + +[1]: /security/application_security/setup/nodejs/compatibility +[2]: /security/application_security/setup/nodejs/troubleshooting diff --git a/content/en/security/application_security/setup/nodejs/kubernetes.md b/content/en/security/application_security/setup/nodejs/kubernetes.md new file mode 100644 index 0000000000000..ca34a787f0b2f --- /dev/null +++ b/content/en/security/application_security/setup/nodejs/kubernetes.md @@ -0,0 +1,132 @@ +--- +title: Set up App and API Protection for Node.js in Kubernetes +code_lang: kubernetes +type: multi-code-lang +code_lang_weight: 20 +further_reading: +- link: "/security/application_security/how-it-works/" + tag: "Documentation" + text: "How App and API Protection Works" +- link: "/security/default_rules/?category=cat-application-security" + tag: "Documentation" + text: "OOTB App and API Protection Rules" +- link: "/security/application_security/troubleshooting" + tag: "Documentation" + text: "Troubleshooting App and API Protection" +--- +{{% aap/aap_and_api_protection_nodejs_setup_options platform="kubernetes" %}} + +{{% aap/aap_and_api_protection_nodejs_overview %}} + +## Prerequisites + +- Kubernetes cluster +- Node.js application containerized with Docker +- kubectl configured to access your cluster +- Helm (recommended for Agent installation) +- Your Datadog API key +- Datadog Node.js tracing library (see [version requirements][1]) + +## 1. Installing the Datadog Agent + +Install the Datadog Agent by following the [setup instructions for Kubernetes](/agent/?tab=cloud_and_container). + +## 2. Enabling App and API Protection monitoring + +{{% aap/aap_and_api_protection_nodejs_navigation_menu %}} +{{% aap/aap_and_api_protection_nodejs_remote_config_activation %}} + +### Manually enabling App and API Protection monitoring + +Ensure your Dockerfile includes the Datadog Node.js library: + +```dockerfile +FROM node:18-alpine + +# Install the Datadog Node.js library +RUN npm install dd-trace + +# Copy your application files +COPY package*.json ./ +COPY . . +RUN npm install + +# Start the application with the Datadog tracer +CMD ["node", "--require", "dd-trace/init", "app.js"] +``` + +{{% collapse-content title="APM Tracing Enabled" level="h4" %}} + +Update your Kubernetes deployment to include the required environment variables: + +```yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: your-nodejs-app +spec: + template: + spec: + containers: + - name: your-nodejs-app + image: your-nodejs-app-image + env: + - name: DD_APPSEC_ENABLED + value: "true" + - name: DD_SERVICE + value: "" + - name: DD_ENV + value: "" +``` + +{{% /collapse-content %}} + +{{% collapse-content title="APM Tracing Disabled" level="h4" %}} +To disable APM tracing while keeping App and API Protection enabled, you must set the APM tracing variable to false. + +Update your Kubernetes deployment to include the required environment variables: + +```yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: your-nodejs-app +spec: + template: + spec: + containers: + - name: your-nodejs-app + image: your-nodejs-app-image + env: + - name: DD_APPSEC_ENABLED + value: "true" + - name: DD_APM_TRACING_ENABLED + value: "false" + - name: DD_SERVICE + value: "" + - name: DD_ENV + value: "" +``` + +{{% /collapse-content %}} + +## 3. Run your application + +Apply your updated deployment: + +```bash +kubectl apply -f your-deployment.yaml +``` + +{{% aap/aap_and_api_protection_nodejs_verify_setup %}} + +## Troubleshooting + +If you encounter issues while setting up App and API Protection for your Node.js application, see the [Node.js App and API Protection troubleshooting guide][2]. + +## Further Reading + +{{< partial name="whats-next/whats-next.html" >}} + +[1]: /security/application_security/setup/nodejs/compatibility +[2]: /security/application_security/setup/nodejs/troubleshooting diff --git a/content/en/security/application_security/setup/nodejs/linux.md b/content/en/security/application_security/setup/nodejs/linux.md new file mode 100644 index 0000000000000..c0fc99e8c2871 --- /dev/null +++ b/content/en/security/application_security/setup/nodejs/linux.md @@ -0,0 +1,83 @@ +--- +title: Set up App and API Protection for Node.js on Linux +code_lang: linux +type: multi-code-lang +code_lang_weight: 30 +further_reading: +- link: "/security/application_security/how-it-works/" + tag: "Documentation" + text: "How App and API Protection Works" +- link: "/security/default_rules/?category=cat-application-security" + tag: "Documentation" + text: "OOTB App and API Protection Rules" +- link: "/security/application_security/troubleshooting" + tag: "Documentation" + text: "Troubleshooting App and API Protection" +--- +{{% aap/aap_and_api_protection_nodejs_setup_options platform="linux" %}} + +{{% aap/aap_and_api_protection_nodejs_overview %}} + +## Prerequisites + +- Linux operating system +- Node.js application +- Root or sudo privileges +- Systemd (for service management) +- Your Datadog API key +- Datadog Node.js tracing library (see [version requirements][1]) + +## 1. Installing the Datadog Agent + +Install the Datadog Agent by following the [setup instructions for Linux hosts](/agent/?tab=Linux). + +## 2. Enabling App and API Protection monitoring + +{{% aap/aap_and_api_protection_nodejs_navigation_menu %}} +{{% aap/aap_and_api_protection_nodejs_remote_config_activation %}} + +### Manually enabling App and API Protection monitoring + +Install the latest version of the Datadog Node.js library: + +```bash +npm install dd-trace +``` + +{{% collapse-content title="APM Tracing Enabled" level="h4" %}} + +Start your Node.js application with the Datadog library and App and API Protection enabled: + +```bash +DD_APPSEC_ENABLED=true DD_SERVICE= DD_ENV= node --require dd-trace/init app.js +``` + +{{% /collapse-content %}} + +{{% collapse-content title="APM Tracing Disabled" level="h4" %}} +To disable APM tracing while keeping App and API Protection enabled, you must set the APM tracing variable to false. + +Start your Node.js application with the Datadog library and App and API Protection enabled: + +```bash +DD_APPSEC_ENABLED=true DD_APM_TRACING_ENABLED=false DD_SERVICE= DD_ENV= node --require dd-trace/init app.js +``` + +{{% /collapse-content %}} + +## 3. Run your application + +Start your Node.js application with the configured settings. + +{{% aap/aap_and_api_protection_nodejs_verify_setup %}} + +## Troubleshooting + +If you encounter issues while setting up App and API Protection for your Node.js application, see the [Node.js App and API Protection troubleshooting guide][2]. + +## Further Reading + +{{< partial name="whats-next/whats-next.html" >}} + +[1]: /security/application_security/setup/nodejs/compatibility +[2]: /security/application_security/setup/nodejs/troubleshooting diff --git a/content/en/security/application_security/setup/nodejs/macos.md b/content/en/security/application_security/setup/nodejs/macos.md new file mode 100644 index 0000000000000..bd3c987bbea03 --- /dev/null +++ b/content/en/security/application_security/setup/nodejs/macos.md @@ -0,0 +1,81 @@ +--- +title: Set up App and API Protection for Node.js on macOS +code_lang: macos +type: multi-code-lang +code_lang_weight: 40 +further_reading: +- link: "/security/application_security/how-it-works/" + tag: "Documentation" + text: "How App and API Protection Works" +- link: "/security/default_rules/?category=cat-application-security" + tag: "Documentation" + text: "OOTB App and API Protection Rules" +- link: "/security/application_security/troubleshooting" + tag: "Documentation" + text: "Troubleshooting App and API Protection" +--- +{{% aap/aap_and_api_protection_nodejs_overview %}} + +## Prerequisites + +- macOS operating system +- Node.js application +- Homebrew (recommended for Agent installation) +- Administrator privileges for some configuration steps +- Your Datadog API key +- Datadog Node.js tracing library (see [version requirements][1]) + +## 1. Installing the Datadog Agent + +Install the Datadog Agent by following the [setup instructions for macOS](/agent/?tab=macOS). + +## 2. Enabling App and API Protection monitoring + +{{% aap/aap_and_api_protection_nodejs_navigation_menu %}} +{{% aap/aap_and_api_protection_nodejs_remote_config_activation %}} + +### Manually enabling App and API Protection monitoring + +Install the latest version of the Datadog Node.js library: + +```bash +npm install dd-trace +``` + +{{% collapse-content title="APM Tracing Enabled" level="h4" %}} + +Start your Node.js application with the Datadog library and App and API Protection enabled: + +```bash +DD_APPSEC_ENABLED=true DD_SERVICE= DD_ENV= node --require dd-trace/init app.js +``` + +{{% /collapse-content %}} + +{{% collapse-content title="APM Tracing Disabled" level="h4" %}} +To disable APM tracing while keeping App and API Protection enabled, you must set the APM tracing variable to false. + +Start your Node.js application with the Datadog library and App and API Protection enabled: + +```bash +DD_APPSEC_ENABLED=true DD_APM_TRACING_ENABLED=false DD_SERVICE= DD_ENV= node --require dd-trace/init app.js +``` + +{{% /collapse-content %}} + +## 3. Run your application + +Start your Node.js application with the configured settings. + +{{% aap/aap_and_api_protection_nodejs_verify_setup %}} + +## Troubleshooting + +If you encounter issues while setting up App and API Protection for your Node.js application, see the [Node.js App and API Protection troubleshooting guide][2]. + +## Further Reading + +{{< partial name="whats-next/whats-next.html" >}} + +[1]: /security/application_security/setup/nodejs/compatibility +[2]: /security/application_security/setup/nodejs/troubleshooting diff --git a/content/en/security/application_security/setup/nodejs/troubleshooting.md b/content/en/security/application_security/setup/nodejs/troubleshooting.md new file mode 100644 index 0000000000000..6838baec6c8cf --- /dev/null +++ b/content/en/security/application_security/setup/nodejs/troubleshooting.md @@ -0,0 +1,79 @@ +--- +title: Troubleshooting Node.js App and API Protection +--- + +## Common Issues + +### No security signals appearing + +If you don't see AAP threat information in the [Trace and Signals Explorer][1] for your Node.js application, follow these steps to troubleshoot the issue: + +1. Verify Agent version: + - Ensure you're running Datadog Agent v7.41.1 or higher. + - Check Agent status: `datadog-agent status`. + +2. Check Node.js tracer version: + - Confirm you're using Node.js tracer v4.30.0 or higher. + - Verify the tracer is loaded: `node -e "console.log(require('dd-trace/package.json').version)"`. + +3. Verify environment variables: + - Ensure `DD_APPSEC_ENABLED=true` is set. + - Check `DD_SERVICE` and `DD_ENV` are properly configured. + - Verify `DD_APM_ENABLED=true` if using APM features. + +4. Check tracer initialization: + - Ensure `dd-trace/init` is required at the start of your application. + - Verify the tracer is properly loaded before your application code. + +### Application fails to start + +1. Check Node.js version compatibility: + - Ensure you're using a supported Node.js version (see [compatibility requirements][2]). + - Verify Node.js version: `node --version`. + +2. Check dd-trace installation: + - Ensure `dd-trace` is properly installed: `npm list dd-trace`. + - Reinstall if necessary: `npm install dd-trace`. + +3. Module loading errors: + - Check for conflicts with other tracing libraries. + - Verify the tracer is required before other modules. + +### Performance impact + +1. High latency: + - Check Agent resource usage. + - Verify network connectivity between Agent and Datadog. + - Consider adjusting sampling rates. + - Review [performance considerations][3]. + +2. High memory usage: + - Monitor Node.js process memory usage. + - Check for memory leaks in your application. + - Consider adjusting tracer configuration. + +### Configuration issues + +1. Environment variables not recognized: + - Ensure environment variables are set before starting the application. + - Check for typos in environment variable names. + - Verify that the tracer is initialized with the correct configuration. + +2. Tracer initialization problems: + - Make sure `require('dd-trace/init')` is the first line in your application. + - Check for syntax errors in your tracer configuration. + - Verify that the tracer is being imported correctly. + +### Still having issues? + +If you're still experiencing problems: +1. Check the [Application Security Monitoring troubleshooting guide][1]. +2. Review the [Node.js tracer documentation][4]. +3. Enable debug logging: `DD_TRACE_DEBUG=true`. +4. Contact [Datadog support][5]. + +[1]: /security/application_security/troubleshooting +[2]: /security/application_security/setup/nodejs/compatibility +[3]: /tracing/trace_collection/compatibility/nodejs/#performance +[4]: /tracing/trace_collection/compatibility/nodejs/ +[5]: /help diff --git a/content/en/security/application_security/setup/nodejs/windows.md b/content/en/security/application_security/setup/nodejs/windows.md new file mode 100644 index 0000000000000..d66e4ab048086 --- /dev/null +++ b/content/en/security/application_security/setup/nodejs/windows.md @@ -0,0 +1,89 @@ +--- +title: Set up App and API Protection for Node.js on Windows +code_lang: windows +type: multi-code-lang +code_lang_weight: 50 +further_reading: +- link: "/security/application_security/how-it-works/" + tag: "Documentation" + text: "How App and API Protection Works" +- link: "/security/default_rules/?category=cat-application-security" + tag: "Documentation" + text: "OOTB App and API Protection Rules" +- link: "/security/application_security/troubleshooting" + tag: "Documentation" + text: "Troubleshooting App and API Protection" +--- +{{% aap/aap_and_api_protection_nodejs_overview %}} + +## Prerequisites + +- Windows operating system +- Node.js application +- Administrator privileges for some configuration steps +- Your Datadog API key +- Datadog Node.js tracing library (see [version requirements][1]) + +## 1. Installing the Datadog Agent + +Install the Datadog Agent by following the [setup instructions for Windows](/agent/?tab=Windows). + +## 2. Enabling App and API Protection monitoring + +{{% aap/aap_and_api_protection_nodejs_navigation_menu %}} +{{% aap/aap_and_api_protection_nodejs_remote_config_activation %}} + +### Manually enabling App and API Protection monitoring + +Install the latest version of the Datadog Node.js library: + +```powershell +npm install dd-trace +``` + +{{% collapse-content title="APM Tracing Enabled" level="h4" %}} + +Start your Node.js application with the Datadog library and App and API Protection enabled: + +```powershell +$env:DD_APPSEC_ENABLED="true" +$env:DD_SERVICE="" +$env:DD_ENV="" + +node --require dd-trace/init app.js +``` + +{{% /collapse-content %}} + +{{% collapse-content title="APM Tracing Disabled" level="h4" %}} +To disable APM tracing while keeping App and API Protection enabled, you must set the APM tracing variable to false. + +Start your Node.js application with the Datadog library and App and API Protection enabled: + +```powershell +$env:DD_APPSEC_ENABLED="true" +$env:DD_APM_TRACING_ENABLED="false" +$env:DD_SERVICE="" +$env:DD_ENV="" + +node --require dd-trace/init app.js +``` + +{{% /collapse-content %}} + +## 3. Run your application + +Start your Node.js application with the configured settings. + +{{% aap/aap_and_api_protection_nodejs_verify_setup %}} + +## Troubleshooting + +If you encounter issues while setting up App and API Protection for your Node.js application, see the [Node.js App and API Protection troubleshooting guide][2]. + +## Further Reading + +{{< partial name="whats-next/whats-next.html" >}} + +[1]: /security/application_security/setup/nodejs/compatibility +[2]: /security/application_security/setup/nodejs/troubleshooting diff --git a/content/en/security/application_security/setup/windows/_index.md b/content/en/security/application_security/setup/windows/_index.md index 5e4c80bc97f94..6ac8f4c96a599 100644 --- a/content/en/security/application_security/setup/windows/_index.md +++ b/content/en/security/application_security/setup/windows/_index.md @@ -27,6 +27,7 @@ Learn how to set up App and API Protection (AAP) on your Windows services by sel {{< appsec-integrations >}} + {{< appsec-integration name="Node.js" avatar="node" link="/security/application_security/setup/nodejs/windows" >}} {{< appsec-integration name="Java" avatar="java" link="/security/application_security/setup/java/windows" >}} {{< appsec-integration name=".NET" avatar="dotnet" link="/security/application_security/setup/dotnet" >}} {{< /appsec-integrations >}} diff --git a/content/en/security/guide/aws_fargate_config_guide.md b/content/en/security/guide/aws_fargate_config_guide.md index 8594620cf285d..d216554daf228 100644 --- a/content/en/security/guide/aws_fargate_config_guide.md +++ b/content/en/security/guide/aws_fargate_config_guide.md @@ -423,7 +423,7 @@ For step-by-step instructions, see [AWS Configuration Guide for Cloud SIEM][17]. [11]: /security/application_security/setup/aws/fargate/dotnet/?tab=awsfargate [12]: /security/application_security/setup/aws/fargate/dotnet/?tab=awsfargate [13]: /security/application_security/setup/aws/fargate/ruby/?tab=awsfargate -[14]: /security/application_security/setup/aws/fargate/nodejs/?tab=awsfargate +[14]: /security/application_security/setup/nodejs/aws-fargate [15]: /security/application_security/setup/aws/fargate/python/?tab=awsfargate [16]: /security/application_security/ [17]: /security/cloud_siem/guide/aws-config-guide-for-cloud-siem/ diff --git a/layouts/shortcodes/aap/aap_and_api_protection_nodejs_navigation_menu.html b/layouts/shortcodes/aap/aap_and_api_protection_nodejs_navigation_menu.html new file mode 100644 index 0000000000000..f3bf483f70c26 --- /dev/null +++ b/layouts/shortcodes/aap/aap_and_api_protection_nodejs_navigation_menu.html @@ -0,0 +1,47 @@ + + + diff --git a/layouts/shortcodes/aap/aap_and_api_protection_nodejs_overview.md b/layouts/shortcodes/aap/aap_and_api_protection_nodejs_overview.md new file mode 100644 index 0000000000000..d1cff92241d5b --- /dev/null +++ b/layouts/shortcodes/aap/aap_and_api_protection_nodejs_overview.md @@ -0,0 +1,14 @@ +{{ $showSetup := .Get "showSetup" | default "true" | eq "true" }} + +## Overview +App and API Protection works by leveraging the [Datadog Node.js library](https://github.com/DataDog/dd-trace-js/) to monitor and secure your Node.js service. The library integrates seamlessly with your existing application without requiring code changes. + +For detailed compatibility information, including supported Node.js versions, frameworks, and deployment environments, see [Node.js Compatibility Requirements](/security/application_security/setup/nodejs/compatibility). + +{{ if $showSetup }} +This guide explains how to set up App and API Protection (AAP) for Node.js applications. The setup involves: +1. Installing the Datadog Agent +2. Enabling App and API Protection monitoring +3. Running your Node.js application with the Datadog Agent +4. Verifying the setup +{{ end }} \ No newline at end of file diff --git a/layouts/shortcodes/aap/aap_and_api_protection_nodejs_remote_config_activation.md b/layouts/shortcodes/aap/aap_and_api_protection_nodejs_remote_config_activation.md new file mode 100644 index 0000000000000..24677ef4640af --- /dev/null +++ b/layouts/shortcodes/aap/aap_and_api_protection_nodejs_remote_config_activation.md @@ -0,0 +1,6 @@ +### Automatically enabling App and API Protection through Remote Configuration +
+APM Tracing cannot be disabled for the time being with remote config. +
+

You can enable remote configuration on your services dashboard. +Simply check the box for the service you want to enable App and API Protection for under "Activate on your APM services".

diff --git a/layouts/shortcodes/aap/aap_and_api_protection_nodejs_setup_options.md b/layouts/shortcodes/aap/aap_and_api_protection_nodejs_setup_options.md new file mode 100644 index 0000000000000..99b40b15244ce --- /dev/null +++ b/layouts/shortcodes/aap/aap_and_api_protection_nodejs_setup_options.md @@ -0,0 +1,9 @@ +
+

You can enable App and API Protection for Node.js services with the following setup options:

+ +
    +
  1. If your Node.js service already has APM tracing set up and running, then skip to service configuration
  2. +
  3. If your Node.js service doesn't have APM tracing set up, you can easily enable App and API Protection with Datadog's Automatic Installation
  4. +
  5. Otherwise, keep reading the following manual setup instructions
  6. +
+
\ No newline at end of file diff --git a/layouts/shortcodes/aap/aap_and_api_protection_nodejs_verify_setup.md b/layouts/shortcodes/aap/aap_and_api_protection_nodejs_verify_setup.md new file mode 100644 index 0000000000000..e357fc69ccbc9 --- /dev/null +++ b/layouts/shortcodes/aap/aap_and_api_protection_nodejs_verify_setup.md @@ -0,0 +1,6 @@ +## 4. Verify setup +To verify that App and API Protection is working correctly: + +1. Send some traffic to your application +2. Check the [Application Signals Explorer](https://app.datadoghq.com/security/appsec) in Datadog +3. Look for security signals and vulnerabilities