Skip to content

Limit the CI workflow token to read-only contents - #271

Merged
yourconscience merged 1 commit into
mainfrom
fix/codeql-alerts
Nov 15, 2026
Merged

yourconscience merged 1 commit into
mainfrom
fix/codeql-alerts

Conversation

@yourconscience

@yourconscience yourconscience commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

What and why

CodeQL's first scan of main left 11 open alerts. Five are real and fixed here; six are not and stay as they are.

  • Fixed, alerts 1 to 5 (actions/missing-workflow-permissions). The five ci.yml jobs had no permissions: block, so each got the repository's default token. No job needs more than read access. ci.yml now sets contents: read at the top level, as release.yml and vuln.yml do.
  • Not exploitable, alerts 10 and 11 (go/command-injection, crons_actions.go). The flagged value is the action in the request body. doCronAction passes only run, pause or resume on to the shell; anything else returns "unknown action". Host, unit and plist come from the last cron scan, never from the request, and the scan covers only crons.hosts.
  • False positives, alerts 6 to 9 (go/allocation-size-overflow). len(a)+len(b) over slices of config lines, skill sources and held lock entries. The inputs are bounded by memory and, in the view, by a 2 MiB request cap.

No Go code changes.

How I checked it

  • Against a build of main in a throwaway home with recording stubs for ssh and launchctl, through tackroom view on loopback: a host that is not configured got 409, a host of -oProxyCommand=... got 409, an action of run; touch ... got 422, a cross-site Origin got 403. None reached the stubs. A normal configured host reached ssh with the expected arguments.

  • ci.yml parses with permissions: {contents: read} over all five jobs.

  • Not checked: older OpenSSH versions and a remote login shell of fish.

  • go test ./... and go vet ./... pass

  • I can explain this change without an AI tool

Summary by Sourcery

Harden CI workflow permissions by limiting its repository token to read-only contents access.

Enhancements:

  • Restrict the CI workflow's default GitHub token to read-only repository contents access.

CI:

  • Add a top-level read-only contents permission to the CI workflow.

@sourcery-ai

sourcery-ai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Configuration

Restrict the CI workflow token to read-only repository contents so its jobs do not inherit broader default permissions.

  • .github/workflows/ci.yml L9-11

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

@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 31aa6f7b-a072-4a42-9b19-596a17d18ecb
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@sourcery-ai sourcery-ai 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.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@yourconscience
yourconscience merged commit bfc0ab3 into main Nov 15, 2026
13 checks passed
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