dmint 2.0.2__tar.gz → 2.0.4__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.
- {dmint-2.0.2 → dmint-2.0.4}/PKG-INFO +150 -33
- dmint-2.0.2/src/dmint.egg-info/PKG-INFO → dmint-2.0.4/README.md +134 -79
- {dmint-2.0.2 → dmint-2.0.4}/pyproject.toml +34 -10
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/__init__.py +33 -1
- dmint-2.0.4/src/dmint/cli/__init__.py +132 -0
- dmint-2.0.4/src/dmint/cli/__main__.py +266 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/cli/approvals.py +197 -12
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/cli/compile_policy.py +3 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/cli/create_mcp_policy.py +98 -20
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/cli/create_policy.py +198 -8
- dmint-2.0.4/src/dmint/cli/demo.py +418 -0
- dmint-2.0.4/src/dmint/cli/hooks.py +2357 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/cli/install_skill.py +9 -4
- dmint-2.0.4/src/dmint/cli/keys.py +231 -0
- dmint-2.0.4/src/dmint/cli/logs.py +396 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/cli/mcp_auth.py +126 -10
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/cli/mcp_connections.py +11 -11
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/cli/mcp_credentials.py +4 -1
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/cli/mcp_oauth.py +167 -23
- dmint-2.0.4/src/dmint/cli/policy_digest.py +62 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/cli/prompts/policy_skill.md +8 -1
- dmint-2.0.4/src/dmint/cli/ui.py +278 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/cli/verify_policy.py +29 -2
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/__init__.py +19 -1
- dmint-2.0.4/src/dmint/core/audit.py +629 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/enforcement.py +231 -14
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/errors.py +3 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/policy.py +56 -11
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/resources.py +13 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/storage/__init__.py +13 -1
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/storage/base.py +10 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/storage/factory.py +15 -1
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/storage/sql.py +160 -45
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/storage/sqlite.py +80 -28
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/storage/thread_safe.py +14 -2
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/dashboard/__main__.py +28 -8
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/dashboard/routes.py +24 -7
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/mcp/__main__.py +7 -0
- dmint-2.0.4/src/dmint/mcp/_stdlib_mcp.py +758 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/mcp/auth.py +1 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/mcp/client.py +28 -5
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/mcp/config_loader.py +28 -2
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/mcp/gateway.py +63 -10
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/mcp/proxy.py +53 -15
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/mcp/ssrf.py +26 -5
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/skills/skill.py +12 -1
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/skills/skills/dmint-policy-manager/SKILL.md +32 -1
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/storage/__init__.py +6 -1
- dmint-2.0.4/src/dmint/templates/__init__.py +177 -0
- dmint-2.0.4/src/dmint/templates/data/aws.json +113 -0
- dmint-2.0.4/src/dmint/templates/data/claude-code.json +5018 -0
- dmint-2.0.4/src/dmint/templates/data/cline.json +5004 -0
- dmint-2.0.4/src/dmint/templates/data/codex.json +5099 -0
- dmint-2.0.4/src/dmint/templates/data/cursor.json +6288 -0
- dmint-2.0.4/src/dmint/templates/data/filesystem.json +1384 -0
- dmint-2.0.4/src/dmint/templates/data/github.json +107 -0
- dmint-2.0.4/src/dmint/templates/data/kubernetes.json +107 -0
- dmint-2.0.4/src/dmint/templates/data/opencode.json +3249 -0
- dmint-2.0.4/src/dmint/templates/data/postgres.json +83 -0
- dmint-2.0.4/src/dmint/templates/data/shell.json +663 -0
- dmint-2.0.4/src/dmint/templates/data/stripe.json +125 -0
- dmint-2.0.4/src/dmint/templates/data/windsurf.json +5005 -0
- dmint-2.0.4/src/dmint/templates/py.typed +1 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/version.py +5 -5
- dmint-2.0.2/README.md → dmint-2.0.4/src/dmint.egg-info/PKG-INFO +196 -23
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint.egg-info/SOURCES.txt +22 -1
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint.egg-info/requires.txt +8 -8
- dmint-2.0.2/src/dmint/cli/__init__.py +0 -74
- dmint-2.0.2/src/dmint/cli/__main__.py +0 -224
- dmint-2.0.2/src/dmint/cli/keys.py +0 -164
- dmint-2.0.2/src/dmint/cli/policy_digest.py +0 -37
- {dmint-2.0.2 → dmint-2.0.4}/LICENSE +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/setup.cfg +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/setup.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/approvals.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/authority.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/canonicalize.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/cli/api.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/cli/dashboard.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/cli/errors.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/cli/io_utils.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/cli/limits.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/cli/prompts/__init__.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/cli/py.typed +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/cli/version.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/approvals.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/authority.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/canonicalize.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/constraints.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/hashing.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/keys.py +4 -4
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/models.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/py.typed +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/redaction.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/request_binding.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/storage/postgres_schema.sql +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/verification.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/versions.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/core/webhooks.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/dashboard/__init__.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/dashboard/app.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/dashboard/auth.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/dashboard/core_client.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/dashboard/py.typed +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/dashboard/static/favicon.svg +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/dashboard/static/logo.svg +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/dashboard/static/style.css +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/dashboard/static/theme.js +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/dashboard/templates/approval.html +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/dashboard/templates/audit.html +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/dashboard/templates/base.html +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/dashboard/templates/error.html +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/dashboard/templates/index.html +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/dashboard/templates/login.html +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/enforcement.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/errors.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/hashing.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/mcp/__init__.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/mcp/config.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/mcp/errors.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/mcp/mapper.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/mcp/py.typed +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/models.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/policy.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/py.typed +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/request_binding.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/skills/__init__.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/skills/manager.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/skills/py.typed +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/skills/version.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/storage/sqlite.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint/versions.py +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint.egg-info/dependency_links.txt +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint.egg-info/entry_points.txt +0 -0
- {dmint-2.0.2 → dmint-2.0.4}/src/dmint.egg-info/top_level.txt +0 -0
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dmint
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.4
|
|
4
4
|
Summary: Deterministic authorization and security enforcement for AI-agent tool execution
|
|
5
5
|
Author: Dmint Authors
|
|
6
6
|
License-Expression: Apache-2.0
|
|
7
|
-
|
|
7
|
+
Project-URL: Homepage, https://github.com/dmint-app/dmint
|
|
8
|
+
Project-URL: Documentation, https://docs.dmint.app
|
|
9
|
+
Project-URL: Repository, https://github.com/dmint-app/dmint
|
|
10
|
+
Project-URL: Issues, https://github.com/dmint-app/dmint/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/dmint-app/dmint/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: ai-agents,mcp,model-context-protocol,security,authorization,claude-code,codex,opencode,cursor,windsurf,cline,ed25519,rfc8785
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
8
14
|
Classifier: Environment :: Console
|
|
9
15
|
Classifier: Intended Audience :: Developers
|
|
10
16
|
Classifier: Operating System :: OS Independent
|
|
@@ -18,24 +24,24 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
18
24
|
Requires-Python: >=3.10
|
|
19
25
|
Description-Content-Type: text/markdown
|
|
20
26
|
License-File: LICENSE
|
|
21
|
-
Requires-Dist: cryptography<
|
|
27
|
+
Requires-Dist: cryptography<52,>=50.0.0
|
|
22
28
|
Requires-Dist: rfc8785<0.2,>=0.1.2
|
|
23
29
|
Requires-Dist: questionary<3.0.0,>=2.0.0
|
|
24
30
|
Requires-Dist: sqlalchemy<3.0.0,>=2.0.0
|
|
25
31
|
Provides-Extra: postgres
|
|
26
|
-
Requires-Dist: psycopg2-binary>=2.9.
|
|
27
|
-
Requires-Dist: psycopg[binary]>=3.1.
|
|
32
|
+
Requires-Dist: psycopg2-binary>=2.9.9; extra == "postgres"
|
|
33
|
+
Requires-Dist: psycopg[binary]>=3.1.18; extra == "postgres"
|
|
28
34
|
Provides-Extra: mcp
|
|
29
35
|
Requires-Dist: mcp<3.0.0,>=2.2.0; extra == "mcp"
|
|
30
36
|
Requires-Dist: anyio>=4.9; extra == "mcp"
|
|
31
|
-
Requires-Dist: starlette>=0.
|
|
37
|
+
Requires-Dist: starlette>=0.40.0; extra == "mcp"
|
|
32
38
|
Requires-Dist: uvicorn>=0.31; extra == "mcp"
|
|
33
|
-
Requires-Dist: httpx2<3.0.0,>=2.
|
|
39
|
+
Requires-Dist: httpx2<3.0.0,>=2.12.0; extra == "mcp"
|
|
34
40
|
Provides-Extra: dashboard
|
|
35
|
-
Requires-Dist: fastapi<1.0,>=0.
|
|
41
|
+
Requires-Dist: fastapi<1.0,>=0.116.0; extra == "dashboard"
|
|
36
42
|
Requires-Dist: uvicorn[standard]<1.0,>=0.31; extra == "dashboard"
|
|
37
|
-
Requires-Dist: jinja2<4.0,>=3.1; extra == "dashboard"
|
|
38
|
-
Requires-Dist: python-multipart<1.0,>=0.0.
|
|
43
|
+
Requires-Dist: jinja2<4.0,>=3.1.6; extra == "dashboard"
|
|
44
|
+
Requires-Dist: python-multipart<1.0,>=0.0.20; extra == "dashboard"
|
|
39
45
|
Provides-Extra: all
|
|
40
46
|
Requires-Dist: dmint[dashboard,mcp,postgres]; extra == "all"
|
|
41
47
|
Provides-Extra: dev
|
|
@@ -132,7 +138,7 @@ Modern AI agents (Claude Code, Cursor, Antigravity, AutoGPT, custom LangChain/Ll
|
|
|
132
138
|
|
|
133
139
|
## Subsystems
|
|
134
140
|
|
|
135
|
-
`dmint` v2.0.
|
|
141
|
+
`dmint` v2.0.4 is organized as a unified monorepo providing modular packages under a single distribution:
|
|
136
142
|
|
|
137
143
|
| Module | Description | Primary Exports / Entrypoint |
|
|
138
144
|
| :--- | :--- | :--- |
|
|
@@ -173,8 +179,99 @@ pip install "dmint[all]"
|
|
|
173
179
|
|
|
174
180
|
---
|
|
175
181
|
|
|
182
|
+
## 10-Second Live Proof (Zero Configuration)
|
|
183
|
+
|
|
184
|
+
Want to see Dmint defeat 7 real-world AI agent attacks (compound shell smuggling, symlink escape, multi-file patch smuggling, Ed25519 single-use approval, post-approval parameter tampering, and replay/key forgery) right in your terminal?
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
pip install dmint
|
|
188
|
+
dmint demo
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## 60-Second Quickstart: Coding Agents (Claude Code, Codex, OpenCode, Cursor, Windsurf, Cline)
|
|
194
|
+
|
|
195
|
+
Protect built-in shell commands (`Bash`, `exec_command`, `run_commands`), file edits (`Read`, `Write`, `Edit`, `apply_patch`), and MCP tools across all 6 major AI coding harnesses with one command:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# Generates .dmint/ keys (0600), dedicated per-harness policies (.dmint/policies/<harness>.policy.json), and hooks:
|
|
199
|
+
dmint init --harness all
|
|
200
|
+
|
|
201
|
+
# Verify cryptographic engine, keys, per-harness policies, hooks, and 4 built-in security vectors:
|
|
202
|
+
dmint doctor
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Supported harnesses out of the box (`--harness all` or comma-separated):
|
|
206
|
+
- **Claude Code** (`.claude/settings.json` `PreToolUse` hook)
|
|
207
|
+
- **OpenAI Codex CLI** (`.codex/hooks.json` & `.codex/dmint-hook.sh`)
|
|
208
|
+
- **OpenCode** (`.opencode/plugin/dmint-guard.ts` `tool.execute.before` plugin)
|
|
209
|
+
- **Cursor** (`.cursor/hooks.json`), **Windsurf** (`.windsurf/hooks.json`), **Cline / Roo Code** (`.clinerules/hooks.json`)
|
|
210
|
+
|
|
211
|
+
Test how your `policy.json` evaluates any command right from the terminal:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
dmint check -t shell.execute -r "git status" # -> ALLOW (exit 0)
|
|
215
|
+
dmint check -t shell.execute -r "git push origin main" # -> APPROVAL_REQUIRED (exit 1)
|
|
216
|
+
dmint check -t shell.execute -r "rm -rf /" # -> DENY (exit 2)
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
When an agent hits an `APPROVAL_REQUIRED` rule (like `git push origin main`), approve it once from your terminal and ask the agent to retry:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
dmint pending
|
|
223
|
+
dmint approve apr_... --by alice@company.com
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
The next retry automatically verifies the Ed25519 signature against the exact RFC 8785 canonicalized arguments and consumes the approval atomically (`APPROVED -> CONSUMED`). Editing any argument or replaying the call a second time is refused.
|
|
227
|
+
|
|
228
|
+
Inspect and verify the tamper-evident SHA-256 hash-chained audit trail of every tool call your agent made:
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
dmint logs # View color-coded audit table
|
|
232
|
+
dmint logs --denied # View only blocked (DENY) tool calls
|
|
233
|
+
dmint logs --verify # Cryptographically verify the SHA-256 hash chain
|
|
234
|
+
dmint logs --follow # Live-tail agent tool calls in real time
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
> **Zero-Friction Onboarding (Shadow Mode & Auto-Learn Policy)**: Want to observe what your coding agent does before blocking anything? Run hooks with `--mode shadow` (or `export DMINT_MODE=shadow`), then synthesize a verified least-privilege `policy.json` from your real session logs with `dmint learn-policy`.
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
176
241
|
## Quickstart: Python SDK
|
|
177
242
|
|
|
243
|
+
### Option A: Zero-Config Local Setup (`Dmint.local`)
|
|
244
|
+
|
|
245
|
+
For local agents and quick evaluation, `Dmint.local()` automatically creates `.dmint/signing.key`, `.dmint/integrity.key`, and `.dmint/approvals.sqlite3`:
|
|
246
|
+
|
|
247
|
+
```python
|
|
248
|
+
from dmint import ApprovalRequiredError, Dmint, Policy, Rule
|
|
249
|
+
|
|
250
|
+
policy = Policy(
|
|
251
|
+
[
|
|
252
|
+
Rule.allow("database", "select"),
|
|
253
|
+
Rule.approval_required("database", "update"),
|
|
254
|
+
Rule.deny("database", "drop"),
|
|
255
|
+
]
|
|
256
|
+
)
|
|
257
|
+
dmint = Dmint.local(policy)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
@dmint.protect("database.update")
|
|
261
|
+
def update_user_role(user_id: int, role: str) -> str:
|
|
262
|
+
return f"Updated user {user_id} to {role}"
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
try:
|
|
266
|
+
update_user_role(1, "admin")
|
|
267
|
+
except ApprovalRequiredError as exc:
|
|
268
|
+
print(f"Paused for human sign-off: dmint approve {exc.approval_id}")
|
|
269
|
+
# After running `dmint approve <id>`, retry without manually passing the credential bytes:
|
|
270
|
+
# dmint.retry(update_user_role, 1, "admin")
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Option B: Explicit Production Configuration
|
|
274
|
+
|
|
178
275
|
Dmint's approval store is tamper-evident: pending records are HMAC-signed with a local integrity key, and approvals are signed with an Ed25519 key. Generate both once before running the example:
|
|
179
276
|
|
|
180
277
|
```bash
|
|
@@ -214,7 +311,7 @@ store = SQLiteApprovalStore("./approvals.sqlite3", deployment_epoch="prod-v1")
|
|
|
214
311
|
provenance = PolicyProvenance("prod-v1", policy_digest(policy), datetime.now(timezone.utc))
|
|
215
312
|
|
|
216
313
|
# 3. Initialize Dmint enforcement engine
|
|
217
|
-
|
|
314
|
+
dmint = Dmint(
|
|
218
315
|
policy=policy,
|
|
219
316
|
agent_id="data-analyst-agent",
|
|
220
317
|
context=TrustedContext({"environment": "production"}),
|
|
@@ -225,17 +322,17 @@ engine = Dmint(
|
|
|
225
322
|
|
|
226
323
|
|
|
227
324
|
# 4. Protect your tool callables with decorators
|
|
228
|
-
@
|
|
325
|
+
@dmint.protect("database.select")
|
|
229
326
|
def select_users(query: str) -> list[dict]:
|
|
230
327
|
return [{"id": 1, "username": "alice"}]
|
|
231
328
|
|
|
232
329
|
|
|
233
|
-
@
|
|
330
|
+
@dmint.protect("database.update")
|
|
234
331
|
def update_user_role(user_id: int, role: str) -> str:
|
|
235
332
|
return f"Updated user {user_id} to {role}"
|
|
236
333
|
|
|
237
334
|
|
|
238
|
-
@
|
|
335
|
+
@dmint.protect("database.drop")
|
|
239
336
|
def drop_table(table_name: str) -> str:
|
|
240
337
|
return f"Dropped {table_name}"
|
|
241
338
|
|
|
@@ -261,7 +358,7 @@ except ApprovalRequiredError as exc:
|
|
|
261
358
|
```
|
|
262
359
|
|
|
263
360
|
> [!NOTE]
|
|
264
|
-
> **Supported callable types**: `@
|
|
361
|
+
> **Supported callable types**: `@dmint.protect` supports synchronous functions (`def`), asynchronous functions (`async def`), instance methods, class methods (`@classmethod`), and static methods (`@staticmethod`). Generator and async-generator functions are not supported.
|
|
265
362
|
>
|
|
266
363
|
> **Measured Performance**: In-memory policy evaluation runs in ~3 µs; persistent storage operations (SQLite/PostgreSQL approval lifecycle) take ~2-5 ms.
|
|
267
364
|
|
|
@@ -352,19 +449,27 @@ Add Dmint MCP as a stdio server in your client configuration (e.g. `.cursor/mcp.
|
|
|
352
449
|
|
|
353
450
|
| Command | Usage | Description |
|
|
354
451
|
| :--- | :--- | :--- |
|
|
355
|
-
| `dmint
|
|
356
|
-
| `dmint
|
|
452
|
+
| `dmint init` | `dmint init --harness all` | One-command setup: generates `.dmint/` keys, per-harness policies (`.dmint/policies/*.policy.json`), and pre-tool hooks. |
|
|
453
|
+
| `dmint doctor` | `dmint doctor [--json]` | Verifies Ed25519/HMAC crypto, keys (`0600`), SQLite store, per-harness policies, hooks, and runs a 4-vector security self-test. |
|
|
454
|
+
| `dmint status` | `dmint status [--json]` | Displays installed coding-agent hooks, per-harness policy paths, and key status. |
|
|
455
|
+
| `dmint demo` | `dmint demo [--json]` | Runs a live 7-scenario red-team attack & cryptographic simulation (`dmint redteam` alias). |
|
|
456
|
+
| `dmint logs` | `dmint logs [--level WARNING] [--verify]` | Inspects, filters, tails (`-f`), exports, and verifies the SHA-256 hash-chained audit trail (`dmint audit` alias). |
|
|
457
|
+
| `dmint learn-policy` | `dmint learn-policy [-o policy.json]` | Auto-learns a verified least-privilege `policy.json` from `.dmint/audit.jsonl` (Shadow or Enforce mode). |
|
|
458
|
+
| `dmint check` | `dmint check shell.execute -r "git status"` | Simulates a tool call against `policy.json` (`ALLOW` / `APPROVAL_REQUIRED` / `DENY`) via positional `<tool.action>` or `-t`/`-a`. |
|
|
459
|
+
| `dmint hook` | `dmint hook <install\|list\|status\|run\|uninstall>` | Manages and runs pre-tool hooks for Claude Code, Codex, OpenCode, Cursor, Windsurf, and Cline. |
|
|
460
|
+
| `dmint create-policy` | `dmint create-policy [-t\|-r\|-i\|-p\|-f] -o policy.json` | Creates a verified `policy.json` via 4 modes: `--template` (`-t`), `--rule` (`-r`), `--interactive` (`-i`), or AI prompt (`-p`/`-f`). |
|
|
461
|
+
| `dmint create-mcp-policy` | `dmint create-mcp-policy --command npx ... [--offline]` | Discovers live MCP server tools, pins SHA-256 `schema_hash` digests, and writes `policy.json` + `mcp_protection.json` (offline or AI). |
|
|
357
462
|
| `dmint protect-mcp` | `dmint protect-mcp --url https://api.example.com/mcp` | Compatibility alias for `dmint create-mcp-policy` (identical options). |
|
|
358
|
-
| `dmint verify-policy` | `dmint verify-policy policy.json` | 100% offline schema and
|
|
359
|
-
| `dmint policy-digest` | `dmint policy-digest policy.json` | Computes the SHA-256 digest of the exact policy file bytes (for `DMINT_EXPECTED_POLICY_DIGEST`). |
|
|
360
|
-
| `dmint compile-policy` | `dmint compile-policy -f access.md -o policy.json` | [Compatibility] Legacy LLM
|
|
361
|
-
| `dmint pending` | `dmint pending` | Lists all approval requests currently in `PENDING` state across SQLite or PostgreSQL. |
|
|
362
|
-
| `dmint approve` | `dmint approve <id>
|
|
363
|
-
| `dmint reject` | `dmint reject <id> [--reason "..."]` | Marks a pending request as `REJECTED` with an optional audit reason. |
|
|
364
|
-
| `dmint dashboard` | `dmint dashboard --db-path ./approvals.sqlite3` | Launches the local human approval web dashboard (FastAPI). |
|
|
463
|
+
| `dmint verify-policy` | `dmint verify-policy policy.json [--json]` | 100% offline schema, capability, and invariant validation. Zero network, zero LLM. |
|
|
464
|
+
| `dmint policy-digest` | `dmint policy-digest policy.json [--json]` | Computes the SHA-256 digest of the exact policy file bytes (for `DMINT_EXPECTED_POLICY_DIGEST`). |
|
|
465
|
+
| `dmint compile-policy` | `dmint compile-policy -f access.md -o policy.json` | [Compatibility] Legacy LLM batch compiler delegating to `create-policy` non-interactive mode. |
|
|
466
|
+
| `dmint pending` | `dmint pending [--json]` | Lists all approval requests currently in `PENDING` state across SQLite or PostgreSQL. |
|
|
467
|
+
| `dmint approve` | `dmint approve <id> --by alice@company.com` | Signs and approves a pending request via Core Ed25519 primitives after policy re-verification. |
|
|
468
|
+
| `dmint reject` / `deny` | `dmint reject <id> [--reason "..."]` | Marks a pending request as `REJECTED` with an optional audit reason (`dmint deny` is an alias). |
|
|
469
|
+
| `dmint dashboard` | `dmint dashboard --db-path ./approvals.sqlite3` | Launches the local authenticated human approval web dashboard (FastAPI). |
|
|
365
470
|
| `dmint install-skill` | `dmint install-skill -y` | Installs the `dmint-policy-manager` skill into `.agents/skills/` for AI coding assistants. |
|
|
366
|
-
| `dmint init-keys` | `dmint init-keys` | Generates and persists Ed25519 signing and HMAC integrity keys (`0600`, atomic). |
|
|
367
|
-
| `dmint export-public-key` | `dmint export-public-key --
|
|
471
|
+
| `dmint init-keys` | `dmint init-keys [--dir <path>]` | Generates and persists Ed25519 signing and HMAC integrity keys (`0600`, atomic). |
|
|
472
|
+
| `dmint export-public-key` | `dmint export-public-key [--dir <path>] [--json]` | Prints the public key (hex + PEM + JSON) and issuer ID for gateway `trusted_issuers`. |
|
|
368
473
|
|
|
369
474
|
---
|
|
370
475
|
|
|
@@ -386,6 +491,17 @@ export DMINT_TEAMS_WEBHOOK_URL="https://example.webhook.office.com/webhookb2/...
|
|
|
386
491
|
> **TODO (Approver Environment)**: Because `--database-url` credentials are strictly stripped from outgoing webhook notifications to prevent credential leakage in chat channels, approvers executing `dmint approve <id>` must ensure the `DMINT_DATABASE_URL` environment variable is configured in their execution environment if using a remote PostgreSQL store.
|
|
387
492
|
|
|
388
493
|
|
|
494
|
+
---
|
|
495
|
+
|
|
496
|
+
## When to Use Dmint (and When to Pick Something Else)
|
|
497
|
+
|
|
498
|
+
| If you... | Use | Why |
|
|
499
|
+
| :--- | :--- | :--- |
|
|
500
|
+
| **Need self-hosted, Ed25519-signed, single-use human sign-off on high-risk actions in Python, MCP, or coding-agent hooks** | **Dmint** | Approvals are cryptographically bound to exact RFC 8785 arguments, usable once (`PENDING -> APPROVED -> CONSUMED`), and voided if `policy.json` changes. |
|
|
501
|
+
| Run entirely on AWS Bedrock AgentCore | AWS AgentCore Policy | Managed Cedar policy enforcement at the AWS gateway with zero infrastructure to host. |
|
|
502
|
+
| Need broad multi-language governance across Go, .NET, Java, and Rust | Microsoft Agent Governance Toolkit / Cerbos | Multi-language SDKs and centralized policy decision points (PDPs). |
|
|
503
|
+
| Need prompt-injection classification, toxicity filtering, or PII redaction | LLM Guardrails (Llama Guard, NeMo) | Dmint is a deterministic capability and argument gate—never a text classifier. |
|
|
504
|
+
|
|
389
505
|
---
|
|
390
506
|
|
|
391
507
|
## Security Invariants
|
|
@@ -416,7 +532,7 @@ For complete vulnerability reporting guidelines and threat boundaries, see [SECU
|
|
|
416
532
|
> 4. **Dashboard Token Theft**: Reading the dashboard token from configuration files or `/proc/<pid>/environ`.
|
|
417
533
|
> 5. **Client Configuration Replacement**: Overwriting `.cursor/mcp.json` or client settings to bypass `dmint-mcp` entirely and talk to unprotected tools directly.
|
|
418
534
|
>
|
|
419
|
-
> **Protection Guarantee**: Dmint's cryptographic security boundary holds **strictly when the AI agent process runs under a different OS user or in an isolated container** with no filesystem access to Dmint keys, policies, or stores. See [docs/
|
|
535
|
+
> **Protection Guarantee**: Dmint's cryptographic security boundary holds **strictly when the AI agent process runs under a different OS user or in an isolated container** with no filesystem access to Dmint keys, policies, or stores. See [**`PRODUCTION_SECURITY_GUIDE.md`**](PRODUCTION_SECURITY_GUIDE.md) and [`docs/operations/production-proof.mdx`](docs/operations/production-proof.mdx) for complete step-by-step production key separation, `chattr +i` policy locking, and 3-zone container blueprints.
|
|
420
536
|
|
|
421
537
|
---
|
|
422
538
|
|
|
@@ -506,10 +622,10 @@ python3 -m venv /tmp/dmint-test-env
|
|
|
506
622
|
source /tmp/dmint-test-env/bin/activate
|
|
507
623
|
|
|
508
624
|
# Install the wheel with all extras
|
|
509
|
-
pip install "dist/dmint-2.0.
|
|
625
|
+
pip install "dist/dmint-2.0.4-py3-none-any.whl[all]"
|
|
510
626
|
|
|
511
627
|
# 4. Verify all installed CLI entrypoints
|
|
512
|
-
dmint --version # Expected: dmint 2.0.
|
|
628
|
+
dmint --version # Expected: dmint 2.0.4
|
|
513
629
|
dmint --help # Policy wizards and verification commands
|
|
514
630
|
dmint-mcp --help # MCP multi-server gateway
|
|
515
631
|
dmint-dashboard --help # Approval web review console
|
|
@@ -567,6 +683,7 @@ npm start
|
|
|
567
683
|
- [`PLAIN.md`](PLAIN.md) — Deep architectural specification, state machine proofs, and 15-section security review checklist.
|
|
568
684
|
- [`.agents/skills/`](.agents/skills/) — AI coding agent skills for security reviews, policy authoring, and adversarial testing.
|
|
569
685
|
- [`CONTRIBUTING.md`](CONTRIBUTING.md) — Community contribution guidelines, Conventional Commits format, and PR process.
|
|
686
|
+
- [`PRODUCTION_SECURITY_GUIDE.md`](PRODUCTION_SECURITY_GUIDE.md) — Complete production proof, Ed25519 private/public key placement, HMAC integrity keys, and 3-zone deployment blueprints.
|
|
570
687
|
- [`SECURITY.md`](SECURITY.md) — Security policy, threat boundary definitions, and vulnerability reporting.
|
|
571
688
|
|
|
572
689
|
---
|
|
@@ -577,9 +694,9 @@ Dmint adheres strictly to **[Semantic Versioning 2.0.0](https://semver.org/)** a
|
|
|
577
694
|
|
|
578
695
|
| Change severity | SemVer bump | Typical changes |
|
|
579
696
|
|---|---|---|
|
|
580
|
-
| **High / Major** | `2.0.
|
|
581
|
-
| **Medium / Minor** | `2.0.
|
|
582
|
-
| **Low / Patch** | `2.0.
|
|
697
|
+
| **High / Major** | `2.0.4` → `3.0.0` | Incompatible API changes, breaking policy schema modifications, removed public methods. |
|
|
698
|
+
| **Medium / Minor** | `2.0.4` → `2.1.0` | Backwards-compatible features, new CLI flags, new integrations. |
|
|
699
|
+
| **Low / Patch** | `2.0.4` → `2.0.5` | Bug fixes, security hardening, documentation updates, test additions, non-breaking refactors. |
|
|
583
700
|
|
|
584
701
|
Every push must include the appropriate version decision and bump. A push carrying any Major change is Major; otherwise any Minor change makes it Minor; otherwise it is Patch. When severity is ambiguous, choose the higher severity and ask before a Major bump.
|
|
585
702
|
|
|
@@ -1,59 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: dmint
|
|
3
|
-
Version: 2.0.2
|
|
4
|
-
Summary: Deterministic authorization and security enforcement for AI-agent tool execution
|
|
5
|
-
Author: Dmint Authors
|
|
6
|
-
License-Expression: Apache-2.0
|
|
7
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
8
|
-
Classifier: Environment :: Console
|
|
9
|
-
Classifier: Intended Audience :: Developers
|
|
10
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
-
Classifier: Topic :: Security
|
|
17
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
-
Requires-Python: >=3.10
|
|
19
|
-
Description-Content-Type: text/markdown
|
|
20
|
-
License-File: LICENSE
|
|
21
|
-
Requires-Dist: cryptography<51,>=42
|
|
22
|
-
Requires-Dist: rfc8785<0.2,>=0.1.2
|
|
23
|
-
Requires-Dist: questionary<3.0.0,>=2.0.0
|
|
24
|
-
Requires-Dist: sqlalchemy<3.0.0,>=2.0.0
|
|
25
|
-
Provides-Extra: postgres
|
|
26
|
-
Requires-Dist: psycopg2-binary>=2.9.0; extra == "postgres"
|
|
27
|
-
Requires-Dist: psycopg[binary]>=3.1.0; extra == "postgres"
|
|
28
|
-
Provides-Extra: mcp
|
|
29
|
-
Requires-Dist: mcp<3.0.0,>=2.2.0; extra == "mcp"
|
|
30
|
-
Requires-Dist: anyio>=4.9; extra == "mcp"
|
|
31
|
-
Requires-Dist: starlette>=0.27; extra == "mcp"
|
|
32
|
-
Requires-Dist: uvicorn>=0.31; extra == "mcp"
|
|
33
|
-
Requires-Dist: httpx2<3.0.0,>=2.5; extra == "mcp"
|
|
34
|
-
Provides-Extra: dashboard
|
|
35
|
-
Requires-Dist: fastapi<1.0,>=0.110; extra == "dashboard"
|
|
36
|
-
Requires-Dist: uvicorn[standard]<1.0,>=0.31; extra == "dashboard"
|
|
37
|
-
Requires-Dist: jinja2<4.0,>=3.1; extra == "dashboard"
|
|
38
|
-
Requires-Dist: python-multipart<1.0,>=0.0.9; extra == "dashboard"
|
|
39
|
-
Provides-Extra: all
|
|
40
|
-
Requires-Dist: dmint[dashboard,mcp,postgres]; extra == "all"
|
|
41
|
-
Provides-Extra: dev
|
|
42
|
-
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
43
|
-
Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
|
|
44
|
-
Requires-Dist: ruff>=0.4.0; extra == "dev"
|
|
45
|
-
Requires-Dist: mypy>=1.10.0; extra == "dev"
|
|
46
|
-
Requires-Dist: build; extra == "dev"
|
|
47
|
-
Requires-Dist: twine; extra == "dev"
|
|
48
|
-
Requires-Dist: pre-commit>=3.7.0; extra == "dev"
|
|
49
|
-
Requires-Dist: commitizen>=3.29.0; extra == "dev"
|
|
50
|
-
Requires-Dist: dmint[all]; extra == "dev"
|
|
51
|
-
Provides-Extra: test
|
|
52
|
-
Requires-Dist: pytest>=8.0.0; extra == "test"
|
|
53
|
-
Requires-Dist: pytest-cov>=5.0.0; extra == "test"
|
|
54
|
-
Requires-Dist: dmint[all]; extra == "test"
|
|
55
|
-
Dynamic: license-file
|
|
56
|
-
|
|
57
1
|
<div align="center">
|
|
58
2
|
|
|
59
3
|
<img src="assets/logo.svg" alt="Dmint Logo" width="100" height="100" />
|
|
@@ -132,7 +76,7 @@ Modern AI agents (Claude Code, Cursor, Antigravity, AutoGPT, custom LangChain/Ll
|
|
|
132
76
|
|
|
133
77
|
## Subsystems
|
|
134
78
|
|
|
135
|
-
`dmint` v2.0.
|
|
79
|
+
`dmint` v2.0.4 is organized as a unified monorepo providing modular packages under a single distribution:
|
|
136
80
|
|
|
137
81
|
| Module | Description | Primary Exports / Entrypoint |
|
|
138
82
|
| :--- | :--- | :--- |
|
|
@@ -173,8 +117,99 @@ pip install "dmint[all]"
|
|
|
173
117
|
|
|
174
118
|
---
|
|
175
119
|
|
|
120
|
+
## 10-Second Live Proof (Zero Configuration)
|
|
121
|
+
|
|
122
|
+
Want to see Dmint defeat 7 real-world AI agent attacks (compound shell smuggling, symlink escape, multi-file patch smuggling, Ed25519 single-use approval, post-approval parameter tampering, and replay/key forgery) right in your terminal?
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
pip install dmint
|
|
126
|
+
dmint demo
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 60-Second Quickstart: Coding Agents (Claude Code, Codex, OpenCode, Cursor, Windsurf, Cline)
|
|
132
|
+
|
|
133
|
+
Protect built-in shell commands (`Bash`, `exec_command`, `run_commands`), file edits (`Read`, `Write`, `Edit`, `apply_patch`), and MCP tools across all 6 major AI coding harnesses with one command:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# Generates .dmint/ keys (0600), dedicated per-harness policies (.dmint/policies/<harness>.policy.json), and hooks:
|
|
137
|
+
dmint init --harness all
|
|
138
|
+
|
|
139
|
+
# Verify cryptographic engine, keys, per-harness policies, hooks, and 4 built-in security vectors:
|
|
140
|
+
dmint doctor
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Supported harnesses out of the box (`--harness all` or comma-separated):
|
|
144
|
+
- **Claude Code** (`.claude/settings.json` `PreToolUse` hook)
|
|
145
|
+
- **OpenAI Codex CLI** (`.codex/hooks.json` & `.codex/dmint-hook.sh`)
|
|
146
|
+
- **OpenCode** (`.opencode/plugin/dmint-guard.ts` `tool.execute.before` plugin)
|
|
147
|
+
- **Cursor** (`.cursor/hooks.json`), **Windsurf** (`.windsurf/hooks.json`), **Cline / Roo Code** (`.clinerules/hooks.json`)
|
|
148
|
+
|
|
149
|
+
Test how your `policy.json` evaluates any command right from the terminal:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
dmint check -t shell.execute -r "git status" # -> ALLOW (exit 0)
|
|
153
|
+
dmint check -t shell.execute -r "git push origin main" # -> APPROVAL_REQUIRED (exit 1)
|
|
154
|
+
dmint check -t shell.execute -r "rm -rf /" # -> DENY (exit 2)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
When an agent hits an `APPROVAL_REQUIRED` rule (like `git push origin main`), approve it once from your terminal and ask the agent to retry:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
dmint pending
|
|
161
|
+
dmint approve apr_... --by alice@company.com
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
The next retry automatically verifies the Ed25519 signature against the exact RFC 8785 canonicalized arguments and consumes the approval atomically (`APPROVED -> CONSUMED`). Editing any argument or replaying the call a second time is refused.
|
|
165
|
+
|
|
166
|
+
Inspect and verify the tamper-evident SHA-256 hash-chained audit trail of every tool call your agent made:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
dmint logs # View color-coded audit table
|
|
170
|
+
dmint logs --denied # View only blocked (DENY) tool calls
|
|
171
|
+
dmint logs --verify # Cryptographically verify the SHA-256 hash chain
|
|
172
|
+
dmint logs --follow # Live-tail agent tool calls in real time
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
> **Zero-Friction Onboarding (Shadow Mode & Auto-Learn Policy)**: Want to observe what your coding agent does before blocking anything? Run hooks with `--mode shadow` (or `export DMINT_MODE=shadow`), then synthesize a verified least-privilege `policy.json` from your real session logs with `dmint learn-policy`.
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
176
179
|
## Quickstart: Python SDK
|
|
177
180
|
|
|
181
|
+
### Option A: Zero-Config Local Setup (`Dmint.local`)
|
|
182
|
+
|
|
183
|
+
For local agents and quick evaluation, `Dmint.local()` automatically creates `.dmint/signing.key`, `.dmint/integrity.key`, and `.dmint/approvals.sqlite3`:
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
from dmint import ApprovalRequiredError, Dmint, Policy, Rule
|
|
187
|
+
|
|
188
|
+
policy = Policy(
|
|
189
|
+
[
|
|
190
|
+
Rule.allow("database", "select"),
|
|
191
|
+
Rule.approval_required("database", "update"),
|
|
192
|
+
Rule.deny("database", "drop"),
|
|
193
|
+
]
|
|
194
|
+
)
|
|
195
|
+
dmint = Dmint.local(policy)
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
@dmint.protect("database.update")
|
|
199
|
+
def update_user_role(user_id: int, role: str) -> str:
|
|
200
|
+
return f"Updated user {user_id} to {role}"
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
try:
|
|
204
|
+
update_user_role(1, "admin")
|
|
205
|
+
except ApprovalRequiredError as exc:
|
|
206
|
+
print(f"Paused for human sign-off: dmint approve {exc.approval_id}")
|
|
207
|
+
# After running `dmint approve <id>`, retry without manually passing the credential bytes:
|
|
208
|
+
# dmint.retry(update_user_role, 1, "admin")
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Option B: Explicit Production Configuration
|
|
212
|
+
|
|
178
213
|
Dmint's approval store is tamper-evident: pending records are HMAC-signed with a local integrity key, and approvals are signed with an Ed25519 key. Generate both once before running the example:
|
|
179
214
|
|
|
180
215
|
```bash
|
|
@@ -214,7 +249,7 @@ store = SQLiteApprovalStore("./approvals.sqlite3", deployment_epoch="prod-v1")
|
|
|
214
249
|
provenance = PolicyProvenance("prod-v1", policy_digest(policy), datetime.now(timezone.utc))
|
|
215
250
|
|
|
216
251
|
# 3. Initialize Dmint enforcement engine
|
|
217
|
-
|
|
252
|
+
dmint = Dmint(
|
|
218
253
|
policy=policy,
|
|
219
254
|
agent_id="data-analyst-agent",
|
|
220
255
|
context=TrustedContext({"environment": "production"}),
|
|
@@ -225,17 +260,17 @@ engine = Dmint(
|
|
|
225
260
|
|
|
226
261
|
|
|
227
262
|
# 4. Protect your tool callables with decorators
|
|
228
|
-
@
|
|
263
|
+
@dmint.protect("database.select")
|
|
229
264
|
def select_users(query: str) -> list[dict]:
|
|
230
265
|
return [{"id": 1, "username": "alice"}]
|
|
231
266
|
|
|
232
267
|
|
|
233
|
-
@
|
|
268
|
+
@dmint.protect("database.update")
|
|
234
269
|
def update_user_role(user_id: int, role: str) -> str:
|
|
235
270
|
return f"Updated user {user_id} to {role}"
|
|
236
271
|
|
|
237
272
|
|
|
238
|
-
@
|
|
273
|
+
@dmint.protect("database.drop")
|
|
239
274
|
def drop_table(table_name: str) -> str:
|
|
240
275
|
return f"Dropped {table_name}"
|
|
241
276
|
|
|
@@ -261,7 +296,7 @@ except ApprovalRequiredError as exc:
|
|
|
261
296
|
```
|
|
262
297
|
|
|
263
298
|
> [!NOTE]
|
|
264
|
-
> **Supported callable types**: `@
|
|
299
|
+
> **Supported callable types**: `@dmint.protect` supports synchronous functions (`def`), asynchronous functions (`async def`), instance methods, class methods (`@classmethod`), and static methods (`@staticmethod`). Generator and async-generator functions are not supported.
|
|
265
300
|
>
|
|
266
301
|
> **Measured Performance**: In-memory policy evaluation runs in ~3 µs; persistent storage operations (SQLite/PostgreSQL approval lifecycle) take ~2-5 ms.
|
|
267
302
|
|
|
@@ -352,19 +387,27 @@ Add Dmint MCP as a stdio server in your client configuration (e.g. `.cursor/mcp.
|
|
|
352
387
|
|
|
353
388
|
| Command | Usage | Description |
|
|
354
389
|
| :--- | :--- | :--- |
|
|
355
|
-
| `dmint
|
|
356
|
-
| `dmint
|
|
390
|
+
| `dmint init` | `dmint init --harness all` | One-command setup: generates `.dmint/` keys, per-harness policies (`.dmint/policies/*.policy.json`), and pre-tool hooks. |
|
|
391
|
+
| `dmint doctor` | `dmint doctor [--json]` | Verifies Ed25519/HMAC crypto, keys (`0600`), SQLite store, per-harness policies, hooks, and runs a 4-vector security self-test. |
|
|
392
|
+
| `dmint status` | `dmint status [--json]` | Displays installed coding-agent hooks, per-harness policy paths, and key status. |
|
|
393
|
+
| `dmint demo` | `dmint demo [--json]` | Runs a live 7-scenario red-team attack & cryptographic simulation (`dmint redteam` alias). |
|
|
394
|
+
| `dmint logs` | `dmint logs [--level WARNING] [--verify]` | Inspects, filters, tails (`-f`), exports, and verifies the SHA-256 hash-chained audit trail (`dmint audit` alias). |
|
|
395
|
+
| `dmint learn-policy` | `dmint learn-policy [-o policy.json]` | Auto-learns a verified least-privilege `policy.json` from `.dmint/audit.jsonl` (Shadow or Enforce mode). |
|
|
396
|
+
| `dmint check` | `dmint check shell.execute -r "git status"` | Simulates a tool call against `policy.json` (`ALLOW` / `APPROVAL_REQUIRED` / `DENY`) via positional `<tool.action>` or `-t`/`-a`. |
|
|
397
|
+
| `dmint hook` | `dmint hook <install\|list\|status\|run\|uninstall>` | Manages and runs pre-tool hooks for Claude Code, Codex, OpenCode, Cursor, Windsurf, and Cline. |
|
|
398
|
+
| `dmint create-policy` | `dmint create-policy [-t\|-r\|-i\|-p\|-f] -o policy.json` | Creates a verified `policy.json` via 4 modes: `--template` (`-t`), `--rule` (`-r`), `--interactive` (`-i`), or AI prompt (`-p`/`-f`). |
|
|
399
|
+
| `dmint create-mcp-policy` | `dmint create-mcp-policy --command npx ... [--offline]` | Discovers live MCP server tools, pins SHA-256 `schema_hash` digests, and writes `policy.json` + `mcp_protection.json` (offline or AI). |
|
|
357
400
|
| `dmint protect-mcp` | `dmint protect-mcp --url https://api.example.com/mcp` | Compatibility alias for `dmint create-mcp-policy` (identical options). |
|
|
358
|
-
| `dmint verify-policy` | `dmint verify-policy policy.json` | 100% offline schema and
|
|
359
|
-
| `dmint policy-digest` | `dmint policy-digest policy.json` | Computes the SHA-256 digest of the exact policy file bytes (for `DMINT_EXPECTED_POLICY_DIGEST`). |
|
|
360
|
-
| `dmint compile-policy` | `dmint compile-policy -f access.md -o policy.json` | [Compatibility] Legacy LLM
|
|
361
|
-
| `dmint pending` | `dmint pending` | Lists all approval requests currently in `PENDING` state across SQLite or PostgreSQL. |
|
|
362
|
-
| `dmint approve` | `dmint approve <id>
|
|
363
|
-
| `dmint reject` | `dmint reject <id> [--reason "..."]` | Marks a pending request as `REJECTED` with an optional audit reason. |
|
|
364
|
-
| `dmint dashboard` | `dmint dashboard --db-path ./approvals.sqlite3` | Launches the local human approval web dashboard (FastAPI). |
|
|
401
|
+
| `dmint verify-policy` | `dmint verify-policy policy.json [--json]` | 100% offline schema, capability, and invariant validation. Zero network, zero LLM. |
|
|
402
|
+
| `dmint policy-digest` | `dmint policy-digest policy.json [--json]` | Computes the SHA-256 digest of the exact policy file bytes (for `DMINT_EXPECTED_POLICY_DIGEST`). |
|
|
403
|
+
| `dmint compile-policy` | `dmint compile-policy -f access.md -o policy.json` | [Compatibility] Legacy LLM batch compiler delegating to `create-policy` non-interactive mode. |
|
|
404
|
+
| `dmint pending` | `dmint pending [--json]` | Lists all approval requests currently in `PENDING` state across SQLite or PostgreSQL. |
|
|
405
|
+
| `dmint approve` | `dmint approve <id> --by alice@company.com` | Signs and approves a pending request via Core Ed25519 primitives after policy re-verification. |
|
|
406
|
+
| `dmint reject` / `deny` | `dmint reject <id> [--reason "..."]` | Marks a pending request as `REJECTED` with an optional audit reason (`dmint deny` is an alias). |
|
|
407
|
+
| `dmint dashboard` | `dmint dashboard --db-path ./approvals.sqlite3` | Launches the local authenticated human approval web dashboard (FastAPI). |
|
|
365
408
|
| `dmint install-skill` | `dmint install-skill -y` | Installs the `dmint-policy-manager` skill into `.agents/skills/` for AI coding assistants. |
|
|
366
|
-
| `dmint init-keys` | `dmint init-keys` | Generates and persists Ed25519 signing and HMAC integrity keys (`0600`, atomic). |
|
|
367
|
-
| `dmint export-public-key` | `dmint export-public-key --
|
|
409
|
+
| `dmint init-keys` | `dmint init-keys [--dir <path>]` | Generates and persists Ed25519 signing and HMAC integrity keys (`0600`, atomic). |
|
|
410
|
+
| `dmint export-public-key` | `dmint export-public-key [--dir <path>] [--json]` | Prints the public key (hex + PEM + JSON) and issuer ID for gateway `trusted_issuers`. |
|
|
368
411
|
|
|
369
412
|
---
|
|
370
413
|
|
|
@@ -386,6 +429,17 @@ export DMINT_TEAMS_WEBHOOK_URL="https://example.webhook.office.com/webhookb2/...
|
|
|
386
429
|
> **TODO (Approver Environment)**: Because `--database-url` credentials are strictly stripped from outgoing webhook notifications to prevent credential leakage in chat channels, approvers executing `dmint approve <id>` must ensure the `DMINT_DATABASE_URL` environment variable is configured in their execution environment if using a remote PostgreSQL store.
|
|
387
430
|
|
|
388
431
|
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
## When to Use Dmint (and When to Pick Something Else)
|
|
435
|
+
|
|
436
|
+
| If you... | Use | Why |
|
|
437
|
+
| :--- | :--- | :--- |
|
|
438
|
+
| **Need self-hosted, Ed25519-signed, single-use human sign-off on high-risk actions in Python, MCP, or coding-agent hooks** | **Dmint** | Approvals are cryptographically bound to exact RFC 8785 arguments, usable once (`PENDING -> APPROVED -> CONSUMED`), and voided if `policy.json` changes. |
|
|
439
|
+
| Run entirely on AWS Bedrock AgentCore | AWS AgentCore Policy | Managed Cedar policy enforcement at the AWS gateway with zero infrastructure to host. |
|
|
440
|
+
| Need broad multi-language governance across Go, .NET, Java, and Rust | Microsoft Agent Governance Toolkit / Cerbos | Multi-language SDKs and centralized policy decision points (PDPs). |
|
|
441
|
+
| Need prompt-injection classification, toxicity filtering, or PII redaction | LLM Guardrails (Llama Guard, NeMo) | Dmint is a deterministic capability and argument gate—never a text classifier. |
|
|
442
|
+
|
|
389
443
|
---
|
|
390
444
|
|
|
391
445
|
## Security Invariants
|
|
@@ -416,7 +470,7 @@ For complete vulnerability reporting guidelines and threat boundaries, see [SECU
|
|
|
416
470
|
> 4. **Dashboard Token Theft**: Reading the dashboard token from configuration files or `/proc/<pid>/environ`.
|
|
417
471
|
> 5. **Client Configuration Replacement**: Overwriting `.cursor/mcp.json` or client settings to bypass `dmint-mcp` entirely and talk to unprotected tools directly.
|
|
418
472
|
>
|
|
419
|
-
> **Protection Guarantee**: Dmint's cryptographic security boundary holds **strictly when the AI agent process runs under a different OS user or in an isolated container** with no filesystem access to Dmint keys, policies, or stores. See [docs/
|
|
473
|
+
> **Protection Guarantee**: Dmint's cryptographic security boundary holds **strictly when the AI agent process runs under a different OS user or in an isolated container** with no filesystem access to Dmint keys, policies, or stores. See [**`PRODUCTION_SECURITY_GUIDE.md`**](PRODUCTION_SECURITY_GUIDE.md) and [`docs/operations/production-proof.mdx`](docs/operations/production-proof.mdx) for complete step-by-step production key separation, `chattr +i` policy locking, and 3-zone container blueprints.
|
|
420
474
|
|
|
421
475
|
---
|
|
422
476
|
|
|
@@ -506,10 +560,10 @@ python3 -m venv /tmp/dmint-test-env
|
|
|
506
560
|
source /tmp/dmint-test-env/bin/activate
|
|
507
561
|
|
|
508
562
|
# Install the wheel with all extras
|
|
509
|
-
pip install "dist/dmint-2.0.
|
|
563
|
+
pip install "dist/dmint-2.0.4-py3-none-any.whl[all]"
|
|
510
564
|
|
|
511
565
|
# 4. Verify all installed CLI entrypoints
|
|
512
|
-
dmint --version # Expected: dmint 2.0.
|
|
566
|
+
dmint --version # Expected: dmint 2.0.4
|
|
513
567
|
dmint --help # Policy wizards and verification commands
|
|
514
568
|
dmint-mcp --help # MCP multi-server gateway
|
|
515
569
|
dmint-dashboard --help # Approval web review console
|
|
@@ -567,6 +621,7 @@ npm start
|
|
|
567
621
|
- [`PLAIN.md`](PLAIN.md) — Deep architectural specification, state machine proofs, and 15-section security review checklist.
|
|
568
622
|
- [`.agents/skills/`](.agents/skills/) — AI coding agent skills for security reviews, policy authoring, and adversarial testing.
|
|
569
623
|
- [`CONTRIBUTING.md`](CONTRIBUTING.md) — Community contribution guidelines, Conventional Commits format, and PR process.
|
|
624
|
+
- [`PRODUCTION_SECURITY_GUIDE.md`](PRODUCTION_SECURITY_GUIDE.md) — Complete production proof, Ed25519 private/public key placement, HMAC integrity keys, and 3-zone deployment blueprints.
|
|
570
625
|
- [`SECURITY.md`](SECURITY.md) — Security policy, threat boundary definitions, and vulnerability reporting.
|
|
571
626
|
|
|
572
627
|
---
|
|
@@ -577,9 +632,9 @@ Dmint adheres strictly to **[Semantic Versioning 2.0.0](https://semver.org/)** a
|
|
|
577
632
|
|
|
578
633
|
| Change severity | SemVer bump | Typical changes |
|
|
579
634
|
|---|---|---|
|
|
580
|
-
| **High / Major** | `2.0.
|
|
581
|
-
| **Medium / Minor** | `2.0.
|
|
582
|
-
| **Low / Patch** | `2.0.
|
|
635
|
+
| **High / Major** | `2.0.4` → `3.0.0` | Incompatible API changes, breaking policy schema modifications, removed public methods. |
|
|
636
|
+
| **Medium / Minor** | `2.0.4` → `2.1.0` | Backwards-compatible features, new CLI flags, new integrations. |
|
|
637
|
+
| **Low / Patch** | `2.0.4` → `2.0.5` | Bug fixes, security hardening, documentation updates, test additions, non-breaking refactors. |
|
|
583
638
|
|
|
584
639
|
Every push must include the appropriate version decision and bump. A push carrying any Major change is Major; otherwise any Minor change makes it Minor; otherwise it is Patch. When severity is ambiguous, choose the higher severity and ask before a Major bump.
|
|
585
640
|
|