Skip to content

Add policy-as-code layer for agent runtime governance #2

Open

Description

@cschanhniem

ShellWard's 8-layer defense is the strongest open-source agent security middleware I've seen — it covers everything from PII detection to DLP to data exfiltration blocking. One area that would complement the runtime defense is a declarative policy layer for agent governance at the Git/CI boundary.

Why it fits: ShellWard already handles runtime behavior (block dangerous commands, redact secrets, enforce DLP). A policy-as-code file in the repo (e.g. ) would let teams declare pre-deployment rules like:

  • "Only the tool may run in CI — never "
  • "Agents authored by external contributors must have limited tool scope"
  • "Prompt injection detector must be enabled for all PRs touching "

This creates a defense-in-depth chain: policy at Git push → enforcement at runtime, closing the gap where an agent can be injected during development but only caught at execution. ShellWard's existing GitHub Action integration is the natural place to evaluate such a policy before the agent even starts.

Activity

  1. jnMetaCode commented on Jun 23, 2026

    @jnMetaCode
    Owner

    Thanks @cschanhniem — this is a great suggestion and exactly the right direction (policy at the Git/CI boundary complementing runtime enforcement). I shipped a lightweight v1 of policy-as-code in v0.7.21:

    Drop a .shellward.json in your repo root:

    {
      "failOn": ["secret", "pii"],
      "maxFindings": 0,
      "allowOverseas": ["OpenAI"]
    }
    • failOn — fail CI if any finding matches these kinds (secret / pii / overseas / env-perm) or severities (critical / high / medium)
    • maxFindings — max total findings allowed
    • allowOverseas — overseas LLM providers explicitly permitted (exempt from failure)

    shellward scan --ci (and the GitHub Action) reads it and gates the build; without the file it defaults to "fail on any critical". This gives the declare-at-push → enforce-at-runtime chain you described.

    This is a deliberately small first cut. The richer rules you mentioned are the natural next step — I'd love your input to get them right:

    • Tool-scope by authorship ("external contributors get limited tool scope") — what would the rule shape look like for you?
    • Per-path requirements ("PRs touching /agents must have injection detection enabled")
    • A policyVersion / schema so it's forward-compatible

    If you can share 2–3 concrete rules from your own setup, I'll extend the schema to cover them. PRs very welcome too. Thanks again for engaging — this is the first community-driven feature in the project. 🙏

  2. MemoAsh commented on Jul 5, 2026

    @MemoAsh

    I am testing an AI coding-agent safety receipt pack. If you had to keep this minimal for a paid pilot, what 2-3 policy fields would you require at PR-review scope?

    For example:

    • restricted paths/actions
    • max findings by severity/kind
    • allowlist for provider/tooling
    • mandatory evidence fields (checks_run / blocked / unverified)

    If you think the pack is still too weak without runtime enforcement, tell me what is the minimal enforcement boundary you would trust for a first-paid tryout.

  3. jnMetaCode commented on Sep 28, 2026

    @jnMetaCode
    Owner

    Update (v0.7.22): two items from the list above are now shipped via #5.

    • Per-path requirements — rules: [{ "path": "agents/**", "failOn": ["overseas"] }], checked on top of the global rules; per-rule allowOverseas can override the global allowlist.
    • version field — "version": 1; a newer version, unknown fields or misspelled failOn values now produce visible warnings instead of being silently ignored (previously a typo could quietly turn the gate into a no-op).

    Still open: tool scope by authorship (external contributors get a narrower policy). That needs PR author context, which scan --ci does not have today; the likely shape is the GitHub Action passing author association into the policy. Leaving this issue open for that — concrete rule examples are still very welcome.

  4. chenhz01 commented on Oct 2, 2026

    @chenhz01

    ShellWard's 8-layer runtime defense is genuinely strong, and a declarative policy layer at the Git/CI boundary is the right complement — runtime blocking catches bad behavior, but a policy gate at merge time stops the dangerous config from shipping at all. Since the maintainer already shipped per-path requirements (#5), the natural next step is a policy test: assert that a PR adding overseas to agents/** fails the gate. That closes the loop between the policy and its enforcement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions