Skip to content

ci: restrict build.yml to read-only repository permissions - #8

Merged
bnayahu merged 2 commits into
mainfrom
ci/build-workflow-permissions
Aug 11, 2026
Merged

ci: restrict build.yml to read-only repository permissions#8
bnayahu merged 2 commits into
mainfrom
ci/build-workflow-permissions

Conversation

@bnayahu

@bnayahu bnayahu commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Closes #3

Problem

.github/workflows/build.yml had no permissions: block, so the default GITHUB_TOKEN permissions applied. Hygiene only — the job makes no repository writes, so the defaults were adequate and nothing was broken.

Change

permissions:
  contents: read

The job checks out the repo, builds, and uploads an artifact. contents: read covers actions/checkout; actions/upload-artifact@v4 authenticates with the Actions runtime token rather than GITHUB_TOKEN, so it is unaffected by the narrowing.

The accompanying comment records why this workflow gets read and warns against copying it into release.yml, which genuinely needs contents: write for gh release create.

Verification

  • .github/workflows/build.yml parses as valid YAML; permissions resolves to {contents: read} and all 9 steps of the build job are intact.
  • The workflow run on this PR exercises the change directly — if contents: read were insufficient, checkout or artifact upload would fail here.

Assisted-By: Claude (Anthropic AI) noreply@anthropic.com

Pressing OK could call CheckAndApplyAutoSwitch() three times: once in the
auto-switch settings block, once in the base-mouse-count block, and once
in the forced re-apply after the cached device state is discarded. Each
call enumerates raw input devices, retrying GetRawInputDeviceList up to
three times, so a single click cost up to three enumerations.

The repeats were harmless — the direction is persisted before all three
calls and ApplyMouseOrientation() sets an absolute value rather than
toggling — but only the last call could do useful work in the common
case, since the first two early-return on unchanged state.

Remove the two earlier calls and keep the forced re-apply at the end of
the handler. By that point every setting the check reads is persisted, so
one pass applies them all; the first call previously ran before
SetBaseMouseCount(), so it could not see a changed base count anyway.

Dropping the base-mouse-count call also stops a re-apply from running
when the auto-switch flag itself failed to persist: that call was gated
on autoSwitchEnabled alone, not on autoSwitchWritten. The surviving call
is gated on both, matching 3a00a42.

Closes #2

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Jonathan Bnayahu <bnayahu@il.ibm.com>
build.yml declared no permissions: block, so the workflow ran with the
default GITHUB_TOKEN permissions. The job only checks out the repository,
builds, and uploads an artifact, so read access to contents is all it
needs. actions/upload-artifact authenticates with the Actions runtime
token rather than GITHUB_TOKEN, so it is unaffected.

Nothing was broken; this narrows the token to what the job actually uses.

The comment warns against copying the block into release.yml, which
genuinely needs contents: write for `gh release create`.

Closes #3

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Jonathan Bnayahu <bnayahu@il.ibm.com>
@bnayahu
bnayahu force-pushed the ci/build-workflow-permissions branch from 741793e to c113fd9 Compare August 11, 2026 18:39
@bnayahu
bnayahu merged commit c113fd9 into main Aug 11, 2026
1 check passed
@bnayahu
bnayahu deleted the ci/build-workflow-permissions branch August 11, 2026 18:47
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.

Add explicit permissions: block to build.yml

1 participant