diff --git a/pip_audit/_cli.py b/pip_audit/_cli.py index 4797dd9c..5a1217ba 100644 --- a/pip_audit/_cli.py +++ b/pip_audit/_cli.py @@ -378,7 +378,7 @@ def _parser() -> argparse.ArgumentParser: # pragma: no cover metavar="ID", action="append", dest="ignore_vulns", - default=[], + default=os.environ.get("PIP_AUDIT_IGNORE_VULNS", "").split(), help=( "ignore a specific vulnerability by its vulnerability ID; " "this option can be used multiple times" diff --git a/test/test_cli.py b/test/test_cli.py index 60c9e065..e8519262 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -222,6 +222,7 @@ def test_environment_variable(monkeypatch): monkeypatch.setenv("PIP_AUDIT_OUTPUT", "/tmp/fake") monkeypatch.setenv("PIP_AUDIT_PROGRESS_SPINNER", "off") monkeypatch.setenv("PIP_AUDIT_VULNERABILITY_SERVICE", "osv") + monkeypatch.setenv("PIP_AUDIT_IGNORE_VULNS", "cve ghsa xyz") parser = pip_audit._cli._parser() monkeypatch.setattr(pip_audit._cli, "_parse_args", lambda *a: parser.parse_args([])) @@ -232,3 +233,4 @@ def test_environment_variable(monkeypatch): assert args.output == Path("/tmp/fake") assert not args.progress_spinner assert args.vulnerability_service == VulnerabilityServiceChoice.Osv + assert args.ignore_vulns == ["cve", "ghsa", "xyz"]