Scope the Bar comment job to pull requests instead of issues - #65
Merged
Conversation
The comment job held issues:write, which grants write access to every issue in the repository even though it only ever comments on the pull request the collector validated. pull-requests:write covers commenting on a pull request through the issue-comments endpoint and nothing else, so a wrong pull request number can no longer reach an unrelated issue. The permission assertions now compare each job's whole permissions block rather than searching for substrings, so granting an extra scope fails the test instead of passing because the expected line is still present. GitHub error bodies are untrusted input that lands in the Actions log. Error reporting now projects only a bounded message and a documentation URL rebuilt from validated components on docs.github.com. Mentions, HTML delimiters, workflow-command punctuation, line breaks, control characters, and every other URL are removed, and no other response field is echoed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Narrows the comment job's write scope and stops GitHub error bodies from
reaching the Actions log unfiltered.
Permission
investigateactions: read,contents: read,pull-requests: readcommentcontents: read,issues: writecontents: read,pull-requests: writeissues: writegranted write access to every issue in the repository,while the job only ever comments on the pull request the collector
validated against GitHub.
pull-requests: writecovers commenting on apull request through the issue-comments endpoint and nothing more, so a
wrong pull request number can no longer land on an unrelated issue.
The investigation job is untouched and remains read-only. The comment
job still receives no
BAR_ACCESS_*and no Actions read.Stronger permission assertions
The tests now compare each job's entire permissions block for equality
instead of searching for substrings. A substring test passes when an
extra scope is added, because the line it looks for is still there.
Verified by mutation — every one of these now fails the test:
issues: writeandpull-requests: writeon the comment jobissues: writerestored on the comment jobactions: readadded to the comment jobcontents: writeon the comment jobissues: writeadded to the investigation jobpull-requests: readpromoted towriteGitHub error reporting
A GitHub error body is untrusted input that lands in the Actions log.
Errors now report only two projected fields:
and format characters removed, URLs and bare domains replaced, and
@ < > : &stripped so no mention, HTML, or workflow command canform. Bounded to 160 characters.
when it is a canonical HTTPS URL on
docs.github.comwith nouserinfo, port, backslash, whitespace, or non-ASCII.
No other response field is echoed.
Verified against hostile inputs:
::error::and::add-path::injection, mentions, HTML, external URLs, bare domains, bidi overrides,
zero-width characters, control bytes, multiline bodies, and a 4,000
character message. Zero escapes. Every hostile
documentation_urlwasrejected, including
docs.github.com@attacker.example,docs.github.com.attacker.example, a trailing-dot host, an explicitport, embedded credentials,
javascript:, and backslash paths.Verification
Comment tests 26 passed, collector tests 37 passed, full suite 1073
passed, release hygiene passed, hygiene tests 11 passed, ruff clean,
actionlint clean,
git diff --checkclean.