> 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/dependency-firewall/firewall-audit.md).

# Firewall audit with the CLI

Use the Harness CLI to audit dependencies against Dependency Firewall policies before they reach your registry, locally and in CI pipelines.

The Dependency Firewall Violations tab shows you what was blocked after a package was fetched. The CLI audit shifts that check earlier: you evaluate your dependency manifest or lock file before anything is pulled, so policy violations surface during development or in a PR check instead of after a build runs.

This page covers three CLI capabilities:

* **`hc registry fw audit`**: scan a manifest or lock file against firewall policies
* **`hc registry fw explain`**: check the firewall status of a single package version
* **`hc artifact <pm> install`**: install wrappers that add firewall evaluation and dependency graph tracking to your existing install commands

## Before you begin

* Install and authenticate the Harness CLI. Go to [CLI reference](https://developer.harness.io/artifact-registry/3.0/reference/cli.md#install-and-authenticate) for setup steps.
* Dependency Firewall is enabled on the upstream proxy registry you are auditing against. Go to [Dependency Firewall overview](https://developer.harness.io/artifact-registry/3.0/dependency-firewall/overview.md) if it is not set up yet.
* For `hc artifact` install wrappers: the package manager client is configured to use your upstream proxy registry (`hc registry configure <type>`).

## Audit a dependency file

`hc registry fw audit` reads your manifest or lock file and evaluates every listed package version against the firewall policies on your upstream proxy registry. It tells you which packages are allowed, blocked, or warned before you try to build.

```bash
hc registry fw audit --file <FILE> --registry <REGISTRY_NAME> --org <ORG> --project <PROJECT>
```

**Required flags**:

| Flag           | Description                                          |
| -------------- | ---------------------------------------------------- |
| `--file`, `-f` | Path to your manifest or lock file                   |
| `--registry`   | The upstream proxy registry name to evaluate against |

Add `--org` and `--project` when your CLI session is not already scoped to the target Harness organization and project.

**What file to pass**:

| File                                                                | Packages evaluated                 |
| ------------------------------------------------------------------- | ---------------------------------- |
| `package.json`                                                      | Direct dependencies only           |
| `package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`                  | Direct and transitive dependencies |
| `pom.xml`, `build.gradle`, `build.gradle.kts`                       | Per Maven or Gradle resolution     |
| `requirements.txt`, `pyproject.toml`, `Pipfile.lock`, `poetry.lock` | Per pip resolution                 |

Pass a lock file when you need the full dependency graph including transitive packages. Pass the manifest when you only care about direct dependencies. Doing so is faster and appropriate for a quick pre-merge check.

**Sample output**:

```
Parsing dependency file: package-lock.json...
Found 15 dependencies in package-lock.json
Initiating bulk scan evaluation for registry: npmproxy...

Scan Results for 15 dependencies:
  Warnings: 2
  Allowed: 13

┌──────────────────────────────────────────────┐
│ Package Name  │ Version   │ Status            │
│ body-parser   │ 1.20.1    │ WARN              │
│ express       │ 4.18.2    │ ALLOWED           │
│ lodash        │ 4.17.20   │ WARN              │
│ ...           │ ...       │ ...               │
└──────────────────────────────────────────────┘
```

**Status codes**:

| Status      | Meaning                                                                                                                                                                               |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **ALLOWED** | The package passes all firewall policies. Safe to use.                                                                                                                                |
| **WARN**    | The package triggered a warn-level policy. It is still usable by default unless your policy is set to quarantine on warn. Review the finding and decide whether to update or proceed. |
| **BLOCKED** | The package violates a block-level policy. It will not be available through the upstream proxy. Update the dependency or submit an exception request.                                 |

If the audit exits with blocked packages, the exit code is non-zero, suitable for failing a CI step.

## Generate a lock file for audit when you do not store one

If your project does not commit lock files, generate one in your pipeline or locally before running the audit. The generated file is used for the audit only; you do not need to commit it.

{% tabs %}
{% tab title="npm" %}

```bash
npm install --package-lock-only
hc registry fw audit --file package-lock.json --registry <REGISTRY_NAME> --org <ORG> --project <PROJECT>
```

{% endtab %}

{% tab title="Yarn" %}

```bash
yarn install --frozen-lockfile
hc registry fw audit --file yarn.lock --registry <REGISTRY_NAME> --org <ORG> --project <PROJECT>
```

{% endtab %}

{% tab title="pnpm" %}

```bash
pnpm install --lockfile-only
hc registry fw audit --file pnpm-lock.yaml --registry <REGISTRY_NAME> --org <ORG> --project <PROJECT>
```

{% endtab %}
{% endtabs %}

## Run the audit in CI

Add a firewall audit step to your pipeline to block merges or deploys when blocked packages are detected.

{% tabs %}
{% tab title="GitHub Actions" %}

```yaml
jobs:
  audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Harness CLI
        run: |
          curl -L https://github.com/harness/harness-cli/releases/latest/download/harness-linux-amd64.tar.gz | tar xz
          sudo mv hc /usr/local/bin/

      - name: Authenticate
        run: hc auth login --api-url https://app.harness.io --api-token $HARNESS_API_KEY
        env:
          HARNESS_API_KEY: ${{ secrets.HARNESS_API_KEY }}

      - name: Audit dependencies
        run: |
          hc registry fw audit \
            --file package-lock.json \
            --registry $HAR_REGISTRY \
            --org $HARNESS_ORG \
            --project $HARNESS_PROJECT
        env:
          HAR_REGISTRY: ${{ vars.HAR_REGISTRY }}
          HARNESS_ORG: ${{ vars.HARNESS_ORG }}
          HARNESS_PROJECT: ${{ vars.HARNESS_PROJECT }}
```

The audit step exits non-zero if any package is blocked, which fails the job. Add `continue-on-error: true` if you want the audit to report without blocking the pipeline.
{% endtab %}

{% tab title="Jenkins" %}

```groovy
pipeline {
  agent any
  environment {
    HARNESS_ORG     = 'default'
    HARNESS_PROJECT = 'my-project'
    HAR_REGISTRY    = 'npm-upstream'
  }
  stages {
    stage('Firewall Audit') {
      steps {
        withCredentials([string(credentialsId: 'harness-api-key', variable: 'HARNESS_API_KEY')]) {
          sh '''
            hc auth login --api-url https://app.harness.io --api-token "$HARNESS_API_KEY"
            hc registry fw audit \
              --file package-lock.json \
              --registry "$HAR_REGISTRY" \
              --org "$HARNESS_ORG" \
              --project "$HARNESS_PROJECT"
          '''
        }
      }
    }
  }
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Audit at PR time, not only at deploy time**

Running the audit as a PR check catches blocked packages before they reach your build pipeline. Add it as a required status check so a blocked dependency stops a merge rather than a deploy.
{% endhint %}

## Check one package's firewall status

`hc registry fw explain` returns the current firewall verdict for a specific package version already in your upstream proxy registry. Use it to investigate a blocked version or confirm a package passes policies before writing it into a manifest.

```bash
hc registry fw explain \
  --registry <REGISTRY_NAME> \
  --package <PACKAGE_NAME> \
  --version <VERSION> \
  --org <ORG> \
  --project <PROJECT>
```

**Example**:

```bash
hc registry fw explain \
  --registry npm-upstream \
  --package lodash \
  --version 4.17.20 \
  --org default \
  --project my-project
```

**Sample output**:

```
Package:     lodash
Version:     4.17.20
Scan Status: BLOCKED

This artifact version is BLOCKED by the firewall.

Violated policies:
  Policy set: Security baseline
    - CVSS Threshold: score 9.1 exceeds threshold 7.0 (Critical)

Recommendation: Update to 4.17.21 or later.
```

The output names which policy set and which individual policy produced the verdict, so you can target your update.

## Track dependency graphs with install wrappers

The `hc artifact <pm> install` commands wrap your native package manager install. They run the install through your upstream proxy and upload the dependency graph to Harness, which populates the **Pulled in By** field and **Affected Pipelines** tab in the Dependency Firewall dashboard.

| Command                      | Wraps            |
| ---------------------------- | ---------------- |
| `hc artifact npm install`    | `npm install`    |
| `hc artifact npm ci`         | `npm ci`         |
| `hc artifact mvn install`    | `mvn install`    |
| `hc artifact pip install`    | `pip install`    |
| `hc artifact dotnet restore` | `dotnet restore` |

**Example**:

```bash
# Configure the registry once
hc registry configure npm --registry npm-upstream --org default --project my-project --global

# Install with firewall evaluation and graph tracking
hc artifact npm install
```

Subcommands not listed in this table pass through to the native tool without modification.

**What this adds over a plain install**:

* Firewall policy evaluation runs at install time: blocked packages surface immediately with policy details.
* The resolved dependency graph is uploaded to Harness so the Violations tab can show which pipelines introduced a flagged package.

Using install wrappers in CI is the recommended way to populate Affected Pipelines data. Running `npm install` directly routes packages through the proxy but does not upload the graph.

## Troubleshooting

<details>

<summary>The audit completes but shows no results for some packages</summary>

Threat intelligence data may not yet be indexed for newly published packages. Run the audit again after a few minutes. If a package consistently shows no data, it may not be in the ecosystems supported by your firewall policy type. Go to [Built-in policy templates](https://developer.harness.io/artifact-registry/3.0/dependency-firewall/built-in-policy-templates.md) to confirm which package types each template evaluates.

</details>

<details>

<summary>hc registry fw audit exits with an error, not a BLOCKED status</summary>

An authentication or connection error appears as an error exit, not a scan result. Confirm:

* `hc auth login` completed successfully and your token has not expired.
* The `--registry`, `--org`, and `--project` values match an existing upstream proxy registry with Dependency Firewall enabled.
* Your account has at least viewer access on the project.

</details>

<details>

<summary>The audit shows ALLOWED but the package is blocked when pulled at build time</summary>

The audit evaluates the policy state at the time it runs. Threat intelligence databases refresh periodically. A package that was ALLOWED when audited may be blocked by the time it is pulled if a new CVE was published in the interim. Re-run the audit immediately before your build if strict consistency is required.

</details>

## Next steps

* [View and triage violations](https://developer.harness.io/artifact-registry/3.0/dependency-firewall/view-and-triage-violations.md): investigate packages blocked in the registry
* [Request an exception](https://developer.harness.io/artifact-registry/3.0/dependency-firewall/request-an-exception.md): get temporary access to a blocked package
* [CLI reference](https://developer.harness.io/artifact-registry/3.0/reference/cli.md): full `hc registry fw` command reference

{% @harness-feedback/feedback %}
