安全漏洞|pip-audit:功能强大的安全漏洞扫描工具( 二 )



                        on any dependency (default: False)

  --desc [{onoffauto


                        include a description for each vulnerability; `auto`

                        defaults to `on` for the `json` format. This flag has

                        no effect on the `cyclonedx-json` or `cyclonedx-xml`

                        formats. (default: auto)

  --cache-dir CACHE_DIR

                        the directory to use as an HTTP cache for PyPI; uses

                        the `pip` HTTP cache by default (default: None)

  --progress-spinner {onoff

                        display a progress spinner (default: on)

  --timeout TIMEOUT     set the socket timeout (default: 15)

  --path PATHS          restrict to the specified installation path for

                        auditing packages; this option can be used multiple

                        times (default: [
)

  -v --verbose         give more output; this setting overrides the

                        `PIP_AUDIT_LOGLEVEL` variable and is equivalent to

                        setting it to `debug` (default: False)

  --fix                 automatically upgrade dependencies with known

                        vulnerabilities (default: False)

  --require-hashes      require a hash to check each requirement against for

                        repeatable audits; this option is implied when any

                        package in a requirements file has a `--hash` option.

                        (default: False)

退出代码任务完成后 ,pip-audit将会退出运行 , 并返回一个代码以显示其状态 , 其中:


0:未检测到已知漏洞;
1:检测到了一个或多个已知漏洞;
工具使用样例审计当前Python环境中的依赖:
$ pip-audit

No known vulnerabilities found

审计给定requirements文件的依赖:
$ pip-audit -r ./requirements.txt

No known vulnerabilities found

审计一个requirements文件 , 并排除系统包:
$ pip-audit -r ./requirements.txt -l

No known vulnerabilities found

审计依赖中发现的安全漏洞:
$ pip-audit

Found 2 known vulnerabilities in 1 package

Name  Version ID             Fix Versions

----  ------- -------------- ------------

Flask 0.5     PYSEC-2019-179 1.0

Flask 0.5     PYSEC-2018-66  0.12.3

审计依赖(包含描述):
$ pip-audit --desc

Found 2 known vulnerabilities in 1 package

Name  Version ID             Fix Versions Description