Safeguard
Developer Tools•

What exit codes do dependency audit tools return?

npm audit, pip-audit, composer audit and yarn npm audit exit non-zero on findings. Dependency-Check uses a CVSS threshold, NuGet uses warnings as errors.

Safeguard Security Team
3 min read

Most dependency audit tools exit with a non-zero code when they find vulnerabilities. npm audit, yarn npm audit, pip-audit and composer audit work this way. Dependency-Check fails above a CVSS score you set, and NuGet audit raises warnings that you can treat as errors. Knowing the rule tells you how to wire each into a pipeline.

Definitions

Exit code. The number a command returns to the shell. Zero is success.

Threshold. The severity or score at which a tool starts to fail.

Gate. A pipeline step that stops the build on failure.

Behaviour by tool

ToolExit behaviourThreshold control
npm audit0 when none found, non-zero by default otherwiseAudit level option sets the minimum severity, without filtering the report
yarn npm auditNon-zero when a report is found for the selected packagesDocs do not say whether severity or ignore change the code
pip-audit0 for none, 1 for one or more foundNone; the code cannot be suppressed
composer audit0 for no issues, 1 when packages match policies or the audit failedIgnore severity option
Dependency-CheckExit code reflects whether a score at or above the CVSS threshold was foundFail on CVSS option, 0 to 10
NuGet auditRestore warnings NU1901 to NU1904Treat chosen codes as errors
pnpm auditNot listed in general in the docsAudit level option, check behaviour in your version

Steps

  1. Run the tool locally on a known vulnerable project and note the exit code.
  2. Decide the threshold you want the pipeline to enforce.
  3. Wire the command into CI. Avoid pipes that swallow the exit code.
  4. Add a distinct step or job name, so a failure is readable.
  5. Save the report as an artifact.
npm audit --audit-level=high; echo $?
pip-audit -r requirements.txt; echo $?

Pitfalls

  • Piping output to another command can mask the code unless your shell fails on pipe errors.
  • A fallback that forces success, such as an or true suffix, silences the gate.
  • A tool that failed to reach its data source may exit differently from one that found issues. Check the documented codes, for example composer treats missing packages as a failed audit.

Try it yourself

Click through it at your own pace, or open it full screen.

Open a pull request and see which rule blocks the merge.

Quick check

Why does CI pass even though the tool printed findings?

Often a pipe or a forced success hid the exit code. Run the command alone and check.

Can I make pip-audit ignore its exit code?

The project says the code cannot be suppressed. Teams that need to continue use a shell fallback, which should be a deliberate choice.

Safeguard policy gates can block a pull request on findings that match your rules. A free scan shows what would trigger them.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.