Skip to content

Enforcement rules reference

Enforcement files are TOML. Each enabled rule matches a CEL expression against a security event and specifies allow, ask, or block. For a procedure, see Enforce security policy.

Rule groups

GroupOwner
[profiles.rules.KEY]User/general profile rules.
Provider rule groupsRules scoped to configured provider identities.
[corp.rules.KEY]Administrator-owned rules compiled from corporate sources.
[profiles.rules.block_api_writes]
name = "block_api_writes"
action = "block"
priority = 10
match = 'http.host == "api.example.com" && http.method != "GET" && http.method != "HEAD"'
reason = "Only GET and HEAD are permitted."

Fields

FieldTypeDefault / contract
nameStringRequired display name.
actionallow|ask|blockRequired.
matchStringRequired CEL condition; see the complete syntax.
enabledBooleantrue. Disabled rules do not enforce.
priorityInteger or "default"Source-dependent; lower numbers evaluate first.
detection_levelSeverityOptional: informational, low, medium, high, critical.
reasonStringOptional explanation recorded with the decision.
corp_lockedBooleanfalse; corporate authority is validated from the source, not trusted from this flag alone.
managedTagged objectManaged MCP/plugin target; generated/validated by policy tooling.
Plugin-specific fieldsPlugin-defined valuesValidated for that plugin; not arbitrary extensions to the CEL field set.

Processing actions

preprocess, rewrite, and postprocess identify processing rules; they do not select an allow/ask/block decision. rewrite also accepts the legacy aliases redact, mutate, and neutralize. Plugin handling determines the transformation. Use postprocess for an observation-only Sigma detection.

Priority and decisions

SourcePermitted numeric bandDefault
Corporate or corporate-locked-1000 through -10-10
User/plugin10 through 100010
Built-in defaultNamed "default"1001

Rules sort by ascending priority, then rule ID. The first matching enforcement rule selects the rule decision. Matching detections are still recorded. A user/plugin cannot claim a negative corporate priority.

Preprocess plugins prepare event facts. Postprocess plugins can tighten allow to ask or block; they cannot loosen a refusal. An ask is pending approval, not permission to forward.

Network connection and probe admission require an explicit allow. Other event defaults and provider rules still matter; the absence of your own match is not a universal allow or block rule.

Detection versus enforcement

A severity records evidence; an action controls admission where the operation has an enforcement boundary. Observation events, including guest audit reports, cannot stop an operation that has already happened.

Sigma rules compile into the same rule model. A detection-only postprocess rule can record a severity without changing access.

Load and validate

User files are selected by [rule_files].enforcement; administrator files by [corp_rule_files].enforcement. Relative paths resolve from their containing configuration file. Validate with:

Terminal window
capsem-admin enforcement validate ~/.capsem/access-rules.toml --source user --json

Validation checks syntax, known event fields, priorities, and rule structure. Test an allowed and a refused operation to verify the effective policy. Required audit admission must also succeed before an enforced operation proceeds.