Audit / Filter Advisories By Severity
Filter Advisories By Severity
Performs a security audit on your `pnpm` dependencies, filtering results according to specified severity levels.
pnpm audit --audit-level <severity> pnpm audit --audit-level <severity> #!/bin/bash
# Filter Advisories By Severity
pnpm audit --audit-level {{severity}} import subprocess
# Filter Advisories By Severity
# Make sure to replace <placeholders> with actual values
def run_command():
cmd = [
"audit",
"audit",
"--audit-level",
"<severity>"
]
try:
print(f"Executing: {' '.join(cmd)}")
subprocess.run(cmd, check=True)
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
except FileNotFoundError:
print("Error: audit not found. Please install it first.")
if __name__ == "__main__":
run_command() When To Use
During a security compliance check before a production release.
Pro Tip
Use `--json` flag to get machine-readable output, which allows for programmatic handling of advisory data.
Command Builder
Tune the command before you copy it
pnpm audit --audit-level <severity> Anatomy of Output
Understanding the result
┌──────────────────────────────┐ Advisory Output Header Start of the advisory report.
│ moderate | Some package │ Severity Level Severity level of the advisory.
│ vulnerable | path/to/package │ Affected Package Path Path to the vulnerable package.
│ 9.0.1 | 2.0.0 │ Vulnerable Version / Patched Version Versions of the package that are affected and patched.
└──────────────────────────────┘ Advisory Output Footer End of the advisory report.
Troubleshooting
Common pitfalls
ERR_PNPM_AUDIT_NO_ADVISORIES
Solution: Ensure dependencies are installed correctly or check the lockfile.
ERR_PNPM_AUDIT_INVALID_SEVERITY
Solution: Use a valid severity level: low, moderate, or high.
ERR_PNPM_OP_FAILED
Solution: Check network connectivity or the registry status if the command fails.
Command Breakdown
What each part is doing
-
pnpm - Base Command
- The executable that performs this operation. Here it runs Audit before the shell applies any redirect operators.
-
<severity> - severity
- The value supplied for severity.
-
--audit-level - Command Option
- Tool-specific option used by this command invocation.
Alternative Approaches
Comparable commands in other tools
Alternative package management tools for the same job.