snulbug 0.1.1__tar.gz

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 (303) hide show
  1. snulbug-0.1.1/.gitignore +7 -0
  2. snulbug-0.1.1/CHANGELOG.md +45 -0
  3. snulbug-0.1.1/CODE_OF_CONDUCT.md +7 -0
  4. snulbug-0.1.1/CONTRIBUTING.md +29 -0
  5. snulbug-0.1.1/LICENSE +21 -0
  6. snulbug-0.1.1/PKG-INFO +449 -0
  7. snulbug-0.1.1/README.md +409 -0
  8. snulbug-0.1.1/SECURITY.md +135 -0
  9. snulbug-0.1.1/docs/README.md +61 -0
  10. snulbug-0.1.1/docs/actions.md +138 -0
  11. snulbug-0.1.1/docs/bundles.md +65 -0
  12. snulbug-0.1.1/docs/ci-policy-gates.md +72 -0
  13. snulbug-0.1.1/docs/comparison.md +61 -0
  14. snulbug-0.1.1/docs/devcontainers.md +122 -0
  15. snulbug-0.1.1/docs/getting-started.md +207 -0
  16. snulbug-0.1.1/docs/lua-policy-dsl.md +314 -0
  17. snulbug-0.1.1/docs/lua-request-api.md +591 -0
  18. snulbug-0.1.1/docs/mcp-auth-recipes.md +164 -0
  19. snulbug-0.1.1/docs/mcp-client-recipes.md +473 -0
  20. snulbug-0.1.1/docs/mcp-evidence.md +125 -0
  21. snulbug-0.1.1/docs/mcp-fabric.md +793 -0
  22. snulbug-0.1.1/docs/mcp-gateway.md +76 -0
  23. snulbug-0.1.1/docs/mcp-guide.md +55 -0
  24. snulbug-0.1.1/docs/mcp-impact.md +100 -0
  25. snulbug-0.1.1/docs/mcp-learn.md +160 -0
  26. snulbug-0.1.1/docs/mcp-policy.md +116 -0
  27. snulbug-0.1.1/docs/mcp-presets.md +150 -0
  28. snulbug-0.1.1/docs/mcp-proxy.md +1152 -0
  29. snulbug-0.1.1/docs/mcp-recorder.md +210 -0
  30. snulbug-0.1.1/docs/mcp-schemas.md +181 -0
  31. snulbug-0.1.1/docs/mcp-share.md +607 -0
  32. snulbug-0.1.1/docs/ngrok-end-to-end.md +215 -0
  33. snulbug-0.1.1/docs/quickstart.md +370 -0
  34. snulbug-0.1.1/docs/release.md +40 -0
  35. snulbug-0.1.1/docs/roadmap.md +27 -0
  36. snulbug-0.1.1/docs/security-model.md +107 -0
  37. snulbug-0.1.1/docs/state.md +74 -0
  38. snulbug-0.1.1/examples/auth_claim_patterns/.gitignore +3 -0
  39. snulbug-0.1.1/examples/auth_claim_patterns/README.md +84 -0
  40. snulbug-0.1.1/examples/auth_claim_patterns/ci-workload-identity.toml +41 -0
  41. snulbug-0.1.1/examples/auth_claim_patterns/group-gated-tools.toml +57 -0
  42. snulbug-0.1.1/examples/auth_claim_patterns/policy.lua +19 -0
  43. snulbug-0.1.1/examples/auth_claim_patterns/tenant-isolation.toml +40 -0
  44. snulbug-0.1.1/examples/basic/README.md +19 -0
  45. snulbug-0.1.1/examples/basic/app.py +34 -0
  46. snulbug-0.1.1/examples/bundles/idempotency.snulbug/README.md +19 -0
  47. snulbug-0.1.1/examples/bundles/idempotency.snulbug/fixtures/duplicate-delivery.json +8 -0
  48. snulbug-0.1.1/examples/bundles/idempotency.snulbug/fixtures/first-delivery.json +8 -0
  49. snulbug-0.1.1/examples/bundles/idempotency.snulbug/manifest.json +32 -0
  50. snulbug-0.1.1/examples/bundles/idempotency.snulbug/policy.lua +10 -0
  51. snulbug-0.1.1/examples/bundles/idempotency.snulbug/snapshots/duplicate.json +5 -0
  52. snulbug-0.1.1/examples/bundles/idempotency.snulbug/snapshots/empty.json +3 -0
  53. snulbug-0.1.1/examples/bundles/mcp-gateway.snulbug/README.md +25 -0
  54. snulbug-0.1.1/examples/bundles/mcp-gateway.snulbug/fixtures/allowed-tool.json +9 -0
  55. snulbug-0.1.1/examples/bundles/mcp-gateway.snulbug/fixtures/blocked-tool.json +9 -0
  56. snulbug-0.1.1/examples/bundles/mcp-gateway.snulbug/fixtures/unauthenticated.json +8 -0
  57. snulbug-0.1.1/examples/bundles/mcp-gateway.snulbug/manifest.json +51 -0
  58. snulbug-0.1.1/examples/bundles/mcp-gateway.snulbug/policy.lua +44 -0
  59. snulbug-0.1.1/examples/bundles/mcp-gateway.snulbug/snapshots/empty.json +3 -0
  60. snulbug-0.1.1/examples/codespace_local_gateway/.devcontainer/devcontainer.json +27 -0
  61. snulbug-0.1.1/examples/codespace_local_gateway/README.md +200 -0
  62. snulbug-0.1.1/examples/codespace_local_gateway/mcp-client.json +7 -0
  63. snulbug-0.1.1/examples/codespace_local_gateway/mock_mcp_server.py +116 -0
  64. snulbug-0.1.1/examples/codespace_local_gateway/policy.lua +6 -0
  65. snulbug-0.1.1/examples/codespace_local_gateway/snulbug.env-gateway.toml +46 -0
  66. snulbug-0.1.1/examples/codespace_local_gateway/snulbug.local-gateway.toml +47 -0
  67. snulbug-0.1.1/examples/customer_policy/README.md +29 -0
  68. snulbug-0.1.1/examples/customer_policy/app.py +75 -0
  69. snulbug-0.1.1/examples/customer_policy/policies/acme.lua +25 -0
  70. snulbug-0.1.1/examples/customer_policy/policies/default.lua +8 -0
  71. snulbug-0.1.1/examples/customer_policy/policies/globex.lua +28 -0
  72. snulbug-0.1.1/examples/customer_policy/requests/acme-invalid.json +8 -0
  73. snulbug-0.1.1/examples/customer_policy/requests/acme-valid.json +9 -0
  74. snulbug-0.1.1/examples/customer_policy/requests/globex-sandbox.json +9 -0
  75. snulbug-0.1.1/examples/customer_policy/requests/unknown-tenant.json +8 -0
  76. snulbug-0.1.1/examples/github-actions/snulbug-policy-gates.yml +83 -0
  77. snulbug-0.1.1/examples/keycloak_oauth_demo/.gitignore +2 -0
  78. snulbug-0.1.1/examples/keycloak_oauth_demo/Dockerfile.gateway +12 -0
  79. snulbug-0.1.1/examples/keycloak_oauth_demo/README.md +124 -0
  80. snulbug-0.1.1/examples/keycloak_oauth_demo/auth/keycloak/README.md +89 -0
  81. snulbug-0.1.1/examples/keycloak_oauth_demo/auth/keycloak/auth-init.json +50 -0
  82. snulbug-0.1.1/examples/keycloak_oauth_demo/auth/keycloak/client-token-request.json +11 -0
  83. snulbug-0.1.1/examples/keycloak_oauth_demo/auth/keycloak/commands.json +6 -0
  84. snulbug-0.1.1/examples/keycloak_oauth_demo/auth/keycloak/snulbug.auth.toml +20 -0
  85. snulbug-0.1.1/examples/keycloak_oauth_demo/docker-compose.yml +56 -0
  86. snulbug-0.1.1/examples/keycloak_oauth_demo/get-token.py +57 -0
  87. snulbug-0.1.1/examples/keycloak_oauth_demo/keycloak/snulbug-demo-realm.json +93 -0
  88. snulbug-0.1.1/examples/keycloak_oauth_demo/mock_mcp_server.py +118 -0
  89. snulbug-0.1.1/examples/keycloak_oauth_demo/policy.snulbug/policy.lua +52 -0
  90. snulbug-0.1.1/examples/keycloak_oauth_demo/requests/blocked-write-file.json +13 -0
  91. snulbug-0.1.1/examples/keycloak_oauth_demo/requests/read-file.json +12 -0
  92. snulbug-0.1.1/examples/keycloak_oauth_demo/requests/tools-list.json +7 -0
  93. snulbug-0.1.1/examples/keycloak_oauth_demo/snulbug.toml +70 -0
  94. snulbug-0.1.1/examples/mcp_container_facade/Dockerfile.gateway +11 -0
  95. snulbug-0.1.1/examples/mcp_container_facade/Dockerfile.remote-peer +6 -0
  96. snulbug-0.1.1/examples/mcp_container_facade/README.md +49 -0
  97. snulbug-0.1.1/examples/mcp_container_facade/docker-compose.yml +50 -0
  98. snulbug-0.1.1/examples/mcp_container_facade/hypertele-client.json +3 -0
  99. snulbug-0.1.1/examples/mcp_container_facade/hypertele-server.json +6 -0
  100. snulbug-0.1.1/examples/mcp_container_facade/mcp-client.json +10 -0
  101. snulbug-0.1.1/examples/mcp_container_facade/mock_mcp_server.js +92 -0
  102. snulbug-0.1.1/examples/mcp_container_facade/mock_mcp_server.py +100 -0
  103. snulbug-0.1.1/examples/mcp_container_facade/policy.lua +41 -0
  104. snulbug-0.1.1/examples/mcp_container_facade/snulbug.facade.toml +51 -0
  105. snulbug-0.1.1/examples/mcp_container_facade/snulbug.local.toml +39 -0
  106. snulbug-0.1.1/examples/mcp_gateway/README.md +46 -0
  107. snulbug-0.1.1/examples/mcp_gateway/app.py +88 -0
  108. snulbug-0.1.1/examples/mcp_proxy_demo/.gitignore +1 -0
  109. snulbug-0.1.1/examples/mcp_proxy_demo/README.md +100 -0
  110. snulbug-0.1.1/examples/mcp_proxy_demo/requests/blocked-tool.json +11 -0
  111. snulbug-0.1.1/examples/mcp_proxy_demo/requests/safe-tool.json +11 -0
  112. snulbug-0.1.1/examples/mcp_proxy_demo/requests/tools-list.json +5 -0
  113. snulbug-0.1.1/examples/mcp_proxy_demo/run_demo.py +222 -0
  114. snulbug-0.1.1/examples/mcp_proxy_demo/upstream.py +129 -0
  115. snulbug-0.1.1/examples/policy_promotion/README.md +31 -0
  116. snulbug-0.1.1/examples/policy_promotion/active.lua +16 -0
  117. snulbug-0.1.1/examples/policy_promotion/draft.lua +16 -0
  118. snulbug-0.1.1/examples/policy_promotion/fixtures/acme-invalid.json +8 -0
  119. snulbug-0.1.1/examples/policy_promotion/fixtures/acme-valid.json +9 -0
  120. snulbug-0.1.1/examples/provider_policy_templates/README.md +31 -0
  121. snulbug-0.1.1/examples/provider_policy_templates/cloudflare-access-group-gate.lua +63 -0
  122. snulbug-0.1.1/examples/provider_policy_templates/entra-app-role-gate.lua +83 -0
  123. snulbug-0.1.1/examples/provider_policy_templates/github-actions-workload-gate.lua +75 -0
  124. snulbug-0.1.1/examples/provider_policy_templates/keycloak-role-gate.lua +69 -0
  125. snulbug-0.1.1/examples/state_replay/README.md +13 -0
  126. snulbug-0.1.1/examples/state_replay/duplicate-state.json +5 -0
  127. snulbug-0.1.1/examples/state_replay/idempotency.lua +10 -0
  128. snulbug-0.1.1/examples/state_replay/request.json +8 -0
  129. snulbug-0.1.1/examples/webhook_normalization/README.md +42 -0
  130. snulbug-0.1.1/examples/webhook_normalization/app.py +61 -0
  131. snulbug-0.1.1/examples/webhook_normalization/policies/github.lua +58 -0
  132. snulbug-0.1.1/examples/webhook_normalization/policies/stripe.lua +58 -0
  133. snulbug-0.1.1/examples/webhook_normalization/policies/unknown.lua +8 -0
  134. snulbug-0.1.1/examples/webhook_normalization/requests/github-push.json +10 -0
  135. snulbug-0.1.1/examples/webhook_normalization/requests/stripe-invoice.json +9 -0
  136. snulbug-0.1.1/examples/webhook_normalization/requests/stripe-malformed.json +8 -0
  137. snulbug-0.1.1/examples/webhook_normalization/requests/unknown-vendor.json +8 -0
  138. snulbug-0.1.1/features/snulbug/README.md +41 -0
  139. snulbug-0.1.1/features/snulbug/devcontainer-feature.json +96 -0
  140. snulbug-0.1.1/features/snulbug/install.sh +309 -0
  141. snulbug-0.1.1/pyproject.toml +105 -0
  142. snulbug-0.1.1/snulbug/__init__.py +588 -0
  143. snulbug-0.1.1/snulbug/__main__.py +3 -0
  144. snulbug-0.1.1/snulbug/auth_recipes.py +715 -0
  145. snulbug-0.1.1/snulbug/builtin_presets/mcp/auth-required.snulbug/README.md +6 -0
  146. snulbug-0.1.1/snulbug/builtin_presets/mcp/auth-required.snulbug/fixtures/authenticated.json +8 -0
  147. snulbug-0.1.1/snulbug/builtin_presets/mcp/auth-required.snulbug/fixtures/missing-token.json +6 -0
  148. snulbug-0.1.1/snulbug/builtin_presets/mcp/auth-required.snulbug/manifest.json +28 -0
  149. snulbug-0.1.1/snulbug/builtin_presets/mcp/auth-required.snulbug/policy.lua +34 -0
  150. snulbug-0.1.1/snulbug/builtin_presets/mcp/local-dev-safe.snulbug/README.md +10 -0
  151. snulbug-0.1.1/snulbug/builtin_presets/mcp/local-dev-safe.snulbug/fixtures/missing-token.json +8 -0
  152. snulbug-0.1.1/snulbug/builtin_presets/mcp/local-dev-safe.snulbug/fixtures/safe-tool.json +9 -0
  153. snulbug-0.1.1/snulbug/builtin_presets/mcp/local-dev-safe.snulbug/fixtures/unsafe-tool.json +9 -0
  154. snulbug-0.1.1/snulbug/builtin_presets/mcp/local-dev-safe.snulbug/manifest.json +49 -0
  155. snulbug-0.1.1/snulbug/builtin_presets/mcp/local-dev-safe.snulbug/policy.lua +50 -0
  156. snulbug-0.1.1/snulbug/builtin_presets/mcp/local-dev-safe.snulbug/snapshots/empty.json +3 -0
  157. snulbug-0.1.1/snulbug/builtin_presets/mcp/no-shell-tools.snulbug/README.md +10 -0
  158. snulbug-0.1.1/snulbug/builtin_presets/mcp/no-shell-tools.snulbug/fixtures/missing-token.json +8 -0
  159. snulbug-0.1.1/snulbug/builtin_presets/mcp/no-shell-tools.snulbug/fixtures/safe-tool.json +9 -0
  160. snulbug-0.1.1/snulbug/builtin_presets/mcp/no-shell-tools.snulbug/fixtures/shell-tool.json +9 -0
  161. snulbug-0.1.1/snulbug/builtin_presets/mcp/no-shell-tools.snulbug/manifest.json +39 -0
  162. snulbug-0.1.1/snulbug/builtin_presets/mcp/no-shell-tools.snulbug/policy.lua +66 -0
  163. snulbug-0.1.1/snulbug/builtin_presets/mcp/project-path-allowlist.snulbug/README.md +19 -0
  164. snulbug-0.1.1/snulbug/builtin_presets/mcp/project-path-allowlist.snulbug/fixtures/absolute-path.json +9 -0
  165. snulbug-0.1.1/snulbug/builtin_presets/mcp/project-path-allowlist.snulbug/fixtures/allowed-path.json +9 -0
  166. snulbug-0.1.1/snulbug/builtin_presets/mcp/project-path-allowlist.snulbug/fixtures/traversal-path.json +9 -0
  167. snulbug-0.1.1/snulbug/builtin_presets/mcp/project-path-allowlist.snulbug/fixtures/unsafe-tool.json +9 -0
  168. snulbug-0.1.1/snulbug/builtin_presets/mcp/project-path-allowlist.snulbug/manifest.json +50 -0
  169. snulbug-0.1.1/snulbug/builtin_presets/mcp/project-path-allowlist.snulbug/policy.lua +120 -0
  170. snulbug-0.1.1/snulbug/builtin_presets/mcp/read-only-local-dev.snulbug/README.md +11 -0
  171. snulbug-0.1.1/snulbug/builtin_presets/mcp/read-only-local-dev.snulbug/fixtures/missing-token.json +8 -0
  172. snulbug-0.1.1/snulbug/builtin_presets/mcp/read-only-local-dev.snulbug/fixtures/safe-tool.json +9 -0
  173. snulbug-0.1.1/snulbug/builtin_presets/mcp/read-only-local-dev.snulbug/fixtures/tools-list.json +9 -0
  174. snulbug-0.1.1/snulbug/builtin_presets/mcp/read-only-local-dev.snulbug/fixtures/write-method.json +9 -0
  175. snulbug-0.1.1/snulbug/builtin_presets/mcp/read-only-local-dev.snulbug/manifest.json +58 -0
  176. snulbug-0.1.1/snulbug/builtin_presets/mcp/read-only-local-dev.snulbug/policy.lua +82 -0
  177. snulbug-0.1.1/snulbug/builtin_presets/mcp/read-only-local-dev.snulbug/snapshots/empty.json +3 -0
  178. snulbug-0.1.1/snulbug/builtin_presets/mcp/tool-allowlist.snulbug/README.md +6 -0
  179. snulbug-0.1.1/snulbug/builtin_presets/mcp/tool-allowlist.snulbug/fixtures/safe-tool.json +8 -0
  180. snulbug-0.1.1/snulbug/builtin_presets/mcp/tool-allowlist.snulbug/fixtures/tools-list.json +8 -0
  181. snulbug-0.1.1/snulbug/builtin_presets/mcp/tool-allowlist.snulbug/fixtures/unsafe-tool.json +8 -0
  182. snulbug-0.1.1/snulbug/builtin_presets/mcp/tool-allowlist.snulbug/manifest.json +37 -0
  183. snulbug-0.1.1/snulbug/builtin_presets/mcp/tool-allowlist.snulbug/policy.lua +22 -0
  184. snulbug-0.1.1/snulbug/builtin_presets/mcp/tunnel-safe.snulbug/README.md +12 -0
  185. snulbug-0.1.1/snulbug/builtin_presets/mcp/tunnel-safe.snulbug/fixtures/batch-request.json +9 -0
  186. snulbug-0.1.1/snulbug/builtin_presets/mcp/tunnel-safe.snulbug/fixtures/missing-token.json +8 -0
  187. snulbug-0.1.1/snulbug/builtin_presets/mcp/tunnel-safe.snulbug/fixtures/safe-tool.json +9 -0
  188. snulbug-0.1.1/snulbug/builtin_presets/mcp/tunnel-safe.snulbug/fixtures/unsafe-tool.json +9 -0
  189. snulbug-0.1.1/snulbug/builtin_presets/mcp/tunnel-safe.snulbug/manifest.json +60 -0
  190. snulbug-0.1.1/snulbug/builtin_presets/mcp/tunnel-safe.snulbug/policy.lua +70 -0
  191. snulbug-0.1.1/snulbug/builtin_presets/mcp/tunnel-safe.snulbug/snapshots/empty.json +3 -0
  192. snulbug-0.1.1/snulbug/builtin_presets/mcp/workspace-firewall.snulbug/README.md +31 -0
  193. snulbug-0.1.1/snulbug/builtin_presets/mcp/workspace-firewall.snulbug/fixtures/allowed-read.json +9 -0
  194. snulbug-0.1.1/snulbug/builtin_presets/mcp/workspace-firewall.snulbug/fixtures/missing-token.json +8 -0
  195. snulbug-0.1.1/snulbug/builtin_presets/mcp/workspace-firewall.snulbug/fixtures/secret-path.json +9 -0
  196. snulbug-0.1.1/snulbug/builtin_presets/mcp/workspace-firewall.snulbug/fixtures/traversal-path.json +9 -0
  197. snulbug-0.1.1/snulbug/builtin_presets/mcp/workspace-firewall.snulbug/fixtures/unsafe-tool.json +9 -0
  198. snulbug-0.1.1/snulbug/builtin_presets/mcp/workspace-firewall.snulbug/manifest.json +64 -0
  199. snulbug-0.1.1/snulbug/builtin_presets/mcp/workspace-firewall.snulbug/policy.lua +121 -0
  200. snulbug-0.1.1/snulbug/bundle.py +684 -0
  201. snulbug-0.1.1/snulbug/cli/__init__.py +1 -0
  202. snulbug-0.1.1/snulbug/cli/common.py +18 -0
  203. snulbug-0.1.1/snulbug/cli/evidence.py +269 -0
  204. snulbug-0.1.1/snulbug/cli/fabric.py +1070 -0
  205. snulbug-0.1.1/snulbug/cli/policy.py +315 -0
  206. snulbug-0.1.1/snulbug/cli/rich_reports.py +630 -0
  207. snulbug-0.1.1/snulbug/cli/rich_share.py +271 -0
  208. snulbug-0.1.1/snulbug/cli/schemas.py +189 -0
  209. snulbug-0.1.1/snulbug/cli/share.py +1700 -0
  210. snulbug-0.1.1/snulbug/cli_helpers.py +147 -0
  211. snulbug-0.1.1/snulbug/cloudflare_access.py +375 -0
  212. snulbug-0.1.1/snulbug/codespaces.py +643 -0
  213. snulbug-0.1.1/snulbug/config.py +1317 -0
  214. snulbug-0.1.1/snulbug/confirm.py +220 -0
  215. snulbug-0.1.1/snulbug/control_events.py +82 -0
  216. snulbug-0.1.1/snulbug/controller.py +1574 -0
  217. snulbug-0.1.1/snulbug/credentials.py +252 -0
  218. snulbug-0.1.1/snulbug/discovery.py +958 -0
  219. snulbug-0.1.1/snulbug/events.py +580 -0
  220. snulbug-0.1.1/snulbug/fabric.py +2691 -0
  221. snulbug-0.1.1/snulbug/fabric_control.py +518 -0
  222. snulbug-0.1.1/snulbug/fabric_members.py +557 -0
  223. snulbug-0.1.1/snulbug/fabric_runtime.py +657 -0
  224. snulbug-0.1.1/snulbug/gateway_templates.py +89 -0
  225. snulbug-0.1.1/snulbug/guide.py +337 -0
  226. snulbug-0.1.1/snulbug/impact.py +436 -0
  227. snulbug-0.1.1/snulbug/inspection.py +394 -0
  228. snulbug-0.1.1/snulbug/lab.py +1031 -0
  229. snulbug-0.1.1/snulbug/learn.py +773 -0
  230. snulbug-0.1.1/snulbug/leases.py +716 -0
  231. snulbug-0.1.1/snulbug/manifests.py +122 -0
  232. snulbug-0.1.1/snulbug/mcp_auth.py +1586 -0
  233. snulbug-0.1.1/snulbug/mcp_policy_bundles.py +100 -0
  234. snulbug-0.1.1/snulbug/mcp_schema_policy.py +1055 -0
  235. snulbug-0.1.1/snulbug/mcp_schemas.py +761 -0
  236. snulbug-0.1.1/snulbug/mcp_tools.py +401 -0
  237. snulbug-0.1.1/snulbug/middleware.py +689 -0
  238. snulbug-0.1.1/snulbug/policy_activation.py +210 -0
  239. snulbug-0.1.1/snulbug/policy_review.py +315 -0
  240. snulbug-0.1.1/snulbug/presets.py +861 -0
  241. snulbug-0.1.1/snulbug/promotion.py +345 -0
  242. snulbug-0.1.1/snulbug/proxy.py +3863 -0
  243. snulbug-0.1.1/snulbug/py.typed +1 -0
  244. snulbug-0.1.1/snulbug/quickstart.py +541 -0
  245. snulbug-0.1.1/snulbug/recorder.py +225 -0
  246. snulbug-0.1.1/snulbug/redaction.py +302 -0
  247. snulbug-0.1.1/snulbug/response_policy.py +327 -0
  248. snulbug-0.1.1/snulbug/runtime.py +2649 -0
  249. snulbug-0.1.1/snulbug/sarif.py +293 -0
  250. snulbug-0.1.1/snulbug/scaffolds.py +507 -0
  251. snulbug-0.1.1/snulbug/schema_policy.py +466 -0
  252. snulbug-0.1.1/snulbug/share.py +7736 -0
  253. snulbug-0.1.1/snulbug/share_session.py +258 -0
  254. snulbug-0.1.1/snulbug/simulator.py +273 -0
  255. snulbug-0.1.1/snulbug/state.py +430 -0
  256. snulbug-0.1.1/snulbug/tool_risk.py +326 -0
  257. snulbug-0.1.1/snulbug/tunnel.py +1776 -0
  258. snulbug-0.1.1/tests/test_auth_claim_patterns.py +139 -0
  259. snulbug-0.1.1/tests/test_auth_recipes.py +142 -0
  260. snulbug-0.1.1/tests/test_cli_helpers.py +53 -0
  261. snulbug-0.1.1/tests/test_cloudflare_access.py +242 -0
  262. snulbug-0.1.1/tests/test_codespaces.py +269 -0
  263. snulbug-0.1.1/tests/test_config.py +1135 -0
  264. snulbug-0.1.1/tests/test_customer_policy_demo.py +98 -0
  265. snulbug-0.1.1/tests/test_devcontainer_feature.py +113 -0
  266. snulbug-0.1.1/tests/test_discovery.py +357 -0
  267. snulbug-0.1.1/tests/test_events.py +78 -0
  268. snulbug-0.1.1/tests/test_fabric.py +836 -0
  269. snulbug-0.1.1/tests/test_fabric_controller.py +1028 -0
  270. snulbug-0.1.1/tests/test_keycloak_oauth_demo.py +81 -0
  271. snulbug-0.1.1/tests/test_leases.py +207 -0
  272. snulbug-0.1.1/tests/test_manifests.py +105 -0
  273. snulbug-0.1.1/tests/test_mcp_gateway_demo.py +129 -0
  274. snulbug-0.1.1/tests/test_mcp_guide.py +67 -0
  275. snulbug-0.1.1/tests/test_mcp_helpers.py +1338 -0
  276. snulbug-0.1.1/tests/test_mcp_impact.py +175 -0
  277. snulbug-0.1.1/tests/test_mcp_inspection.py +220 -0
  278. snulbug-0.1.1/tests/test_mcp_lab.py +72 -0
  279. snulbug-0.1.1/tests/test_mcp_learn.py +444 -0
  280. snulbug-0.1.1/tests/test_mcp_policy_bundles.py +74 -0
  281. snulbug-0.1.1/tests/test_mcp_presets.py +241 -0
  282. snulbug-0.1.1/tests/test_mcp_proxy_demo.py +67 -0
  283. snulbug-0.1.1/tests/test_mcp_quickstart.py +288 -0
  284. snulbug-0.1.1/tests/test_mcp_recorder.py +99 -0
  285. snulbug-0.1.1/tests/test_mcp_schema_policy.py +162 -0
  286. snulbug-0.1.1/tests/test_mcp_schemas.py +241 -0
  287. snulbug-0.1.1/tests/test_mcp_share.py +2038 -0
  288. snulbug-0.1.1/tests/test_mcp_tools.py +217 -0
  289. snulbug-0.1.1/tests/test_middleware.py +412 -0
  290. snulbug-0.1.1/tests/test_policy_bundle.py +178 -0
  291. snulbug-0.1.1/tests/test_policy_promotion.py +299 -0
  292. snulbug-0.1.1/tests/test_policy_state.py +171 -0
  293. snulbug-0.1.1/tests/test_provider_policy_templates.py +211 -0
  294. snulbug-0.1.1/tests/test_proxy.py +4344 -0
  295. snulbug-0.1.1/tests/test_redaction_audit.py +385 -0
  296. snulbug-0.1.1/tests/test_sandbox_abuse.py +70 -0
  297. snulbug-0.1.1/tests/test_scaffolds.py +145 -0
  298. snulbug-0.1.1/tests/test_state_snapshots.py +127 -0
  299. snulbug-0.1.1/tests/test_tunnel_audit.py +120 -0
  300. snulbug-0.1.1/tests/test_tunnel_doctor.py +194 -0
  301. snulbug-0.1.1/tests/test_tunnel_init.py +358 -0
  302. snulbug-0.1.1/tests/test_webhook_normalization_demo.py +106 -0
  303. snulbug-0.1.1/tests/test_webhooks.py +113 -0
@@ -0,0 +1,7 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .pytest_cache/
4
+ .venv/
5
+ dist/
6
+ .snulbug/
7
+ .snulbug-lab/
@@ -0,0 +1,45 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on Keep a Changelog, and this project follows semantic versioning after `1.0.0`. Before `1.0.0`, minor versions may include action schema or trace schema changes.
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.1] - 2026-06-16
10
+
11
+ - Fixed PyPI/TestPyPI project metadata and README logo URLs to point at the
12
+ published `nahuaque/snulbug` repository.
13
+ - Added public GitHub project metadata, CI, contribution docs, security docs, issue templates, and reference documentation.
14
+ - Added the basic ASGI middleware example under `examples/basic`.
15
+ - Added bundled MCP policy presets with `snulbug mcp policy preset`.
16
+ - Added MCP request decision recording and replay with `snulbug mcp evidence record` and `snulbug mcp evidence replay`.
17
+ - Added secret redaction and redacted MCP audit JSONL logs.
18
+ - Added local-dev MCP reverse proxy mode with `snulbug mcp share run`.
19
+ - Added live proxy request recording and audit logging with `snulbug mcp share run --record-out`.
20
+ - Added MCP proxy TOML config files with `snulbug mcp share config init` and `snulbug mcp share run --config`.
21
+ - Added configurable MCP policy generation options to `snulbug mcp policy preset`.
22
+ - Added live proxy decision console output with generated console event sinks.
23
+ - Added MCP-aware audit fields for JSON-RPC id, method, operation, targets, key names, batches, and initialize metadata.
24
+ - Added policy decision `reason` and `reason_code` conventions across MCP helpers, presets, audit logs, and live console output.
25
+ - Added offline MCP log inspection with `snulbug mcp evidence inspect`.
26
+ - Changed MCP record/proxy defaults to redact replay artifacts unless exact logging is explicitly requested.
27
+ - Added MCP client setup recipes for local, tunneled, authenticated, recording, and stdio-only workflows.
28
+ - Added a local MCP policy gateway quickstart and `snulbug mcp share quickstart` generator.
29
+ - Added a runnable end-to-end MCP policy proxy demo.
30
+ - Added MCP risk-profile presets for read-only local development, shell-tool denial, project path allowlists, and tunneled servers.
31
+ - Added Markdown MCP session reports with `snulbug mcp evidence inspect --report-out`.
32
+ - Documented `tunnel-safe` as the recommended default for public tunnel use.
33
+ - Added MCP facade mode for serving multiple local MCP HTTP servers through one `snulbug mcp share run` endpoint.
34
+ - Added managed stdio MCP upstreams for facade mode, so local stdio servers can be exposed through the same policy-controlled HTTP endpoint.
35
+ - Added MCP learn mode with `snulbug mcp policy learn` to compile captured replay/audit logs into least-privilege policy bundles.
36
+ - Added MCP amend mode with `snulbug mcp policy amend` to produce candidate patches from blocked learned-policy decisions.
37
+ - Added `snulbug mcp share lab`, a one-command local MCP policy lab covering facade, recording, inspection, learn, and amend.
38
+
39
+ ## [0.1.0] - 2026-06-12
40
+
41
+ - Initial alpha package for programmable Lua request policy in ASGI middleware.
42
+ - Added request actions: `continue`, `set_context`, `rewrite`, `respond`, `reject`, `challenge`, `redirect`, and `rate_limit`.
43
+ - Added bounded policy state with memory, SQLite, Redis, snapshot, and dry-run support.
44
+ - Added simulator, policy diffing, shadow policy support, bundle validation, bundle tests, and bundle packing.
45
+ - Added customer-owned request policy, webhook normalization, state replay, idempotency bundle, and MCP gateway examples.
@@ -0,0 +1,7 @@
1
+ # Code of Conduct
2
+
3
+ This project expects contributors to be direct, respectful, and focused on the work.
4
+
5
+ Unacceptable behavior includes harassment, personal attacks, threats, or publishing private information. Maintainers may remove comments, close issues, or restrict participation when behavior makes productive collaboration harder.
6
+
7
+ Report conduct concerns privately to the repository owner.
@@ -0,0 +1,29 @@
1
+ # Contributing
2
+
3
+ Thanks for considering a contribution to `snulbug`.
4
+
5
+ ## Development setup
6
+
7
+ ```bash
8
+ uv sync --extra dev
9
+ ```
10
+
11
+ Run the checks used by CI:
12
+
13
+ ```bash
14
+ uv run ruff format --check .
15
+ uv run ruff check .
16
+ PYTHONDONTWRITEBYTECODE=1 uv run pytest
17
+ uv build
18
+ ```
19
+
20
+ ## Pull requests
21
+
22
+ - Keep changes scoped to one behavior or public API surface.
23
+ - Add tests for new middleware behavior, simulator behavior, state adapters, or bundle validation rules.
24
+ - Update README or `docs/` when public behavior changes.
25
+ - Do not include generated caches, local databases, virtual environments, or build artifacts.
26
+
27
+ ## Policy compatibility
28
+
29
+ Until `1.0`, `snulbug` is alpha software. Action schemas and trace fields may still change. When changing a public action or trace field, document the migration path in `CHANGELOG.md`.
snulbug-0.1.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 snulbug contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
snulbug-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,449 @@
1
+ Metadata-Version: 2.4
2
+ Name: snulbug
3
+ Version: 0.1.1
4
+ Summary: A local-dev MCP policy proxy with Lua policies, replay logs, and learned least-privilege bundles
5
+ Project-URL: Homepage, https://github.com/nahuaque/snulbug
6
+ Project-URL: Repository, https://github.com/nahuaque/snulbug
7
+ Project-URL: Issues, https://github.com/nahuaque/snulbug/issues
8
+ Project-URL: Changelog, https://github.com/nahuaque/snulbug/blob/main/CHANGELOG.md
9
+ Author: snulbug contributors
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: asgi,fastapi,lua,mcp,middleware,policy,proxy,security,starlette,webhooks
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Framework :: AsyncIO
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Lua
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Internet :: WWW/HTTP
24
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
+ Requires-Python: >=3.10
26
+ Requires-Dist: lupa>=2.5
27
+ Requires-Dist: pyjwt[crypto]>=2.8
28
+ Requires-Dist: rich>=15.0.0
29
+ Requires-Dist: tomli>=2.0; python_version < '3.11'
30
+ Requires-Dist: uvicorn>=0.30
31
+ Provides-Extra: dev
32
+ Requires-Dist: bandit>=1.9.4; extra == 'dev'
33
+ Requires-Dist: pytest>=8.0; extra == 'dev'
34
+ Requires-Dist: ruff>=0.8; extra == 'dev'
35
+ Provides-Extra: discovery
36
+ Requires-Dist: pyyaml>=6.0; extra == 'discovery'
37
+ Provides-Extra: redis
38
+ Requires-Dist: redis>=5.0; extra == 'redis'
39
+ Description-Content-Type: text/markdown
40
+
41
+ <p align="center">
42
+ <img src="https://raw.githubusercontent.com/nahuaque/snulbug/main/assets/snulbug.png" alt="snulbug logo" width="220">
43
+ </p>
44
+
45
+ # snulbug
46
+
47
+ `snulbug` is a local-dev MCP policy proxy. Put it between an MCP client and one
48
+ or more local MCP servers before you hand an agent a broad toolset or expose a
49
+ server through a public tunnel.
50
+
51
+ It gives you a tight loop for agent-tool safety:
52
+
53
+ - start with a conservative `tunnel-safe` policy
54
+ - watch live allow/block decisions while traffic flows
55
+ - record redacted replay and audit logs
56
+ - learn a least-privilege policy from observed traffic
57
+ - amend blocked requests into reviewable candidate bundles
58
+ - classify observed and schema-declared MCP tools by risk before handoff
59
+ - use task-scoped leases for temporary tool/path grants, optionally bound to
60
+ OAuth subject, tenant, client, group, issuer, or auth profile
61
+ - turn OAuth identity into MCP-specific tool permissions
62
+ - pin facade upstream identity with signed manifests
63
+
64
+ The standalone ASGI Lua middleware is still available, but it is an
65
+ implementation surface. The main use case is protecting local MCP traffic.
66
+
67
+ ## Auth Model
68
+
69
+ snulbug can act as an MCP OAuth protected resource, but the useful part is the
70
+ MCP-specific authorization layer on top:
71
+
72
+ - validate JWTs with local or remote JWKS, issuer discovery, or token introspection
73
+ - enforce exact resource/audience settings so tunnel URLs do not drift silently
74
+ - trust multiple issuer or tenant profiles for facade and fabric gateways
75
+ - map OAuth scopes to concrete MCP methods and tools
76
+ - map tenant, group, subject, client ID, or custom claims to tool allowlists
77
+ - strip caller OAuth tokens before upstream calls and inject separate upstream credentials
78
+ - compose OAuth identity with task-scoped leases and Lua policy before a tool call is allowed
79
+ - surface auth runtime counters for JWKS cache state, refreshes, issuer failures, and scope denials
80
+ - generate auth conformance packs from config, schemas, sample token refs, and replay/audit logs
81
+
82
+ Audit records include the selected auth profile, scope/claim-policy decisions,
83
+ lease state, auth runtime counters, and Lua decision without logging raw bearer
84
+ tokens.
85
+
86
+ ## Install
87
+
88
+ Install the CLI with `uv`:
89
+
90
+ ```bash
91
+ uv tool install "snulbug[discovery]"
92
+ snulbug --help
93
+ ```
94
+
95
+ For one-off use without a persistent tool install:
96
+
97
+ ```bash
98
+ uvx "snulbug[discovery]" --help
99
+ ```
100
+
101
+ From another `uv` project:
102
+
103
+ ```bash
104
+ uv add "snulbug[discovery]"
105
+ ```
106
+
107
+ Add the Redis extra when you need Redis-backed policy, runtime, or member state:
108
+
109
+ ```bash
110
+ uv add "snulbug[discovery,redis]"
111
+ ```
112
+
113
+ From this repository, use source mode:
114
+
115
+ ```bash
116
+ uv sync --all-extras --dev
117
+ uv run snulbug --help
118
+ uv run pytest
119
+ ```
120
+
121
+ The examples below use the installed `snulbug` command. If you are working from
122
+ the checkout without installing the tool, prefix commands with `uv run`.
123
+
124
+ `snulbug` supports Python 3.10 through 3.13.
125
+
126
+ ## Golden Path
127
+
128
+ The primary workflow is:
129
+
130
+ ```text
131
+ share create -> share run -> share status -> share policy amend -> share policy activate -> share doctor -> share contract -> share report
132
+ ```
133
+
134
+ Ask the CLI for a copy-paste version before wiring a client or harness:
135
+
136
+ ```bash
137
+ snulbug mcp guide --workflow share
138
+ snulbug mcp guide --workflow learn-amend-impact --compact
139
+ ```
140
+
141
+ 1. Create a temporary share session with generated bearer auth, a task lease,
142
+ provider setup, client config, and close-out report commands:
143
+
144
+ ```bash
145
+ snulbug mcp share create \
146
+ --provider holepunch \
147
+ --upstream http://127.0.0.1:9000 \
148
+ --allow-tool safe_read_file \
149
+ --allow-tool list_project_files \
150
+ --ttl 30m
151
+ ```
152
+
153
+ 2. Run the protected gateway from the generated share directory:
154
+
155
+ ```bash
156
+ export SNULBUG_SHARE_TOKEN=...
157
+ snulbug mcp share run .snulbug/shares/share-...
158
+ ```
159
+
160
+ Inside a generated share directory, `snulbug mcp share run` is enough;
161
+ it reads `.snulbug/share/session.json` and reconciles the active config,
162
+ policy, lease, and log paths before starting the gateway.
163
+
164
+ 3. Check what is happening:
165
+
166
+ ```bash
167
+ snulbug mcp share status .snulbug/shares/share-...
168
+ ```
169
+
170
+ 4. If a legitimate request was blocked, amend the reviewed policy bundle from
171
+ the audit log:
172
+
173
+ ```bash
174
+ snulbug mcp share policy amend .snulbug/shares/share-...
175
+ ```
176
+
177
+ By default this uses the share audit/session log and updates the share policy
178
+ bundle in place; pass `--out` when you want a detached candidate bundle.
179
+
180
+ 5. Promote and activate the share policy without leaving the share workflow:
181
+
182
+ ```bash
183
+ export SNULBUG_BUNDLE_SECRET=...
184
+ snulbug mcp share policy promote .snulbug/shares/share-... --to proposed --key-id local-review
185
+ snulbug mcp share policy promote .snulbug/shares/share-... --to approved --key-id local-review
186
+ snulbug mcp share policy activate .snulbug/shares/share-... --key-id local-review
187
+ ```
188
+
189
+ 6. Generate the closeout report from the session model and audit evidence:
190
+
191
+ ```bash
192
+ snulbug mcp share report .snulbug/shares/share-... \
193
+ --output .snulbug/shares/share-.../share-report.md
194
+ ```
195
+
196
+ Before sharing a public URL or client config, run the share doctor. It is the
197
+ single pre-share gate for generated config, policy bundle validity, fabric
198
+ checks, current status, and public tunnel safety:
199
+
200
+ ```bash
201
+ PUBLIC_MCP_URL=https://YOUR-FORWARDING-DOMAIN/mcp
202
+ snulbug mcp share doctor .snulbug/shares/share-... \
203
+ --url "${PUBLIC_MCP_URL}"
204
+ snulbug mcp share client .snulbug/shares/share-...
205
+ export SNULBUG_SHARE_CONTRACT_SECRET=...
206
+ snulbug mcp share contract .snulbug/shares/share-... \
207
+ --sign \
208
+ --key-id local-review \
209
+ --output .snulbug/shares/share-.../share-contract.json
210
+ ```
211
+
212
+ To bind the live gateway to that approved contract, run with:
213
+
214
+ ```bash
215
+ snulbug mcp share run .snulbug/shares/share-... \
216
+ --require-contract .snulbug/shares/share-.../share-contract.json
217
+ ```
218
+
219
+ The running gateway publishes a zero-install trust surface:
220
+
221
+ - `https://YOUR-FORWARDING-DOMAIN/snulbug` human trust page
222
+ - `https://YOUR-FORWARDING-DOMAIN/.well-known/snulbug/share` compact JSON summary
223
+ - `https://YOUR-FORWARDING-DOMAIN/.well-known/snulbug/share-contract` approved contract JSON
224
+ - `https://YOUR-FORWARDING-DOMAIN/.well-known/snulbug/share-contract.sha256` binding digest
225
+
226
+ If the share uses OAuth protected-resource mode, run the auth doctor too:
227
+
228
+ ```bash
229
+ snulbug mcp share auth doctor .snulbug/shares/share-... \
230
+ --url "${PUBLIC_MCP_URL}" \
231
+ --token "${ACCESS_TOKEN}"
232
+ ```
233
+
234
+ For multi-upstream facade setups, inspect the declared fabric before handing it
235
+ to an agent:
236
+
237
+ ```bash
238
+ snulbug mcp fabric status --config snulbug.toml
239
+ snulbug mcp fabric doctor --config snulbug.toml --token local-dev-secret
240
+ snulbug mcp fabric conformance generate \
241
+ --config snulbug.toml \
242
+ --log traces/session.jsonl \
243
+ --out .snulbug/fabric-conformance
244
+ snulbug mcp fabric conformance run .snulbug/fabric-conformance
245
+ ```
246
+
247
+ See the full [local MCP policy gateway quickstart](docs/quickstart.md) for
248
+ client setup, facade mode, fabric checks, recording, replay, inspection, and
249
+ tunnel notes.
250
+
251
+ ## Demos
252
+
253
+ Run the local policy lab when you want the full lifecycle without wiring a real
254
+ server:
255
+
256
+ ```bash
257
+ snulbug mcp share demo local
258
+ ```
259
+
260
+ The lab creates fake MCP upstreams behind one facade, records traffic, learns a
261
+ least-privilege policy, amends a blocked request into a candidate policy, and
262
+ writes replay/audit/report artifacts under `.snulbug-lab/`.
263
+
264
+ Run the OAuth auth lab when you want to prove the stronger public-share model:
265
+ valid OAuth subject, tenant/group identity fence, mapped MCP tool scope, active
266
+ task lease, Lua approval, and redacted audit output.
267
+
268
+ ```bash
269
+ snulbug mcp share demo auth
270
+ ```
271
+
272
+ It writes a mock issuer, JWKS, demo tokens, lease file, proxy config, requests,
273
+ session/audit logs, and `AUTH_LAB.md` under `.snulbug-auth-lab/`.
274
+
275
+ For a real provider, the [Keycloak OAuth compose demo](examples/keycloak_oauth_demo/README.md)
276
+ runs Keycloak, snulbug, and a demo MCP upstream together. It uses generated
277
+ `share auth init --provider keycloak` setup, validates JWTs through issuer
278
+ discovery, maps Keycloak scopes to MCP tools, and proves caller OAuth tokens are
279
+ not forwarded upstream.
280
+
281
+ Other provider flows are generated setup recipes until their live demos are
282
+ validated against dev accounts. See
283
+ [MCP auth interop recipes](docs/mcp-auth-recipes.md) for the current status.
284
+
285
+ For Codespaces, start the bundled mock MCP server in the Codespace terminal:
286
+
287
+ ```bash
288
+ snulbug mcp share member codespace serve-demo
289
+ ```
290
+
291
+ It prints the forwarded MCP URL and the matching laptop command. On the laptop,
292
+ attach that URL to a local snulbug gateway:
293
+
294
+ ```bash
295
+ snulbug mcp share member codespace attach https://YOUR-CODESPACE-9001.app.github.dev/mcp
296
+ ```
297
+
298
+ `attach` generates `.snulbug/codespace-local/`, preflights the upstream with
299
+ `tools/list`, starts the gateway at `http://127.0.0.1:8080/mcp`, and writes
300
+ replay/audit logs for inspection.
301
+
302
+ ## Live Use
303
+
304
+ Watch decisions while proxying. The generated config includes a console event
305
+ sink by default:
306
+
307
+ ```bash
308
+ snulbug mcp share run --config snulbug.toml
309
+ ```
310
+
311
+ Create a task-scoped lease when you want an MCP client or agent to do one
312
+ bounded job:
313
+
314
+ ```bash
315
+ snulbug mcp share lease create \
316
+ --file leases.json \
317
+ --task "Read project docs only" \
318
+ --allow-tool safe_read_file \
319
+ --allow-path README.md \
320
+ --allow-subject user-1 \
321
+ --ttl 30m
322
+ ```
323
+
324
+ Send the returned `x-snulbug-lease` header with MCP requests. Set
325
+ `lease_required = true` in `snulbug.toml` when every `tools/call` must carry an
326
+ active lease. OAuth-protected shares can require both a valid scoped OAuth token
327
+ and an active task lease before Lua allows the tool call. If a lease includes
328
+ auth binding flags, the current sanitized OAuth context must match those bounds
329
+ too; a copied lease token alone is not enough.
330
+
331
+ After a session, inspect the logs:
332
+
333
+ ```bash
334
+ snulbug mcp evidence inspect traces/session.jsonl
335
+ snulbug mcp evidence inspect traces/audit.jsonl --kind audit
336
+ ```
337
+
338
+ Learn a least-privilege bundle from observed traffic:
339
+
340
+ ```bash
341
+ snulbug mcp policy learn traces/session.jsonl --out learned-policy.snulbug
342
+ snulbug bundle validate learned-policy.snulbug
343
+ snulbug bundle test learned-policy.snulbug
344
+ ```
345
+
346
+ Preview the blast radius before enabling a candidate policy or lease:
347
+
348
+ ```bash
349
+ snulbug mcp evidence impact traces/session.jsonl \
350
+ --policy learned-policy.snulbug/policy.lua \
351
+ --lease leases.json \
352
+ --report-out traces/impact-report.md
353
+ ```
354
+
355
+ When the learned policy blocks a legitimate request, generate a candidate
356
+ amendment instead of editing the active policy in place:
357
+
358
+ ```bash
359
+ snulbug mcp policy amend \
360
+ learned-policy.snulbug \
361
+ traces/audit.jsonl \
362
+ --out candidate-policy.snulbug
363
+ ```
364
+
365
+ ## What It Enforces
366
+
367
+ Request-side policy:
368
+
369
+ - bearer challenges and auth checks
370
+ - MCP method and tool allowlists
371
+ - JSON-RPC batch rejection
372
+ - project path constraints for tool arguments
373
+ - agent workspace firewalling with path classification and secret/generated path blocks
374
+ - schema-aware validation of `tools/call` arguments from MCP `inputSchema`
375
+ - schema-aware Lua intent guards for tool categories and risk levels
376
+ - task-scoped capability leases with expiring tool/path grants
377
+ - small stateful policies such as rate limits and idempotency keys
378
+
379
+ Response-side policy:
380
+
381
+ - redaction of likely secrets from tool/resource/prompt results
382
+ - maximum MCP response body size
383
+ - optional blocking for instruction-like tool output
384
+ - `tools/list` description and schema pinning to catch silent upstream changes
385
+ - human confirmation for risky or otherwise blocked calls, with allow-once or session approval
386
+
387
+ Workflow:
388
+
389
+ - redacted replay logs for deterministic policy testing
390
+ - audit JSONL with MCP-aware fields
391
+ - policy evidence diffs that summarize newly allowed tools, MCP path patterns, and argument shapes
392
+ - SARIF output for CI gates on policy diffs, schema drift, and share readiness failures
393
+ - share reports that classify observed MCP tools by risk signals before handoff
394
+ - provider-aware tunnel audit fields for ngrok, Cloudflare, Tailscale, Pinggy, Holepunch, and generic forwarders
395
+ - Cloudflare Tunnel profiles for Access-gated, service-token, OAuth-resource, and audit-first shares
396
+ - Tailscale Funnel/Serve profiles for public bearer+lease shares, tailnet-only shares, and OAuth-resource shares
397
+ - optional Cloudflare Access origin-side audit/enforcement with Access JWT validation
398
+ - optional OAuth protected-resource mode with JWT/JWKS or token-introspection validation and MCP bearer challenges
399
+ - OAuth scope-to-MCP method/tool mapping for least-privilege public shares
400
+ - OAuth resource/audience drift checks for tunnel-safe public shares
401
+ - generated auth setup flows for Keycloak, Auth0, Okta, Entra, Cloudflare Access, and GitHub OIDC
402
+ - composable OAuth + auth-bound task lease + Lua policy access decisions
403
+ - anti-passthrough credential brokering so caller OAuth tokens stop at snulbug
404
+ - learned least-privilege bundles from observed traffic
405
+ - candidate amendments for blocked legitimate requests
406
+ - a decision console for live local tunnel traffic
407
+
408
+ ## Documentation
409
+
410
+ Start with:
411
+
412
+ - [Quickstart: local MCP policy gateway](docs/quickstart.md)
413
+ - [MCP share sessions](docs/mcp-share.md)
414
+ - [MCP CLI guide for agents and harnesses](docs/mcp-guide.md)
415
+ - [MCP policy workflow: preset, learn, amend, lifecycle](docs/mcp-policy.md)
416
+ - [MCP schema workflow: discover, diff, generate policy](docs/mcp-schemas.md)
417
+ - [MCP evidence workflow: record, replay, inspect, impact, diff](docs/mcp-evidence.md)
418
+ - [CI policy gates and SARIF output](docs/ci-policy-gates.md)
419
+ - [MCP reverse proxy](docs/mcp-proxy.md)
420
+ - [MCP fabric config, discovery, and conformance](docs/mcp-fabric.md)
421
+ - [Codespaces and devcontainers](docs/devcontainers.md)
422
+ - [MCP client setup recipes](docs/mcp-client-recipes.md)
423
+ - [MCP auth interop recipes](docs/mcp-auth-recipes.md)
424
+ - [Lua policy DSL guide](docs/lua-policy-dsl.md)
425
+ - [OAuth claim-policy examples](examples/auth_claim_patterns/README.md)
426
+ - [Provider-aware Lua policy templates](examples/provider_policy_templates/README.md)
427
+ - [Security model](docs/security-model.md)
428
+ - [Positioning and comparisons](docs/comparison.md)
429
+ - [Roadmap](docs/roadmap.md)
430
+
431
+ Reference docs:
432
+
433
+ - [MCP presets](docs/mcp-presets.md)
434
+ - [MCP learn and amend mode](docs/mcp-learn.md)
435
+ - [MCP evidence record, replay, and inspect](docs/mcp-recorder.md)
436
+ - [MCP evidence impact preview](docs/mcp-impact.md)
437
+ - [ASGI middleware getting started](docs/getting-started.md)
438
+ - [Lua policy reference](docs/lua-request-api.md)
439
+ - [Action reference](docs/actions.md)
440
+ - [State adapters](docs/state.md)
441
+ - [Policy bundles](docs/bundles.md)
442
+ - [MCP gateway example](docs/mcp-gateway.md)
443
+ - [End-to-end ngrok MCP gateway](docs/ngrok-end-to-end.md)
444
+ - [End-to-end MCP policy proxy demo](examples/mcp_proxy_demo/README.md)
445
+ - [Keycloak OAuth compose demo](examples/keycloak_oauth_demo/README.md)
446
+ - [Release process](docs/release.md)
447
+
448
+ `snulbug` is currently alpha software. Until 1.0, action schemas and trace
449
+ fields may evolve.