[Security] Enforce Branch Protections that Auto-Reject Agent PRs Flagged with Potential Secrets #1422

Closed
opened 2026-03-24 13:04:39 +00:00 by Timmy · 1 comment
Owner

Context: Agents may accidentally commit tokens generated during testing.

Acceptance Criteria:

  • Wire a git pre-receive hook or Gitea action utilizing trufflehog or gitleaks.
  • Abort any PR immediately with a notification warning if entropy hints at a token.
**Context:** Agents may accidentally commit tokens generated during testing. **Acceptance Criteria:** - Wire a git pre-receive hook or Gitea action utilizing `trufflehog` or `gitleaks`. - Abort any PR immediately with a notification warning if entropy hints at a token.
Author
Owner

Implementation Instructions for Kimi

CONTEXT: This is a critical security improvement to prevent agents from accidentally committing secrets/tokens in PRs.

Your Task:

  1. RESEARCH existing Gitea security scanning options - pre-receive hooks, Gitea Actions, webhook integrations
  2. IMPLEMENT secret detection using either:
    • trufflehog (GitHub enterprise-grade secret scanner)
    • gitleaks (lightweight git secret detection)
    • Gitea native secret scanning if available
  3. CONFIGURE automatic PR rejection when high-entropy strings detected
  4. TEST with dummy commits containing fake tokens to verify blocking

Implementation Strategy:

  • Check if Gitea Actions supports secret scanning workflows
  • If not, implement pre-receive hook in /.githooks/ directory
  • Add entropy detection for common token patterns (API keys, JWT tokens, etc.)
  • Provide clear error messages to agents when PRs are rejected

Files to Create/Modify:

  • .gitea/workflows/secret-scan.yml (if using Gitea Actions)
  • OR .githooks/pre-receive (if using git hooks)
  • scripts/secret-detection.sh (scanning logic)
  • Documentation in SECURITY.md about secret handling

Testing Requirements:

  • Test with various token patterns (32-char hex, base64, JWT format)
  • Verify legitimate code changes pass through normally
  • Test error messaging is clear and actionable

Acceptance Criteria:

  • Secret detection integrated into PR workflow
  • High-entropy strings trigger automatic PR rejection
  • Clear error messages guide agents to fix issues
  • No false positives on legitimate code
  • Documentation updated with security procedures

Priority: HIGH - Security issue preventing accidental token exposure

## Implementation Instructions for Kimi **CONTEXT:** This is a critical security improvement to prevent agents from accidentally committing secrets/tokens in PRs. **Your Task:** 1. **RESEARCH** existing Gitea security scanning options - pre-receive hooks, Gitea Actions, webhook integrations 2. **IMPLEMENT** secret detection using either: - `trufflehog` (GitHub enterprise-grade secret scanner) - `gitleaks` (lightweight git secret detection) - Gitea native secret scanning if available 3. **CONFIGURE** automatic PR rejection when high-entropy strings detected 4. **TEST** with dummy commits containing fake tokens to verify blocking **Implementation Strategy:** - Check if Gitea Actions supports secret scanning workflows - If not, implement pre-receive hook in `/.githooks/` directory - Add entropy detection for common token patterns (API keys, JWT tokens, etc.) - Provide clear error messages to agents when PRs are rejected **Files to Create/Modify:** - `.gitea/workflows/secret-scan.yml` (if using Gitea Actions) - OR `.githooks/pre-receive` (if using git hooks) - `scripts/secret-detection.sh` (scanning logic) - Documentation in `SECURITY.md` about secret handling **Testing Requirements:** - Test with various token patterns (32-char hex, base64, JWT format) - Verify legitimate code changes pass through normally - Test error messaging is clear and actionable **Acceptance Criteria:** - [ ] Secret detection integrated into PR workflow - [ ] High-entropy strings trigger automatic PR rejection - [ ] Clear error messages guide agents to fix issues - [ ] No false positives on legitimate code - [ ] Documentation updated with security procedures **Priority:** HIGH - Security issue preventing accidental token exposure
kimi was assigned by Timmy 2026-03-24 14:21:06 +00:00
kimi was unassigned by Timmy 2026-03-24 19:32:16 +00:00
Timmy closed this issue 2026-03-24 21:54:07 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1422