Skip to content

chore(security): harden repo posture - #35

Merged
alain-sv merged 1 commit into
mainfrom
chore/security-hardening
May 13, 2026
Merged

chore(security): harden repo posture#35
alain-sv merged 1 commit into
mainfrom
chore/security-hardening

Conversation

@alain-sv

Copy link
Copy Markdown
Contributor

Summary

  • SHA-pin all third-party GitHub Actionstrufflehog@main (critical: floating branch), softprops/action-gh-release@v3, astral-sh/setup-uv@v7, pypa/gh-action-pypi-publish@release/v1; all now pinned to commit SHAs with version comments
  • Add pypi environment required reviewer — alain-sv must approve before OIDC publish secrets are exposed; previously any push to main triggered an immediate PyPI release with no gate
  • Add .github/dependabot.yml — weekly updates for pip + github-actions ecosystems with a 5-day cooldown window (supply-chain worm mitigation)
  • Add security-scan.yml — OSV-Scanner (Google, free) runs daily and on every PR against the OSV.dev malicious package index; SARIF uploaded to GitHub Security tab
  • Enforce uv sync --frozen in CI — lockfile cannot silently change during builds
  • Add SECURITY.md — responsible disclosure via GitHub private advisories; documents supply-chain posture
  • Add security rules to AGENTS.md — mandatory rules for coding agents (no direct pushes to main, no lockfile hand-edits, no workflow modifications without approval, no hatch publish locally)

GitHub settings applied (outside this diff)

  • Secret scanning + push protection: enabled
  • Dependabot vulnerability alerts + security updates: enabled
  • Private vulnerability reporting: enabled
  • Classic branch protection replaced with ruleset: required CI checks (pre-commit + build 3.10–3.13), enforced on admins
  • Tag ruleset: v* tags are now immutable

Test plan

  • CI passes on this PR (Python package workflow)
  • Verify OSV-Scanner workflow runs on this PR
  • After merge: confirm next push to main triggers pypi environment approval request before publish step

🤖 Generated with Claude Code

@qodo-code-review

Copy link
Copy Markdown

Review Summary by Qodo

Harden repository security posture with action pinning, Dependabot, and supply-chain controls

✨ Enhancement 📝 Documentation

Grey Divider

Walkthroughs

Description
• Pin all third-party GitHub Actions to commit SHAs with version comments
• Add Dependabot configuration for weekly pip and GitHub Actions updates
• Add OSV-Scanner security workflow for daily malicious package detection
• Enforce uv sync --frozen in CI to prevent silent lockfile changes
• Add SECURITY.md documenting supply-chain controls and responsible disclosure
• Add mandatory security rules to AGENTS.md for coding agents
Diagram
flowchart LR
  A["GitHub Actions"] -->|"Pin to commit SHAs"| B["Hardened Workflows"]
  C["Dependencies"] -->|"Weekly Dependabot updates"| D["Supply-chain Protection"]
  E["Malicious Packages"] -->|"OSV-Scanner daily scan"| F["Security Events"]
  G["Lockfile"] -->|"Enforce --frozen flag"| H["Immutable Builds"]
  B --> I["Enhanced Security Posture"]
  D --> I
  F --> I
  H --> I
Loading

Grey Divider

File Changes

1. .github/dependabot.yml ⚙️ Configuration changes +28/-0

Add Dependabot configuration for dependency updates

.github/dependabot.yml


2. .github/workflows/publish-pypi.yml Security enhancement +2/-2

Pin setup-uv and pypa publish actions to commit SHAs

.github/workflows/publish-pypi.yml


3. .github/workflows/python-package.yml Security enhancement +4/-8

Pin setup-uv action and enforce frozen lockfile

.github/workflows/python-package.yml


View more (6)
4. .github/workflows/release.yml Security enhancement +1/-1

Pin softprops action to commit SHA

.github/workflows/release.yml


5. .github/workflows/security-scan.yml Security enhancement +31/-0

Add OSV-Scanner workflow for malicious package detection

.github/workflows/security-scan.yml


6. .github/workflows/trufflehog-full-scan.yml Security enhancement +1/-1

Pin trufflehog action to commit SHA

.github/workflows/trufflehog-full-scan.yml


7. .github/workflows/trufflehog-security.yml Security enhancement +1/-1

Pin trufflehog action to commit SHA

.github/workflows/trufflehog-security.yml


8. AGENTS.md 📝 Documentation +33/-0

Add mandatory security and supply-chain rules

AGENTS.md


9. SECURITY.md 📝 Documentation +33/-0

Add security policy and supply-chain posture documentation

SECURITY.md


Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented May 13, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0)

Grey Divider


Action required

1. Frozen sync breaks CI 🐞 Bug ☼ Reliability
Description
python-package.yml now runs uv sync --frozen in the build job while still testing Python
3.10/3.11, but both pyproject.toml and uv.lock require Python >=3.12, so dependency install will
fail on those matrix entries. This will break CI for PRs/merges until the matrix is aligned with the
supported Python versions (or the lock/project constraints are changed).
Code

.github/workflows/python-package.yml[R52-54]

+        uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
      - name: Install dependencies
-        run: uv sync --extra dev --extra deploy
+        run: uv sync --frozen --extra dev --extra deploy
Evidence
The workflow matrix still includes 3.10/3.11 and now enforces the lockfile via --frozen, while
both the project metadata and lockfile explicitly require Python >=3.12; therefore the frozen sync
cannot succeed on 3.10/3.11.

.github/workflows/python-package.yml[37-56]
pyproject.toml[1-6]
uv.lock[1-9]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The CI build matrix includes Python 3.10/3.11, but the project and lockfile require Python >=3.12. With the newly enforced `uv sync --frozen`, installs will fail for unsupported Python versions.

## Issue Context
- `pyproject.toml` declares `requires-python = ">=3.12"`.
- `uv.lock` also declares `requires-python = ">=3.12"`.
- The workflow build job still runs for `python-version: ["3.10", "3.11", "3.12", "3.13"]` and now uses `uv sync --frozen`.

## Fix Focus Areas
- .github/workflows/python-package.yml[40-55]
- pyproject.toml[1-6]
- uv.lock[1-9]

## Suggested fix
Update the build matrix to only include supported versions (e.g., `3.12` and `3.13`). If you truly need to test 3.10/3.11, you must also change `requires-python` and regenerate a compatible lockfile (but that contradicts the current project metadata).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Unpinned checkout action 🐞 Bug ⛨ Security
Description
The new security-scan.yml workflow introduces actions/checkout@v5 as a floating tag, which
conflicts with the repo’s newly added rule that new actions must be pinned to a commit SHA. This
leaves a supply-chain update surface in the newly added security workflow.
Code

.github/workflows/security-scan.yml[19]

+      - uses: actions/checkout@v5
Evidence
The security scan workflow newly introduces a checkout action referenced by a floating tag, while
AGENTS.md explicitly mandates SHA pinning for new actions; the new workflow violates that rule as
written.

.github/workflows/security-scan.yml[15-22]
AGENTS.md[56-61]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A newly added workflow uses `actions/checkout@v5` by tag. The repo’s security rules (added in this PR) state that new actions must be pinned to a commit SHA with a version comment.

## Issue Context
`security-scan.yml` is a new workflow file introduced in this PR. It adds a new `uses: actions/checkout@v5` step.

## Fix Focus Areas
- .github/workflows/security-scan.yml[18-22]
- AGENTS.md[56-61]

## Suggested fix
Replace `actions/checkout@v5` with a commit SHA pin and keep a version comment, e.g.:
- `uses: actions/checkout@<sha> # v5.x.y`
(Use the official commit SHA for the intended release.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@alain-sv
alain-sv force-pushed the chore/security-hardening branch from c65cc91 to 25b1ea2 Compare May 13, 2026 08:08
Comment on lines +52 to +54
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
- name: Install dependencies
run: uv sync --extra dev --extra deploy
run: uv sync --frozen --extra dev --extra deploy

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Frozen sync breaks ci 🐞 Bug ☼ Reliability

python-package.yml now runs uv sync --frozen in the build job while still testing Python
3.10/3.11, but both pyproject.toml and uv.lock require Python >=3.12, so dependency install will
fail on those matrix entries. This will break CI for PRs/merges until the matrix is aligned with the
supported Python versions (or the lock/project constraints are changed).
Agent Prompt
## Issue description
The CI build matrix includes Python 3.10/3.11, but the project and lockfile require Python >=3.12. With the newly enforced `uv sync --frozen`, installs will fail for unsupported Python versions.

## Issue Context
- `pyproject.toml` declares `requires-python = ">=3.12"`.
- `uv.lock` also declares `requires-python = ">=3.12"`.
- The workflow build job still runs for `python-version: ["3.10", "3.11", "3.12", "3.13"]` and now uses `uv sync --frozen`.

## Fix Focus Areas
- .github/workflows/python-package.yml[40-55]
- pyproject.toml[1-6]
- uv.lock[1-9]

## Suggested fix
Update the build matrix to only include supported versions (e.g., `3.12` and `3.13`). If you truly need to test 3.10/3.11, you must also change `requires-python` and regenerate a compatible lockfile (but that contradicts the current project metadata).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@alain-sv
alain-sv merged commit b25c186 into main May 13, 2026
8 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c65cc91a1b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

name: Security scan

on:
pull_request:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Guard SARIF upload on pull_request from untrusted sources

This workflow triggers on pull_request and always runs SARIF upload, but pull requests from forks (and Dependabot PRs) receive a read-only GITHUB_TOKEN, so write operations like code-scanning uploads can fail with Resource not accessible by integration. Because upload-sarif requires security-events: write, this can cause otherwise-valid PR checks to fail for external contributors; restrict the upload step to trusted contexts (for example push/schedule or non-fork PRs).

Useful? React with 👍 / 👎.

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