{"id":50755267,"url":"https://github.com/escoffier-labs/content-guard","last_synced_at":"2026-06-11T04:02:44.823Z","repository":{"id":363746367,"uuid":"1247804601","full_name":"escoffier-labs/content-guard","owner":"escoffier-labs","description":"Policy-driven content scanning and publish checks","archived":false,"fork":false,"pushed_at":"2026-06-10T07:14:30.000Z","size":871,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-10T08:12:41.044Z","etag":null,"topics":["content-filter","openclaw","privacy","publish-check","python","redaction"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/escoffier-labs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-05-23T20:00:34.000Z","updated_at":"2026-06-10T07:14:34.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/escoffier-labs/content-guard","commit_stats":null,"previous_names":["escoffier-labs/content-guard"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/escoffier-labs/content-guard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/escoffier-labs%2Fcontent-guard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/escoffier-labs%2Fcontent-guard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/escoffier-labs%2Fcontent-guard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/escoffier-labs%2Fcontent-guard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/escoffier-labs","download_url":"https://codeload.github.com/escoffier-labs/content-guard/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/escoffier-labs%2Fcontent-guard/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34181555,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-11T02:00:06.485Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["content-filter","openclaw","privacy","publish-check","python","redaction"],"created_at":"2026-06-11T04:02:44.017Z","updated_at":"2026-06-11T04:02:44.815Z","avatar_url":"https://github.com/escoffier-labs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/assets/content-guard-banner.jpg\" alt=\"Content Guard banner\"\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eContent Guard\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cstrong\u003ePolicy-driven scanning and redaction for public content, publishing pipelines, and agent output.\u003c/strong\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/python-3.11%2B-3776AB?style=for-the-badge\u0026logo=python\u0026logoColor=white\" alt=\"Python 3.11+\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/license-Apache--2.0-blue?style=for-the-badge\" alt=\"Apache-2.0 license\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/dependencies-zero_required-2ea44f?style=for-the-badge\" alt=\"Zero required third-party dependencies\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/OPF-optional-8A2BE2?style=for-the-badge\" alt=\"Optional OPF backend\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/markdown-aware-083344?style=for-the-badge\u0026logo=markdown\u0026logoColor=white\" alt=\"Markdown aware\"\u003e\n\u003c/p\u003e\n\nContent Guard keeps private infrastructure, secrets, and personal context out of public surfaces before they ship. It is built for Markdown docs, PR bodies, social drafts, generated agent output, and automation pipelines where one sloppy paste can leak more than intended.\n\nIt takes the practical parts of the local content scrubber and the useful model-backed idea behind Privacy Filter, then turns them into one maintainable system.\n\n## What It Checks\n\n- Deterministic rules for infrastructure, secrets, and high-confidence patterns\n- Optional OPF backend for model-based PII review and redaction\n- Custom policy files for private names, internal projects, unreleased plans, and environment-specific rules\n- Blocking, warning, redaction, and allow decisions from one report format\n- Markdown-aware scanning with frontmatter and allow-comment support\n\nThe core package has no required third-party dependencies. OPF is optional and runs through its CLI when available.\n\n## Quick Start\n\nInstall from a local clone:\n\n```bash\npython -m pip install -e .\n```\n\nScan or redact a file:\n\n```bash\ncontent-guard scan examples/sample.md --policy policies/public-content.json\ncontent-guard redact examples/sample.md --policy policies/public-content.json\ncontent-guard scan examples/sample.md --json\ncontent-guard scan examples/ --policy policies/public-content.json\n```\n\nUse OPF if it is installed locally:\n\n```bash\ncontent-guard redact examples/sample.md --opf\n```\n\nBy default, `--opf` looks for `~/.opf-venv/bin/opf`. Override it with:\n\n```bash\nCONTENT_GUARD_OPF_BIN=/path/to/opf content-guard scan file.md --opf\n```\n\nOPF can also be enabled from a policy file:\n\n```json\n{\n  \"backends\": {\n    \"opf\": {\n      \"enabled\": true,\n      \"action\": \"warn\",\n      \"device\": \"cpu\"\n    }\n  }\n}\n```\n\n## Policies\n\nPolicies are JSON so the project stays dependency-free. A policy can set default actions by category, override individual rules, and add private custom regex rules.\n\n```json\n{\n  \"name\": \"public-content\",\n  \"defaults\": {\n    \"infrastructure\": \"block\",\n    \"secret\": \"block\",\n    \"pii\": \"warn\"\n  },\n  \"rules\": {\n    \"email\": \"warn\"\n  },\n  \"custom_rules\": [\n    {\n      \"id\": \"internal-hostname-example\",\n      \"category\": \"infrastructure\",\n      \"pattern\": \"\\\\\\\\binternal-host\\\\\\\\b\",\n      \"replacement\": \"[redacted-host]\"\n    }\n  ]\n}\n```\n\nActions:\n\n- `block`: fail the scan, usually for publish gates\n- `redact`: rewrite matching content\n- `warn`: report without failing\n- `allow`: ignore matching findings\n\n### Bundled Policies\n\nTwo bundled policies share the `infrastructure` category but treat it differently on purpose:\n\n- `policies/public-repo.json`: for technical docs repos. It keeps `private-ipv4` (RFC 1918), secrets, PII, and `Co-authored-by` trailers as hard blocks, but downgrades `loopback-ipv4` (127.x), `localhost-port`, `localhost-bare`, and `port-reference` to warnings. README and CONTRIBUTING files often need to discuss `localhost`, named ports, and `127.0.0.1` for setup instructions. See [policies/public-repo.md](policies/public-repo.md) for the long-form rationale.\n- `policies/public-content.json`: for blog posts and social drafts. It keeps the full infrastructure category at block because marketing surfaces have a higher leak risk and should not expose internal addresses or named ports.\n\n## Allow Comments\n\nUse a local allow comment on the same line or directly above a line:\n\n```md\n\u003c!-- content-guard: allow localhost-bare --\u003e\nThis tutorial uses localhost as an example.\n```\n\nUse `content-guard: allow all` sparingly for examples where every finding is intentional.\n\nFor known-public literals that trip history scans (where inline comments cannot reach old commit diffs), add them to the private policy allowlist from the command line:\n\n```bash\ncontent-guard allow add \"git@github.com\" --note \"SSH remote prefix, public by definition\"\ncontent-guard allow list\n```\n\nBy default this edits `~/.config/content-guard/internal.json` (override with `--policy` or `CONTENT_GUARD_PRIVATE_POLICY`).\n\n## PR and Git Guards\n\nPR bodies and public repository content are publishing boundaries too. Use stricter policies before copying generated summaries, dogfood notes, local test output, fixtures, or docs into public GitHub surfaces:\n\n```bash\ncontent-guard scan examples/pr-body.md --policy policies/pr-draft.json\ncontent-guard diff examples/pr-body.md --policy policies/pr-draft.json\ncontent-guard-pr examples/pr-body.md\ncontent-guard-pr-prepare examples/pr-body.md --json\ncontent-guard-publish-check --pr-body examples/pr-body.md --json\ncontent-guard-n8n-advisory \u003c payload.json\ncontent-guard-n8n-validate --json\ncontent-guard-git --policy policies/public-repo.json\ncontent-guard-git --all-tracked --policy policies/public-repo.json\ncontent-guard-commits --range origin/main..HEAD --policy policies/public-repo.json\n```\n\nSee [docs/PR_DRAFTS.md](docs/PR_DRAFTS.md) and [docs/GIT_PUBLIC_REPO_GUARD.md](docs/GIT_PUBLIC_REPO_GUARD.md).\n\nUse `content-guard-publish-check` as the practical local pre-publish wrapper. It prepares a sanitized PR body when `--pr-body` is provided, scans staged files, scans commit messages, and can optionally scan all tracked files:\n\n```bash\ncontent-guard-publish-check --pr-body pr-body.md --json\ncontent-guard-publish-check --pr-body pr-body.md --all-tracked\n```\n\nPR body findings are advisory by default because the wrapper writes a sanitized body and prints `publish_body_file`. Staged file, commit message, and optional all-tracked blockers fail the command unless `--advisory-only` is set.\n\nUse `content-guard-pr-prepare` when a later PR publishing step needs a stable sanitized body path:\n\n```bash\ncontent-guard-pr-prepare pr-body.md\ngh pr create --body-file .content-guard/pr-drafts/pr-body.public.md\n```\n\nFor local run-alongside testing against the legacy scrubber, see [docs/DOGFOOD_TEST_REPO.md](docs/DOGFOOD_TEST_REPO.md).\n\nFor n8n publish workflows, start with an advisory step that reports findings without mutating live publishes. See [docs/N8N_ADVISORY.md](docs/N8N_ADVISORY.md) and [docs/N8N_WORKFLOW_RECIPE.md](docs/N8N_WORKFLOW_RECIPE.md). Validate cloned workflow wiring with [docs/N8N_VALIDATION_PACK.md](docs/N8N_VALIDATION_PACK.md).\n\n## OpenClaw Plugin\n\nContent Guard can also run as an OpenClaw outbound message plugin. The plugin lives in `openclaw-plugin/` and shells out to the same Python engine, so OpenClaw messages use the same policy model as publish gates.\n\nThe plugin is an example adapter. It is installed from source (clone this repo and point OpenClaw at `openclaw-plugin/`) and is not published to npm or any other registry. Only the `content-guard` Python package on PyPI is published.\n\nSee [docs/OPENCLAW_PLUGIN.md](docs/OPENCLAW_PLUGIN.md).\n\n## Design Notes\n\nPrivacy Filter influenced the optional model-backed PII layer, especially the idea that some personal data detection benefits from context. Content Guard does not copy Privacy Filter code. OPF integration is a subprocess adapter so the deterministic engine remains portable and maintainable.\n\nThe deterministic rules are intentionally conservative. Public publishing should fail loudly on infrastructure and secret leakage, while model findings are better treated as review signals until a local policy proves they are reliable enough to block.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fescoffier-labs%2Fcontent-guard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fescoffier-labs%2Fcontent-guard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fescoffier-labs%2Fcontent-guard/lists"}