@aporthq/aport-agent-guardrails 1.0.8

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 (237) hide show
  1. package/LICENSE +217 -0
  2. package/README.md +481 -0
  3. package/bin/agent-guardrails +133 -0
  4. package/bin/aport-create-passport.sh +444 -0
  5. package/bin/aport-cursor-hook.sh +90 -0
  6. package/bin/aport-guardrail-api.sh +108 -0
  7. package/bin/aport-guardrail-bash.sh +394 -0
  8. package/bin/aport-guardrail-v2.sh +5 -0
  9. package/bin/aport-guardrail.sh +5 -0
  10. package/bin/aport-resolve-paths.sh +71 -0
  11. package/bin/aport-status.sh +276 -0
  12. package/bin/frameworks/crewai.sh +49 -0
  13. package/bin/frameworks/cursor.sh +95 -0
  14. package/bin/frameworks/langchain.sh +48 -0
  15. package/bin/frameworks/n8n.sh +36 -0
  16. package/bin/frameworks/openclaw.sh +19 -0
  17. package/bin/lib/allowlist.sh +18 -0
  18. package/bin/lib/common.sh +28 -0
  19. package/bin/lib/config.sh +46 -0
  20. package/bin/lib/constants.sh +232 -0
  21. package/bin/lib/detect.sh +65 -0
  22. package/bin/lib/error.sh +269 -0
  23. package/bin/lib/passport.sh +19 -0
  24. package/bin/lib/templates/.gitkeep +1 -0
  25. package/bin/lib/templates/config.yaml +6 -0
  26. package/bin/lib/validation.sh +206 -0
  27. package/bin/openclaw +660 -0
  28. package/docs/ADDING_A_FRAMEWORK.md +87 -0
  29. package/docs/AGENTS.md.example +40 -0
  30. package/docs/CODE_REVIEW.md +192 -0
  31. package/docs/DEPLOYMENT_READINESS.md +81 -0
  32. package/docs/FAQ_SECURITY_SCANNERS.md +373 -0
  33. package/docs/FRAMEWORK_ROADMAP.md +41 -0
  34. package/docs/HOSTED_PASSPORT_SETUP.md +362 -0
  35. package/docs/IMPLEMENTING_YOUR_OWN_EVALUATOR.md +433 -0
  36. package/docs/OPENCLAW_COMPATIBILITY.md +73 -0
  37. package/docs/OPENCLAW_LOCAL_INTEGRATION.md +596 -0
  38. package/docs/OPENCLAW_TOOLS_AND_POLICIES.md +54 -0
  39. package/docs/QUICKSTART.md +470 -0
  40. package/docs/QUICKSTART_OPENCLAW_PLUGIN.md +470 -0
  41. package/docs/README.md +28 -0
  42. package/docs/RELEASE.md +87 -0
  43. package/docs/REPO_LAYOUT.md +47 -0
  44. package/docs/SKILLS_ECOSYSTEM_ANALYSIS_FEB17.md +1260 -0
  45. package/docs/TOOL_POLICY_MAPPING.md +46 -0
  46. package/docs/UPGRADE.md +46 -0
  47. package/docs/VERIFICATION_METHODS.md +97 -0
  48. package/docs/assets/README.md +8 -0
  49. package/docs/assets/porter.svg +54 -0
  50. package/docs/development/ERROR_CODES.md +616 -0
  51. package/docs/frameworks/GITHUB_ISSUE_PROPOSALS.md +1105 -0
  52. package/docs/frameworks/crewai.md +114 -0
  53. package/docs/frameworks/cursor.md +159 -0
  54. package/docs/frameworks/langchain.md +72 -0
  55. package/docs/frameworks/n8n.md +40 -0
  56. package/docs/frameworks/openclaw.md +40 -0
  57. package/docs/launch/ADD_APORT_AWESOME_LISTS_INSTRUCTIONS.md +146 -0
  58. package/docs/launch/ANNOUNCEMENT_GUIDE.md +266 -0
  59. package/docs/launch/AWESOME_REPOS.md +53 -0
  60. package/docs/launch/CURSOR_VSCODE_HOOKS_RESEARCH.md +77 -0
  61. package/docs/launch/DEMO_TERMINAL_OUTPUT.txt +48 -0
  62. package/docs/launch/DRY_AND_PLAN_CHECKLIST.md +47 -0
  63. package/docs/launch/EVIDENCE_README.md +61 -0
  64. package/docs/launch/EVIDENCE_TERMINAL_CAPTURE.txt +10 -0
  65. package/docs/launch/FRAMEWORK_SUPPORT_PLAN.md +1640 -0
  66. package/docs/launch/LAUNCH_READINESS_CHECKLIST.md +237 -0
  67. package/docs/launch/LAUNCH_STRATEGY_SUMMARY.md +464 -0
  68. package/docs/launch/OPENCLAW_FEEDBACK_AND_FIXES.md +85 -0
  69. package/docs/launch/POST_1_VALENTINE_IMPROVED.md +233 -0
  70. package/docs/launch/POST_2_GUARDRAIL_IMPROVED.md +369 -0
  71. package/docs/launch/PRE_LAUNCH_FIXES.md +766 -0
  72. package/docs/launch/QUICK_LAUNCH_CHECKLIST.md +400 -0
  73. package/docs/launch/READINESS_SUMMARY.md +262 -0
  74. package/docs/launch/README.md +68 -0
  75. package/docs/launch/USER_STORIES.md +327 -0
  76. package/docs/launch/scripts/add-aport-awesome-pr.sh +69 -0
  77. package/docs/operations/MONITORING.md +588 -0
  78. package/docs/reviews/2026-02-18-staff-review.md +268 -0
  79. package/extensions/openclaw-aport/README.md +415 -0
  80. package/extensions/openclaw-aport/index.js +625 -0
  81. package/extensions/openclaw-aport/openclaw-aport.js +7 -0
  82. package/extensions/openclaw-aport/openclaw.plugin.json +46 -0
  83. package/extensions/openclaw-aport/package.json +36 -0
  84. package/extensions/openclaw-aport/test.js +307 -0
  85. package/external/aport-policies/README.md +363 -0
  86. package/external/aport-policies/agent.session.create.v1/README.md +345 -0
  87. package/external/aport-policies/agent.session.create.v1/policy.json +162 -0
  88. package/external/aport-policies/agent.tool.register.v1/README.md +361 -0
  89. package/external/aport-policies/agent.tool.register.v1/policy.json +172 -0
  90. package/external/aport-policies/code.release.publish.v1/README.md +51 -0
  91. package/external/aport-policies/code.release.publish.v1/policy.json +121 -0
  92. package/external/aport-policies/code.repository.merge.v1/README.md +287 -0
  93. package/external/aport-policies/code.repository.merge.v1/express.example.js +332 -0
  94. package/external/aport-policies/code.repository.merge.v1/fastapi.example.py +370 -0
  95. package/external/aport-policies/code.repository.merge.v1/policy.json +162 -0
  96. package/external/aport-policies/data.export.create.v1/README.md +226 -0
  97. package/external/aport-policies/data.export.create.v1/express.example.js +172 -0
  98. package/external/aport-policies/data.export.create.v1/fastapi.example.py +165 -0
  99. package/external/aport-policies/data.export.create.v1/policy.json +133 -0
  100. package/external/aport-policies/data.report.ingest.v1/README.md +134 -0
  101. package/external/aport-policies/data.report.ingest.v1/express.example.js +105 -0
  102. package/external/aport-policies/data.report.ingest.v1/minimal-example.js +68 -0
  103. package/external/aport-policies/data.report.ingest.v1/policy.json +174 -0
  104. package/external/aport-policies/finance.crypto.trade.v1/README.md +146 -0
  105. package/external/aport-policies/finance.crypto.trade.v1/express.example.js +109 -0
  106. package/external/aport-policies/finance.crypto.trade.v1/minimal-example.js +65 -0
  107. package/external/aport-policies/finance.crypto.trade.v1/policy.json +176 -0
  108. package/external/aport-policies/finance.payment.charge.v1/README.md +326 -0
  109. package/external/aport-policies/finance.payment.charge.v1/express.example.js +250 -0
  110. package/external/aport-policies/finance.payment.charge.v1/fastapi.example.py +227 -0
  111. package/external/aport-policies/finance.payment.charge.v1/minimal-example.js +64 -0
  112. package/external/aport-policies/finance.payment.charge.v1/policy.json +224 -0
  113. package/external/aport-policies/finance.payment.charge.v1/tests/contexts.jsonl +12 -0
  114. package/external/aport-policies/finance.payment.charge.v1/tests/expected.jsonl +12 -0
  115. package/external/aport-policies/finance.payment.charge.v1/tests/passport.instance.json +42 -0
  116. package/external/aport-policies/finance.payment.charge.v1/tests/passport.template.json +40 -0
  117. package/external/aport-policies/finance.payment.charge.v1/tests/payments-charge-policy.test.js +817 -0
  118. package/external/aport-policies/finance.payment.charge.v1/tests/test_payments_charge_policy.py +486 -0
  119. package/external/aport-policies/finance.payment.payout.v1/README.md +78 -0
  120. package/external/aport-policies/finance.payment.payout.v1/policy.json +181 -0
  121. package/external/aport-policies/finance.payment.refund.v1/README.md +275 -0
  122. package/external/aport-policies/finance.payment.refund.v1/express.example.js +167 -0
  123. package/external/aport-policies/finance.payment.refund.v1/fastapi.example.py +136 -0
  124. package/external/aport-policies/finance.payment.refund.v1/minimal-example.js +183 -0
  125. package/external/aport-policies/finance.payment.refund.v1/policy.json +216 -0
  126. package/external/aport-policies/finance.payment.refund.v1/tests/refunds-policy.test.js +924 -0
  127. package/external/aport-policies/finance.payment.refund.v1/tests/test_refunds_policy.py +778 -0
  128. package/external/aport-policies/finance.transaction.execute.v1/README.md +309 -0
  129. package/external/aport-policies/finance.transaction.execute.v1/express.example.js +261 -0
  130. package/external/aport-policies/finance.transaction.execute.v1/fastapi.example.py +231 -0
  131. package/external/aport-policies/finance.transaction.execute.v1/minimal-example.js +78 -0
  132. package/external/aport-policies/finance.transaction.execute.v1/policy.json +189 -0
  133. package/external/aport-policies/finance.transaction.execute.v1/tests/contexts.jsonl +12 -0
  134. package/external/aport-policies/finance.transaction.execute.v1/tests/expected.jsonl +12 -0
  135. package/external/aport-policies/finance.transaction.execute.v1/tests/passport.instance.json +42 -0
  136. package/external/aport-policies/finance.transaction.execute.v1/tests/passport.template.json +42 -0
  137. package/external/aport-policies/finance.transaction.execute.v1/tests/test_transactions_policy.py +214 -0
  138. package/external/aport-policies/finance.transaction.execute.v1/tests/transactions-policy.test.js +306 -0
  139. package/external/aport-policies/governance.data.access.v1/README.md +292 -0
  140. package/external/aport-policies/governance.data.access.v1/express.example.js +321 -0
  141. package/external/aport-policies/governance.data.access.v1/fastapi.example.py +279 -0
  142. package/external/aport-policies/governance.data.access.v1/minimal-example.js +65 -0
  143. package/external/aport-policies/governance.data.access.v1/policy.json +208 -0
  144. package/external/aport-policies/governance.data.access.v1/tests/contexts.jsonl +12 -0
  145. package/external/aport-policies/governance.data.access.v1/tests/data-access-policy.test.js +308 -0
  146. package/external/aport-policies/governance.data.access.v1/tests/expected.jsonl +12 -0
  147. package/external/aport-policies/governance.data.access.v1/tests/passport.instance.json +56 -0
  148. package/external/aport-policies/governance.data.access.v1/tests/passport.template.json +56 -0
  149. package/external/aport-policies/governance.data.access.v1/tests/test_data_access_policy.py +214 -0
  150. package/external/aport-policies/legal.contract.review.v1/README.md +109 -0
  151. package/external/aport-policies/legal.contract.review.v1/policy.json +378 -0
  152. package/external/aport-policies/legal.contract.review.v1/tests/legal-contract-review-policy.test.js +609 -0
  153. package/external/aport-policies/legal.contract.review.v1/tests/passport.template.json +49 -0
  154. package/external/aport-policies/mcp.tool.execute.v1/README.md +301 -0
  155. package/external/aport-policies/mcp.tool.execute.v1/policy.json +141 -0
  156. package/external/aport-policies/messaging.message.send.v1/README.md +230 -0
  157. package/external/aport-policies/messaging.message.send.v1/express.example.js +183 -0
  158. package/external/aport-policies/messaging.message.send.v1/fastapi.example.py +193 -0
  159. package/external/aport-policies/messaging.message.send.v1/policy.json +144 -0
  160. package/external/aport-policies/policy-template.json +107 -0
  161. package/external/aport-policies/system.command.execute.v1/README.md +275 -0
  162. package/external/aport-policies/system.command.execute.v1/policy.json +146 -0
  163. package/external/aport-spec/CONTRIBUTING.md +273 -0
  164. package/external/aport-spec/LICENSE +21 -0
  165. package/external/aport-spec/README.md +168 -0
  166. package/external/aport-spec/conformance/README.md +294 -0
  167. package/external/aport-spec/conformance/cases/data.export.v1/contexts/allow_users.json +6 -0
  168. package/external/aport-spec/conformance/cases/data.export.v1/contexts/deny_pii.json +6 -0
  169. package/external/aport-spec/conformance/cases/data.export.v1/expected/allow_users.decision.json +19 -0
  170. package/external/aport-spec/conformance/cases/data.export.v1/expected/deny_pii.decision.json +19 -0
  171. package/external/aport-spec/conformance/cases/data.export.v1/passports/template.json +29 -0
  172. package/external/aport-spec/conformance/cases/payments.refunds.v1/contexts/allow_50usd.json +9 -0
  173. package/external/aport-spec/conformance/cases/payments.refunds.v1/contexts/deny_150usd.json +9 -0
  174. package/external/aport-spec/conformance/cases/payments.refunds.v1/contexts/deny_currency.json +9 -0
  175. package/external/aport-spec/conformance/cases/payments.refunds.v1/expected/allow_50usd.decision.json +19 -0
  176. package/external/aport-spec/conformance/cases/payments.refunds.v1/expected/deny_150usd.decision.json +19 -0
  177. package/external/aport-spec/conformance/cases/payments.refunds.v1/expected/deny_currency.decision.json +19 -0
  178. package/external/aport-spec/conformance/cases/payments.refunds.v1/passports/template.json +42 -0
  179. package/external/aport-spec/conformance/package.json +44 -0
  180. package/external/aport-spec/conformance/pnpm-lock.yaml +642 -0
  181. package/external/aport-spec/conformance/src/cases.ts +371 -0
  182. package/external/aport-spec/conformance/src/ed25519.ts +167 -0
  183. package/external/aport-spec/conformance/src/jcs.ts +85 -0
  184. package/external/aport-spec/conformance/src/runner.ts +533 -0
  185. package/external/aport-spec/conformance/src/validators.ts +185 -0
  186. package/external/aport-spec/conformance/test-runner.js +315 -0
  187. package/external/aport-spec/conformance/tsconfig.json +21 -0
  188. package/external/aport-spec/error-schema.json +192 -0
  189. package/external/aport-spec/index.json +12 -0
  190. package/external/aport-spec/integrations/clawmoat/README.md +12 -0
  191. package/external/aport-spec/integrations/shield/README.md +245 -0
  192. package/external/aport-spec/integrations/shield/adapters/index.js +116 -0
  193. package/external/aport-spec/integrations/shield/adapters/system-command-execute.js +133 -0
  194. package/external/aport-spec/integrations/shield/test/README.md +58 -0
  195. package/external/aport-spec/integrations/shield/test/shield.md +40 -0
  196. package/external/aport-spec/integrations/shield/test/test-shield-to-verify.js +274 -0
  197. package/external/aport-spec/metrics-schema.json +504 -0
  198. package/external/aport-spec/oap/CHANGELOG.md +54 -0
  199. package/external/aport-spec/oap/VERSION.md +40 -0
  200. package/external/aport-spec/oap/capability-registry.md +229 -0
  201. package/external/aport-spec/oap/conformance.md +257 -0
  202. package/external/aport-spec/oap/decision-schema.json +114 -0
  203. package/external/aport-spec/oap/examples/context.refund.usd.50.json +9 -0
  204. package/external/aport-spec/oap/examples/decision.allow.sample.json +20 -0
  205. package/external/aport-spec/oap/examples/decision.deny.sample.json +23 -0
  206. package/external/aport-spec/oap/examples/passport.instance.v1.json +50 -0
  207. package/external/aport-spec/oap/examples/passport.template.v1.json +71 -0
  208. package/external/aport-spec/oap/oap-spec.md +426 -0
  209. package/external/aport-spec/oap/passport-schema.json +396 -0
  210. package/external/aport-spec/oap/security.md +213 -0
  211. package/external/aport-spec/oap/vc/context-oap-v1.jsonld +137 -0
  212. package/external/aport-spec/oap/vc/examples/oap-decision-vc.json +37 -0
  213. package/external/aport-spec/oap/vc/examples/oap-passport-vc.json +68 -0
  214. package/external/aport-spec/oap/vc/tools/INTEGRATION.md +375 -0
  215. package/external/aport-spec/oap/vc/tools/README.md +278 -0
  216. package/external/aport-spec/oap/vc/tools/examples/decision-to-vc.js +66 -0
  217. package/external/aport-spec/oap/vc/tools/examples/passport-to-vc.js +83 -0
  218. package/external/aport-spec/oap/vc/tools/examples/vc-to-decision.js +77 -0
  219. package/external/aport-spec/oap/vc/tools/examples/vc-to-passport.js +94 -0
  220. package/external/aport-spec/oap/vc/tools/package.json +38 -0
  221. package/external/aport-spec/oap/vc/tools/pnpm-lock.yaml +472 -0
  222. package/external/aport-spec/oap/vc/tools/src/cli.ts +226 -0
  223. package/external/aport-spec/oap/vc/tools/src/crypto-utils.ts +427 -0
  224. package/external/aport-spec/oap/vc/tools/src/index.ts +653 -0
  225. package/external/aport-spec/oap/vc/tools/src/test.ts +148 -0
  226. package/external/aport-spec/oap/vc/tools/src/vp.ts +382 -0
  227. package/external/aport-spec/oap/vc/tools/test-simple.js +214 -0
  228. package/external/aport-spec/oap/vc/tools/tsconfig.json +19 -0
  229. package/external/aport-spec/oap/vc/vc-mapping.md +443 -0
  230. package/external/aport-spec/passport-schema.json +586 -0
  231. package/external/aport-spec/rate-limiting.md +136 -0
  232. package/external/aport-spec/transport-profile.md +325 -0
  233. package/external/aport-spec/webhook-spec.md +314 -0
  234. package/package.json +70 -0
  235. package/skills/aport-agent-guardrail/SKILL.md +314 -0
  236. package/src/evaluator.js +252 -0
  237. package/src/server/index.js +72 -0
@@ -0,0 +1,275 @@
1
+ # System Command Execution Policy v1
2
+
3
+ **Policy ID:** `system.command.execute.v1`
4
+ **Status:** Active
5
+ **Min Assurance:** L0
6
+
7
+ ## Overview
8
+
9
+ The System Command Execution Policy provides pre-action governance for shell command execution by AI agents. This policy enforces command allowlists, blocked patterns, execution time limits, and environment restrictions to ensure secure agent operations.
10
+
11
+ ## Use Cases
12
+
13
+ - **Development Agents**: Running npm, git, node, yarn commands
14
+ - **DevOps Agents**: Executing deployment scripts, infrastructure commands
15
+ - **Data Pipeline Agents**: Running data processing commands
16
+ - **Testing Agents**: Executing test suites and build commands
17
+
18
+ ## Required Capabilities
19
+
20
+ - `system.command.execute`
21
+
22
+ ## Required Limits
23
+
24
+ - `allowed_commands` (array of strings): Allowlist of commands. Use `["*"]` to allow any command (blocked_patterns still apply).
25
+ - `max_execution_time` (integer): Maximum execution time in seconds
26
+
27
+ ## Optional Limits
28
+
29
+ - `blocked_patterns` (array of strings): Patterns to block (e.g., "rm -rf", "sudo")
30
+ - `allowed_working_directories` (array of strings): Allowed working directories
31
+ - `blocked_env_vars` (array of strings): Blocked environment variables (e.g., "PATH", "LD_LIBRARY_PATH")
32
+
33
+ ## Context Schema
34
+
35
+ ### Required Fields
36
+
37
+ - `command` (string): Command to execute
38
+
39
+ ### Optional Fields
40
+
41
+ - `args` (array): Command arguments
42
+ - `cwd` (string): Working directory
43
+ - `env` (object): Environment variables
44
+ - `timeout` (integer): Command timeout in seconds
45
+ - `shell` (string): Shell to use (bash, sh, zsh, etc.)
46
+ - `user` (string): User to run command as
47
+ - `mcp_servers`, `mcp_tools`, `mcp_session`: MCP integration fields
48
+
49
+ ## Evaluation Rules
50
+
51
+ 1. **passport_status_active**: Passport must be active
52
+ 2. **command_capability**: Agent must have `system.command.execute` capability
53
+ 3. **command_allowlist**: Command must be in allowed list
54
+ 4. **blocked_patterns**: Command must not contain blocked patterns
55
+ 5. **execution_time_limit**: Timeout must not exceed max_execution_time
56
+ 6. **working_directory**: Working directory must be allowed
57
+ 7. **environment_variables**: Environment variables must not contain blocked vars
58
+
59
+ ## Example Passport Limits
60
+
61
+ ```json
62
+ {
63
+ "limits": {
64
+ "system.command.execute": {
65
+ "allowed_commands": [
66
+ "npm",
67
+ "yarn",
68
+ "pnpm",
69
+ "git",
70
+ "node",
71
+ "bash",
72
+ "sh",
73
+ "python",
74
+ "pip"
75
+ ],
76
+ "blocked_patterns": [
77
+ "rm -rf",
78
+ "sudo",
79
+ "chmod 777",
80
+ "dd if=",
81
+ "mkfs",
82
+ "> /dev/",
83
+ "curl | bash",
84
+ "wget | sh"
85
+ ],
86
+ "max_execution_time": 300,
87
+ "allowed_working_directories": [
88
+ "/workspace",
89
+ "/tmp",
90
+ "/home/agent"
91
+ ],
92
+ "blocked_env_vars": [
93
+ "PATH",
94
+ "LD_LIBRARY_PATH",
95
+ "LD_PRELOAD"
96
+ ]
97
+ }
98
+ }
99
+ }
100
+ ```
101
+
102
+ ## Example Request Context
103
+
104
+ ```json
105
+ {
106
+ "command": "npm",
107
+ "args": ["install", "--production"],
108
+ "cwd": "/workspace/myproject",
109
+ "env": {
110
+ "NODE_ENV": "production"
111
+ },
112
+ "timeout": 120,
113
+ "shell": "bash",
114
+ "mcp_session": "sess_abc123"
115
+ }
116
+ ```
117
+
118
+ ## Example Decision (Allow)
119
+
120
+ ```json
121
+ {
122
+ "decision_id": "dec_xyz789",
123
+ "policy_id": "system.command.execute.v1",
124
+ "passport_id": "pass_abc123",
125
+ "owner_id": "org_12345",
126
+ "assurance_level": "L0",
127
+ "allow": true,
128
+ "reasons": [{
129
+ "code": "oap.allowed",
130
+ "message": "All policy checks passed"
131
+ }],
132
+ "issued_at": "2026-02-14T22:00:00Z",
133
+ "expires_at": "2026-02-14T22:01:00Z",
134
+ "passport_digest": "sha256:...",
135
+ "signature": "ed25519:...",
136
+ "kid": "oap:registry:key-2026-02"
137
+ }
138
+ ```
139
+
140
+ ## Example Decision (Deny - Blocked Pattern)
141
+
142
+ ```json
143
+ {
144
+ "decision_id": "dec_xyz790",
145
+ "policy_id": "system.command.execute.v1",
146
+ "passport_id": "pass_abc123",
147
+ "owner_id": "org_12345",
148
+ "assurance_level": "L0",
149
+ "allow": false,
150
+ "reasons": [{
151
+ "code": "oap.blocked_pattern",
152
+ "message": "Command contains blocked pattern: 'sudo'"
153
+ }],
154
+ "issued_at": "2026-02-14T22:00:00Z",
155
+ "expires_at": "2026-02-14T22:01:00Z",
156
+ "passport_digest": "sha256:...",
157
+ "signature": "ed25519:...",
158
+ "kid": "oap:registry:key-2026-02"
159
+ }
160
+ ```
161
+
162
+ ## Security Best Practices
163
+
164
+ 1. **Minimal Allowlist**: Only allow commands absolutely necessary for the agent's purpose
165
+ 2. **Block Dangerous Patterns**: Always block `rm -rf`, `sudo`, privilege escalation attempts
166
+ 3. **Time Limits**: Set conservative execution time limits to prevent runaway processes
167
+ 4. **Directory Restrictions**: Limit working directories to agent workspace
168
+ 5. **Audit Logging**: Log all command executions for security review
169
+ 6. **Progressive Limits**: Start with strict limits and relax gradually based on behavior
170
+ 7. **MCP Integration**: Use MCP session tracking for cross-tool audit trails
171
+ 8. **Status Webhooks**: Subscribe to passport status changes for instant revocation
172
+
173
+ ## Error Codes
174
+
175
+ - `oap.passport_suspended`: Passport is not active
176
+ - `oap.unknown_capability`: Missing system.command.execute capability
177
+ - `oap.command_not_allowed`: Command not in allowlist
178
+ - `oap.blocked_pattern`: Command contains blocked pattern
179
+ - `oap.limit_exceeded`: Execution time exceeds limit
180
+ - `oap.directory_not_allowed`: Working directory not allowed
181
+ - `oap.env_var_blocked`: Environment variable is blocked
182
+
183
+ ## Integration Examples
184
+
185
+ ### Express.js (Node.js)
186
+
187
+ ```javascript
188
+ const { exec } = require('child_process');
189
+ const axios = require('axios');
190
+
191
+ async function executeCommand(passport, command, args) {
192
+ const context = {
193
+ command,
194
+ args,
195
+ cwd: process.cwd(),
196
+ timeout: 120
197
+ };
198
+
199
+ // Check policy
200
+ const decision = await axios.post('https://api.aport.io/v1/decide', {
201
+ passport_id: passport.passport_id,
202
+ policy_id: 'system.command.execute.v1',
203
+ context
204
+ });
205
+
206
+ if (!decision.data.allow) {
207
+ throw new Error(`Command blocked: ${decision.data.reasons[0].message}`);
208
+ }
209
+
210
+ // Execute command
211
+ return new Promise((resolve, reject) => {
212
+ exec(`${command} ${args.join(' ')}`, {
213
+ cwd: context.cwd,
214
+ timeout: context.timeout * 1000
215
+ }, (error, stdout, stderr) => {
216
+ if (error) reject(error);
217
+ else resolve({ stdout, stderr });
218
+ });
219
+ });
220
+ }
221
+ ```
222
+
223
+ ### Python (FastAPI)
224
+
225
+ ```python
226
+ import subprocess
227
+ import httpx
228
+
229
+ async def execute_command(passport: dict, command: str, args: list):
230
+ context = {
231
+ "command": command,
232
+ "args": args,
233
+ "cwd": "/workspace",
234
+ "timeout": 120
235
+ }
236
+
237
+ # Check policy
238
+ async with httpx.AsyncClient() as client:
239
+ response = await client.post(
240
+ "https://api.aport.io/v1/decide",
241
+ json={
242
+ "passport_id": passport["passport_id"],
243
+ "policy_id": "system.command.execute.v1",
244
+ "context": context
245
+ }
246
+ )
247
+ decision = response.json()
248
+
249
+ if not decision["allow"]:
250
+ raise PermissionError(f"Command blocked: {decision['reasons'][0]['message']}")
251
+
252
+ # Execute command
253
+ result = subprocess.run(
254
+ [command] + args,
255
+ cwd=context["cwd"],
256
+ timeout=context["timeout"],
257
+ capture_output=True,
258
+ text=True
259
+ )
260
+
261
+ return {
262
+ "stdout": result.stdout,
263
+ "stderr": result.stderr,
264
+ "returncode": result.returncode
265
+ }
266
+ ```
267
+
268
+ ## Version History
269
+
270
+ - **v1.0.0** (2026-02-14): Initial release
271
+
272
+ ## References
273
+
274
+ - [OAP Specification](https://github.com/aporthq/aport-spec)
275
+ - [Policy Pack Guidelines](https://github.com/aporthq/aport-policies/blob/main/GUIDELINES.md)
@@ -0,0 +1,146 @@
1
+ {
2
+ "id": "system.command.execute.v1",
3
+ "name": "System Command Execution Policy",
4
+ "description": "Pre-action governance for shell command execution. Enforces command allowlists, blocked patterns, execution time limits, and environment restrictions for secure agent operations.",
5
+ "version": "1.0.0",
6
+ "status": "active",
7
+ "requires_capabilities": ["system.command.execute"],
8
+ "min_assurance": "L0",
9
+ "limits_required": ["allowed_commands", "max_execution_time"],
10
+ "required_fields": ["command"],
11
+ "optional_fields": ["args", "cwd", "env", "timeout", "shell", "user"],
12
+ "enforcement": {
13
+ "command_allowlist_enforced": true,
14
+ "blocked_patterns_enforced": true,
15
+ "execution_time_enforced": true,
16
+ "environment_restrictions_enforced": true,
17
+ "user_restrictions_enforced": false
18
+ },
19
+ "mcp": {
20
+ "require_allowlisted_if_present": true
21
+ },
22
+ "advice": [
23
+ "Use command allowlists to prevent unauthorized system access",
24
+ "Block dangerous patterns (rm -rf, sudo, chmod 777, etc.)",
25
+ "Enforce execution time limits to prevent runaway processes",
26
+ "Restrict environment variables to prevent privilege escalation",
27
+ "Log all command executions for Verifiable Attestation",
28
+ "Use working directory restrictions to limit file system access",
29
+ "Implement progressive limits for new agents",
30
+ "Monitor command execution patterns for anomalies",
31
+ "Subscribe to status webhooks for instant suspend",
32
+ "Consider sandboxing for untrusted commands"
33
+ ],
34
+ "required_context": {
35
+ "$schema": "http://json-schema.org/draft-07/schema#",
36
+ "type": "object",
37
+ "required": ["command"],
38
+ "properties": {
39
+ "command": {
40
+ "type": "string",
41
+ "minLength": 1,
42
+ "maxLength": 10000,
43
+ "description": "Command to execute (e.g., 'npm', 'git', 'node')"
44
+ },
45
+ "args": {
46
+ "type": "array",
47
+ "items": { "type": "string" },
48
+ "maxItems": 100,
49
+ "description": "Command arguments"
50
+ },
51
+ "cwd": {
52
+ "type": "string",
53
+ "maxLength": 4096,
54
+ "description": "Working directory for command execution"
55
+ },
56
+ "env": {
57
+ "type": "object",
58
+ "additionalProperties": { "type": "string" },
59
+ "maxProperties": 100,
60
+ "description": "Environment variables for command execution"
61
+ },
62
+ "timeout": {
63
+ "type": "integer",
64
+ "minimum": 1,
65
+ "maximum": 3600,
66
+ "description": "Command timeout in seconds"
67
+ },
68
+ "shell": {
69
+ "type": "string",
70
+ "enum": ["bash", "sh", "zsh", "fish", "powershell", "cmd"],
71
+ "description": "Shell to use for command execution"
72
+ },
73
+ "user": {
74
+ "type": "string",
75
+ "description": "User to run command as (requires elevated privileges)"
76
+ },
77
+ "mcp_servers": {
78
+ "type": "array",
79
+ "items": { "type": "string" },
80
+ "description": "MCP servers being used in this request"
81
+ },
82
+ "mcp_tools": {
83
+ "type": "array",
84
+ "items": { "type": "string" },
85
+ "description": "MCP tools being used in this request"
86
+ },
87
+ "mcp_server": {
88
+ "type": "string",
89
+ "description": "Single MCP server being used (backward compatibility)"
90
+ },
91
+ "mcp_tool": {
92
+ "type": "string",
93
+ "description": "Single MCP tool being used (backward compatibility)"
94
+ },
95
+ "mcp_session": {
96
+ "type": "string",
97
+ "description": "MCP session identifier for audit trail (optional)"
98
+ }
99
+ }
100
+ },
101
+ "evaluation_rules_version": "1.0",
102
+ "evaluation_rules": [
103
+ {
104
+ "name": "command_allowlist",
105
+ "type": "expression",
106
+ "condition": "limits.allowed_commands.includes('*') || limits.allowed_commands.includes(context.command) || limits.allowed_commands.some(c => context.command.startsWith(c))",
107
+ "deny_code": "oap.command_not_allowed",
108
+ "description": "Command must be in allowed list"
109
+ },
110
+ {
111
+ "name": "blocked_patterns",
112
+ "type": "custom_validator",
113
+ "validator": "validateBlockedPatterns",
114
+ "deny_code": "oap.blocked_pattern",
115
+ "description": "Command must not contain blocked patterns"
116
+ },
117
+ {
118
+ "name": "execution_time_limit",
119
+ "type": "expression",
120
+ "condition": "!context.timeout || context.timeout <= limits.max_execution_time",
121
+ "deny_code": "oap.limit_exceeded",
122
+ "description": "Execution time must not exceed limit"
123
+ },
124
+ {
125
+ "name": "working_directory",
126
+ "type": "custom_validator",
127
+ "validator": "validateWorkingDirectory",
128
+ "deny_code": "oap.directory_not_allowed",
129
+ "description": "Working directory must be allowed"
130
+ },
131
+ {
132
+ "name": "environment_variables",
133
+ "type": "custom_validator",
134
+ "validator": "validateEnvironmentVariables",
135
+ "deny_code": "oap.env_var_blocked",
136
+ "description": "Environment variables must not contain blocked vars"
137
+ }
138
+ ],
139
+ "cache": {
140
+ "default_ttl_seconds": 60,
141
+ "suspend_invalidate_seconds": 30
142
+ },
143
+ "deprecation": null,
144
+ "created_at": "2026-02-14T00:00:00Z",
145
+ "updated_at": "2026-02-14T00:00:00Z"
146
+ }
@@ -0,0 +1,273 @@
1
+ # Contributing to Open Agent Passport (OAP)
2
+
3
+ Thank you for your interest in contributing to the Open Agent Passport specification! This document provides guidelines for contributing to the OAP specification, tooling, and documentation.
4
+
5
+ ## How to Contribute
6
+
7
+ ### Reporting Issues
8
+
9
+ Before creating an issue, please:
10
+
11
+ 1. **Search existing issues** to avoid duplicates
12
+ 2. **Use the issue templates** when available
13
+ 3. **Provide clear reproduction steps** for bugs
14
+ 4. **Include relevant logs** and error messages
15
+
16
+ ### Suggesting Enhancements
17
+
18
+ For feature requests or specification changes:
19
+
20
+ 1. **Check existing proposals** in the issues
21
+ 2. **Describe the use case** and problem being solved
22
+ 3. **Provide examples** of how the change would work
23
+ 4. **Consider backward compatibility** implications
24
+
25
+ ### Submitting Changes
26
+
27
+ 1. **Fork the repository**
28
+ 2. **Create a feature branch** from `main`
29
+ 3. **Make your changes** following our guidelines
30
+ 4. **Add tests** for new functionality
31
+ 5. **Update documentation** as needed
32
+ 6. **Submit a pull request**
33
+
34
+ ## Development Guidelines
35
+
36
+ ### Specification Changes
37
+
38
+ When modifying the OAP specification:
39
+
40
+ #### Schema Changes
41
+ - **Update JSON schemas** in `oap/` directory
42
+ - **Maintain backward compatibility** when possible
43
+ - **Add migration notes** for breaking changes
44
+ - **Update examples** to reflect changes
45
+
46
+ #### Documentation Updates
47
+ - **Update specification documents** in `oap/`
48
+ - **Revise examples** to match new schemas
49
+ - **Update changelog** with detailed change descriptions
50
+ - **Increment version** appropriately
51
+
52
+ ### Code Contributions
53
+
54
+ #### Conformance Testing
55
+ - **Add test cases** for new functionality
56
+ - **Update existing tests** when schemas change
57
+ - **Ensure all tests pass** before submitting
58
+ - **Add performance benchmarks** for critical paths
59
+
60
+ #### VC Tools
61
+ - **Follow TypeScript best practices**
62
+ - **Add comprehensive error handling**
63
+ - **Include unit tests** for new functions
64
+ - **Update CLI help** and documentation
65
+
66
+ #### API Documentation
67
+ - **Update OpenAPI specifications** when endpoints change
68
+ - **Add JSDoc comments** for new functions
69
+ - **Include request/response examples**
70
+ - **Update error schemas** as needed
71
+
72
+ ### Documentation Standards
73
+
74
+ #### Writing Style
75
+ - **Use clear, concise language**
76
+ - **Provide practical examples**
77
+ - **Include code snippets** where helpful
78
+ - **Link to related specifications**
79
+
80
+ #### Formatting
81
+ - **Use Markdown** for documentation
82
+ - **Follow consistent heading structure**
83
+ - **Include table of contents** for long documents
84
+ - **Use code blocks** with language specification
85
+
86
+ #### Examples
87
+ - **Provide realistic examples**
88
+ - **Include both success and error cases**
89
+ - **Use consistent naming conventions**
90
+ - **Add explanatory comments**
91
+
92
+ ## Review Process
93
+
94
+ ### Pull Request Requirements
95
+
96
+ 1. **Clear description** of changes made
97
+ 2. **Reference to related issues** if applicable
98
+ 3. **Updated tests** and documentation
99
+ 4. **Breaking change notice** if applicable
100
+ 5. **Migration guide** for significant changes
101
+
102
+ ### Review Criteria
103
+
104
+ Reviewers will check for:
105
+
106
+ - **Specification compliance** with OAP standards
107
+ - **Code quality** and best practices
108
+ - **Test coverage** and accuracy
109
+ - **Documentation completeness**
110
+ - **Backward compatibility** considerations
111
+ - **Performance implications**
112
+
113
+ ### Review Timeline
114
+
115
+ - **Initial review**: Within 3 business days
116
+ - **Follow-up reviews**: Within 1 business day
117
+ - **Final approval**: Within 5 business days
118
+ - **Merge**: After approval and CI passes
119
+
120
+ ## Development Setup
121
+
122
+ ### Prerequisites
123
+
124
+ - **Node.js** 18+ and npm/pnpm
125
+ - **TypeScript** 5.0+
126
+ - **Git** for version control
127
+
128
+ ### Local Development
129
+
130
+ 1. **Clone the repository**:
131
+ ```bash
132
+ git clone https://github.com/aporthq/aport-spec.git
133
+ cd aport-spec
134
+ ```
135
+
136
+ 2. **Install dependencies**:
137
+ ```bash
138
+ npm install
139
+ # or
140
+ pnpm install
141
+ ```
142
+
143
+ 3. **Run tests**:
144
+ ```bash
145
+ npm test
146
+ # or
147
+ pnpm test
148
+ ```
149
+
150
+ 4. **Run conformance tests**:
151
+ ```bash
152
+ cd conformance
153
+ npm test
154
+ ```
155
+
156
+ ### Testing
157
+
158
+ #### Conformance Testing
159
+ ```bash
160
+ # Run all conformance tests
161
+ npm run test:conformance
162
+
163
+ # Run specific test suite
164
+ npm run test:conformance -- --suite finance.payment.refund.v1
165
+
166
+ # Run with verbose output
167
+ npm run test:conformance -- --verbose
168
+ ```
169
+
170
+ #### VC Tools Testing
171
+ ```bash
172
+ # Run VC conversion tests
173
+ cd oap/vc/tools
174
+ npm test
175
+
176
+ # Test CLI tools
177
+ npm run test:cli
178
+ ```
179
+
180
+ #### API Testing
181
+ ```bash
182
+ # Test OpenAPI generation
183
+ npm run generate:openapi
184
+ npm run test:openapi
185
+ ```
186
+
187
+ ## Code Style
188
+
189
+ ### TypeScript
190
+ - **Use strict mode** and enable all strict checks
191
+ - **Prefer interfaces** over types for object shapes
192
+ - **Use meaningful variable names**
193
+ - **Add JSDoc comments** for public APIs
194
+ - **Follow ESLint configuration**
195
+
196
+ ### JSON Schemas
197
+ - **Use descriptive titles** and descriptions
198
+ - **Include examples** for complex schemas
199
+ - **Use consistent property ordering**
200
+ - **Validate schemas** before committing
201
+
202
+ ### Markdown
203
+ - **Use consistent heading levels**
204
+ - **Include table of contents** for long documents
205
+ - **Use code blocks** with language specification
206
+ - **Link to related documents**
207
+
208
+ ## Release Process
209
+
210
+ ### Versioning
211
+
212
+ We follow [Semantic Versioning](https://semver.org/):
213
+
214
+ - **MAJOR**: Breaking changes to the specification
215
+ - **MINOR**: New features, backward compatible
216
+ - **PATCH**: Bug fixes, backward compatible
217
+
218
+ ### Release Checklist
219
+
220
+ 1. **Update version numbers** in all relevant files
221
+ 2. **Update changelog** with detailed change descriptions
222
+ 3. **Run full test suite** and ensure all tests pass
223
+ 4. **Update documentation** to reflect changes
224
+ 5. **Create release notes** highlighting key changes
225
+ 6. **Tag the release** with appropriate version number
226
+
227
+ ### Breaking Changes
228
+
229
+ For breaking changes:
230
+
231
+ 1. **Provide migration guide** with step-by-step instructions
232
+ 2. **Maintain deprecation period** of at least 6 months
233
+ 3. **Update all examples** to use new format
234
+ 4. **Notify community** through appropriate channels
235
+
236
+ ## Community Guidelines
237
+
238
+ ### Communication
239
+
240
+ - **Be respectful** and constructive in all interactions
241
+ - **Ask questions** if something is unclear
242
+ - **Help others** when you can
243
+ - **Follow the code of conduct**
244
+
245
+ ### Getting Help
246
+
247
+ - **Check documentation** first
248
+ - **Search existing issues** for similar problems
249
+ - **Ask questions** in GitHub discussions
250
+ - **Join community forums** for broader discussions
251
+
252
+ ### Recognition
253
+
254
+ Contributors will be recognized in:
255
+
256
+ - **CONTRIBUTORS.md** file
257
+ - **Release notes** for significant contributions
258
+ - **Community highlights** for outstanding work
259
+
260
+ ## License
261
+
262
+ By contributing to the Open Agent Passport specification, you agree that your contributions will be licensed under the same MIT License that covers the project.
263
+
264
+ ## Questions?
265
+
266
+ If you have questions about contributing, please:
267
+
268
+ 1. **Check this document** for answers
269
+ 2. **Search existing issues** for similar questions
270
+ 3. **Create a new issue** with the "question" label
271
+ 4. **Join our community discussions**
272
+
273
+ Thank you for contributing to the Open Agent Passport specification!