Deploying a Node.js IAST agent
You can deploy an IAST agent on the application server that supports Java, .NET, Node.js or PHP based applications. This section explains how to create a Node.js agent on your web server.
About this task
- Node.js (agent from npm): Retrieve the agent from the public npm registry using the key obtained from ASoC. Recommended for environments with an internet connection that can access the npm registry.
- Node.js (download agent): Download the Node.js agent from ASoC as a self-contained tarball, allowing installation without npm access. Recommended for air-gapped or restricted environments without access to the public npm registry.
Installing the agent from npm
About this task
Procedure
-
Generate a key for the
Node.jsagent (through the user interface or API).
-
On your web server:
- Install the agent from the public npm repository:
npm install @hclsoftware/secagent - Add the following environment variables:
IAST_ACCESS_TOKEN: [key]IAST_HOST: as shown in the instructions (e.g. https://cloud.appscan.com/IAST)
- Install the agent from the public npm repository:
-
Edit
package.jsonby locating this line:"start": "node index.js",
then replace it with this:"start": "node -r @hclsoftware/secagent/src/Iast.js index.js",
Note: Alternatively, you can add the key to the package.json command as follows:- Windows:
"start": "set IAST_ACCESS_TOKEN=12345 && node -r @hclsoftware/secagent/src/Iast.js index.js" - Linux:
"start": "IAST_ACCESS_TOKEN=12354 node -r @hclsoftware/secagent/src/Iast.js index.js"
Tip: If you use Next to run your applications, the IAST agent can be run with theNODE_OPTIONSenvironment variable before the original command, for example:NODE_OPTIONS='-r @hclsoftware/secagent/src/Iast.js' next app.js - Windows:
-
Start your application using
npm start.
Results
Installing from a self-contained package
About this task
Procedure
-
On your web server, install the agent from the downloaded file:
npm install hclsoftware-secagent.tgz
-
Edit
package.jsonby locating this line:"start": "node index.js",
then replace it with this:"start": "node -r @hclsoftware/secagent/src/Iast.js index.js",
Tip: If you use Next to run your applications, the IAST agent can be run with theNODE_OPTIONSenvironment variable before the original command, for example:NODE_OPTIONS='-r @hclsoftware/secagent/src/Iast.js' next app.js -
Start your application using
npm start.