Skip to content

Scope the Bar comment job to pull requests instead of issues - #65

Merged
gowtham0992 merged 1 commit into
mainfrom
bar-comment-permissions
Aug 15, 2026
Merged

Scope the Bar comment job to pull requests instead of issues#65
gowtham0992 merged 1 commit into
mainfrom
bar-comment-permissions

Conversation

@gowtham0992

@gowtham0992 gowtham0992 commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Narrows the comment job's write scope and stops GitHub error bodies from
reaching the Actions log unfiltered.

Permission

Job Before After
investigate actions: read, contents: read, pull-requests: read unchanged
comment contents: read, issues: write contents: read, pull-requests: write

issues: write granted 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: write covers commenting on a
pull 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:

  • both issues: write and pull-requests: write on the comment job
  • issues: write restored on the comment job
  • actions: read added to the comment job
  • contents: write on the comment job
  • issues: write added to the investigation job
  • investigation pull-requests: read promoted to write

GitHub error reporting

A GitHub error body is untrusted input that lands in the Actions log.
Errors now report only two projected fields:

  • message — NFKC-normalized, line breaks folded to spaces, control
    and format characters removed, URLs and bare domains replaced, and
    @ < > : & stripped so no mention, HTML, or workflow command can
    form. Bounded to 160 characters.
  • documentation_url — rebuilt from validated components, and only
    when it is a canonical HTTPS URL on docs.github.com with no
    userinfo, 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_url was
rejected, including docs.github.com@attacker.example,
docs.github.com.attacker.example, a trailing-dot host, an explicit
port, 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 --check clean.

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.
@gowtham0992
gowtham0992 merged commit 9274577 into main Aug 15, 2026
10 checks passed
@gowtham0992
gowtham0992 deleted the bar-comment-permissions branch August 15, 2026 21:00
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