Skip to content

chore(ci): guard PR text and commits against unredacted identifiers - #392

Merged
ModerRAS merged 2 commits into
masterfrom
chore/privacy-guard
Sep 16, 2026
Merged

ModerRAS merged 2 commits into
masterfrom
chore/privacy-guard

Conversation

@ModerRAS

@ModerRAS ModerRAS commented Sep 16, 2026 •

Copy link
Copy Markdown
Owner

Why

A recent PR body quoted a raw production log line and exposed a real Telegram group chat id. Agent-authored PRs must not publish production identifiers or secrets, and "remember to redact" is not a control.

Layers

1. AGENTS.md hard rule — never paste raw production logs/configs into public artifacts (PR/issue bodies, comments, commit messages, docs); redact ids, tokens, keys and internal hosts; full logs stay local. AGENTS.md is loaded into every agent session for this repo.

2. Local git hooks (.githooks/) — block the commit before it exists:

  • pre-commit scans staged content, commit-msg scans the commit message
  • patterns are shared with CI via .githooks/sensitive-patterns.txt
  • auto-installed: a fresh clone runs git config core.hooksPath .githooks on the first dotnet build/test via Directory.Build.targets (skipped when CI=true); manual fallback git config core.hooksPath .githooks
  • .githooks/selftest.sh proves the patterns catch leaked shapes and ignore redacted ones

3. CI guard (.github/workflows/privacy-guard.yml) — scans PR title, body and the PR's commit messages, and fails on:

  • Telegram supergroup chat ids (-100…)
  • Telegram bot token shape (id:35 chars)
  • OpenAI sk-…, GitHub gh[pousr]_…, AWS AKIA… keys

Re-runs on edited, so redacting a PR body clears the check without a new push. It reports matched line numbers only and never echoes the matched content, so a detected value is not re-published in CI logs.

Validation

  • .githooks/selftest.sh → 5/5 leaked samples caught, redacted sample clean
  • End-to-end: staging a file containing a chat-id shape makes git commit fail; a commit message with one is rejected by commit-msg
  • Auto-install: after git config --unset core.hooksPath, a dotnet build restores core.hooksPath=.githooks
  • Workflow YAML parses; commit/PR text passes the scanner

Notes

  • Applies from merge onward; existing PRs are not retro-scanned.
  • Hooks scan staged diffs and commit messages only; PR bodies are covered by the CI guard.
  • Bypass is possible (--no-verify) and documented as not allowed.

A recent PR body quoted a raw production log line, exposing a real Telegram
group chat id. Add two layers of prevention:

- AGENTS.md: hard rule that public artifacts (PR/issue bodies, commit
  messages, docs, comments) must redact real ids/tokens and never quote raw
  production logs.
- privacy-guard workflow: scans PR title, body and commits for Telegram chat
  ids, bot tokens, OpenAI/GitHub/AWS key shapes and fails the check on any
  unredacted match. Re-runs on PR edit so a redacted body clears the check.
@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: d9c8947c-fd6d-451b-968f-aeb8d5acb664


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

PR Check Report

Summary

Test Results

Platform Status Details
Ubuntu Passed Tests passed, artifacts uploaded
Windows Passed Tests passed, artifacts uploaded

Code Quality

  • Code formatting check
  • Security vulnerability scan
  • Dependency analysis
  • Code coverage collection

Test Artifacts

  • Test results artifacts count: 2
  • Code coverage uploaded to Codecov

Links


This report is auto-generated by GitHub Actions

- .githooks/pre-commit + .githooks/commit-msg: block commits whose staged
  content or message matches sensitive patterns (<chat_id>/<token>/<key> shapes)
- .githooks/sensitive-patterns.txt: single pattern source for hooks and CI
- .githooks/selftest.sh: positive/negative samples assembled from fragments so
  the test data itself does not trip the hooks
- Directory.Build.targets: first build in a fresh clone runs
  'git config core.hooksPath .githooks' (skipped when CI=true)
- privacy-guard workflow: read the shared pattern file, and report only matched
  line numbers so a detected value is never echoed into public CI logs
- AGENTS.md: document the hooks and their automatic installation
@ModerRAS
ModerRAS merged commit a21ae7b into master Sep 16, 2026
7 checks passed
@ModerRAS
ModerRAS deleted the chore/privacy-guard branch September 16, 2026 07:47
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