@contrast/reporter
Subscribes to agent messages and reports them to the Contrast UI, the security logger, or a file.
Reporting follows a publish/subscribe model. Agent components emit events on
core.messages (event names are the Event enum from @contrast/common), and
each reporter subscribes to the events it cares about. Reporters can also
publish, e.g. the Contrast UI reporter emits Event.SERVER_SETTINGS_UPDATE when
new remote settings arrive.
Reporters
| Reporter | Enabled when |
|---|---|
| Contrast UI | api.enable is true |
| Security logger | protect.enable is true, unless agent.security_logger.path is /dev/null and agent.security_logger.stdout is false |
| File | agent.reporters.file is set to a path |
The Contrast UI reporter also onboards the agent: its agent and application startup requests return the remote settings and entitlements the rest of the agent depends on. That's why the reporter installs before any other agent component.
The security logger writes security events, such as Protect attacks, to a file,
stdout, or syslog according to the agent.security_logger.* options.
Usage
@contrast/agentify composes the reporter onto core, and core.reporter.install()
installs every enabled reporter.
const { Event } = require('@contrast/common');
core.messages.emit(Event.PROTECT_FINDING, finding);