Command line

The Artifact Firewall is the varnish-artifact-firewall binary. The Docker image runs it as its entrypoint, and a command that names the binary runs it without the entrypoint’s banner:

docker run --rm varnish/artifact-firewall varnish-artifact-firewall -version

Options

Option Description
-config <path> The configuration file to read. Takes precedence over ARTIFACT_FIREWALL_CONFIG.
-version Print the version and the Git revision of the build, then exit.
-schema Print the JSON Schema of the configuration file, then exit.
-validate-rulesets <path>... Check ruleset files and directories without starting a firewall, then exit. See Validating rulesets.

Configuration file

The firewall reads one YAML file, named by -config or else by the ARTIFACT_FIREWALL_CONFIG environment variable, set to /etc/varnish-artifact-firewall/default.yaml in the image. The file holds these top-level sections:

An unknown key stops the firewall at startup.

-schema prints the file’s JSON Schema, for an editor or a CI job to check a configuration before the firewall reads it:

docker run --rm varnish/artifact-firewall varnish-artifact-firewall -schema > config.schema.json

An editor that uses yaml-language-server reads it from a comment at the top of the file, with a path relative to the file:

# yaml-language-server: $schema=config.schema.json

The schema refuses an empty value, such as api_address:, although the firewall accepts one and keeps the default. Write api_address: "" to turn the admin API off.

The schema also says what a reload does with each field, for a deployment tool that decides whether a changed file is enough or the firewall has to be restarted. x-reload on a field is live when a reload applies it, and restart or refused when only a restart does, so a reload that changes it is refused. The class holds for everything below the field. x-reload-index on the root lists the paths where a class is stated, with [] for a list element, and a path takes the class of its longest listed prefix, or else default:

"x-reload-index": {
  "default": "restart",
  "live": ["config_watch", "firewall"],
  "restart": ["firewall.rulesets[].git", "firewall.rulesets[].http"],
  "refused": ["firewall.address", "firewall.api_address", "firewall.audit_log_output", "firewall.deployment", "firewall.log_output", "firewall.maven", "firewall.port", "firewall.pypi", "firewall.redirects", "firewall.storage", "firewall.work_dir", "license", "otel"]
}

Environment variables

  • ARTIFACT_FIREWALL_CONFIG: the configuration file, when -config is not given.
  • ARTIFACT_FIREWALL_CONFIG_WATCH: on or off, which overrides config_watch.enabled. Any other value is ignored with a warning.

Settings for a secret hold the name of an environment variable, not the secret itself: auth.token_env and github_app.private_key_env for a ruleset source, and redirects.signing.key_env.

Signals

  • SIGHUP reloads the configuration file, rebuilds the rules, and reopens the log files, so that a rotation tool can rename a log file and then signal. In Docker, send it with docker kill --signal=HUP <container>.
  • SIGTERM and SIGINT shut the firewall down.

config_watch

config_watch:
  enabled: true
  interval: 15

With enabled, the default, the firewall checks its configuration file’s contents every interval seconds, 15 by default, and reloads it when they changed. SIGHUP applies a change at once. The watcher follows the symbolic link swapped by Kubernetes when it updates a mounted ConfigMap, and leaves a file modified in the last 250 milliseconds for its next check, so a file that is still being written is not read.

Reloading the configuration

A reload applies the whole file or none of it. A file that does not parse or validate is refused, and so is a change to one of these, which needs a restart:

  • address, port, api_address, deployment, work_dir, storage, redirects, maven, pypi, log_output and audit_log_output in the firewall section
  • the otel and license sections
  • the rulesets entries with git or http, added, removed, edited or reordered

A refused reload is logged at ERROR, naming the changed settings and, by their name, the git and http sources that were added, removed or edited, or the ones that moved when sources were only reordered. It is logged again at WARN every five minutes for as long as the running configuration differs from the file:

level=ERROR msg="failed to reload configuration" err="configuration changes not allowed for fields: [firewall.port]"

Everything else applies without dropping a connection, including registries and the rulesets entries with a path. A request is handled under the old configuration or the new one, never a mix of both. A reload fetches no Git or HTTP ruleset source, and applies mode only when its value in the file changed, so it does not undo a mode set through /api/mode. It logs the names of the changed firewall settings:

level=INFO msg="configuration reloaded" fields=[default_quarantine_days] field_count=1

SIGHUP also rebuilds the rules, from the ruleset files and from the last fetch of each remote source. That is how an edited ruleset file at a local path is applied, since the watcher looks at the configuration file only. Rulesets that load as they were leave the rules alone, as on a SIGHUP from log rotation. A rebuild that changes the rules sends the webhook, and so does a reload that changes preserve_manifest, registries, mode or default_quarantine_days.

A firewall bundled with the Virtual Registry reads no file of its own. The Supervisor’s reload hands it the firewall section, and the firewall applies it under the same rules. A change that needs a restart refuses the Supervisor’s whole reload. The Supervisor’s SIGHUP rebuilds the rules too.


®Varnish Software, Wallingatan 12, 111 60 Stockholm, Organization nr. 556805-6203