Examples
Merge these selected observe-mode permissions into a policy derived from your workload. Paths and dependencies vary; valid JSON alone does not establish enforcement coverage. Omitted operations have no permissions.
Minimal Policies
A mode-only policy has empty permissions: derive learns, observe reports every covered operation, and enforce treats each as a violation. See mode-only behavior.
Complete Node.js Build Example
This Node.js example demonstrates execution, network, JIT memory, process, and broad workspace access. Replace broad all rules with derived paths before enforcement. The temporary-directory rules use /tmp; change them to the directory your workload actually uses.
{
"mode": "observe",
"path": {
"execute": [
"all|all|{/bin,/usr/bin}/{bash,node,npm}",
"all|all|{/bin,/usr/bin}/{cat,cp,grep,ls,mkdir,mv,rm,sed}"
],
"create": [
"all|%workspace%",
"all|/tmp"
],
"delete": [
"all|%workspace%",
"all|/tmp"
],
"open": ["all"],
"write": [
"all|%workspace%",
"all|/tmp"
]
},
"ip": {
"connect": [
"all|{registry.npmjs.org,github.com}|443"
]
},
"unix": {
"connect": ["all"]
},
"hook": {
"wx": ["{/bin,/usr/bin}/node"]
},
"task": {
"kill": ["all"],
"pgroup": ["all"]
},
"ioctl": {
"cmd": ["all"]
}
}Key decisions:
hook.wxpermits Node.js JIT memory.- Network rules restrict package and source access to expected services.
- File mutation is limited to the workspace and
/tmp. path.openremains broad because build tools read system libraries and configuration. Refine it from observed paths.
Toolchain Deltas
The following are rule additions, not complete policies. Merge only the values your derived policy needs.
| Toolchain | path.execute values | Common ip.connect targets | Other operation |
|---|---|---|---|
| Python | all|all|{/usr/bin,/usr/local/bin}/{python,python3,pip,pip3,pytest} | pypi.org|443, files.pythonhosted.org|443 | hook.wx for Python when required |
| Go | all|all|/usr/local/go/bin/{go,gofmt}; derive compiler paths from go env GOTOOLDIR | proxy.golang.org|443, sum.golang.org|443 | Usually no hook.wx |
| Java/Maven | all|all|{/usr/bin,/usr/local/bin}/{java,mvn} | repo.maven.apache.org|443 | hook.wx for the JVM when required |
| Rust/Cargo | all|all|{%home%/.cargo/bin,/usr/bin,/usr/local/bin}/{cargo,rustc} | crates.io|443, static.crates.io|443 | Compiler workspace writes |
An IP rule has the complete form process|address|port, for example:
all|pypi.org|443Derivation usually records concrete /32 or /128 addresses. Verify service ranges before broadening them.
Complete Container Build Example
This example permits Docker to run selected images and access its daemon socket:
{
"mode": "observe",
"container": {
"run": [
"docker.io/library/node|all",
"gcr.io/example/application|all"
]
},
"path": {
"execute": [
"all|all|{/bin,/usr/bin}/bash",
"all|all|/usr/bin/docker",
"all|all|{/bin,/usr/bin}/{cat,cp,ls,mkdir,mv,rm}"
],
"create": ["all"],
"delete": ["all"],
"open": ["all"],
"write": ["all"],
"pivot": [
"/usr/bin/runc|all|all"
]
},
"ip": {
"connect": [
"all|registry-1.docker.io|443",
"all|auth.docker.io|443",
"all|gcr.io|443"
]
},
"unix": {
"connect": [
"all|/var/run/docker.sock"
]
},
"netlink": {
"bind": ["all"]
},
"task": {
"kill": ["all"],
"pgroup": ["all"]
},
"ioctl": {
"cmd": ["all"]
}
}Docker daemon access is equivalent to host-level control. Permit it only for builds that require it, then refine the broad file and IOCTL rules from derivation.
Infrastructure Tool Deltas
| Tool | Execution value | Typical network requirement |
|---|---|---|
| Kubernetes | all|all|{/usr/bin,/usr/local/bin}/{kubectl,helm} | Cluster API address on 443 |
| Terraform | all|all|{/usr/bin,/usr/local/bin}/terraform | Provider registry and selected cloud APIs |
| Security scanners | all|all|{/usr/bin,/usr/local/bin}/{grype,semgrep,snyk,trivy} | Scanner database and API endpoints |
| Database migration | all|all|{/usr/bin,/usr/local/bin}/{flyway,mysql,psql} | Approved database CIDRs and ports |
Prefer exact service CIDRs over blanket private-network rules.
Compiler Rule Examples
These rules separate executable and source access. Derive the complete toolchain: compilers also invoke cc1, cc1plus, as, and ld, read libraries/headers, and create or rename temporary files. Paths vary by distribution/version.
{
"mode": "observe",
"path": {
"execute": [
"all|all|{/bin,/usr/bin}/bash",
"all|all|/usr/bin/{make,gcc,g++}",
"all|/usr/bin/make|{/bin,/usr/bin}/sh"
],
"open": [
"/usr/bin/make|%workspace%/Makefile",
"/usr/bin/{gcc,g++}|%workspace%/src",
"all|/usr/include"
],
"create": [
"all|%workspace%/build"
],
"write": [
"all|%workspace%/build"
],
"overwrite": [
"all|%workspace%/build"
]
}
}Source files and Makefiles are opened inputs, not execution targets. Resolve unexplained violations in representative observe-mode builds before enforcing.
Granular Operation Examples
File Mutation
{
"mode": "observe",
"path": {
"create": [
"/usr/bin/node|%workspace%/node_modules"
],
"delete": [
"/usr/bin/node|%workspace%/node_modules"
],
"rename": [
"/bin/mv|%workspace%|%workspace%"
],
"symlink": [
"/usr/bin/ln|%workspace%"
],
"write": [
"/usr/bin/node|%workspace%/build"
]
}
}Kernel Modules
These rules permit kernel module requests by name. Explicit module-file loading also needs the appropriate kernel.read permission when that hook is evaluated.
{
"mode": "observe",
"kernel": {
"module": [
"/usr/sbin/ip|dummy",
"/usr/bin/runc|overlay"
]
}
}Container Socket Exposure
{
"mode": "observe",
"container": {
"socket": [
"docker.io/docker|27",
"gcr.io/kaniko-project/executor|all"
]
}
}Socket-Backed Standard Streams
socket.stdio evaluates only AF_INET and AF_INET6 socket-backed standard streams. Permit the executing and executed program pair:
{
"mode": "observe",
"socket": {
"stdio": [
"/usr/sbin/xinetd|/usr/sbin/in.telnetd"
]
}
}Unix domain socket-backed standard streams are not evaluated by this operation.
Refinement Patterns
Consolidate Values with Braces
Before:
/usr/bin/curl|api.example.com|80
/usr/bin/curl|api.example.com|443
/usr/bin/curl|api.example.com|8080After:
/usr/bin/curl|api.example.com|{80,443,8080}Consolidate Dynamic Paths
Before:
/bin/bash|%workspace%/scripts/build.sh
/bin/bash|%workspace%/scripts/test.sh
/bin/bash|%workspace%/scripts/deploy.shAfter:
/bin/bash|%workspace%/scripts/{build,test,deploy}.shUse Verified CIDRs
Before:
all|192.168.1.1/32|443
all|192.168.1.2/32|443
all|192.168.1.3/32|443After confirming that the entire subnet belongs to the service:
all|192.168.1.0/24|443Escaping Paths
Whitespace inside a value is significant:
{
"mode": "observe",
"path": {
"open": [
"all|%workspace%/My Project/build"
]
}
}The characters \, {, }, ,, %, and | are structural. Escape a literal structural character with a backslash. JSON also escapes backslashes, so one literal backslash in a path requires four in policy JSON:
{
"mode": "observe",
"path": {
"open": [
"all|/srv/back\\\\slash",
"all|/srv/report\\,2024.csv",
"all|/srv/100\\%"
]
}
}These values name /srv/back\slash, /srv/report,2024.csv, and /srv/100%.
Empty components such as all| and all||443 are invalid rather than wildcards.