fix: scope the auth header to the Gitea server; README trust note

- review.yml and git.push set http.<GITHUB_SERVER_URL>/.extraHeader, so the bot token
  is sent only to the Gitea server; git.push falls back to the unscoped key when no
  server is known.
- README: a same-repository PR runs the caller workflow from its head, so the
  safeguards bound PR content, not edits to the caller; drafter: local fails the job.
- Tests: the source-grep fetch test is replaced by a behavioral one over a resumed run
  (fetch ends options, push uses the scoped key); the no-op summary test is dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-12 15:06:30 -05:00
1 parent 7783b6e78f
commit 70c762bf8a
7 files changed
+64 -23

No files matched your search

+12 -4
View File
@@ -163,10 +163,18 @@ class TestGitHardening(unittest.TestCase):
git.fetch(f"--upload-pack=touch {out}", self.repo)
self.assertFalse(out.exists())
def test_flows_fetch_only_through_the_helper(self):
from docs_review import run_monthly, run_pr
for module in (run_pr, run_monthly):
self.assertNotIn('["fetch"', inspect.getsource(module))
def test_push_scopes_header_to_the_server(self):
calls = self._record()
git.run(["checkout", "-q", "-b", "docs-review/pr-4"], self.repo)
git.push("docs-review/pr-4", self.repo, self.TOKEN, "https://gitea.example.org/")
env = calls[-1][1]
self.assertEqual(env["GIT_CONFIG_KEY_0"], "http.https://gitea.example.org/.extraHeader")
self.assertEqual(env["GIT_CONFIG_VALUE_0"], f"Authorization: token {self.TOKEN}")
def test_header_key_falls_back_to_unscoped(self):
self.assertEqual(git.header_key(None), "http.extraHeader")
self.assertEqual(git.header_key(""), "http.extraHeader")
self.assertEqual(git.header_key("https://h.example"), "http.https://h.example/.extraHeader")
def test_push_without_token_adds_no_header(self):
calls = self._record()