This API allows you to submit a file to a ClamAV antivirus engine and retrieve the result.
919
Antivirus scanning of files as a service, built on ClamAVā , Kafka and S3 storage (MinIO).
š Documentation: https://cyr-ius.github.io/scanavasservice/ā
processed/, infected files to quarantine/.clamd instances, with cooldown of failing ones.flowchart LR
C[Client] -->|upload| A[API]
A --> S[(S3 bucket)]
S -->|put event| K[[Kafka]]
K --> W[Worker]
W -->|INSTREAM| AV[clamd]
W -->|tags, processed/ or quarantine/| S
W -.->|result| H[Webhook / Kafka]
The image runs two components: the API (uvicorn app.api:app, port 8000) and the
worker (python -m app), which consumes the Kafka topic and scans the files.
Requirements: Docker with Docker Compose.
Set the secrets (in your shell or in a .env file next to the Compose file):
export CLIENT_ID=demo
export CLIENT_SECRET="$(openssl rand -base64 32)"
export SECRET_KEY="$(openssl rand -base64 64 | tr -d '\n')"
Start the example stack (Kafka, MinIO, two ClamAV instances and the scanner):
docker compose -f examples/docker/docker-compose.yaml up --build -d
ClamAV downloads its signatures on first start: allow a minute or two. The API listens on
127.0.0.1:8000.
Scan a file:
TOKEN=$(curl -s -X POST http://localhost:8000/api/token \
-d "username=$CLIENT_ID" -d "password=$CLIENT_SECRET" | jq -r .access_token)
KEY=$(curl -s -X POST http://localhost:8000/api/v1/upload \
-H "Authorization: Bearer $TOKEN" -F "file=@./sample.pdf" | jq -r .key)
curl -s -H "Authorization: Bearer $TOKEN" http://localhost:8000/api/v1/status/$KEY | jq
The status is PENDING until the scan ends, then CLEAN, INFECTED or ERROR. Use
demo/test_upload.com (EICAR test file) to try a detection.
Download a clean file:
curl -H "Authorization: Bearer $TOKEN" -o scanned.pdf \
http://localhost:8000/api/v1/download/$KEY
The interactive API documentation is at http://localhost:8000/api/docsā .
Warning
The example stack uses the MinIO root credentials (`minioadmin`) and an unauthenticated Kafka. It is meant for a local test only: see the [deployment guide](https://cyr-ius.github.io/scanavasservice/demarrage/deploiement/).
Everything is configured through environment variables. The main ones:
| Variable | Purpose |
|---|---|
KAFKA_SERVERS, KAFKA_TOPIC | Kafka brokers and topic of the S3 put events |
S3_ENDPOINT_URL, S3_BUCKET | S3 endpoint and bucket of the files to scan |
S3_ACCESS_KEY, S3_SECRET_KEY | S3 credentials |
CLAMD_HOSTS | clamd instances (host:port, comma separated) |
CLIENT_ID, CLIENT_SECRET | Client credentials of the API |
SECRET_KEY | Signing key of the API tokens (same on every instance) |
OIDC_ISSUER, OIDC_JWKS_URL | Optional OIDC identity provider |
See the full list of variablesā with their defaults.
The repository ships a devcontainer (.devcontainer/) that starts Kafka, MinIO and ClamAV.
Outside of it, install Python 3.15 and uvā :
uv sync --extra dev
uv run python -m app # worker
uv run uvicorn app.api:app --port 8000 --reload # API
uv run pytest && uv run ruff check . && uv run ruff format --check .
uv run --extra docs mkdocs serve -a 127.0.0.1:8001 # documentation preview
In the devcontainer, start the Execute - API + Runtime launch configuration, then run the
Demo - upload a file to scan task to send a clean or an infected (EICAR) file and see its
verdict. The devcontainer sets development-only API credentials (CLIENT_ID=dev).
Commits follow Conventional Commitsā ; releases are made by Release Please.
Please report vulnerabilities privately, as described in SECURITY.mdā .
Content type
Image
Digest
sha256:0de3d9ce8ā¦
Size
99.2 MB
Last updated
1 day ago
docker pull cyrius44/scanasservice