How the Artefact Validations service works#
This page explains what the SKA CI/CD Artefact Validations service is, the design decisions behind it, and how artefacts move through it. If you want to run or configure it, see Run and operate the Artefact Validations; for the exhaustive list of endpoints, toggles, and settings, see Endpoints, toggles, configuration, and metrics.
Why the service exists#
The service, known by its bot identity Marvin
(marvin-42-service), guards the SKAO Central Artefact Repository. Every
artefact published to Nexus or Harbor is validated against the SKAO naming,
versioning, and metadata conventions before it becomes generally available.
The service quarantines non-compliant artefacts (in Nexus) or holds them back from production (in Harbor), and Marvin opens a GitLab merge request to notify their authors.
The goal is to keep the repository compliant automatically, at publish time,
without a human gatekeeper: developers get fast, actionable feedback and the
production project only ever contains artefacts that passed every gate.
Architecture#
The service is split into two cooperating processes that share a Redis broker, a MongoDB database, and an Unleash feature-flag backend:
A FastAPI webhook receiver (
main_api.py) that accepts webhooks from Nexus and Harbor, authenticates them, validates their shape, and enqueues work. It also serves Prometheus metrics.A pool of Celery workers (
main.py) that run the actual validation, promotion, and signing logic asynchronously.
Component |
Purpose |
|---|---|
FastAPI receiver |
Terminates the webhook, authenticates it, validates the payload against
a Pydantic model, and dispatches a Celery task. Returns |
Celery workers |
Execute |
Redis |
Celery broker and result backend. |
MongoDB |
Stores one audit record per processed artefact. |
Unleash (via proxy) |
Feature-flag backend that toggles individual checks and behaviours on and off at runtime. |
Keeping the HTTP surface thin and doing the work in Celery means a slow registry call, a vulnerability scan that has not finished, or an artefact that is not yet signed never blocks the webhook: the receiver answers immediately and the worker retries on its own schedule.
Webhook-driven design#
Each endpoint maps to exactly one trigger and one Celery task:
Endpoint |
Trigger |
Task |
|---|---|---|
|
Nexus component webhook ( |
|
|
Harbor |
|
|
Harbor |
|
|
Prometheus scrape. |
none (serves metrics inline) |
Every payload is validated against a Pydantic model before any task is
enqueued. The models also determine which events are acted on, so a
payload failing validation is ordinary traffic rather than a fault - it is
logged at info level and acknowledged with 200 and {"message":
"Ignored"} so Harbor does not redeliver it. Several of those validators
encode important behaviour:
Nexus only accepts the
CREATEDaction. Deletions and updates are rejected with400 Bad Requestso the service never reacts to an artefact being removed.Harbor rejects resources whose tag begins with
sha256. Harbor emits a push event when a signature is pushed, and those carry asha256-...tag; skipping them stops the service from validating its own signatures. A digest-only push (no tag) is allowed and falls back to the digest.Harbor only accepts
PUSH_ARTIFACTon/harbor, so a scan or a replication cannot start a validation run.Harbor SBOM only accepts
SCANNING_COMPLETEDwhoseevent_data.scan.scan_typeissbom. Harbor reports that same event type twice for one artefact - once when the vulnerability scan finishes and once when the SBOM scan does - and only the second has an SBOM to sign. See Sign-once idempotency for why acting on both was a problem.
The generalised artefact#
Nexus and Harbor artefacts are very different on the wire, but the checks
should not care. Both handlers therefore normalise their input into a single
Artefact object before running any check. An artefact carries its
project, name, tag, type (OCI, PYPI, HELM,
RAW, CONAN), metadata (labels), assets, the checks_results,
and, for Harbor, the vulnerability report. Conan artefacts additionally
carry group and channel.
Because every check operates on the generalised artefact, a single check implementation (for example the naming-convention check) runs identically for a PyPI wheel, a Helm chart, and an OCI image.
The check framework#
Checks live in checks/ and each subclasses the abstract
Check base class. A check declares a feature_toggle and implements
four coroutines: check (returns True when the artefact passes),
type (the severity: FAILURE, WARNING or INFO),
description, and mitigation_strategy.
At import time import_check_classes() scans the checks/ directory and
registers every class whose name starts with Check. Adding a compliant file
to that directory is therefore enough to add a new check. At run time run_checks() executes only the checks whose
feature toggle is enabled, concurrently, and records each result and its
runtime.
Each check is individually gated by its own feature toggle, and can be skipped
for a specific artefact through a per-artefact exclusion toggle
(<toggle>-excluded). This lets an operator disable a single check globally,
or grant one repository a temporary exemption, without redeploying.
Why this matters
Compliance checks are a first line of software supply chain security. Enforcing consistent naming, versioning and metadata keeps every artefact in the repository traceable to the commit, pipeline and author that produced it. An artefact that cannot be traced cannot be trusted, no matter how it is signed later.
Handler flows#
Nexus flow#
For a Nexus component the handler:
Builds an
Artefactfrom the webhook (deriving the version from the filename forRAWartefacts, which carry no explicit version).Downloads the artefact’s assets and extracts its metadata.
Runs the enabled checks.
If the artefact is not compliant, uploads it to the project’s quarantine repository,
<project-prefix>-quarantine, where the prefix is the part of the project name before the first-and, whendeleteis configured, removes it from its original repository.Cleans up the downloaded files.
The handler always returns the artefact so the caller can persist a record and open a merge request.
Harbor flow and the promotion pipeline#
Harbor is a staging-to-production pipeline. Images are pushed into a staging
project; the service decides whether each one earns promotion to the
production project. On a push the handler:
Builds an
Artefactfrom the webhook and loads its labels.Runs the enabled checks and labels the artefact with an
Invalid*label for every failed check.Fetches the vulnerability report (retrying while Harbor is still compiling it) and compares its severity to the configured threshold.
Promotes the artefact only if it clears every gate.
Promotion copies the artefact into the production project and, when
delete is enabled, deletes the source from staging. If Harbor rejects the
copy, the handler leaves the source in staging and propagates the error so
main_task can retry it under its standard policy.
The promotion gates#
An artefact is promoted only when all of the following hold:
Gate |
Requirement |
|---|---|
Compliance checks |
No enabled check failed (no |
Vulnerabilities |
Either the report severity is below the configured
|
Signatures |
When the |
Why this matters
The vulnerability gate is a software supply chain safeguard: scanning at
promotion time keeps images with critical known vulnerabilities out of
production, so a dangerous CVE blocks release rather than being
discovered after the image is already deployed across the telescope.
Signature checking#
Why this matters
Signatures are the backbone of software supply chain security. A signed
image proves it came from a trusted builder and has not been tampered with
in transit or at rest, and a signed SBOM lets downstream consumers trust the
inventory of what is actually inside. Gating promotion on signatures is what
stops an unsigned (and therefore unverifiable) artefact from reaching
production and being deployed across the telescope.
When the require-signatures toggle is on, the service verifies before
promotion that the image is signed and that its SBOM is present (and, when
verify_sbom_signature is enabled, signed). The image is signed by an
external signer; the SBOM is signed by this service (see the sign-once and
signing-flow sections below). The check
works for single-platform images and for multi-platform images (OCI indices):
for a multi-platform image the index and every child manifest must each
carry their own image signature, and every child manifest must also have its
own SBOM.
Images built with docker buildx build --sbom --provenance (the default of
the SKA .make oci-build target) carry one extra child per platform: a
BuildKit attestation manifest, with the platform unknown/unknown and the
annotation vnd.docker.reference.type: attestation-manifest. It holds the
build-time SBOM and SLSA provenance of its platform image as in-toto
statements. It is not a runnable image, so Harbor never generates an
sbom.harbor accessory for it. The gate still requires every attestation
manifest to be signed, but does not require it to have an SBOM.
The index markers alone do not grant this exemption, because the publisher
writes the index and could put them on a runnable image. The gate also reads
the child’s manifest from Harbor’s registry API (/v2, with the service’s
Harbor credentials), checks that it matches the child’s digest, and exempts the
child only when every layer is an in-toto statement
(application/vnd.in-toto+json). No container runtime can unpack such
layers into a filesystem. This covers both BuildKit formats: the default, with
a placeholder image config for the unknown platform, and
oci-artifact=true, with the empty OCI config. A child with no layers, any
other layer type, or a manifest that cannot be read keeps the SBOM
requirement.
Requiring the SBOM signature is configurable, and is off by default
(verify_sbom_signature). With it disabled the gate still requires each SBOM
to exist but does not check that it is signed, logging a warning so the
relaxation is visible in the logs. This matches the current flow, in which the
SBOM is signed only once the scan finishes on the promoted image, after
promotion. The SBOM’s presence is always required.
Because signing is asynchronous, the gate does not give up on the first miss. It waits on two levels, giving the external signer and the SBOM-signing flow time to catch up:
In-handler poll. Within a single task run the gate re-checks the accessories
signature_check_retriestimes (default 5), sleepingsignature_check_retry_delay_sseconds (default 30) between attempts — the same blocking-poll pattern the vulnerability report uses.Task retry. If the artefact is still unsigned after that poll, the handler raises
ArtefactNotSignedError, which the task’sautoretry_forpolicy retries every 10 minutes for up to an hour.
If the signatures never appear the task ultimately fails and the artefact stays in staging, unpromoted, rather than being released unverified. The exact budgets are in Endpoints, toggles, configuration, and metrics.
Sign-once idempotency#
An SBOM must be signed exactly once, and two mechanisms keep it that way.
The first is the event filter described in Webhook-driven design: only the
SCANNING_COMPLETED event of the SBOM scan reaches sbom_sign_task.
Without it the vulnerability-scan event was signed too, and because both events
name the same artefact, both resolved to the same SBOM. The two tasks then ran
concurrently - Celery runs several at a time - and neither could see the
other’s signature, because notation sign takes several seconds to push it.
One signature landed and the duplicate hit the notation timeout, failing
the task and scheduling a pointless retry.
The second is the check in process_sbom_sign_request: before signing, it
fetches the SBOM’s accessories and skips signing when a signature.notation
accessory is already present. This covers the invocations the filter cannot
prevent - a Celery retry, a Harbor redelivery, or a manual re-scan - and makes
each of them a cheap no-op instead of a redundant signature artefact that later
has to be cleaned up. This check is not concurrency-safe on its own:
it is a check-then-act, so it only helps once the earlier signature is visible
in Harbor. The filter is what keeps concurrent duplicates from arising in the
first place.
The signing flow and Vault PKI#
When an SBOM needs signing, the service does not hold a long-lived signing key. Instead it mints a short-lived certificate from HashiCorp Vault for each signing session:
Authenticate to Vault with the AppRole method (
VAULT_AUTH_APPROLE_ROLE_ID/VAULT_AUTH_APPROLE_SECRET_ID).Issue a certificate from the PKI role
oci-pki/issue/oci-image-signing-24h-ttl-certificate, usingVAULT_OCI_PKI_URIas the common name. The certificate has a 24-hour TTL.Write the key and certificate chain into Notation’s signing configuration.
Invoke the
notation signCLI against the SBOM reference, countersigning it with an RFC 3161 timestamping authority (DigiCert by default, overridable viaTSA_URL/TSA_ROOT_CERT).
The certificate is reused across signing calls until it expires: before each signing the service validates the on-disk certificate and only fetches a new one from Vault when it is missing or expired. A 24-hour TTL keeps the number of Vault round-trips low while ensuring keys are never long-lived.
The timestamp is what makes this safe: because each signature is timestamped by
a trusted authority, it remains verifiable long after the 24-hour signing
certificate has expired. The DigiCert TSA root certificate is baked into the
image at TSA_ROOT_CERT; point TSA_URL/TSA_ROOT_CERT elsewhere to use
a different authority. To avoid the certificate lapsing mid-signing, a
certificate within 30 seconds of expiry is refreshed before use.
Persistence and notifications#
After validation, main_task fans out to two independent tasks:
insertdb_taskwrites one JSON audit record per artefact to MongoDB.create_merge_request_taskruns only for non-compliant artefacts. It opens (as Marvin) a merge request against the artefact’s GitLab repository (found through theCI_PROJECT_IDlabel) containing a table of every failed check, its description, and its mitigation. The MR is assigned to the publishing user (GITLAB_USER_ID) when that label is present.
Because the merge request is keyed off CI metadata baked into the artefact, an artefact that is missing the required metadata cannot be traced back to a project, and no merge request can be opened for it.
Maintenance: dangling signature cleanup#
Harbor does not let you delete a signature accessory directly, so orphaned
signature artefacts (signatures whose referenced SBOM digest no longer exists) can
accumulate over time. A scheduled GitLab CI job runs
scripts/delete_dangling_sbom_signature_artifacts.py, which walks every
repository in a project, finds signature artefacts (tagged sha256-...),
checks whether the SBOM they point at still exists, and deletes the ones that
are dangling. See Run and operate the Artefact Validations for how to run it.
Known quirks#
The
config.harbor.promoteandconfig.nexus.quarantinesettings are present in the configuration schema but are not consulted by the current handlers: Harbor promotes whenever the gates pass, and Nexus quarantines whenever an artefact is non-compliant. Only thedeleteflags gate behaviour today.The
Invalid*label name is derived by replacingCheckArtefactwithInvalidin the check class name, soCheckRawArtefactAssetdoes not gain anInvalidprefix - its failure label is the class name unchanged.