cortex policy

Manage security policy rules for the Parallax security model. Policy rules control which operations agents are allowed to perform, based on pattern matching with priority-based evaluation.

Usage

cortex policy list                              # List all policy rules
cortex policy add "<pattern>" --kind shell --effect deny --reason "reason"
cortex policy check shell "rm -rf /etc"          # Check if an action would be allowed
cortex policy remove <rule_id>                   # Remove a rule by ID

Subcommands

SubcommandDescription
listList all policy rules with their patterns, effects, and priorities
addAdd a new policy rule
removeRemove a policy rule by ID
checkCheck whether a specific action would be allowed or denied

Options

OptionDescription
--kindRule kind: tool, shell, domain
--effectallow or deny
--reasonHuman-readable reason for the rule
--priorityRule priority (lower number = higher precedence, default: 500)
--helpShow help for this command

Default Deny Rules

On first migration, the following dangerous patterns are seeded:

RulePatternBlocks
Recursive root deleterm\s+-rf\s+/rm -rf / and variants
Fork bombs:\(\)\{.*\}Shell fork bomb patterns
Direct disk writesdd\s+if=.*of=/dev/dd to block devices
World-writable rootchmod\s+777\s+/Making root world-writable

Policy Evaluation

checkPolicy(kind, value):
  for rule in rules WHERE kind = ? ORDER BY priority ASC:
    if regex(rule.pattern).test(value):
      return { allowed: rule.effect === 'allow', reason: rule.reason }
  return { allowed: true, reason: 'default allow' }

Priority ASC means lower numbers are evaluated first. A deny at priority 100 will override an allow at priority 500.

Examples

# List all current rules
cortex policy list

# Add a deny rule for a dangerous domain pattern
cortex policy add "curl.*evil\.com" --kind shell --effect deny --reason "Block known malicious domain"

# Check if a command would be allowed
cortex policy check shell "curl https://evil.com"
# → { allowed: false, reason: "Block known malicious domain" }

# Add an allow rule with high priority to override deny
cortex policy add "git pull" --kind shell --effect allow --priority 100 --reason "Allow git operations"

# Remove a rule
cortex policy remove pol_abc123