Skip to content

Commit 96c07c5

Browse files
committed
feat: add support for environment variable PIP_AUDIT_IGNORE_VULNS to override the command-line option of the same name
1 parent d6d7ea5 commit 96c07c5

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

pip_audit/_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def _parser() -> argparse.ArgumentParser: # pragma: no cover
378378
metavar="ID",
379379
action="append",
380380
dest="ignore_vulns",
381-
default=[],
381+
default=os.environ.get("PIP_AUDIT_IGNORE_VULNS", "").split(),
382382
help=(
383383
"ignore a specific vulnerability by its vulnerability ID; "
384384
"this option can be used multiple times"

test/test_cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ def test_environment_variable(monkeypatch):
222222
monkeypatch.setenv("PIP_AUDIT_OUTPUT", "/tmp/fake")
223223
monkeypatch.setenv("PIP_AUDIT_PROGRESS_SPINNER", "off")
224224
monkeypatch.setenv("PIP_AUDIT_VULNERABILITY_SERVICE", "osv")
225+
monkeypatch.setenv("PIP_AUDIT_IGNORE_VULNS", "cve ghsa xyz")
225226

226227
parser = pip_audit._cli._parser()
227228
monkeypatch.setattr(pip_audit._cli, "_parse_args", lambda *a: parser.parse_args([]))
@@ -232,3 +233,4 @@ def test_environment_variable(monkeypatch):
232233
assert args.output == Path("/tmp/fake")
233234
assert not args.progress_spinner
234235
assert args.vulnerability_service == VulnerabilityServiceChoice.Osv
236+
assert args.ignore_vulns == ["cve", "ghsa", "xyz"]

0 commit comments

Comments
 (0)