Configuration Using Local Policy File (Docker)
For deployments of open-appsec on Docker the configuration can be done in a declarative way using a single YAML file which holds all the relevant configuration objects. This way it is fully compatible for integration in GitOps CD-based processes.
Alternatively management can also be done centrally via the central open-appsec WebUI (SaaS).
Location of the declarative configuration file
On Docker the declarative configuration file for the open-appsec Agent is typically provided to the agent container via a volume mount.
In your docker-compose.yaml
or the docker run
command which you used for your current deployment you can find the specific folder on the docker host which gets mounted to /ext/appsec
in the open-appsec agent container.
This is the folder which should contain your local_policy.yaml
file.
(Note that this folder then gets mounted internally to /etc/cp/policy/local_policy.yaml
which is where the agent looks for the actual local policy to apply, but on Docker you should always manage the file in /ext/appsec
file location)
You can show and edit the full default declarative configuration file with the following command:
From within the appsec-agent container:
vi /ext/appsec
or by using the interactive CLI tool open-appsec-ctl
: Using the open-appsec-ctl Tool
From the docker host:
(replace "appsec-agent" with your own agent container name, if you adjusted it):
docker exec -it appsec-agent vi /ext/appsec
Basic configuration
The default policy within the default configuration file, which is deployed during the installation, contains the following setting which sets the mode to detect-learn
for all web resources provided by the NGINX or Kong Gateway:
policies.default.mode: detect-learn
If you want attacks instead to be prevented by default for all web resources you can change this as follows:
policies.default.mode: prevent-learn
The section policies.specific-rules
allows you to create specific rule entries for specific hostnames, hostname-path combinations or paths which override the default policy.
The mode settings defined in the policy for default or specific-rules will only have an effect on the actual enforcement for specific security features when the override-mode
setting in the referenced practice is set to as-top-level
as this will cause it to inherited the mode setting from the policy.
It is recommended to configure a specific rule for each of your protected web applications and web APIs assets (starting with detect-learn
mode, later move to prevent-learn
).
This allows you to apply a separate enforcement mode setting for each of these protected assets as well as to customize many other settings like selecting the logging configuration, the threat prevention practices configuration or selecting a custom-response like a specific response code or a custom block page.
Also the real-time contextual machine learning will be done individually per each configured asset/specific rule. Note that these settings are all configured by referencing other elements which are defined separately in the configuration file as well, so that you can reuse them multiple times in a kind of object-oriented way.
It is recommended that once sufficient confidence was gained in detect-learn
mode for an asset which has a specific rule (review the logs) to move this specific rule to prevent-learn
mode:
Applying a changed local declarative configuration file
Once you did any changes to the local declarative configuration file local_policy.yaml
there's two ways how you can get those changes applied:
By using the open-appsec-ctl tool to apply the changes in the policy:
From inside the Agent container:
From the docker host:
Replace appsec-agent
with your agent container name, if it has a different name.
By configuring the agent to automatically apply all changes in the
local_policy.yaml
file in/ext/appsec
once you save any changes within the file: Activate automatic policy load for the open-appsec agent by setting the following environment variable to true in yourdocker-compose.yaml
ordocker run
command:autoPolicyLoad=true
This is especially useful in CI/CD-style deployments that have a continuous deployment process in place.
Last updated