Loading...
Loading...
Post Superagent PR security scan findings as inline GitHub pull request review comments using the authenticated gh CLI. Use whenever you need to comment on a PR scan finding, manage Superagent PR labels, complete a GitHub check run, or avoid posting findings as general PR thread comments. Trigger for any Superagent sandbox PR scan handoff that owns GitHub side effects via gh.
npx skill4agent add superagent-ai/skills pr-github-opsghpr-scan-context.jsonownerrepoprNumberheadShacheckRunIdreviewedFindingPathsdismissedFingerprintsgh pr comment| Goal | Wrong | Right |
|---|---|---|
| Comment on a finding at a diff line | | |
| Summary-only note with no line anchor | | optional |
gh pr commentowner=OWNER
repo=REPO
pr=PR_NUMBER
# Existing inline review comments
gh api "repos/${owner}/${repo}/pulls/${pr}/comments" --paginate
# Existing general PR thread comments (avoid duplicating here)
gh api "repos/${owner}/${repo}/issues/${pr}/comments" --paginate
# PR diff files and patches (confirm path + line are in the diff)
gh api "repos/${owner}/${repo}/pulls/${pr}/files" --paginatefilereviewedFindingPathsfile<!-- brin-pr-finding -->
**P0:** Workflow uses pull_request_target trigger for untrusted fork PRs
Short evidence sentence here.
Short recommendation sentence here.
<!-- superagent-finding-fingerprint:HEX_SHA256 -->criticalhighmediumlowbody='<!-- brin-pr-finding -->
**P1:** Overly broad permissions: write-all in privileged workflow
Grants broad write access to GITHUB_TOKEN.
Replace with least-privilege job permissions.'
printf '%s' "$body" \
| sed 's/<!-- brin-pr-finding -->//g' \
| tr '[:upper:]' '[:lower:]' \
| tr -s '[:space:]' ' ' \
| sed 's/^ //;s/ $//' \
| sha256sum \
| awk '{print $1}'short_evidenceshort_recommendationlinepathhead_sha=HEAD_SHA_FROM_CONTEXT
gh api \
"repos/${owner}/${repo}/pulls/${pr}/comments" \
-X POST \
-f commit_id="$head_sha" \
-f path=".github/workflows/example.yml" \
-f side=RIGHT \
-F line=12 \
-f body="$comment_body"-F line=12-freview.json{
"commit_id": "HEAD_SHA",
"event": "COMMENT",
"body": "<!-- brin-pr-finding -->\nSuperagent found 2 security concern(s).",
"comments": [
{
"path": ".github/workflows/example.yml",
"line": 4,
"side": "RIGHT",
"body": "<!-- brin-pr-finding -->\n**P0:** ...\n\n...\n\n<!-- superagent-finding-fingerprint:abc123... -->"
},
{
"path": ".github/workflows/example.yml",
"line": 8,
"side": "RIGHT",
"body": "<!-- brin-pr-finding -->\n**P1:** ...\n\n...\n\n<!-- superagent-finding-fingerprint:def456... -->"
}
]
}gh api \
"repos/${owner}/${repo}/pulls/${pr}/reviews" \
-X POST \
--input review.jsonfilelinegh api \
"repos/${owner}/${repo}/issues/${pr}/comments" \
-X POST \
-f body="$fallback_body"# Delete inline review comment
gh api "repos/${owner}/${repo}/pulls/comments/COMMENT_ID" -X DELETE
# Delete general PR thread comment
gh api "repos/${owner}/${repo}/issues/comments/COMMENT_ID" -X DELETEgh pr edit "$pr" --repo "${owner}/${repo}" --add-label "pr:flagged"
gh pr edit "$pr" --repo "${owner}/${repo}" --remove-label "pr:verified"gh pr edit "$pr" --repo "${owner}/${repo}" --remove-label "pr:flagged" --add-label "pr:verified"checkRunIdstatus=completedcheck_run_id=CHECK_RUN_ID_FROM_CONTEXT
gh api \
"repos/${owner}/${repo}/check-runs/${check_run_id}" \
-X PATCH \
-f status=completed \
-f conclusion=action_required \
-f 'output[title]=PR requires security review' \
-f 'output[summary]=2 security concern(s) detected.' \
-f 'output[text]=Optional longer details.'successaction_requiredneutralpr-scan-context.jsonfilelineseveritytitleshort_evidenceshort_recommendationgh apigh pr commentgithub_operations_completed: trueposted_comment_ids