predicate-claw 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/.github/workflows/release.yml +76 -0
  2. package/.github/workflows/tests.yml +34 -0
  3. package/.markdownlint.yaml +5 -0
  4. package/.pre-commit-config.yaml +100 -0
  5. package/README.md +405 -0
  6. package/dist/src/adapter.d.ts +17 -0
  7. package/dist/src/adapter.js +36 -0
  8. package/dist/src/authority-client.d.ts +21 -0
  9. package/dist/src/authority-client.js +22 -0
  10. package/dist/src/circuit-breaker.d.ts +86 -0
  11. package/dist/src/circuit-breaker.js +174 -0
  12. package/dist/src/config.d.ts +8 -0
  13. package/dist/src/config.js +7 -0
  14. package/dist/src/control-plane-sync.d.ts +57 -0
  15. package/dist/src/control-plane-sync.js +99 -0
  16. package/dist/src/errors.d.ts +6 -0
  17. package/dist/src/errors.js +6 -0
  18. package/dist/src/index.d.ts +12 -0
  19. package/dist/src/index.js +12 -0
  20. package/dist/src/non-web-evidence.d.ts +46 -0
  21. package/dist/src/non-web-evidence.js +54 -0
  22. package/dist/src/openclaw-hooks.d.ts +27 -0
  23. package/dist/src/openclaw-hooks.js +54 -0
  24. package/dist/src/openclaw-plugin-api.d.ts +18 -0
  25. package/dist/src/openclaw-plugin-api.js +17 -0
  26. package/dist/src/provider.d.ts +48 -0
  27. package/dist/src/provider.js +154 -0
  28. package/dist/src/runtime-integration.d.ts +20 -0
  29. package/dist/src/runtime-integration.js +43 -0
  30. package/dist/src/web-evidence.d.ts +48 -0
  31. package/dist/src/web-evidence.js +49 -0
  32. package/dist/tests/adapter.test.d.ts +1 -0
  33. package/dist/tests/adapter.test.js +63 -0
  34. package/dist/tests/audit-event-e2e.test.d.ts +1 -0
  35. package/dist/tests/audit-event-e2e.test.js +209 -0
  36. package/dist/tests/authority-client.test.d.ts +1 -0
  37. package/dist/tests/authority-client.test.js +46 -0
  38. package/dist/tests/circuit-breaker.test.d.ts +1 -0
  39. package/dist/tests/circuit-breaker.test.js +200 -0
  40. package/dist/tests/control-plane-sync.test.d.ts +1 -0
  41. package/dist/tests/control-plane-sync.test.js +90 -0
  42. package/dist/tests/hack-vs-fix-demo.test.d.ts +1 -0
  43. package/dist/tests/hack-vs-fix-demo.test.js +36 -0
  44. package/dist/tests/jwks-rotation.test.d.ts +1 -0
  45. package/dist/tests/jwks-rotation.test.js +232 -0
  46. package/dist/tests/load-latency.test.d.ts +1 -0
  47. package/dist/tests/load-latency.test.js +175 -0
  48. package/dist/tests/multi-tenant-isolation.test.d.ts +1 -0
  49. package/dist/tests/multi-tenant-isolation.test.js +146 -0
  50. package/dist/tests/non-web-evidence.test.d.ts +1 -0
  51. package/dist/tests/non-web-evidence.test.js +139 -0
  52. package/dist/tests/openclaw-hooks.test.d.ts +1 -0
  53. package/dist/tests/openclaw-hooks.test.js +38 -0
  54. package/dist/tests/openclaw-plugin-api.test.d.ts +1 -0
  55. package/dist/tests/openclaw-plugin-api.test.js +40 -0
  56. package/dist/tests/provider.test.d.ts +1 -0
  57. package/dist/tests/provider.test.js +190 -0
  58. package/dist/tests/runtime-integration.test.d.ts +1 -0
  59. package/dist/tests/runtime-integration.test.js +57 -0
  60. package/dist/tests/web-evidence.test.d.ts +1 -0
  61. package/dist/tests/web-evidence.test.js +89 -0
  62. package/docs/MIGRATION_GUIDE.md +405 -0
  63. package/docs/OPERATIONAL_RUNBOOK.md +389 -0
  64. package/docs/PRODUCTION_READINESS.md +134 -0
  65. package/docs/SLO_THRESHOLDS.md +193 -0
  66. package/examples/README.md +171 -0
  67. package/examples/docker/Dockerfile.test +16 -0
  68. package/examples/docker/README.md +48 -0
  69. package/examples/docker/docker-compose.test.yml +16 -0
  70. package/examples/non-web-evidence-demo.ts +184 -0
  71. package/examples/openclaw-plugin-smoke/index.ts +30 -0
  72. package/examples/openclaw-plugin-smoke/openclaw.plugin.json +11 -0
  73. package/examples/openclaw-plugin-smoke/package.json +9 -0
  74. package/examples/openclaw_integration_example.py +41 -0
  75. package/examples/policy/README.md +165 -0
  76. package/examples/policy/approved-hosts.yaml +137 -0
  77. package/examples/policy/dev-workflow.yaml +206 -0
  78. package/examples/policy/policy.example.yaml +17 -0
  79. package/examples/policy/production-strict.yaml +97 -0
  80. package/examples/policy/sensitive-paths.yaml +114 -0
  81. package/examples/policy/source-trust.yaml +129 -0
  82. package/examples/policy/workspace-isolation.yaml +51 -0
  83. package/examples/runtime_registry_example.py +75 -0
  84. package/package.json +27 -0
  85. package/pyproject.toml +41 -0
  86. package/src/adapter.ts +45 -0
  87. package/src/authority-client.ts +50 -0
  88. package/src/circuit-breaker.ts +245 -0
  89. package/src/config.ts +15 -0
  90. package/src/control-plane-sync.ts +159 -0
  91. package/src/errors.ts +5 -0
  92. package/src/index.ts +12 -0
  93. package/src/non-web-evidence.ts +116 -0
  94. package/src/openclaw-hooks.ts +76 -0
  95. package/src/openclaw-plugin-api.ts +51 -0
  96. package/src/openclaw_predicate_provider/__init__.py +16 -0
  97. package/src/openclaw_predicate_provider/__main__.py +5 -0
  98. package/src/openclaw_predicate_provider/adapter.py +84 -0
  99. package/src/openclaw_predicate_provider/agentidentity_backend.py +78 -0
  100. package/src/openclaw_predicate_provider/cli.py +160 -0
  101. package/src/openclaw_predicate_provider/config.py +42 -0
  102. package/src/openclaw_predicate_provider/errors.py +13 -0
  103. package/src/openclaw_predicate_provider/integrations/__init__.py +5 -0
  104. package/src/openclaw_predicate_provider/integrations/openclaw_runtime.py +74 -0
  105. package/src/openclaw_predicate_provider/models.py +19 -0
  106. package/src/openclaw_predicate_provider/openclaw_hooks.py +75 -0
  107. package/src/openclaw_predicate_provider/provider.py +69 -0
  108. package/src/openclaw_predicate_provider/py.typed +1 -0
  109. package/src/openclaw_predicate_provider/sidecar.py +59 -0
  110. package/src/provider.ts +220 -0
  111. package/src/runtime-integration.ts +68 -0
  112. package/src/web-evidence.ts +95 -0
  113. package/tests/adapter.test.ts +76 -0
  114. package/tests/audit-event-e2e.test.ts +258 -0
  115. package/tests/authority-client.test.ts +52 -0
  116. package/tests/circuit-breaker.test.ts +266 -0
  117. package/tests/conftest.py +9 -0
  118. package/tests/control-plane-sync.test.ts +114 -0
  119. package/tests/hack-vs-fix-demo.test.ts +44 -0
  120. package/tests/jwks-rotation.test.ts +274 -0
  121. package/tests/load-latency.test.ts +214 -0
  122. package/tests/multi-tenant-isolation.test.ts +183 -0
  123. package/tests/non-web-evidence.test.ts +168 -0
  124. package/tests/openclaw-hooks.test.ts +46 -0
  125. package/tests/openclaw-plugin-api.test.ts +50 -0
  126. package/tests/provider.test.ts +227 -0
  127. package/tests/runtime-integration.test.ts +70 -0
  128. package/tests/test_adapter.py +46 -0
  129. package/tests/test_cli.py +26 -0
  130. package/tests/test_openclaw_hooks.py +53 -0
  131. package/tests/test_provider.py +59 -0
  132. package/tests/test_runtime_integration.py +77 -0
  133. package/tests/test_sidecar_client.py +198 -0
  134. package/tests/web-evidence.test.ts +113 -0
  135. package/tsconfig.json +14 -0
  136. package/vitest.config.ts +7 -0
@@ -0,0 +1,137 @@
1
+ # Approved Hosts Policy
2
+ # Allowlist for outbound HTTP requests.
3
+ #
4
+ # Customize this list for your environment:
5
+ # - Internal APIs
6
+ # - Known SaaS endpoints
7
+ # - Package registries
8
+
9
+ version: 1
10
+
11
+ defaults:
12
+ effect: deny
13
+
14
+ rules:
15
+ # ============================================
16
+ # LOCALHOST - Always allowed
17
+ # ============================================
18
+
19
+ - id: allow_localhost
20
+ effect: allow
21
+ action: net.http
22
+ resource:
23
+ - "http://localhost:*"
24
+ - "http://127.0.0.1:*"
25
+ - "https://localhost:*"
26
+ - "https://127.0.0.1:*"
27
+
28
+ # ============================================
29
+ # PACKAGE REGISTRIES
30
+ # ============================================
31
+
32
+ - id: allow_npm_registry
33
+ effect: allow
34
+ action: net.http
35
+ resource:
36
+ - "https://registry.npmjs.org/*"
37
+ - "https://registry.yarnpkg.com/*"
38
+
39
+ - id: allow_pypi
40
+ effect: allow
41
+ action: net.http
42
+ resource:
43
+ - "https://pypi.org/*"
44
+ - "https://files.pythonhosted.org/*"
45
+
46
+ - id: allow_crates_io
47
+ effect: allow
48
+ action: net.http
49
+ resource:
50
+ - "https://crates.io/*"
51
+ - "https://static.crates.io/*"
52
+
53
+ - id: allow_go_proxy
54
+ effect: allow
55
+ action: net.http
56
+ resource:
57
+ - "https://proxy.golang.org/*"
58
+ - "https://sum.golang.org/*"
59
+
60
+ # ============================================
61
+ # GITHUB / SOURCE CONTROL
62
+ # ============================================
63
+
64
+ - id: allow_github_api
65
+ effect: allow
66
+ action: net.http
67
+ resource:
68
+ - "https://api.github.com/*"
69
+ - "https://raw.githubusercontent.com/*"
70
+
71
+ - id: allow_gitlab_api
72
+ effect: allow
73
+ action: net.http
74
+ resource:
75
+ - "https://gitlab.com/api/*"
76
+
77
+ # ============================================
78
+ # DOCUMENTATION SITES
79
+ # ============================================
80
+
81
+ - id: allow_docs_sites
82
+ effect: allow
83
+ action: net.http
84
+ resource:
85
+ - "https://docs.*.com/*"
86
+ - "https://*.readthedocs.io/*"
87
+ - "https://developer.mozilla.org/*"
88
+
89
+ # ============================================
90
+ # INTERNAL APIS (customize for your org)
91
+ # ============================================
92
+
93
+ # Example: internal API gateway
94
+ # - id: allow_internal_api
95
+ # effect: allow
96
+ # action: net.http
97
+ # resource:
98
+ # - "https://api.internal.example.com/*"
99
+
100
+ # Example: internal services
101
+ # - id: allow_internal_services
102
+ # effect: allow
103
+ # action: net.http
104
+ # resource:
105
+ # - "https://*.internal.example.com/*"
106
+
107
+ # ============================================
108
+ # KNOWN SAAS (customize for your tools)
109
+ # ============================================
110
+
111
+ # Example: Slack webhooks
112
+ # - id: allow_slack_webhooks
113
+ # effect: allow
114
+ # action: net.http
115
+ # resource:
116
+ # - "https://hooks.slack.com/*"
117
+
118
+ # Example: Sentry error reporting
119
+ # - id: allow_sentry
120
+ # effect: allow
121
+ # action: net.http
122
+ # resource:
123
+ # - "https://*.ingest.sentry.io/*"
124
+
125
+ # ============================================
126
+ # CATCH-ALL DENY
127
+ # ============================================
128
+
129
+ - id: deny_unknown_hosts
130
+ effect: deny
131
+ action: net.http
132
+ resource: "**"
133
+
134
+ metadata:
135
+ name: Approved Hosts
136
+ description: Allowlist for outbound HTTP requests
137
+ version: 1.0.0
@@ -0,0 +1,206 @@
1
+ # Development Workflow Policy
2
+ # Balanced policy for development agents.
3
+ #
4
+ # Allows common development tools while blocking:
5
+ # - Destructive commands
6
+ # - Production endpoints
7
+ # - Sensitive paths
8
+
9
+ version: 1
10
+
11
+ defaults:
12
+ effect: deny
13
+
14
+ rules:
15
+ # ============================================
16
+ # SAFE SHELL COMMANDS
17
+ # Common development tools
18
+ # ============================================
19
+
20
+ - id: allow_git
21
+ effect: allow
22
+ action: shell.execute
23
+ resource:
24
+ - "git *"
25
+
26
+ - id: allow_npm_yarn
27
+ effect: allow
28
+ action: shell.execute
29
+ resource:
30
+ - "npm *"
31
+ - "npx *"
32
+ - "yarn *"
33
+ - "pnpm *"
34
+
35
+ - id: allow_cargo
36
+ effect: allow
37
+ action: shell.execute
38
+ resource:
39
+ - "cargo *"
40
+ - "rustc *"
41
+ - "rustfmt *"
42
+
43
+ - id: allow_go
44
+ effect: allow
45
+ action: shell.execute
46
+ resource:
47
+ - "go *"
48
+ - "gofmt *"
49
+
50
+ - id: allow_python
51
+ effect: allow
52
+ action: shell.execute
53
+ resource:
54
+ - "python *"
55
+ - "python3 *"
56
+ - "pip *"
57
+ - "pip3 *"
58
+ - "poetry *"
59
+ - "pytest *"
60
+
61
+ - id: allow_node
62
+ effect: allow
63
+ action: shell.execute
64
+ resource:
65
+ - "node *"
66
+ - "ts-node *"
67
+ - "tsx *"
68
+
69
+ - id: allow_build_tools
70
+ effect: allow
71
+ action: shell.execute
72
+ resource:
73
+ - "make *"
74
+ - "cmake *"
75
+ - "tsc *"
76
+ - "esbuild *"
77
+ - "vite *"
78
+ - "webpack *"
79
+
80
+ - id: allow_linters
81
+ effect: allow
82
+ action: shell.execute
83
+ resource:
84
+ - "eslint *"
85
+ - "prettier *"
86
+ - "black *"
87
+ - "ruff *"
88
+ - "clippy *"
89
+
90
+ - id: allow_file_ops
91
+ effect: allow
92
+ action: shell.execute
93
+ resource:
94
+ - "ls *"
95
+ - "cat *"
96
+ - "head *"
97
+ - "tail *"
98
+ - "grep *"
99
+ - "find *"
100
+ - "wc *"
101
+ - "diff *"
102
+
103
+ - id: allow_mkdir
104
+ effect: allow
105
+ action: shell.execute
106
+ resource:
107
+ - "mkdir *"
108
+ - "touch *"
109
+
110
+ # ============================================
111
+ # DANGEROUS COMMANDS - DENY
112
+ # ============================================
113
+
114
+ - id: deny_rm_rf
115
+ effect: deny
116
+ action: shell.execute
117
+ resource:
118
+ - "rm -rf *"
119
+ - "rm -fr *"
120
+
121
+ - id: deny_sudo
122
+ effect: deny
123
+ action: shell.execute
124
+ resource:
125
+ - "sudo *"
126
+
127
+ - id: deny_chmod_sensitive
128
+ effect: deny
129
+ action: shell.execute
130
+ resource:
131
+ - "chmod 777 *"
132
+ - "chmod -R *"
133
+
134
+ - id: deny_curl_bash
135
+ effect: deny
136
+ action: shell.execute
137
+ resource:
138
+ - "curl * | bash*"
139
+ - "curl * | sh*"
140
+ - "wget * | bash*"
141
+
142
+ - id: deny_env_export
143
+ effect: deny
144
+ action: shell.execute
145
+ resource:
146
+ - "export *KEY*"
147
+ - "export *SECRET*"
148
+ - "export *TOKEN*"
149
+ - "export *PASSWORD*"
150
+
151
+ # ============================================
152
+ # FILE SYSTEM
153
+ # ============================================
154
+
155
+ - id: allow_workspace_fs
156
+ effect: allow
157
+ action: fs.*
158
+ resource:
159
+ - ./workspace/**
160
+ - ./**/*.ts
161
+ - ./**/*.js
162
+ - ./**/*.json
163
+ - ./**/*.md
164
+ - ./**/*.yaml
165
+ - ./**/*.yml
166
+
167
+ # ============================================
168
+ # HTTP - Development only
169
+ # ============================================
170
+
171
+ - id: allow_localhost_http
172
+ effect: allow
173
+ action: net.http
174
+ resource:
175
+ - "http://localhost:*"
176
+ - "http://127.0.0.1:*"
177
+ - "https://localhost:*"
178
+
179
+ - id: allow_package_registries
180
+ effect: allow
181
+ action: net.http
182
+ resource:
183
+ - "https://registry.npmjs.org/*"
184
+ - "https://pypi.org/*"
185
+ - "https://crates.io/*"
186
+
187
+ - id: allow_github
188
+ effect: allow
189
+ action: net.http
190
+ resource:
191
+ - "https://api.github.com/*"
192
+ - "https://github.com/*"
193
+
194
+ # Block production endpoints
195
+ - id: deny_prod_endpoints
196
+ effect: deny
197
+ action: net.http
198
+ resource:
199
+ - "https://api.production.*"
200
+ - "https://prod.*"
201
+ - "https://*.prod.*"
202
+
203
+ metadata:
204
+ name: Development Workflow
205
+ description: Balanced policy for development agents
206
+ version: 1.0.0
@@ -0,0 +1,17 @@
1
+ version: 1
2
+ rules:
3
+ - id: allow_workspace_reads
4
+ effect: allow
5
+ action: fs.read
6
+ resource: ./workspace/*
7
+ - id: deny_sensitive_paths
8
+ effect: deny
9
+ action: fs.read
10
+ resource:
11
+ - ~/.ssh/*
12
+ - /etc/*
13
+ - id: deny_untrusted_shell
14
+ effect: deny
15
+ action: shell.execute
16
+ when:
17
+ source: untrusted_dm
@@ -0,0 +1,97 @@
1
+ # Production Strict Policy
2
+ # Maximum security for production agents.
3
+ #
4
+ # Characteristics:
5
+ # - Explicit allowlist only
6
+ # - No shell execution
7
+ # - Audit all decisions
8
+ # - Minimal attack surface
9
+
10
+ version: 1
11
+
12
+ defaults:
13
+ effect: deny
14
+ audit: true # Log all decisions
15
+
16
+ rules:
17
+ # ============================================
18
+ # SHELL - COMPLETELY DISABLED
19
+ # No shell execution in production
20
+ # ============================================
21
+
22
+ - id: deny_all_shell
23
+ effect: deny
24
+ action: shell.execute
25
+ resource: "**"
26
+
27
+ # ============================================
28
+ # FILE SYSTEM - READ ONLY, EXPLICIT PATHS
29
+ # ============================================
30
+
31
+ # Only allow reading specific config files
32
+ - id: allow_read_config
33
+ effect: allow
34
+ action: fs.read
35
+ resource:
36
+ - ./config/**
37
+ - ./public/**
38
+
39
+ # Deny all writes
40
+ - id: deny_all_writes
41
+ effect: deny
42
+ action: fs.write
43
+ resource: "**"
44
+
45
+ # ============================================
46
+ # HTTP - EXPLICIT ALLOWLIST ONLY
47
+ # ============================================
48
+
49
+ # Internal health checks only
50
+ - id: allow_health_checks
51
+ effect: allow
52
+ action: net.http
53
+ resource:
54
+ - "http://localhost:*/health"
55
+ - "http://127.0.0.1:*/health"
56
+
57
+ # Specific internal APIs (customize)
58
+ # - id: allow_internal_api
59
+ # effect: allow
60
+ # action: net.http
61
+ # resource:
62
+ # - "https://api.internal.example.com/v1/*"
63
+
64
+ # Deny everything else
65
+ - id: deny_external_http
66
+ effect: deny
67
+ action: net.http
68
+ resource: "**"
69
+
70
+ # ============================================
71
+ # EXPLICIT DENY FOR HIGH-RISK PATTERNS
72
+ # Defense in depth
73
+ # ============================================
74
+
75
+ - id: deny_sensitive_paths
76
+ effect: deny
77
+ action: fs.*
78
+ resource:
79
+ - ~/.ssh/**
80
+ - ~/.aws/**
81
+ - /etc/**
82
+ - "**/.env*"
83
+
84
+ - id: deny_credential_exfil
85
+ effect: deny
86
+ action: net.http
87
+ resource:
88
+ - "*://*.pastebin.com/*"
89
+ - "*://webhook.site/*"
90
+ - "*://*.ngrok.io/*"
91
+ - "*://*.requestbin.com/*"
92
+
93
+ metadata:
94
+ name: Production Strict
95
+ description: Maximum security policy for production agents
96
+ version: 1.0.0
97
+ audit_all: true
@@ -0,0 +1,114 @@
1
+ # Sensitive Path Blocking Policy
2
+ # Blocks access to common sensitive paths regardless of source.
3
+ #
4
+ # These paths contain credentials, keys, or system configuration
5
+ # that should never be accessible to AI agents.
6
+
7
+ version: 1
8
+
9
+ rules:
10
+ # SSH keys and configuration
11
+ - id: deny_ssh_keys
12
+ effect: deny
13
+ action: fs.*
14
+ resource:
15
+ - ~/.ssh/*
16
+ - ~/.ssh/**
17
+
18
+ # Cloud provider credentials
19
+ - id: deny_aws_credentials
20
+ effect: deny
21
+ action: fs.*
22
+ resource:
23
+ - ~/.aws/*
24
+ - ~/.aws/**
25
+
26
+ - id: deny_gcloud_credentials
27
+ effect: deny
28
+ action: fs.*
29
+ resource:
30
+ - ~/.config/gcloud/*
31
+ - ~/.config/gcloud/**
32
+
33
+ - id: deny_azure_credentials
34
+ effect: deny
35
+ action: fs.*
36
+ resource:
37
+ - ~/.azure/*
38
+ - ~/.azure/**
39
+
40
+ # Kubernetes configs
41
+ - id: deny_kube_config
42
+ effect: deny
43
+ action: fs.*
44
+ resource:
45
+ - ~/.kube/*
46
+ - ~/.kube/**
47
+
48
+ # Docker credentials
49
+ - id: deny_docker_config
50
+ effect: deny
51
+ action: fs.*
52
+ resource:
53
+ - ~/.docker/config.json
54
+ - ~/.docker/**
55
+
56
+ # Environment files (may contain secrets)
57
+ - id: deny_env_files
58
+ effect: deny
59
+ action: fs.*
60
+ resource:
61
+ - "**/.env"
62
+ - "**/.env.*"
63
+ - "**/.envrc"
64
+
65
+ # System paths
66
+ - id: deny_etc
67
+ effect: deny
68
+ action: fs.*
69
+ resource:
70
+ - /etc/*
71
+ - /etc/**
72
+
73
+ - id: deny_var_secrets
74
+ effect: deny
75
+ action: fs.*
76
+ resource:
77
+ - /var/run/secrets/**
78
+
79
+ # macOS keychain
80
+ - id: deny_keychain
81
+ effect: deny
82
+ action: fs.*
83
+ resource:
84
+ - ~/Library/Keychains/*
85
+ - ~/Library/Keychains/**
86
+
87
+ # GPG keys
88
+ - id: deny_gpg
89
+ effect: deny
90
+ action: fs.*
91
+ resource:
92
+ - ~/.gnupg/*
93
+ - ~/.gnupg/**
94
+
95
+ # Git credentials
96
+ - id: deny_git_credentials
97
+ effect: deny
98
+ action: fs.*
99
+ resource:
100
+ - ~/.git-credentials
101
+ - ~/.gitconfig
102
+
103
+ # npm/yarn tokens
104
+ - id: deny_npm_tokens
105
+ effect: deny
106
+ action: fs.*
107
+ resource:
108
+ - ~/.npmrc
109
+ - ~/.yarnrc
110
+
111
+ metadata:
112
+ name: Sensitive Path Blocking
113
+ description: Block access to credential and key material paths
114
+ version: 1.0.0
@@ -0,0 +1,129 @@
1
+ # Source-Based Trust Policy
2
+ # Different permission levels based on where the request originated.
3
+ #
4
+ # Source labels:
5
+ # trusted_ui - Direct user input from trusted interface
6
+ # trusted_api - Authenticated API request
7
+ # untrusted_dm - External message (DM, email, etc.)
8
+ # web_content - Content scraped from web pages
9
+ # system - Internal system calls
10
+
11
+ version: 1
12
+
13
+ defaults:
14
+ effect: deny
15
+
16
+ rules:
17
+ # ============================================
18
+ # TRUSTED UI - Direct user interaction
19
+ # Most permissive, but still blocks credentials
20
+ # ============================================
21
+
22
+ - id: trusted_ui_shell
23
+ effect: allow
24
+ action: shell.execute
25
+ when:
26
+ source: trusted_ui
27
+
28
+ - id: trusted_ui_fs_read
29
+ effect: allow
30
+ action: fs.read
31
+ when:
32
+ source: trusted_ui
33
+
34
+ - id: trusted_ui_fs_write
35
+ effect: allow
36
+ action: fs.write
37
+ resource: ./workspace/**
38
+ when:
39
+ source: trusted_ui
40
+
41
+ - id: trusted_ui_http
42
+ effect: allow
43
+ action: net.http
44
+ when:
45
+ source: trusted_ui
46
+
47
+ # ============================================
48
+ # TRUSTED API - Authenticated programmatic access
49
+ # Similar to trusted_ui but may have tighter resource bounds
50
+ # ============================================
51
+
52
+ - id: trusted_api_shell_safe
53
+ effect: allow
54
+ action: shell.execute
55
+ resource:
56
+ - "git *"
57
+ - "npm *"
58
+ - "cargo *"
59
+ - "go *"
60
+ - "python *"
61
+ when:
62
+ source: trusted_api
63
+
64
+ - id: trusted_api_fs_read
65
+ effect: allow
66
+ action: fs.read
67
+ resource: ./workspace/**
68
+ when:
69
+ source: trusted_api
70
+
71
+ - id: trusted_api_http_internal
72
+ effect: allow
73
+ action: net.http
74
+ resource:
75
+ - "http://localhost:*"
76
+ - "http://127.0.0.1:*"
77
+ when:
78
+ source: trusted_api
79
+
80
+ # ============================================
81
+ # UNTRUSTED DM - External messages
82
+ # Very restrictive - likely prompt injection vector
83
+ # ============================================
84
+
85
+ - id: untrusted_dm_shell_deny
86
+ effect: deny
87
+ action: shell.execute
88
+ when:
89
+ source: untrusted_dm
90
+
91
+ - id: untrusted_dm_fs_read_workspace_only
92
+ effect: allow
93
+ action: fs.read
94
+ resource: ./workspace/public/**
95
+ when:
96
+ source: untrusted_dm
97
+
98
+ - id: untrusted_dm_http_deny
99
+ effect: deny
100
+ action: net.http
101
+ when:
102
+ source: untrusted_dm
103
+
104
+ # ============================================
105
+ # WEB CONTENT - Scraped from web pages
106
+ # Maximum restriction - high injection risk
107
+ # ============================================
108
+
109
+ - id: web_content_deny_all
110
+ effect: deny
111
+ action: "*"
112
+ when:
113
+ source: web_content
114
+
115
+ # ============================================
116
+ # SYSTEM - Internal system calls
117
+ # Trusted but audited
118
+ # ============================================
119
+
120
+ - id: system_allow_all
121
+ effect: allow
122
+ action: "*"
123
+ when:
124
+ source: system
125
+
126
+ metadata:
127
+ name: Source-Based Trust
128
+ description: Different permission levels based on request source
129
+ version: 1.0.0