Skip to content

feat(workflows): add reusable python-audit workflow#19

Merged
CybotTM merged 2 commits intomainfrom
feat/python-audit-workflow
Apr 17, 2026
Merged

feat(workflows): add reusable python-audit workflow#19
CybotTM merged 2 commits intomainfrom
feat/python-audit-workflow

Conversation

@CybotTM
Copy link
Copy Markdown
Member

@CybotTM CybotTM commented Apr 17, 2026

Summary

New reusable workflow python-audit.yml for Python projects, modelled after node-audit.yml. Provides three independent jobs, each opt-outable:

  • pip-audit — produces pinned requirements.txt from uv / poetry / pip, runs pip-audit against it.
  • bandit — static analysis with configurable severity floor (all, medium, high); honours [tool.bandit] in pyproject.toml.
  • sbom — syncs the project so cyclonedx-py environment sees real deps, generates CycloneDX JSON, uploads as artifact.

All steps SHA-pinned and hardened with step-security/harden-runner.

Inputs

Input Default Notes
python-version 3.14 Fallback when python-version-file is empty
python-version-file '' e.g. pyproject.toml, .python-version
package-manager uv uv / poetry / pip
audit-level high pip-audit vulnerability floor
run-bandit true
bandit-severity medium all / medium / high
bandit-target auto src/ if present, else .
generate-sbom true
sbom-retention-days 90

Caller example

jobs:
  security:
    uses: netresearch/.github/.github/workflows/python-audit.yml@main
    permissions:
      contents: read
    with:
      python-version-file: pyproject.toml
      package-manager: uv

Test plan

  • YAML validates (python3 -c "import yaml; yaml.safe_load(...)")
  • Smoke-tested by wiring up netresearch/coding_agent_cli_toolset (PR #75 on that repo) to call @feat/python-audit-workflow first, then switch to @main once this merges.

Three-job reusable workflow for Python repos, modelled after
node-audit.yml:

- pip-audit: resolves pinned requirements (uv export / poetry export
  / pip freeze) and runs pip-audit against them.
- bandit: runs bandit over the package, with configurable severity
  (-ll default, -lll strict). Honours [tool.bandit] in pyproject.toml.
- sbom: syncs the project so cyclonedx-py sees real dependencies,
  generates a CycloneDX JSON SBOM, uploads as artifact (90-day
  retention by default).

Supports uv (default), poetry, and pip. All steps SHA-pinned and
hardened with step-security/harden-runner.

Caller example:
  jobs:
    security:
      uses: netresearch/.github/.github/workflows/python-audit.yml@main
      permissions:
        contents: read
      with:
        python-version-file: 'pyproject.toml'
        package-manager: 'uv'

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
Copilot AI review requested due to automatic review settings April 17, 2026 05:17
@gemini-code-assist
Copy link
Copy Markdown

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new reusable GitHub Actions workflow to run common Python security checks (dependency vulnerability audit, Bandit static analysis, and CycloneDX SBOM generation) for repositories that call it via workflow_call.

Changes:

  • Introduces .github/workflows/python-audit.yml with three opt-in/opt-out jobs: pip-audit, bandit, and sbom.
  • Supports multiple Python package managers (uv, pip, poetry) and optional Python version selection via an explicit version or version file.
  • Uploads a generated CycloneDX SBOM as a workflow artifact.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/python-audit.yml Outdated
Comment thread .github/workflows/python-audit.yml
Comment thread .github/workflows/python-audit.yml Outdated
Comment thread .github/workflows/python-audit.yml Outdated
Comment thread .github/workflows/python-audit.yml
CybotTM added a commit to netresearch/coding_agent_cli_toolset that referenced this pull request Apr 17, 2026
…sables

Review feedback: use reusable workflows from netresearch/.github
instead of direct action calls (matching the node / Go projects).

- security.yml → calls the new python-audit.yml (netresearch/.github#19,
  pinned to @feat/python-audit-workflow until that PR merges). Same
  three jobs (pip-audit, bandit, sbom) but centrally maintained.
- dependency-review.yml → calls netresearch/.github's reusable
  dependency-review.yml, with fail-on-severity: moderate.
- auto-merge-deps.yml → calls netresearch/.github's reusable
  auto-merge-deps.yml. The org version is identical to what we had
  locally; deduplicated.

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
- Removed misleading `audit-level` input: pip-audit has no native
  severity floor, so the input was validated but never applied.
  Behaviour is now fail-on-any-vulnerability, documented in the step
  body.
- Added up-front package-manager validation on both pip-audit and
  SBOM jobs — unknown values now fail fast with a clear annotation
  instead of silently falling through.
- Fixed bandit `*)` fallback: unexpected `bandit-severity` values
  now fail with an annotation (previously silently treated as
  `medium`).
- Fixed Poetry SBOM environment mismatch: `poetry install`
  populates Poetry's venv, but cyclonedx-py was being invoked
  against the system interpreter, missing every dependency. Now
  installs cyclonedx-bom + runs cyclonedx-py via `poetry run` so
  both live in the same venv.

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
@CybotTM CybotTM merged commit 99d87fc into main Apr 17, 2026
6 checks passed
@CybotTM CybotTM deleted the feat/python-audit-workflow branch April 17, 2026 05:49
CybotTM added a commit to netresearch/coding_agent_cli_toolset that referenced this pull request Apr 17, 2026
Follow-up to #75 — the reusable
workflow [netresearch/.github#19][org-pr] has merged to main, so drop
the temporary @feat/python-audit-workflow pin.

[org-pr]: netresearch/.github#19

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
CybotTM added a commit to netresearch/coding_agent_cli_toolset that referenced this pull request Apr 17, 2026
Follow-up to #75. The reusable `python-audit.yml` workflow [merged into
netresearch/.github
main](netresearch/.github#19), so drop the
temporary `@feat/python-audit-workflow` pin.

## Test plan

- [x] YAML valid (`python3 -c "import yaml; yaml.safe_load(...)"`)
- [ ] On-push CI: `audit / pip-audit`, `audit / bandit`, `audit /
CycloneDX SBOM` all resolve `python-audit.yml@main` at the merge commit
and pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants