Skip to content

fix: harden repo settings#296

Merged
vinitkumar merged 2 commits into
masterfrom
feat/security-improvements
May 25, 2026
Merged

fix: harden repo settings#296
vinitkumar merged 2 commits into
masterfrom
feat/security-improvements

Conversation

@vinitkumar

@vinitkumar vinitkumar commented May 25, 2026

Copy link
Copy Markdown
Owner

Summary by Sourcery

Harden GitHub repository automation by tightening workflow permissions, pinning third-party GitHub Actions to specific commits, and documenting the CI supply-chain strategy.

Build:

  • Pin build and packaging workflows (Rust wheel builds, sdist, and PyPI/TestPyPI publishing) to specific action SHAs and set minimal required permissions for tokens.

CI:

  • Restrict default GitHub Actions token permissions to read-only where possible, retain only necessary write scopes (e.g., CodeQL security-events), and pin all CI-related actions (linting, testing, CodeQL, coverage, benchmarks) to immutable commits.
  • Add Dependabot configuration to automatically check github-actions dependencies weekly.

Documentation:

  • Document the workflow supply-chain hardening approach and permissions strategy in the architecture overview.

@sourcery-ai

sourcery-ai Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

This PR hardens the GitHub Actions supply chain by pinning all third‑party actions to specific commit SHAs, tightening workflow permissions to read‑only where possible, documenting the strategy in the architecture docs, and adding Dependabot configuration to keep GitHub Actions pins up to date.

File-Level Changes

Change Details Files
Constrain GitHub Actions workflow permissions and pin all referenced actions to specific SHAs.
  • Add top-level workflow permissions blocks with minimal scopes (primarily contents: read) to multiple workflows, ensuring tokens are read-only by default.
  • Replace floating version tags (e.g., @v4, @v5, @v6, @release/v1) with pinned commit SHAs for actions such as actions/checkout, actions/setup-python, PyO3/maturin-action, actions-rust-lang/setup-rust-toolchain, actions/upload-artifact, actions/download-artifact, codecov/codecov-action, github/codeql-action, astral-sh/setup-uv, and pypa/gh-action-pypi-publish.
  • Remove now-unnecessary job-level permissions overrides (e.g., id-token: write) where the workflow no longer uses OIDC-based publishing and relies on static PyPI tokens instead.
.github/workflows/build-rust-wheels.yml
.github/workflows/rust-ci.yml
.github/workflows/pythonpackage.yml
.github/workflows/codeql.yml
.github/workflows/lint.yml
.github/workflows/publish-to-live-pypi.yml
.github/workflows/publish-to-test-pypi.yml
Document workflow supply-chain hardening strategy and configure automated updates for GitHub Actions pins.
  • Extend architecture documentation to describe workflow supply-chain hardening, including read-only tokens, SHA pinning, and minimal permissions, with CodeQL retaining security-events: write.
  • Add a Dependabot configuration to track the github-actions ecosystem at the repo root and schedule weekly updates so pinned action SHAs stay current.
lat.md/architecture.md
.github/dependabot.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".github/workflows/codeql.yml" line_range="11-12" />
<code_context>
   PACKAGE_NAME: json2xml_rs
   PYTHON_VERSION: '3.12'

+permissions:
+  contents: read
+
 jobs:
</code_context>
<issue_to_address>
**🚨 issue (security):** CodeQL needs `security-events: write` permission in addition to `contents: read`.

Because you’ve set `permissions: contents: read` at the workflow level, all other default permissions are now `none`, including `security-events`. The CodeQL action needs `security-events: write` to upload results to the code scanning dashboard, otherwise the analysis runs but can’t publish findings.

You should update this block to:

```yaml
permissions:
  contents: read
  security-events: write
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/workflows/codeql.yml
@codecov

codecov Bot commented May 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.56%. Comparing base (1b74483) to head (89a25b9).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #296   +/-   ##
=======================================
  Coverage   98.56%   98.56%           
=======================================
  Files           6        6           
  Lines         487      487           
=======================================
  Hits          480      480           
  Misses          7        7           
Flag Coverage Δ
unittests 98.56% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vinitkumar vinitkumar merged commit 8efd90f into master May 25, 2026
62 checks passed
@vinitkumar vinitkumar deleted the feat/security-improvements branch May 25, 2026 15:57
@vinitkumar vinitkumar restored the feat/security-improvements branch June 14, 2026 17:19
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.

1 participant