> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/artifact-registry/3.0/registries/configure-security-scanning.md).

# Configure security scanning

Enable a built-in container scanner on a Docker or Helm registry, attach a policy set to quarantine violations, and validate Cargo metadata.

Harness Artifacts supports automatic security scanning on push for container registries and metadata validation for select package registries. Scanning happens at ingest time; every artifact is evaluated as it enters the registry.

## What you will learn from this topic

* Enable a container scanner (Aqua Trivy or Grype) on a Docker or Helm registry
* Attach a policy set to quarantine artifacts that fail a security check
* Enable metadata validation on a Cargo registry

## Before you begin

* **Container scanning** requires the [Harness Supply Chain Security module](https://developer.harness.io/software-supply-chain-assurance/). Contact your account administrator to confirm the module is enabled.
* Your role must include **Create/Edit** permission on the registry. Go to [RBAC and permissions](https://developer.harness.io/artifact-registry/3.0/reference/rbac-and-permissions.md) for details.

## Enable container scanning (Docker and Helm)

Container scanning is available for Docker and Helm OCI registries. When enabled, Harness creates a scan pipeline that runs automatically every time an artifact is pushed.

1. In the navigation menu, select **Registries**.
2. Click the Docker or Helm registry you want to configure.
3. Select the **Configuration** tab.
4. In the **Security** section, click the edit icon to open the Security drawer.
5. Select the scanner you want to use:

   | Scanner        | Best for                                    |
   | -------------- | ------------------------------------------- |
   | **Aqua Trivy** | Broad OS and library vulnerability coverage |
   | **Grype**      | Fast, SBOM-aware scanning                   |
6. Optionally, enable **Metadata validation** in the same drawer to validate artifact metadata on push.
7. Save the setting.

Scanning begins on the next push to the registry. Scan results appear on each artifact's [version details page](https://developer.harness.io/artifact-registry/3.0/artifacts/artifact-version-details.md) in the **Vulnerabilities** tab.

### Attach a policy set

A policy set defines rules that evaluate scan results and take action, for example, quarantine any image with a Critical severity finding.

Policy sets attached to a registry must be of type **Security Tests**. To create or manage policy sets, go to **Account Settings** > **Policies** in Harness.

To attach a policy set to a registry:

1. In the registry's **Configuration** tab, open the **Security** edit drawer.
2. Under **Policy sets**, click **Add policy set** and select the policy set from the list.
3. Save the setting.

You can attach multiple policy sets for layered enforcement.

### What happens when an artifact fails a policy

When an artifact violates a policy with an **Error and exit** action, Harness quarantines it automatically. Quarantined artifacts cannot be pulled or downloaded until the quarantine is removed. Go to [Quarantine](https://developer.harness.io/artifact-registry/3.0/security-and-compliance/quarantine.md) to review and release quarantined artifacts.

## Enable metadata validation (Cargo)

For Cargo registries, Harness can validate crate metadata on publish, checking that required fields are present and correctly formatted.

1. Open the Cargo registry.
2. Select the **Configuration** tab.
3. In the **Security** section, open the edit drawer.
4. Enable **Metadata validation**.
5. Save the setting.

When enabled, a publish request that contains invalid crate metadata is rejected with an error message identifying the missing or malformed field.

## Troubleshooting

<details>

<summary>The Security section does not appear in Configuration</summary>

Container scanning configuration is available only on Docker and Helm OCI registries. Metadata validation is available on Docker, Helm, and Cargo registries. For all other formats, the Security section is not shown.

</details>

<details>

<summary>Scanner selection is missing, only one scanner is shown</summary>

Both Aqua Trivy and Grype are available in production. If only one scanner appears, confirm your account is on a production environment and that the Supply Chain Security module is fully provisioned. Contact [Harness Support](mailto:support@harness.io) if both scanners do not appear.

</details>

<details>

<summary>Scan results are not appearing on newly pushed artifacts</summary>

Scan pipelines run asynchronously. Results typically appear within a few minutes of the push. If no results appear after 10 minutes, check whether the Supply Chain Security module is enabled and that the scan pipeline was created successfully in the registry configuration.

</details>

## Next steps

* [Vulnerability scanning](https://developer.harness.io/artifact-registry/3.0/security-and-compliance/vulnerability-scanning.md): view and triage CVE findings
* [SBOM: view, score, and download](https://developer.harness.io/artifact-registry/3.0/security-and-compliance/sbom-view-score-and-download.md)
* [Quarantine](https://developer.harness.io/artifact-registry/3.0/security-and-compliance/quarantine.md): manage quarantined artifacts

{% @harness-feedback/feedback %}
