Topics on this page
Node.js
Supported versions
Agents can be installed only in Linux environments. Windows is not supported.
Code protection features
Some of the code protection features are enabled only when specific components are used in the application. The table below lists the required components for a code protection feature to be enabled. No dependencies indicates the code protection feature is enabled by default, it doesn't require specific components.
Feature | Requires |
---|---|
NodeJS versions | Node.js 10, 12 and 14 with ecmascript 5 and 6 |
Asynchronous Body and Stream parsing | Koa 2.13.1 |
SQL Injection |
|
Remote Command Execution | No dependencies |
Illegal File Access | No dependencies |
Open Redirect | Node.js express version 3 and 4 |
Malicious Payload | No dependencies |
Malicious File Upload | No dependencies |
Download the agent
The NodeJS agent is available on the Download page.
Install the agent
The make command, gcc and libstdc++ packages need to be installed on the image for successful installation.
-
From the root of your Node application, enter:
npm install --save trend_app_protect,
-
To activate Application Security, add the following as the first line of your app setup code:
require('trend_app_protect'); //import support added in version 4.5.0 and above for projects that require/support es6 modules import 'trend_app_protect';
The choice of statements to use betweenrequire
orimport
are dependent on the application itself, the modules used, and declarations in the package files. It's independent of Application Security. Some references and examples on when to userequire
versusimport
:- https://nodejs.org/dist/latest-v14.x/docs/api/all.html#esm_interoperability_with_commonjs
- https://nodejs.org/en/knowledge/getting-started/what-is-require/
- https://nodejs.org/en/knowledge/getting-started/what-is-require/
- When the server setup is done within a ES module,
import
can be used or otherwiserequire
can be used. - For applications built with Node version prior to version 14
require
must be used.import
could potentially be used but requires "--experimental-modules" node flag to be present when running the application. - Generically,
require
must be used except when the package.json file contains {"type": "module"}, in that caseimport
must be used.
Please refer to the official NodeJS documentation for more details.
-
The agent key and secret can be configured via the
TREND_AP_KEY
andTREND_AP_SECRET
environment variables. The Key and Secret can be found under Group Settings > Group Credentials.
If you are using a configuration file instead of using environment variables, it needs to be called trend_app_protect.json
and be in the application root folder, and needs to contain at least the following:
{
"key": "my-key",
"secret": "my-secret"
}
The environment variables will take precedence over the configuration file.
Configure the agent to communicate with the proper Trend Micro Cloud One region
If you are using a Cloud One region other than 'us-1', you need to configure the agent's connectivity for the region.