Question
How do I enable/disable the Contrast Service for the Node.js Agent?
Answer
The service will behave a bit differently depending on the version you're running. This article will cover agent versions 2.18.0+
Note: This article only applies to Node.js agent versions prior to version 5.0.0. In version 5.0.0+, the Node.js agent communicates directly with the Contrast UI. As such, there is no Contrast Service, thus no configurations are required.
Default settings -
“Contrast Service enabled?” = Is agent.service.enable
property set to true or false
- in 2.18.0 this property is set to false by default
- in 3.0.0 this property is set to true by default
- in 4.0.0 this property is set to true by default - the contrast service is required to run for this version of the agent
- in 5.0.0 this property does not exist as the Contrast Service is no longer a part of the agent
“Contrast Service config included?” = Is the agent.service
section included in the YAML, CLI command, or env variables at all?
service:
enable: true
socket: /tmp/service.sock
host: localhost
|
Contrast Service config included? |
Contrast Service enabled? |
Outcome |
2.18.x |
yes |
yes |
Agent runs with Contrast Service |
yes |
no |
Standalone Node agent |
|
no |
no |
Standalone Node agent |
|
3.x.x |
yes |
yes |
Agent runs with Contrast Service |
yes |
no |
Standalone Node agent |
|
no |
no |
Agent runs with Contrast Service |
|
4.x.x |
yes |
yes |
Agent runs with Contrast Service |
yes |
no |
Standalone Node agent |
|
no |
no |
Agent runs with Contrast Service |
The agent.service.enable property is used to control the use of the Contrast Service. That can be set as an environment variable, CLI option, or within the YAML like so:
agent:
service:
enable: true
CONTRAST__AGENT__SERVICE__ENABLE=true
--agent.service.enable true
We recommend utilizing the service as there are multiple benefits, including less performance overhead within your application when running Assess. Better input analysis and additional rules when running Protect. Friendlier deployments in containerized applications allowing a single point of communication between multiple containers.