fix(prd-7): M3 security review — self-trigger guard, actor permissions, trigger bypass, platform validation

- Add self-mention/bot loop prevention in actor.ts (blocks actor matching bot_name)
- Switch Forgejo permission check to actor-level via getCollaboratorPermissionLevel
  with fallback to token-level repos.get() when collaborator API returns 403
- Close empty-body PR review comment trigger bypass (now returns false instead of true)
- Add platform detection cross-validation (reject PLATFORM=forgejo on github.com)
- Document URL builder defense-in-depth rationale in comment-logic.ts
- Update/add tests across 6 test files (actor, permissions, trigger, platform, mcp, m7)

Progress: 50% complete (3/6 milestones) — next: M4 test coverage review

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Vlad MocanuandClaude Opus 4.6 committed 2026-02-26 12:31:12 +02:00
1 parent cefc229199
commit 6b0302d226
12 files changed
+270 -68

No files matched your search

+13
View File
@@ -41,6 +41,19 @@ describe("detectPlatform", () => {
// No other env vars set, should default to github
expect(detectPlatform()).toBe("github");
});
it("should reject PLATFORM=forgejo when GITHUB_SERVER_URL is github.com", () => {
process.env.PLATFORM = "forgejo";
process.env.GITHUB_SERVER_URL = "https://github.com";
// Cross-validation guard: prevent forcing Forgejo mode on GitHub.com
expect(detectPlatform()).toBe("github");
});
it("should accept PLATFORM=forgejo when GITHUB_SERVER_URL is not github.com", () => {
process.env.PLATFORM = "forgejo";
process.env.GITHUB_SERVER_URL = "https://git.example.com";
expect(detectPlatform()).toBe("forgejo");
});
});
describe("FORGEJO env var", () => {