diff --git a/.github/workflows/smoke-tests.yml b/.github/workflows/smoke-tests.yml index b0b0cad1..ff13d994 100644 --- a/.github/workflows/smoke-tests.yml +++ b/.github/workflows/smoke-tests.yml @@ -15,6 +15,7 @@ jobs: matrix: test: - default-config-macro + - docker-registry - double_slash - forced-language - git-clone diff --git a/data/clients/docker-client.yaml b/data/clients/docker-client.yaml new file mode 100644 index 00000000..4a07df24 --- /dev/null +++ b/data/clients/docker-client.yaml @@ -0,0 +1,25 @@ +- name: allow-docker-client + action: ALLOW + expression: + all: + - path.startsWith("/v2/") + - userAgent.contains("docker/") + - userAgent.contains("git-commit/") + - '"Accept" in headers' + - headers["Accept"].contains("vnd.docker.distribution") + - '"Baggage" in headers' + - headers["Baggage"].contains("trigger") + +- name: allow-crane-client + action: ALLOW + expression: + all: + - userAgent.contains("crane/") + - userAgent.contains("go-containerregistry/") + +- name: allow-docker-distribution-api-client + action: ALLOW + expression: + all: + - '"Docker-Distribution-Api-Version" in headers' + - '!(userAgent.contains("Mozilla"))' diff --git a/docs/docs/CHANGELOG.md b/docs/docs/CHANGELOG.md index 44ff6280..a35ecdb4 100644 --- a/docs/docs/CHANGELOG.md +++ b/docs/docs/CHANGELOG.md @@ -16,6 +16,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix `SERVE_ROBOTS_TXT` setting file after the double slash fix broke it. - Remove the default configuration rule to block Tencent cloud. If users see abuse from Tencent cloud IP ranges, please contact abuse@tencent.com and mention that you are using Anubis to protect your services. Please include source IP address, source port, timestamp, target IP address, target port, request headers (including the User-Agent header), and target endpoints/patterns. +### Potentially breaking changes + +#### Docker / OCI registry clients + +Anubis v1.23.0 accidentally blocked Docker / OCI registry clients. In order to explicitly allow them, add an import for `(data)/clients/docker-client.yaml`: + +```yaml +bots: + - import: (data)/meta/default-config.yaml + - import: (data)/clients/docker-client.yaml +``` + +This is technically a regression as these clients used to work in Anubis v1.22.0, however it is allowable to make this opt-in as most websites do not expect to be serving Docker / OCI registry client traffic. + ## v1.23.0: Lyse Hext - Add default tencent cloud DENY rule. diff --git a/test/docker-registry/anubis.yaml b/test/docker-registry/anubis.yaml new file mode 100644 index 00000000..f352c701 --- /dev/null +++ b/test/docker-registry/anubis.yaml @@ -0,0 +1,7 @@ +bots: + - import: (data)/meta/default-config.yaml + - import: (data)/clients/docker-client.yaml + +status_codes: + CHALLENGE: 200 + DENY: 403 diff --git a/test/docker-registry/docker-compose.yaml b/test/docker-registry/docker-compose.yaml new file mode 100644 index 00000000..a1095bcb --- /dev/null +++ b/test/docker-registry/docker-compose.yaml @@ -0,0 +1,30 @@ +services: + registry: + image: distribution/distribution:edge + restart: always + + relayd: + image: ghcr.io/xe/x/relayd + pull_policy: always + environment: + CERT_DIR: /etc/techaro/pki/registry.local.cetacean.club + CERT_FNAME: cert.pem + KEY_FNAME: key.pem + PROXY_TO: http://anubis:3000 + ports: + - 3004:3004 + volumes: + - ../pki/registry.local.cetacean.club:/etc/techaro/pki/registry.local.cetacean.club + + anubis: + image: ko.local/anubis + restart: always + environment: + BIND: ":3000" + TARGET: http://registry:5000 + POLICY_FNAME: /etc/techaro/anubis.yaml + USE_REMOTE_ADDRESS: "true" + ports: + - 3000 + volumes: + - ./anubis.yaml:/etc/techaro/anubis.yaml diff --git a/test/docker-registry/test.sh b/test/docker-registry/test.sh new file mode 100755 index 00000000..2fd75f83 --- /dev/null +++ b/test/docker-registry/test.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -euo pipefail + +source ../lib/lib.sh + +build_anubis_ko + +function cleanup() { + docker compose down +} + +trap cleanup EXIT SIGINT + +mint_cert registry.local.cetacean.club + +docker compose up -d + +backoff-retry skopeo \ + --insecure-policy \ + copy \ + --dest-tls-verify=false \ + docker://hello-world \ + docker://registry.local.cetacean.club:3004/hello-world diff --git a/test/docker-registry/var/.gitignore b/test/docker-registry/var/.gitignore new file mode 100644 index 00000000..c96a04f0 --- /dev/null +++ b/test/docker-registry/var/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file