Policy syntax
How to write a policy, rule by rule
A policy is written in the simple form: in the dashboard, in a sandbox spec file, and in the rules field of every API call that takes rules. Each check refuses the same mistakes wherever the rules come from. A sandbox spec file takes every action except call; write call rules in the dashboard or the API.
The simple form
One rule a line: a verdict, an action, a thing, and what the action takes after it. Words are separated by spaces; extra spaces line rules up and mean nothing.
Allow read repo/checkout
Allow write scratch
Allow net api.github.com GET POST /repos/acme/app/*
Allow net registry.npmjs.org GET
Allow net 203.0.113.0/24:5432
Ask use payment-keys
Allow msg to policy:build-peers
Deny net everything else- Verdicts:
Allow,Ask,Deny. - Actions:
read,write,net,use,msgandcall. Actions lists what each one takes. - Order does not matter. The most specific rule wins, and at equal weight Deny beats Ask and Ask beats Allow.
- An unknown word is an error. Every error names its line and column, and one check reports every bad line.
Net rules
Allow net api.github.com GET POST /repos/acme/app/*
Allow net *.example.com:443
Allow net 203.0.113.0/24:5432
Allow net [2001:db8::/32] ports 443,8000-8100
Allow net db.example.com:5432 address-only
Deny net everything else| Part | Written as |
|---|---|
| A host name | Exact, such as api.github.com, or *. for every name beneath one, such as *.example.com. A wildcard over a public suffix, such as *.com, is refused. |
| An address or range | 203.0.113.7, 203.0.113.0/24, or IPv6 in brackets, [2001:db8::/32], with ports after the closing bracket. |
everything else | Every host no other rule names. |
| Ports | After a colon, :443, or as ports 443,8000-8100. The most ranges one rule takes: Not published yet. |
| Protocol | tcp or udp. |
| Methods | GET, POST and the other HTTP methods, before the paths they apply to. |
| Paths | Prefixes, each ending in *: /v1/refunds* matches /v1/refunds and /v1/refunds/42. A path without * is refused. |
address-only | Enforce the name by its address and port only, without reading the traffic. |
Methods and paths need Pod to read the traffic, so a rule with them switches reading on for the sandbox. QUIC is dropped when a policy has name rules that read, and programs fall back to TCP.
Folder rules
Allow read datasets
Allow write scratch at /mnt/scratch
Allow write results to policy:reviewA folder of Pod's shared drive, by name, with an optional path beneath it. at sets the mount point, an absolute path. to policy:<name> and from policy:<name> share a folder between sandboxes under different policies; both sides must say so.
Tool and message rules
Allow use payment-keys
Allow msg to policy:review
Allow msg from policy:builduse names a connected tool. msg names another policy as policy:<name>, or policy:self for the policy's own sandboxes. A message between two policies is delivered only when the sender's policy allows to and the receiver's allows from. Tool rules has the forms that go further.
Names
A named policy is 1 to 63 characters of lowercase letters, digits and -, starting with a letter or digit. It cannot be called organisation, project, default or self.