Skip to content

Commit 4cb88de

Browse files
committed
[pipaudit] Add an option to ignore vulnerabilities
Extend the pipaudit rule, adding an option to ignore vulnerabilities. Sometimes a vulnerability does not have a fix yet. In such a case, the user must be able to ignore those as there is no other option for third-party libraries.
1 parent ec582ce commit 4cb88de

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

quality/private/python/python_pip_audit_rule.bzl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ def _pip_audit_rule_impl(ctx):
2828
requirement_file = ctx.file.requirement
2929

3030
args_list = ["--disable-pip"]
31+
if ctx.attr.ignore_vulnerability:
32+
for vulnerability in ctx.attr.ignore_vulnerability:
33+
args_list.extend(["--ignore-vuln", vulnerability])
3134
if ctx.attr.no_deps:
3235
args_list.append("--no-deps")
3336
if ctx.attr.index_url:
@@ -55,6 +58,13 @@ def _pip_audit_rule_impl(ctx):
5558
pip_audit_rule = rule(
5659
implementation = _pip_audit_rule_impl,
5760
attrs = {
61+
"ignore_vulnerability": attr.string_list(
62+
default = [],
63+
doc = (
64+
"Optional. If set, pip-audit will ignore a specific set of vulnerabilities by their IDs." +
65+
"If not provided, all vulnerabilities will be checked."
66+
),
67+
),
5868
"index_url": attr.string(
5969
default = "",
6070
doc = (

0 commit comments

Comments
 (0)