Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): use a Github Repository Variable DISABLE_PIP_AUDIT to control running pip-audit in CI #551

Merged
merged 4 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
name: Build the package
on:
workflow_call:
inputs:
disable_pip_audit:
required: true
type: boolean
description: Enable or disable running pip_audit to check installed packages for vulnerabilities
outputs:
artifacts-sha256:
description: The hash of the artifacts
Expand Down Expand Up @@ -73,8 +78,10 @@ jobs:
- name: Install dependencies
run: make setup

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

# Build the sdist and wheel distribution of the package and docs as a zip file.
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pr-change-set.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ jobs:
uses: ./.github/workflows/_build.yaml
permissions:
contents: read
with:
disable_pip_audit: ${{ vars.DISABLE_PIP_AUDIT == 'true' }}
4 changes: 4 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
uses: ./.github/workflows/_build.yaml
permissions:
contents: read
with:
disable_pip_audit: ${{ vars.DISABLE_PIP_AUDIT == 'true' }}

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

# Create a new Release on Github from the verified build artifacts, and optionally
# publish the artifacts to a PyPI server.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Automatic package versioning and tagging, publishing to [PyPI](https://pypi.org/

[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.

[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.
[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.

### Package or application?

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dev = [
docs = [
"sphinx >=5.1.1,<8.0.0",
"sphinxnotes-markdown-builder >=0.5.6,<1.0.0",
"typing-extensions <4.6.0", # markdown-builder uses pydash: https://github.com/dgilland/pydash/issues/197
]
hooks = [
"pre-commit >=2.18.0,<3.4.0",
Expand Down