Skip to content

chore(ci): correct CodeQL pinned-version annotations - #33

Merged
PeterGuy326 merged 2 commits into
mainfrom
codex/32-codeql-version-comments
Sep 14, 2026
Merged

PeterGuy326 merged 2 commits into
mainfrom
codex/32-codeql-version-comments

Conversation

@PeterGuy326

Copy link
Copy Markdown
Contributor

Canonical requirement

Refs #32

Decision reference: the initial R1 Issue body. It explicitly records that local candidates preceded this prospective publication record; no retrospective approval is claimed.

Requirement trace

REQ/AC IDs Changed files / domain Tests or review evidence
REQ-001 / AC-001 4 exact-pinned version annotations Exact expected-byte replacement PASS
REQ-002 / AC-002 2 files in bytefolk/.github Repository inventory PASS; aggregate 7 repositories, 13 files, 21 lines
REQ-003 / AC-003 Existing workflow content and modes Parsed YAML and comment-stripped bytes identical
REQ-004 / AC-004 Current-head CI and independent review Local independent replay recorded in the canonical R1 Issue linked above; hosted CI and merge review remain pending

File domains

workflow-templates/bytefolk-scorecard.yml (47); workflow-templates/bytefolk-security.yml (57, 63, 66).

Base: 0aaff626914385ad8acd20cb2b7b47e300417a68
Head: b271c9292060c754925ecef586fd1d8857818f93

Scope and non-goals

Correct only # v4.37.4 to # v4.37.9 on CodeQL uses-lines pinned to cdf488f595d80d6e07e03d4674febd5ab45fa938. The official tag object resolves to that existing pin. Action SHAs, permissions, triggers, steps, matrices, other pins, and runtime code are unchanged.

Validation

  • Exact commands: ruby evidence/verify.rb --baseline and ruby evidence/verify.rb --committed from the retained review packet; git diff --check 0aaff626914385ad8acd20cb2b7b47e300417a68 b271c9292060c754925ecef586fd1d8857818f93 from this repository.
  • Observed counts/results: PASS 2/2 files and 4/4 replacements here; aggregate PASS 13/13 files and 21/21 replacements. Baseline intentionally exits 1 after detecting all 21 stale annotations; committed verification exits 0.
  • Check URLs: NOT VERIFIED: this draft is published before its hosted check results exist.

The strict verifier checks the changed-file allowlist; exact old blobs and line inventory; complete expected-byte replacement; absence of stale target annotations; parsed YAML equality; comment-stripped byte equality and SHA-256 digests; whitespace and unchanged modes; one commit with the exact parent; and clean worktrees with no untracked files. All passed. The independent replay is recorded in canonical R1. The verifier and inventory are retained outside repository commits.

ID REQ/AC Observable acceptance criterion Command or manual steps Environment Expected Observed Status
V1 AC-001, AC-002, AC-003 Exact annotations with executable YAML unchanged ruby evidence/verify.rb --committed Ruby 2.6.10, Psych 3.1.0, isolated review packet Exact scoped replacements and equality 2/2 files; 4/4 lines; all invariants pass PASS
V2 AC-004 Hosted checks on this exact head Inspect this draft's checks GitHub Actions Applicable checks succeed Results not yet collected NOT VERIFIED

Security and compatibility

Documentation annotation only. No dependencies, permissions, credentials, data flows, or runtime behavior change. The diff and commit identity were inspected for public-safe content. No CHANGELOG entry or behavior-documentation update is needed because only explanatory comments change.

Known limitations

Runtime suites, build, coverage, and dependency audits were not rerun for this comment-only change; no runtime test result is claimed. Hosted CI is separate from local equality proof. This is a draft, not merge-ready.

Risk and rollback

Low-risk annotation correction. Roll back through an ordinary revert of this single commit. There is no migration or release action.

Product review handoff

  • Implementation/publication owner: @PeterGuy326
  • Automated pre-review result: independent local replay recorded in R1; no human approval implied.
  • Human final review: PENDING; no human review requested by this publication.
  • Merge ledger owner: @PeterGuy326
  • Product reviewer: @PeterGuy326
  • Milestone or release packet: N/A: bounded documentation annotation maintenance
  • Merge, CI, release, and model judgment do not accept or close the Issue: acknowledged

Annotate the existing cdf488f595d80d6e07e03d4674febd5ab45fa938 pin as v4.37.9. The action SHA and executable workflow configuration are unchanged.

@Bindy-lbb Bindy-lbb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. 两处改动:

  1. codeql-action 注释版本号更新v4.37.4v4.37.9,SHA pin 不变(cdf488f595d80d6e07e03d4674febd5ab45fa938),只是注释对齐实际版本,安全无影响。
  2. scorecard upload-sarif 注释同步更新:同上,SHA 不变,注释更新。

SHA 固定 pin 是最佳实践,注释版本号仅供人类识别,本次变更纯粹是文档对齐。✅

PeterGuy326 added a commit that referenced this pull request Sep 14, 2026
## What this changes

One line deleted from `workflow-templates/bytefolk-security.yml` — the
`if:` guard on the `codeql` job. Nothing else in the template changes.

```diff
   codeql:
     name: CodeQL (${{ matrix.language }})
-    if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
     runs-on: ubuntu-24.04
```

Blob size goes 1979 -> 1858 bytes. The deleted line is exactly 121 bytes
including its newline, so the arithmetic accounts for the whole delta.
The double-quoted `cron`, the `# Change this list to the languages
present in the repository.` comment, the single-language matrix, the
ungated `Autobuild` step and every pinned action SHA are untouched.

## Why

The guard's second clause compares the head repository to the base
repository, so it is false for every fork pull request and the `codeql`
job is skipped. GitHub does not evaluate a skipped job's `name:`
expression, so the skipped job publishes the raw string `CodeQL (${{
matrix.language }})` as its check name and matches none of the
per-language contexts consumers declare as required.

Every repository that adopted this template inherited that behaviour.
The full evidence, the mechanism and the rejected alternatives are
recorded in #35 rather than repeated here.

The consumer-side fix is bytefolk/mem#205, which deletes the same line
from mem's copy. That PR is same-repository, so its own three CodeQL
contexts can demonstrate the fix working. This template PR is filed
separately so the fix propagates on the next template sync instead of
regressing.

## Why deleting the guard rather than documenting a second `codeql-fork`
lane

`bytefolk/digital-employee#250` worked around this by adding a second
job with the inverted guard. That job is identical to the baseline
`codeql` job apart from the guard and the language matrix, so a second
lane duplicates roughly 37 lines to express what deleting one line
already says — and it has to be re-duplicated in every consumer.

The guard is provably redundant for every trigger other than a fork PR:

- `push`, `schedule`, `workflow_dispatch` — the first clause
`github.event_name != 'pull_request'` is already true.
- Same-repository `pull_request` — the second clause is already true.
- Fork `pull_request` — the job was skipped; it now runs. **This is the
only behavioural change.**

Fork `pull_request` runs can carry this job: `digital-employee#250`'s
`codeql-fork` concluded `success` on a fork PR while declaring
`permissions: security-events: write` and containing no
`continue-on-error`, which means the `Analyze` step succeeded — and
`codeql-action/analyze` returns HTTP 403 without that permission. Fork
runs still get no secrets and read-only `contents`. All ByteFolk
repositories are public, so the private-repository restriction on
fork-PR permissions does not apply here.

## Tradeoff, stated plainly

Consumers that adopt the corrected template will build untrusted fork
code in a job holding `security-events: write`. Those runs have no
secrets and read-only `contents`, and the other baseline jobs already
build the same untrusted code, so this adds no new class of exposure. It
is the posture GitHub's own default CodeQL setup takes for public
repositories.

Adopting this is a per-repository decision, not an automatic one: the
template only changes what a consumer gets the next time it syncs, and a
consumer that wants the old behaviour can keep its guard.

## Consumer follow-up required

Any consumer that added its own `codeql-fork` lane must delete it once
it adopts this template, otherwise two jobs publish the same check name.
Today that is `digital-employee` via #250. This PR deliberately does not
touch `digital-employee`; that removal belongs in its own reviewable
change against that repository.

## Interaction with #33

#33 edits this same file, but only the three `github/codeql-action/*`
annotation lines (`# v4.37.4` -> `# v4.37.9`) plus
`bytefolk-scorecard.yml`. This PR deletes the guard line above them. The
hunks do not overlap, so the two 3-way-merge cleanly in either order,
and #32's AC-003 requirement that annotation changes not be mixed into
unrelated PRs is preserved in both directions.

## What this does not touch

- No `permissions:` block changes. The `codeql` job keeps exactly
`contents: read`, `actions: read`, `packages: read`, `security-events:
write`.
- No required status context, branch protection rule or ruleset is
weakened or removed, in this repository or any consumer.
- No action SHA, trigger, matrix entry, step or job other than the
deleted line.
- No annotation correction; those stay in #33.

Refs #35
@PeterGuy326
PeterGuy326 merged commit c2d7ac7 into main Sep 14, 2026
1 check passed
@PeterGuy326
PeterGuy326 deleted the codex/32-codeql-version-comments branch September 14, 2026 14:48
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