Skip to main content

Configure the Python agent

The standard configuration for all agents uses this order of precedence.

As of version 5.24.0 of the agent, the Contrast Runner is the recommended way to use the Python Agent for most supported frameworks. Manual middleware configuration is still supported for backward compatibility and may continue to be necessary for certain frameworks and applications.

Contrast Service Configuration (before version 5.19.0 only)

In earlier versions (before version 5.19.0), the Python agent launches an executable on startup that also needs access to the configuration files. Since the service is generally launched by the Python agent process, it has access to the same configuration file as the agent. However, if the service is started independently, it will attempt to use the same order of precedence for its configuration file.

In other words, the service can share the application's configuration file, if (as is usually the case) the service's working directory is also the base directory of the application. Both the agent and the service use the  /etc/contrast/contrast_security.yaml path.

Tip

Use the Contrast agent configuration editor to create or upload a YAML configuration file, validate YAML, and get setting recommendations.

Python YAML template

Use this template to configure the Python agent using a YAML configuration file. (Learn more about YAML configuration.)

Place your YAML file in the default location: /etc/contrast/contrast_security.yaml

Note

The agent.service section of the YAML configuration file only applies to earlier versions of Python (before version 5.19.0).

https://docs.contrastsecurity.com/common-agent-config/python_contrast_security.yaml