dmint 2.0.4__tar.gz → 2.0.5__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.4/src/dmint.egg-info → dmint-2.0.5}/PKG-INFO +9 -9
- {dmint-2.0.4 → dmint-2.0.5}/README.md +8 -8
- {dmint-2.0.4 → dmint-2.0.5}/pyproject.toml +1 -1
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/demo.py +3 -2
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/hooks.py +76 -24
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/verification.py +134 -1
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/mcp/auth.py +54 -26
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/mcp/gateway.py +27 -27
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/version.py +5 -5
- {dmint-2.0.4 → dmint-2.0.5/src/dmint.egg-info}/PKG-INFO +9 -9
- {dmint-2.0.4 → dmint-2.0.5}/LICENSE +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/setup.cfg +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/setup.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/__init__.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/approvals.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/authority.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/canonicalize.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/__init__.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/__main__.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/api.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/approvals.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/compile_policy.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/create_mcp_policy.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/create_policy.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/dashboard.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/errors.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/install_skill.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/io_utils.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/keys.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/limits.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/logs.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/mcp_auth.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/mcp_connections.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/mcp_credentials.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/mcp_oauth.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/policy_digest.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/prompts/__init__.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/prompts/policy_skill.md +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/py.typed +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/ui.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/verify_policy.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/cli/version.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/__init__.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/approvals.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/audit.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/authority.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/canonicalize.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/constraints.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/enforcement.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/errors.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/hashing.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/keys.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/models.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/policy.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/py.typed +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/redaction.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/request_binding.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/resources.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/storage/__init__.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/storage/base.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/storage/factory.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/storage/postgres_schema.sql +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/storage/sql.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/storage/sqlite.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/storage/thread_safe.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/versions.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/core/webhooks.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/dashboard/__init__.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/dashboard/__main__.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/dashboard/app.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/dashboard/auth.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/dashboard/core_client.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/dashboard/py.typed +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/dashboard/routes.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/dashboard/static/favicon.svg +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/dashboard/static/logo.svg +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/dashboard/static/style.css +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/dashboard/static/theme.js +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/dashboard/templates/approval.html +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/dashboard/templates/audit.html +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/dashboard/templates/base.html +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/dashboard/templates/error.html +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/dashboard/templates/index.html +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/dashboard/templates/login.html +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/enforcement.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/errors.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/hashing.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/mcp/__init__.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/mcp/__main__.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/mcp/_stdlib_mcp.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/mcp/client.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/mcp/config.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/mcp/config_loader.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/mcp/errors.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/mcp/mapper.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/mcp/proxy.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/mcp/py.typed +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/mcp/ssrf.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/models.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/policy.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/py.typed +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/request_binding.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/skills/__init__.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/skills/manager.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/skills/py.typed +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/skills/skill.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/skills/skills/dmint-policy-manager/SKILL.md +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/skills/version.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/storage/__init__.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/storage/sqlite.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/templates/__init__.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/templates/data/aws.json +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/templates/data/claude-code.json +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/templates/data/cline.json +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/templates/data/codex.json +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/templates/data/cursor.json +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/templates/data/filesystem.json +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/templates/data/github.json +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/templates/data/kubernetes.json +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/templates/data/opencode.json +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/templates/data/postgres.json +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/templates/data/shell.json +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/templates/data/stripe.json +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/templates/data/windsurf.json +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/templates/py.typed +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint/versions.py +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint.egg-info/SOURCES.txt +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint.egg-info/dependency_links.txt +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint.egg-info/entry_points.txt +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint.egg-info/requires.txt +0 -0
- {dmint-2.0.4 → dmint-2.0.5}/src/dmint.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dmint
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.5
|
|
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
|
|
@@ -138,7 +138,7 @@ Modern AI agents (Claude Code, Cursor, Antigravity, AutoGPT, custom LangChain/Ll
|
|
|
138
138
|
|
|
139
139
|
## Subsystems
|
|
140
140
|
|
|
141
|
-
`dmint` v2.0.
|
|
141
|
+
`dmint` v2.0.5 is organized as a unified monorepo providing modular packages under a single distribution:
|
|
142
142
|
|
|
143
143
|
| Module | Description | Primary Exports / Entrypoint |
|
|
144
144
|
| :--- | :--- | :--- |
|
|
@@ -571,13 +571,13 @@ ruff format .
|
|
|
571
571
|
# 2. Lint and check for syntax / rule errors
|
|
572
572
|
ruff check .
|
|
573
573
|
|
|
574
|
-
# 3. Type check all
|
|
574
|
+
# 3. Type check all 86 source files
|
|
575
575
|
mypy src/
|
|
576
576
|
|
|
577
577
|
# 4. Run targeted tests for what you changed
|
|
578
578
|
pytest tests/<subsystem>/ -v # e.g., tests/core/, tests/cli/, tests/mcp/, tests/dashboard/
|
|
579
579
|
|
|
580
|
-
# 5. Run full test suite (baseline:
|
|
580
|
+
# 5. Run full test suite (baseline: 1578 passed, 0 skipped, 0 failed)
|
|
581
581
|
pytest tests/ -q
|
|
582
582
|
|
|
583
583
|
# 6. Run pre-commit checks across all files
|
|
@@ -622,10 +622,10 @@ python3 -m venv /tmp/dmint-test-env
|
|
|
622
622
|
source /tmp/dmint-test-env/bin/activate
|
|
623
623
|
|
|
624
624
|
# Install the wheel with all extras
|
|
625
|
-
pip install "dist/dmint-2.0.
|
|
625
|
+
pip install "dist/dmint-2.0.5-py3-none-any.whl[all]"
|
|
626
626
|
|
|
627
627
|
# 4. Verify all installed CLI entrypoints
|
|
628
|
-
dmint --version # Expected: dmint 2.0.
|
|
628
|
+
dmint --version # Expected: dmint 2.0.5
|
|
629
629
|
dmint --help # Policy wizards and verification commands
|
|
630
630
|
dmint-mcp --help # MCP multi-server gateway
|
|
631
631
|
dmint-dashboard --help # Approval web review console
|
|
@@ -694,9 +694,9 @@ Dmint adheres strictly to **[Semantic Versioning 2.0.0](https://semver.org/)** a
|
|
|
694
694
|
|
|
695
695
|
| Change severity | SemVer bump | Typical changes |
|
|
696
696
|
|---|---|---|
|
|
697
|
-
| **High / Major** | `2.0.
|
|
698
|
-
| **Medium / Minor** | `2.0.
|
|
699
|
-
| **Low / Patch** | `2.0.
|
|
697
|
+
| **High / Major** | `2.0.5` → `3.0.0` | Incompatible API changes, breaking policy schema modifications, removed public methods. |
|
|
698
|
+
| **Medium / Minor** | `2.0.5` → `2.1.0` | Backwards-compatible features, new CLI flags, new integrations. |
|
|
699
|
+
| **Low / Patch** | `2.0.5` → `2.0.6` | Bug fixes, security hardening, documentation updates, test additions, non-breaking refactors. |
|
|
700
700
|
|
|
701
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.
|
|
702
702
|
|
|
@@ -76,7 +76,7 @@ Modern AI agents (Claude Code, Cursor, Antigravity, AutoGPT, custom LangChain/Ll
|
|
|
76
76
|
|
|
77
77
|
## Subsystems
|
|
78
78
|
|
|
79
|
-
`dmint` v2.0.
|
|
79
|
+
`dmint` v2.0.5 is organized as a unified monorepo providing modular packages under a single distribution:
|
|
80
80
|
|
|
81
81
|
| Module | Description | Primary Exports / Entrypoint |
|
|
82
82
|
| :--- | :--- | :--- |
|
|
@@ -509,13 +509,13 @@ ruff format .
|
|
|
509
509
|
# 2. Lint and check for syntax / rule errors
|
|
510
510
|
ruff check .
|
|
511
511
|
|
|
512
|
-
# 3. Type check all
|
|
512
|
+
# 3. Type check all 86 source files
|
|
513
513
|
mypy src/
|
|
514
514
|
|
|
515
515
|
# 4. Run targeted tests for what you changed
|
|
516
516
|
pytest tests/<subsystem>/ -v # e.g., tests/core/, tests/cli/, tests/mcp/, tests/dashboard/
|
|
517
517
|
|
|
518
|
-
# 5. Run full test suite (baseline:
|
|
518
|
+
# 5. Run full test suite (baseline: 1578 passed, 0 skipped, 0 failed)
|
|
519
519
|
pytest tests/ -q
|
|
520
520
|
|
|
521
521
|
# 6. Run pre-commit checks across all files
|
|
@@ -560,10 +560,10 @@ python3 -m venv /tmp/dmint-test-env
|
|
|
560
560
|
source /tmp/dmint-test-env/bin/activate
|
|
561
561
|
|
|
562
562
|
# Install the wheel with all extras
|
|
563
|
-
pip install "dist/dmint-2.0.
|
|
563
|
+
pip install "dist/dmint-2.0.5-py3-none-any.whl[all]"
|
|
564
564
|
|
|
565
565
|
# 4. Verify all installed CLI entrypoints
|
|
566
|
-
dmint --version # Expected: dmint 2.0.
|
|
566
|
+
dmint --version # Expected: dmint 2.0.5
|
|
567
567
|
dmint --help # Policy wizards and verification commands
|
|
568
568
|
dmint-mcp --help # MCP multi-server gateway
|
|
569
569
|
dmint-dashboard --help # Approval web review console
|
|
@@ -632,9 +632,9 @@ Dmint adheres strictly to **[Semantic Versioning 2.0.0](https://semver.org/)** a
|
|
|
632
632
|
|
|
633
633
|
| Change severity | SemVer bump | Typical changes |
|
|
634
634
|
|---|---|---|
|
|
635
|
-
| **High / Major** | `2.0.
|
|
636
|
-
| **Medium / Minor** | `2.0.
|
|
637
|
-
| **Low / Patch** | `2.0.
|
|
635
|
+
| **High / Major** | `2.0.5` → `3.0.0` | Incompatible API changes, breaking policy schema modifications, removed public methods. |
|
|
636
|
+
| **Medium / Minor** | `2.0.5` → `2.1.0` | Backwards-compatible features, new CLI flags, new integrations. |
|
|
637
|
+
| **Low / Patch** | `2.0.5` → `2.0.6` | Bug fixes, security hardening, documentation updates, test additions, non-breaking refactors. |
|
|
638
638
|
|
|
639
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.
|
|
640
640
|
|
|
@@ -17,6 +17,7 @@ from dmint import ApprovalRequiredError, Dmint, Policy, Rule
|
|
|
17
17
|
from dmint.cli.approvals import main_approve
|
|
18
18
|
from dmint.cli.hooks import evaluate_hook_request, main_init
|
|
19
19
|
from dmint.cli.ui import DmintHelpFormatter, use_color
|
|
20
|
+
from dmint.version import __version__
|
|
20
21
|
from dmint.core.audit import verify_audit_chain
|
|
21
22
|
from dmint.core.errors import DmintError
|
|
22
23
|
from dmint.core.keys import write_private_key_atomic
|
|
@@ -362,7 +363,7 @@ def main_demo(argv: Sequence[str] | None = None) -> int:
|
|
|
362
363
|
|
|
363
364
|
console = Console()
|
|
364
365
|
table = Table(
|
|
365
|
-
title="Dmint
|
|
366
|
+
title=f"Dmint v{__version__} — Live 7-Scenario Red-Team & Cryptographic Enforcement Simulation",
|
|
366
367
|
show_header=True,
|
|
367
368
|
header_style="bold cyan",
|
|
368
369
|
)
|
|
@@ -402,7 +403,7 @@ def main_demo(argv: Sequence[str] | None = None) -> int:
|
|
|
402
403
|
except Exception:
|
|
403
404
|
pass
|
|
404
405
|
|
|
405
|
-
print("\n=== Dmint
|
|
406
|
+
print(f"\n=== Dmint v{__version__} — Live 7-Scenario Red-Team & Cryptographic Simulation ===", file=out_buf)
|
|
406
407
|
for s in report["scenarios"]:
|
|
407
408
|
badge = "✓ PASS" if s["passed"] else "✗ FAIL"
|
|
408
409
|
print(
|
|
@@ -41,7 +41,7 @@ from dmint.core.models import Decision, NO_RESOURCE, NoResource, ToolRequest, Tr
|
|
|
41
41
|
from dmint.core.policy import Policy, policy_digest
|
|
42
42
|
from dmint.core.request_binding import request_binding_fingerprint
|
|
43
43
|
from dmint.core.storage.sqlite import SQLiteApprovalStore
|
|
44
|
-
from dmint.core.verification import ApprovalVerifier
|
|
44
|
+
from dmint.core.verification import ApprovalVerifier, load_trusted_issuers_from_public_sources
|
|
45
45
|
from dmint.core.webhooks import WebhookNotifier
|
|
46
46
|
from dmint.templates import (
|
|
47
47
|
AVAILABLE_TEMPLATES,
|
|
@@ -246,6 +246,7 @@ def ensure_local_dmint_environment(
|
|
|
246
246
|
templates: list[str] | None = None,
|
|
247
247
|
harnesses: list[str] | None = None,
|
|
248
248
|
force_policy: bool = False,
|
|
249
|
+
create_signing_key: bool = True,
|
|
249
250
|
) -> dict[str, Any]:
|
|
250
251
|
"""Ensure .dmint/ keys, approval DB path, starter policy.json, and per-harness policies exist."""
|
|
251
252
|
base = (workspace_dir or Path.cwd()).resolve()
|
|
@@ -257,12 +258,45 @@ def ensure_local_dmint_environment(
|
|
|
257
258
|
pass
|
|
258
259
|
|
|
259
260
|
signing_key_path = dmint_dir / "signing.key"
|
|
261
|
+
trusted_issuer_path = dmint_dir / "trusted_issuer.json"
|
|
260
262
|
integrity_key_path = dmint_dir / "integrity.key"
|
|
261
263
|
db_path = dmint_dir / "approvals.sqlite3"
|
|
262
264
|
target_policy_path = (policy_path or (base / "policy.json")).resolve()
|
|
263
265
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
+
has_public_issuer = bool(load_trusted_issuers_from_public_sources(base))
|
|
267
|
+
if create_signing_key and not has_public_issuer and not signing_key_path.exists():
|
|
268
|
+
generated_priv = Ed25519PrivateKey.generate()
|
|
269
|
+
write_private_key_atomic(signing_key_path, generated_priv)
|
|
270
|
+
try:
|
|
271
|
+
trusted_issuer_path.write_text(
|
|
272
|
+
json.dumps(
|
|
273
|
+
{
|
|
274
|
+
"issuer_id": "dmint-authority",
|
|
275
|
+
"public_key_hex": public_key_hex(generated_priv.public_key()),
|
|
276
|
+
},
|
|
277
|
+
indent=2,
|
|
278
|
+
)
|
|
279
|
+
+ "\n",
|
|
280
|
+
encoding="utf-8",
|
|
281
|
+
)
|
|
282
|
+
except OSError:
|
|
283
|
+
pass
|
|
284
|
+
elif signing_key_path.exists() and not trusted_issuer_path.exists():
|
|
285
|
+
try:
|
|
286
|
+
existing_pub = load_private_key_from_file(signing_key_path).public_key()
|
|
287
|
+
trusted_issuer_path.write_text(
|
|
288
|
+
json.dumps(
|
|
289
|
+
{
|
|
290
|
+
"issuer_id": "dmint-authority",
|
|
291
|
+
"public_key_hex": public_key_hex(existing_pub),
|
|
292
|
+
},
|
|
293
|
+
indent=2,
|
|
294
|
+
)
|
|
295
|
+
+ "\n",
|
|
296
|
+
encoding="utf-8",
|
|
297
|
+
)
|
|
298
|
+
except Exception:
|
|
299
|
+
pass
|
|
266
300
|
|
|
267
301
|
if not integrity_key_path.exists():
|
|
268
302
|
write_integrity_key_atomic(integrity_key_path, os.urandom(32))
|
|
@@ -827,7 +861,12 @@ def evaluate_hook_request(
|
|
|
827
861
|
_t0 = _time.perf_counter()
|
|
828
862
|
norm_harness = normalize_harness_name(harness)
|
|
829
863
|
raw_native_tool, unpacked_args, detected_ws = _unpack_harness_envelope(payload)
|
|
830
|
-
|
|
864
|
+
inferred_ws: Path | None = None
|
|
865
|
+
if workspace_dir is None and detected_ws is None and db_path is not None:
|
|
866
|
+
db_p = Path(db_path).resolve()
|
|
867
|
+
if db_p.parent.name == ".dmint":
|
|
868
|
+
inferred_ws = db_p.parent.parent
|
|
869
|
+
base = (workspace_dir or detected_ws or inferred_ws or Path.cwd()).resolve()
|
|
831
870
|
|
|
832
871
|
p_path = Path(policy_path)
|
|
833
872
|
if not p_path.is_absolute():
|
|
@@ -1024,13 +1063,15 @@ def evaluate_hook_request(
|
|
|
1024
1063
|
)
|
|
1025
1064
|
|
|
1026
1065
|
# Decision.APPROVAL_REQUIRED: Check or persist in SQLiteApprovalStore
|
|
1027
|
-
env_paths = ensure_local_dmint_environment(base, policy_path=p_path)
|
|
1066
|
+
env_paths = ensure_local_dmint_environment(base, policy_path=p_path, create_signing_key=False)
|
|
1028
1067
|
target_db = Path(db_path).resolve() if db_path else env_paths["db_path"]
|
|
1029
1068
|
target_epoch = deployment_epoch or os.environ.get("DMINT_DEPLOYMENT_EPOCH", "default")
|
|
1030
1069
|
|
|
1031
1070
|
integrity_key: bytes | Path | str | None = None
|
|
1032
1071
|
if not os.environ.get("DMINT_INTEGRITY_KEY") and not os.environ.get("DMINT_INTEGRITY_KEY_FILE"):
|
|
1033
|
-
if
|
|
1072
|
+
if (target_db.parent / "integrity.key").exists():
|
|
1073
|
+
integrity_key = target_db.parent / "integrity.key"
|
|
1074
|
+
elif env_paths["integrity_key"].exists():
|
|
1034
1075
|
integrity_key = env_paths["integrity_key"]
|
|
1035
1076
|
|
|
1036
1077
|
now = datetime.now(timezone.utc)
|
|
@@ -1058,22 +1099,26 @@ def evaluate_hook_request(
|
|
|
1058
1099
|
if matched is not None:
|
|
1059
1100
|
approved_rec, assertion = matched
|
|
1060
1101
|
signing_key_file = env_paths["signing_key"]
|
|
1061
|
-
trusted_issuers: dict[str, Any] = {}
|
|
1062
1102
|
issuer_key = assertion.issuer
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
trusted_issuers[
|
|
1075
|
-
|
|
1076
|
-
|
|
1103
|
+
trusted_issuers: dict[str, Any] = dict(
|
|
1104
|
+
load_trusted_issuers_from_public_sources(base, extra_issuer_ids=(issuer_key,))
|
|
1105
|
+
)
|
|
1106
|
+
strict_pub_only = os.environ.get("DMINT_STRICT_PUBLIC_KEY_ONLY", "").lower() in ("1", "true", "yes")
|
|
1107
|
+
if not trusted_issuers and not strict_pub_only:
|
|
1108
|
+
if signing_key_file.exists():
|
|
1109
|
+
priv = load_private_key_from_file(signing_key_file)
|
|
1110
|
+
pub = priv.public_key()
|
|
1111
|
+
trusted_issuers[issuer_key] = pub
|
|
1112
|
+
trusted_issuers["dmint-cli"] = pub
|
|
1113
|
+
trusted_issuers["dmint-authority"] = pub
|
|
1114
|
+
trusted_issuers["dmint-dashboard"] = pub
|
|
1115
|
+
default_key_file = Path.home() / ".config" / "dmint" / "signing.key"
|
|
1116
|
+
if default_key_file.exists() and not signing_key_file.exists():
|
|
1117
|
+
try:
|
|
1118
|
+
priv_def = load_private_key_from_file(default_key_file)
|
|
1119
|
+
trusted_issuers[issuer_key] = priv_def.public_key()
|
|
1120
|
+
except Exception:
|
|
1121
|
+
pass
|
|
1077
1122
|
|
|
1078
1123
|
if approved_rec.policy_provenance.policy_digest != prov.policy_digest:
|
|
1079
1124
|
try:
|
|
@@ -2162,8 +2207,15 @@ def main_init(args: list[str] | None = None) -> int:
|
|
|
2162
2207
|
print(f"Error initializing Dmint: {exc}", file=sys.stderr)
|
|
2163
2208
|
return 1
|
|
2164
2209
|
|
|
2165
|
-
|
|
2166
|
-
|
|
2210
|
+
if env_paths["signing_key"].exists():
|
|
2211
|
+
priv = load_private_key_from_file(env_paths["signing_key"])
|
|
2212
|
+
pub_hex = public_key_hex(priv.public_key())
|
|
2213
|
+
key_summary_line = f" - Signing key : {env_paths['signing_key']} (0600, public_key_hex={pub_hex[:16]}...)"
|
|
2214
|
+
else:
|
|
2215
|
+
pub_map = load_trusted_issuers_from_public_sources(ws_dir)
|
|
2216
|
+
first_pub = next(iter(pub_map.values()), None)
|
|
2217
|
+
pub_hex = public_key_hex(first_pub) if first_pub is not None else "external"
|
|
2218
|
+
key_summary_line = f" - Trusted key : public-key-only (public_key_hex={pub_hex[:16]}...)"
|
|
2167
2219
|
policy_obj = Policy.from_file(env_paths["policy_path"])
|
|
2168
2220
|
|
|
2169
2221
|
print("✓ Dmint initialized in current workspace!")
|
|
@@ -2171,7 +2223,7 @@ def main_init(args: list[str] | None = None) -> int:
|
|
|
2171
2223
|
for h_name, h_pol_path in env_paths.get("harness_policies", {}).items():
|
|
2172
2224
|
h_pol_obj = Policy.from_file(h_pol_path)
|
|
2173
2225
|
print(f" - {h_name:<13} : {h_pol_path} ({len(h_pol_obj.rules)} rules)")
|
|
2174
|
-
print(
|
|
2226
|
+
print(key_summary_line)
|
|
2175
2227
|
print(f" - Integrity key : {env_paths['integrity_key']} (0600)")
|
|
2176
2228
|
print(f" - Approval DB : {env_paths['db_path']}")
|
|
2177
2229
|
if installed:
|
|
@@ -10,7 +10,9 @@ import base64
|
|
|
10
10
|
import binascii
|
|
11
11
|
import json
|
|
12
12
|
import re
|
|
13
|
-
|
|
13
|
+
import os
|
|
14
|
+
from collections.abc import Callable, Mapping, Sequence
|
|
15
|
+
from pathlib import Path
|
|
14
16
|
from dataclasses import dataclass
|
|
15
17
|
from datetime import datetime, timezone
|
|
16
18
|
from types import MappingProxyType
|
|
@@ -49,6 +51,7 @@ __all__ = [
|
|
|
49
51
|
"public_key_pem",
|
|
50
52
|
"public_key_from_hex",
|
|
51
53
|
"public_key_from_pem",
|
|
54
|
+
"load_trusted_issuers_from_public_sources",
|
|
52
55
|
]
|
|
53
56
|
|
|
54
57
|
DEFAULT_APPROVAL_AUDIENCE: str = "dmint/dashboard/v1"
|
|
@@ -575,3 +578,133 @@ class ApprovalVerifier:
|
|
|
575
578
|
):
|
|
576
579
|
raise ApprovalInvalidError("approval policy provenance mismatch")
|
|
577
580
|
return VerifiedApproval(assertion, record)
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
_DEFAULT_TRUSTED_ISSUER_ALIASES = (
|
|
584
|
+
"dmint-cli",
|
|
585
|
+
"dmint-authority",
|
|
586
|
+
"dmint-dashboard",
|
|
587
|
+
"local-authority",
|
|
588
|
+
"prod-secops-authority",
|
|
589
|
+
)
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
def _register_public_key_aliases(
|
|
593
|
+
target: dict[str, Ed25519PublicKey],
|
|
594
|
+
pub: Ed25519PublicKey,
|
|
595
|
+
issuer_id: str | None = None,
|
|
596
|
+
extra_issuer_ids: Sequence[str] = (),
|
|
597
|
+
) -> None:
|
|
598
|
+
if issuer_id and issuer_id.strip():
|
|
599
|
+
target[issuer_id.strip()] = pub
|
|
600
|
+
for alias in _DEFAULT_TRUSTED_ISSUER_ALIASES:
|
|
601
|
+
target.setdefault(alias, pub)
|
|
602
|
+
for extra in extra_issuer_ids:
|
|
603
|
+
if isinstance(extra, str) and extra.strip():
|
|
604
|
+
target.setdefault(extra.strip(), pub)
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
def _parse_public_key_file_content(
|
|
608
|
+
raw_text: str,
|
|
609
|
+
target: dict[str, Ed25519PublicKey],
|
|
610
|
+
extra_issuer_ids: Sequence[str] = (),
|
|
611
|
+
) -> None:
|
|
612
|
+
stripped = raw_text.strip()
|
|
613
|
+
if not stripped:
|
|
614
|
+
return
|
|
615
|
+
if stripped.startswith("{") or stripped.startswith("["):
|
|
616
|
+
data = json.loads(stripped)
|
|
617
|
+
if isinstance(data, dict):
|
|
618
|
+
if "public_key_hex" in data:
|
|
619
|
+
pub = public_key_from_hex(str(data["public_key_hex"]).strip())
|
|
620
|
+
_register_public_key_aliases(
|
|
621
|
+
target,
|
|
622
|
+
pub,
|
|
623
|
+
str(data.get("issuer_id") or "dmint-authority"),
|
|
624
|
+
extra_issuer_ids,
|
|
625
|
+
)
|
|
626
|
+
elif "trusted_issuers" in data and isinstance(data["trusted_issuers"], list):
|
|
627
|
+
for item in data["trusted_issuers"]:
|
|
628
|
+
if isinstance(item, dict) and "public_key_hex" in item:
|
|
629
|
+
pub = public_key_from_hex(str(item["public_key_hex"]).strip())
|
|
630
|
+
_register_public_key_aliases(
|
|
631
|
+
target,
|
|
632
|
+
pub,
|
|
633
|
+
str(item.get("issuer_id") or "dmint-authority"),
|
|
634
|
+
extra_issuer_ids,
|
|
635
|
+
)
|
|
636
|
+
else:
|
|
637
|
+
for k, v in data.items():
|
|
638
|
+
if isinstance(k, str) and isinstance(v, str) and len(v.strip()) == 64:
|
|
639
|
+
pub = public_key_from_hex(v.strip())
|
|
640
|
+
_register_public_key_aliases(target, pub, k, extra_issuer_ids)
|
|
641
|
+
elif isinstance(data, list):
|
|
642
|
+
for item in data:
|
|
643
|
+
if isinstance(item, dict) and "public_key_hex" in item:
|
|
644
|
+
pub = public_key_from_hex(str(item["public_key_hex"]).strip())
|
|
645
|
+
_register_public_key_aliases(
|
|
646
|
+
target,
|
|
647
|
+
pub,
|
|
648
|
+
str(item.get("issuer_id") or "dmint-authority"),
|
|
649
|
+
extra_issuer_ids,
|
|
650
|
+
)
|
|
651
|
+
return
|
|
652
|
+
if "BEGIN PUBLIC KEY" in stripped:
|
|
653
|
+
pub = public_key_from_pem(stripped)
|
|
654
|
+
_register_public_key_aliases(target, pub, "dmint-authority", extra_issuer_ids)
|
|
655
|
+
return
|
|
656
|
+
if len(stripped) == 64:
|
|
657
|
+
pub = public_key_from_hex(stripped)
|
|
658
|
+
_register_public_key_aliases(target, pub, "dmint-authority", extra_issuer_ids)
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
def load_trusted_issuers_from_public_sources(
|
|
662
|
+
workspace_dir: Path | str | None = None,
|
|
663
|
+
*,
|
|
664
|
+
extra_issuer_ids: Sequence[str] = (),
|
|
665
|
+
) -> dict[str, Ed25519PublicKey]:
|
|
666
|
+
"""Load trusted Ed25519 public keys from public-key-only environment variables or files.
|
|
667
|
+
|
|
668
|
+
Never reads or imports private signing keys.
|
|
669
|
+
"""
|
|
670
|
+
trusted: dict[str, Ed25519PublicKey] = {}
|
|
671
|
+
env_issuer = os.environ.get("DMINT_TRUSTED_ISSUER_ID", "dmint-authority").strip() or "dmint-authority"
|
|
672
|
+
|
|
673
|
+
for env_var in ("DMINT_TRUSTED_PUBLIC_KEY_HEX", "DMINT_AUTHORITY_PUBLIC_KEY_HEX"):
|
|
674
|
+
raw_hex = os.environ.get(env_var, "").strip()
|
|
675
|
+
if raw_hex:
|
|
676
|
+
try:
|
|
677
|
+
pub = public_key_from_hex(raw_hex)
|
|
678
|
+
_register_public_key_aliases(trusted, pub, env_issuer, extra_issuer_ids)
|
|
679
|
+
except Exception:
|
|
680
|
+
pass
|
|
681
|
+
|
|
682
|
+
candidates: list[Path] = []
|
|
683
|
+
env_file = os.environ.get("DMINT_TRUSTED_ISSUERS_FILE", "").strip()
|
|
684
|
+
if env_file:
|
|
685
|
+
candidates.append(Path(env_file).expanduser())
|
|
686
|
+
|
|
687
|
+
if workspace_dir is not None:
|
|
688
|
+
base = Path(workspace_dir).resolve()
|
|
689
|
+
candidates.append(base / ".dmint" / "trusted_issuer.json")
|
|
690
|
+
candidates.append(base / ".dmint" / "public.key")
|
|
691
|
+
else:
|
|
692
|
+
candidates.append(Path(".dmint/trusted_issuer.json"))
|
|
693
|
+
candidates.append(Path(".dmint/public.key"))
|
|
694
|
+
|
|
695
|
+
candidates.append(Path("/etc/dmint/shared/trusted_issuer.json"))
|
|
696
|
+
candidates.append(Path("/etc/dmint/gate/public.key"))
|
|
697
|
+
candidates.append(Path.home() / ".config" / "dmint" / "trusted_issuer.json")
|
|
698
|
+
|
|
699
|
+
for cand in candidates:
|
|
700
|
+
if cand.is_file():
|
|
701
|
+
try:
|
|
702
|
+
_parse_public_key_file_content(
|
|
703
|
+
cand.read_text(encoding="utf-8"),
|
|
704
|
+
trusted,
|
|
705
|
+
extra_issuer_ids=extra_issuer_ids,
|
|
706
|
+
)
|
|
707
|
+
except Exception:
|
|
708
|
+
pass
|
|
709
|
+
|
|
710
|
+
return trusted
|
|
@@ -178,12 +178,61 @@ class AgentAuthMiddleware(BaseHTTPMiddleware):
|
|
|
178
178
|
request: Request,
|
|
179
179
|
call_next: RequestResponseEndpoint,
|
|
180
180
|
) -> Response:
|
|
181
|
-
# 1. Enforce
|
|
181
|
+
# 1. Enforce Bearer authentication first before reading or buffering any request body
|
|
182
|
+
if self.authenticator is not None and self.authenticator.has_tokens:
|
|
183
|
+
auth_header = request.headers.get("authorization")
|
|
184
|
+
agent_id = self.authenticator.authenticate_header(auth_header)
|
|
185
|
+
if agent_id is None:
|
|
186
|
+
return JSONResponse(
|
|
187
|
+
{
|
|
188
|
+
"error": "unauthorized",
|
|
189
|
+
"message": "Missing or invalid authorization token",
|
|
190
|
+
},
|
|
191
|
+
status_code=401,
|
|
192
|
+
headers={"WWW-Authenticate": 'Bearer error="invalid_token"'},
|
|
193
|
+
)
|
|
194
|
+
effective_agent_id = agent_id
|
|
195
|
+
else:
|
|
196
|
+
effective_agent_id = self.default_agent_id
|
|
197
|
+
|
|
198
|
+
# 2. Enforce payload size limit from Content-Length header (reject malformed/negative headers)
|
|
182
199
|
content_length_header = request.headers.get("content-length")
|
|
183
200
|
if content_length_header is not None:
|
|
184
201
|
try:
|
|
185
202
|
cl = int(content_length_header)
|
|
186
|
-
|
|
203
|
+
except ValueError:
|
|
204
|
+
return JSONResponse(
|
|
205
|
+
{
|
|
206
|
+
"error": "invalid_request",
|
|
207
|
+
"code": "DMT_MCP_PROTOCOL_ERROR",
|
|
208
|
+
"message": "Malformed Content-Length header",
|
|
209
|
+
},
|
|
210
|
+
status_code=400,
|
|
211
|
+
)
|
|
212
|
+
if cl < 0:
|
|
213
|
+
return JSONResponse(
|
|
214
|
+
{
|
|
215
|
+
"error": "invalid_request",
|
|
216
|
+
"code": "DMT_MCP_PROTOCOL_ERROR",
|
|
217
|
+
"message": "Negative Content-Length header",
|
|
218
|
+
},
|
|
219
|
+
status_code=400,
|
|
220
|
+
)
|
|
221
|
+
if cl > self.max_request_body_size:
|
|
222
|
+
return JSONResponse(
|
|
223
|
+
{
|
|
224
|
+
"error": "payload_too_large",
|
|
225
|
+
"message": f"Request body exceeds maximum permitted size of {self.max_request_body_size} bytes",
|
|
226
|
+
},
|
|
227
|
+
status_code=413,
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
# 3. Stream body incrementally with hard byte cap and validate JSON syntax / duplicate keys
|
|
231
|
+
if request.method in ("POST", "PUT", "PATCH"):
|
|
232
|
+
buf = bytearray()
|
|
233
|
+
async for chunk in request.stream():
|
|
234
|
+
buf.extend(chunk)
|
|
235
|
+
if len(buf) > self.max_request_body_size:
|
|
187
236
|
return JSONResponse(
|
|
188
237
|
{
|
|
189
238
|
"error": "payload_too_large",
|
|
@@ -191,12 +240,8 @@ class AgentAuthMiddleware(BaseHTTPMiddleware):
|
|
|
191
240
|
},
|
|
192
241
|
status_code=413,
|
|
193
242
|
)
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
# 1.5. Validate JSON body syntax and reject duplicate keys
|
|
198
|
-
if request.method in ("POST", "PUT", "PATCH"):
|
|
199
|
-
body = await request.body()
|
|
243
|
+
body = bytes(buf)
|
|
244
|
+
request._body = body
|
|
200
245
|
request.scope["_dmint_cached_body"] = body
|
|
201
246
|
if body:
|
|
202
247
|
content_type = request.headers.get("content-type", "")
|
|
@@ -204,7 +249,7 @@ class AgentAuthMiddleware(BaseHTTPMiddleware):
|
|
|
204
249
|
try:
|
|
205
250
|
from .gateway import parse_gateway_request
|
|
206
251
|
|
|
207
|
-
parse_gateway_request(body)
|
|
252
|
+
parse_gateway_request(body, max_bytes=self.max_request_body_size)
|
|
208
253
|
except MCPProtocolError as exc:
|
|
209
254
|
return JSONResponse(
|
|
210
255
|
{
|
|
@@ -215,23 +260,6 @@ class AgentAuthMiddleware(BaseHTTPMiddleware):
|
|
|
215
260
|
status_code=400,
|
|
216
261
|
)
|
|
217
262
|
|
|
218
|
-
# 2. Enforce Bearer authentication if authenticator is configured
|
|
219
|
-
if self.authenticator is not None and self.authenticator.has_tokens:
|
|
220
|
-
auth_header = request.headers.get("authorization")
|
|
221
|
-
agent_id = self.authenticator.authenticate_header(auth_header)
|
|
222
|
-
if agent_id is None:
|
|
223
|
-
return JSONResponse(
|
|
224
|
-
{
|
|
225
|
-
"error": "unauthorized",
|
|
226
|
-
"message": "Missing or invalid authorization token",
|
|
227
|
-
},
|
|
228
|
-
status_code=401,
|
|
229
|
-
headers={"WWW-Authenticate": 'Bearer error="invalid_token"'},
|
|
230
|
-
)
|
|
231
|
-
effective_agent_id = agent_id
|
|
232
|
-
else:
|
|
233
|
-
effective_agent_id = self.default_agent_id
|
|
234
|
-
|
|
235
263
|
# 3. Bind authoritative identity to request state and contextvar
|
|
236
264
|
request.state.agent_id = effective_agent_id
|
|
237
265
|
request.scope["agent_id"] = effective_agent_id
|
|
@@ -51,7 +51,12 @@ else:
|
|
|
51
51
|
from dmint.core.canonicalize import canonicalize_bytes
|
|
52
52
|
|
|
53
53
|
from dmint.core.approvals import ApprovalRecord, PolicyProvenance
|
|
54
|
-
from dmint.core.verification import
|
|
54
|
+
from dmint.core.verification import (
|
|
55
|
+
ApprovalAssertion,
|
|
56
|
+
ApprovalVerifier,
|
|
57
|
+
load_trusted_issuers_from_public_sources,
|
|
58
|
+
public_key_from_hex,
|
|
59
|
+
)
|
|
55
60
|
from dmint.core.errors import (
|
|
56
61
|
ApprovalError,
|
|
57
62
|
ApprovalRequiredError,
|
|
@@ -92,15 +97,25 @@ def _reject_duplicate_pairs(pairs: list[tuple[str, Any]]) -> dict[str, Any]:
|
|
|
92
97
|
return result
|
|
93
98
|
|
|
94
99
|
|
|
95
|
-
def parse_gateway_request(raw: str | bytes) -> dict[str, Any]:
|
|
96
|
-
"""Parse an inbound gateway JSON request strictly rejecting duplicate object keys."""
|
|
100
|
+
def parse_gateway_request(raw: str | bytes, *, max_bytes: int = 4 * 1024 * 1024) -> dict[str, Any]:
|
|
101
|
+
"""Parse an inbound gateway JSON request strictly rejecting duplicate object keys and oversized payloads."""
|
|
97
102
|
if isinstance(raw, bytes):
|
|
103
|
+
if len(raw) > max_bytes:
|
|
104
|
+
raise MCPProtocolError(
|
|
105
|
+
f"gateway request exceeds maximum permitted size of {max_bytes} bytes",
|
|
106
|
+
code="DMT_MCP_PROTOCOL_ERROR",
|
|
107
|
+
)
|
|
98
108
|
try:
|
|
99
109
|
raw = raw.decode("utf-8")
|
|
100
110
|
except UnicodeDecodeError as exc:
|
|
101
111
|
raise MCPProtocolError(f"invalid UTF-8 in gateway request: {exc}", code="DMT_MCP_PROTOCOL_ERROR") from exc
|
|
102
112
|
if not isinstance(raw, str):
|
|
103
113
|
raise MCPProtocolError("gateway request payload must be text or bytes", code="DMT_MCP_PROTOCOL_ERROR")
|
|
114
|
+
if len(raw.encode("utf-8")) > max_bytes:
|
|
115
|
+
raise MCPProtocolError(
|
|
116
|
+
f"gateway request exceeds maximum permitted size of {max_bytes} bytes",
|
|
117
|
+
code="DMT_MCP_PROTOCOL_ERROR",
|
|
118
|
+
)
|
|
104
119
|
try:
|
|
105
120
|
data = json.loads(raw, object_pairs_hook=_reject_duplicate_pairs)
|
|
106
121
|
except json.JSONDecodeError as exc:
|
|
@@ -210,30 +225,15 @@ class MCPGateway:
|
|
|
210
225
|
audience=config.approval_audience,
|
|
211
226
|
)
|
|
212
227
|
else:
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
if
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
from dmint.core.keys import load_private_key_from_file
|
|
223
|
-
|
|
224
|
-
pub = load_private_key_from_file(ck).public_key()
|
|
225
|
-
self._approval_verifier = ApprovalVerifier(
|
|
226
|
-
trusted_issuers={
|
|
227
|
-
"dmint-cli": pub,
|
|
228
|
-
"dmint-authority": pub,
|
|
229
|
-
"dmint-dashboard": pub,
|
|
230
|
-
"local-authority": pub,
|
|
231
|
-
},
|
|
232
|
-
audience=config.approval_audience,
|
|
233
|
-
)
|
|
234
|
-
break
|
|
235
|
-
except Exception:
|
|
236
|
-
pass
|
|
228
|
+
ws_hint = Path(config.approval_store_path).resolve().parent.parent if config.approval_store_path else None
|
|
229
|
+
pub_map = load_trusted_issuers_from_public_sources(ws_hint)
|
|
230
|
+
if pub_map:
|
|
231
|
+
self._approval_verifier = ApprovalVerifier(
|
|
232
|
+
trusted_issuers=pub_map,
|
|
233
|
+
audience=config.approval_audience,
|
|
234
|
+
)
|
|
235
|
+
else:
|
|
236
|
+
self._approval_verifier = None
|
|
237
237
|
self._integrations: dict[str, GatewayIntegration] = {}
|
|
238
238
|
|
|
239
239
|
for integ_cfg in config.integrations:
|
|
@@ -9,7 +9,7 @@ from __future__ import annotations
|
|
|
9
9
|
import os
|
|
10
10
|
|
|
11
11
|
# Base package version (single source of truth in code)
|
|
12
|
-
DEFAULT_VERSION: str = "2.0.
|
|
12
|
+
DEFAULT_VERSION: str = "2.0.5"
|
|
13
13
|
|
|
14
14
|
# Canonical package version (overridable via DMINT_VERSION env var)
|
|
15
15
|
__version__: str = os.environ.get("DMINT_VERSION", DEFAULT_VERSION)
|
|
@@ -26,10 +26,10 @@ def get_user_agent(component: str | None = None) -> str:
|
|
|
26
26
|
Can be explicitly overridden via DMINT_USER_AGENT environment variable for base client.
|
|
27
27
|
|
|
28
28
|
Examples:
|
|
29
|
-
get_user_agent() -> 'dmint-cli/2.0.
|
|
30
|
-
get_user_agent('mcp') -> 'dmint-mcp/2.0.
|
|
31
|
-
get_user_agent('oauth') -> 'dmint-oauth/2.0.
|
|
32
|
-
get_user_agent('webhook') -> 'dmint-webhook/2.0.
|
|
29
|
+
get_user_agent() -> 'dmint-cli/2.0.5'
|
|
30
|
+
get_user_agent('mcp') -> 'dmint-mcp/2.0.5'
|
|
31
|
+
get_user_agent('oauth') -> 'dmint-oauth/2.0.5'
|
|
32
|
+
get_user_agent('webhook') -> 'dmint-webhook/2.0.5'
|
|
33
33
|
"""
|
|
34
34
|
version = get_version()
|
|
35
35
|
if component:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dmint
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.5
|
|
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
|
|
@@ -138,7 +138,7 @@ Modern AI agents (Claude Code, Cursor, Antigravity, AutoGPT, custom LangChain/Ll
|
|
|
138
138
|
|
|
139
139
|
## Subsystems
|
|
140
140
|
|
|
141
|
-
`dmint` v2.0.
|
|
141
|
+
`dmint` v2.0.5 is organized as a unified monorepo providing modular packages under a single distribution:
|
|
142
142
|
|
|
143
143
|
| Module | Description | Primary Exports / Entrypoint |
|
|
144
144
|
| :--- | :--- | :--- |
|
|
@@ -571,13 +571,13 @@ ruff format .
|
|
|
571
571
|
# 2. Lint and check for syntax / rule errors
|
|
572
572
|
ruff check .
|
|
573
573
|
|
|
574
|
-
# 3. Type check all
|
|
574
|
+
# 3. Type check all 86 source files
|
|
575
575
|
mypy src/
|
|
576
576
|
|
|
577
577
|
# 4. Run targeted tests for what you changed
|
|
578
578
|
pytest tests/<subsystem>/ -v # e.g., tests/core/, tests/cli/, tests/mcp/, tests/dashboard/
|
|
579
579
|
|
|
580
|
-
# 5. Run full test suite (baseline:
|
|
580
|
+
# 5. Run full test suite (baseline: 1578 passed, 0 skipped, 0 failed)
|
|
581
581
|
pytest tests/ -q
|
|
582
582
|
|
|
583
583
|
# 6. Run pre-commit checks across all files
|
|
@@ -622,10 +622,10 @@ python3 -m venv /tmp/dmint-test-env
|
|
|
622
622
|
source /tmp/dmint-test-env/bin/activate
|
|
623
623
|
|
|
624
624
|
# Install the wheel with all extras
|
|
625
|
-
pip install "dist/dmint-2.0.
|
|
625
|
+
pip install "dist/dmint-2.0.5-py3-none-any.whl[all]"
|
|
626
626
|
|
|
627
627
|
# 4. Verify all installed CLI entrypoints
|
|
628
|
-
dmint --version # Expected: dmint 2.0.
|
|
628
|
+
dmint --version # Expected: dmint 2.0.5
|
|
629
629
|
dmint --help # Policy wizards and verification commands
|
|
630
630
|
dmint-mcp --help # MCP multi-server gateway
|
|
631
631
|
dmint-dashboard --help # Approval web review console
|
|
@@ -694,9 +694,9 @@ Dmint adheres strictly to **[Semantic Versioning 2.0.0](https://semver.org/)** a
|
|
|
694
694
|
|
|
695
695
|
| Change severity | SemVer bump | Typical changes |
|
|
696
696
|
|---|---|---|
|
|
697
|
-
| **High / Major** | `2.0.
|
|
698
|
-
| **Medium / Minor** | `2.0.
|
|
699
|
-
| **Low / Patch** | `2.0.
|
|
697
|
+
| **High / Major** | `2.0.5` → `3.0.0` | Incompatible API changes, breaking policy schema modifications, removed public methods. |
|
|
698
|
+
| **Medium / Minor** | `2.0.5` → `2.1.0` | Backwards-compatible features, new CLI flags, new integrations. |
|
|
699
|
+
| **Low / Patch** | `2.0.5` → `2.0.6` | Bug fixes, security hardening, documentation updates, test additions, non-breaking refactors. |
|
|
700
700
|
|
|
701
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.
|
|
702
702
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|