> 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/set-artifact-filtering-rules.md).

# Set artifact filtering rules

Use allowed and blocked regular expression patterns to control which artifact names can be pushed to a registry on every push.

Artifact filtering rules use regular expressions to control which artifacts can enter a registry. You set rules at the registry level, and they apply on every push.

Two rule types are available:

* **Allowed patterns**: a push succeeds only when the artifact name matches at least one allowed pattern. If allowed patterns are configured and the artifact name does not match, the push is rejected.
* **Blocked patterns**: a push is rejected when the artifact name matches a blocked pattern, regardless of allowed pattern settings.

When both are set, the blocked pattern takes precedence: an artifact that matches both an allowed and a blocked pattern is rejected.

## Before you begin

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.

## Set filtering rules

1. In the navigation menu, select **Registries**.
2. Click the registry you want to configure.
3. Select the **Configuration** tab.
4. In the **Artifact filtering rules** section, click the edit icon to open the drawer.
5. Enter a regex pattern in the **Allowed Patterns** or **Blocked Patterns** field, then press **Enter** to add it. Repeat for each pattern.
6. Save the setting.

Patterns are evaluated against the artifact name (excluding the registry prefix and version). Patterns are matched using standard regex, not wildcards.

## Pattern examples

### Restrict to production artifacts only

To allow only artifacts whose names end with `-prod` and reject any that start with `dev-`:

* **Allowed patterns**: `.*-prod`
* **Blocked patterns**: `dev-.*`

This allows `api-service-prod` and `worker-prod`, and rejects `dev-api-service` and `dev-worker`.

### Block a specific artifact name

To prevent a known problematic package from being pushed:

* **Blocked patterns**: `legacy-auth-service`

### Allow only a namespaced prefix

To enforce that all artifacts in the registry belong to a specific team namespace:

* **Allowed patterns**: `team-payments/.*`

## Considerations

* Patterns apply to pushes only, not to pulls. Existing artifacts in the registry are not retroactively blocked.
* If no allowed pattern is set, all artifact names are permitted unless blocked.
* Each pattern must match the entire artifact name. `.*-prod` matches any name ending with `-prod`; use `^my-service$` to match a single exact name.
* To remove a pattern, open the **Artifact filtering rules** edit drawer and delete the pattern entry.

## Troubleshooting

<details>

<summary>A push is rejected but the artifact name looks correct</summary>

Filtering rules match against the artifact name only, not the full registry path. Check that your allowed pattern matches the artifact name as it appears in the registry, without the `pkg.harness.io/<account>/<registry>/` prefix or the version tag.

</details>

<details>

<summary>I want to allow all artifacts except a few</summary>

Leave **Allowed patterns** empty (which permits all names by default) and add your exclusion rules to **Blocked patterns**.

</details>

## Next steps

* [Add and prioritize upstream proxies](https://developer.harness.io/artifact-registry/3.0/registries/add-and-prioritise-upstream-proxies.md)
* [Configure security scanning](https://developer.harness.io/artifact-registry/3.0/registries/configure-security-scanning.md)

{% @harness-feedback/feedback %}
