Skip to content

Commit ed7c2b5

Browse files
authored
feat(ci): use a Github Repository Variable DISABLE_PIP_AUDIT to control running pip-audit in CI (#551)
1 parent e64682e commit ed7c2b5

4 files changed

Lines changed: 15 additions & 2 deletions

File tree

.github/workflows/_build.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
name: Build the package
2323
on:
2424
workflow_call:
25+
inputs:
26+
disable_pip_audit:
27+
required: true
28+
type: boolean
29+
description: Enable or disable running pip_audit to check installed packages for vulnerabilities
2530
outputs:
2631
artifacts-sha256:
2732
description: The hash of the artifacts
@@ -73,8 +78,10 @@ jobs:
7378
- name: Install dependencies
7479
run: make setup
7580

76-
# Audit all currently installed packages for security vulnerabilities.
81+
# Audit all currently installed packages for security vulnerabilities. This step can
82+
# be disabled by setting the repository variable DISABLE_PIP_AUDIT to 'true'.
7783
- name: Audit installed packages
84+
if: ${{ !inputs.disable_pip_audit }}
7885
run: make audit
7986

8087
# Build the sdist and wheel distribution of the package and docs as a zip file.

.github/workflows/pr-change-set.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ jobs:
1818
uses: ./.github/workflows/_build.yaml
1919
permissions:
2020
contents: read
21+
with:
22+
disable_pip_audit: ${{ vars.DISABLE_PIP_AUDIT == 'true' }}

.github/workflows/release.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
uses: ./.github/workflows/_build.yaml
2424
permissions:
2525
contents: read
26+
with:
27+
disable_pip_audit: ${{ vars.DISABLE_PIP_AUDIT == 'true' }}
2628

2729
# On pushes to the 'main' branch create a new release by bumping the version
2830
# and generating a change log. That's the new bump commit and associated tag.
@@ -79,6 +81,8 @@ jobs:
7981
uses: ./.github/workflows/_build.yaml
8082
permissions:
8183
contents: read
84+
with:
85+
disable_pip_audit: ${{ vars.DISABLE_PIP_AUDIT == 'true' }}
8286

8387
# Create a new Release on Github from the verified build artifacts, and optionally
8488
# publish the artifacts to a PyPI server.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Automatic package versioning and tagging, publishing to [PyPI](https://pypi.org/
6060

6161
[OSSF Security Scorecards](https://github.com/ossf/scorecard) is enabled as a GitHub Actions workflow to give the consumers information about the supply-chain security posture of this project, assigning a score of 0–10. We upload the results as a SARIF (Static Analysis Results Interchange Format) artifact after each run and the results can be found at the Security tab of this GitHub project. We also allow publishing the data at [OpenSSF](https://metrics.openssf.org/). We use this data to continuously improve the security posture of this project. Note that this configuration supports the ``main`` (default) branch and requires the repository to be public and not forked.
6262

63-
[pip-audit](https://github.com/pypa/pip-audit) is part of the default Python virtual environment, and can be used to check all installed packages for documented [CVE](https://www.cve.org/) by querying the [Python Packaging Advisory Database](https://github.com/pypa/advisory-database). The `build.yaml` workflow always runs a package audit before the artifacts are being built.
63+
[pip-audit](https://github.com/pypa/pip-audit) is part of the default Python virtual environment, and can be used to check all installed packages for documented [CVE](https://www.cve.org/) by querying the [Python Packaging Advisory Database](https://github.com/pypa/advisory-database). The `_build.yaml` workflow always runs a package audit before the artifacts are being built. In automated production environments it _may_, on rare occasions, be necessary to suspend package auditing in which case you can [add a repository variable](https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-a-repository) `DISABLE_PIP_AUDIT` with value `true` to your repository to explicitly disable running pip-audit.
6464

6565
### Package or application?
6666

0 commit comments

Comments
 (0)