dmint-cli 0.1.0__py3-none-any.whl
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_cli/__init__.py +14 -0
- dmint_cli/__main__.py +66 -0
- dmint_cli/api.py +172 -0
- dmint_cli/compile_policy.py +209 -0
- dmint_cli/create_policy.py +230 -0
- dmint_cli-0.1.0.dist-info/METADATA +79 -0
- dmint_cli-0.1.0.dist-info/RECORD +11 -0
- dmint_cli-0.1.0.dist-info/WHEEL +5 -0
- dmint_cli-0.1.0.dist-info/entry_points.txt +2 -0
- dmint_cli-0.1.0.dist-info/licenses/LICENSE +176 -0
- dmint_cli-0.1.0.dist-info/top_level.txt +1 -0
dmint_cli/__init__.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Dmint CLI package."""
|
|
2
|
+
|
|
3
|
+
from .api import OpenAICompatClient, mask_secret
|
|
4
|
+
from .compile_policy import compile_policy_file, main_compile
|
|
5
|
+
from .create_policy import main_create, run_create_policy_wizard
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"OpenAICompatClient",
|
|
9
|
+
"compile_policy_file",
|
|
10
|
+
"main_compile",
|
|
11
|
+
"main_create",
|
|
12
|
+
"mask_secret",
|
|
13
|
+
"run_create_policy_wizard",
|
|
14
|
+
]
|
dmint_cli/__main__.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""Entry point for dmint CLI command."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from dmint_cli.compile_policy import main_compile
|
|
9
|
+
from dmint_cli.create_policy import main_create
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def main(args: list[str] | None = None) -> int:
|
|
13
|
+
if args is None:
|
|
14
|
+
args = sys.argv[1:]
|
|
15
|
+
|
|
16
|
+
# Normalize subcommands like "create policy" -> "create-policy" and "compile policy" -> "compile-policy"
|
|
17
|
+
normalized_args: list[str] = []
|
|
18
|
+
i = 0
|
|
19
|
+
while i < len(args):
|
|
20
|
+
arg = args[i]
|
|
21
|
+
if arg == "create" and i + 1 < len(args) and args[i + 1] == "policy":
|
|
22
|
+
normalized_args.append("create-policy")
|
|
23
|
+
i += 2
|
|
24
|
+
continue
|
|
25
|
+
if arg == "compile" and i + 1 < len(args) and args[i + 1] == "policy":
|
|
26
|
+
normalized_args.append("compile-policy")
|
|
27
|
+
i += 2
|
|
28
|
+
continue
|
|
29
|
+
normalized_args.append(arg)
|
|
30
|
+
i += 1
|
|
31
|
+
|
|
32
|
+
parser = argparse.ArgumentParser(
|
|
33
|
+
prog="dmint",
|
|
34
|
+
description="Dmint deterministic security enforcement & policy authoring CLI.",
|
|
35
|
+
)
|
|
36
|
+
subparsers = parser.add_subparsers(dest="command", help="Command to run")
|
|
37
|
+
|
|
38
|
+
subparsers.add_parser(
|
|
39
|
+
"compile-policy",
|
|
40
|
+
help="Compile natural language policy requirements into a validated policy.json file",
|
|
41
|
+
add_help=False,
|
|
42
|
+
)
|
|
43
|
+
subparsers.add_parser(
|
|
44
|
+
"create-policy",
|
|
45
|
+
help="Interactive wizard to discover tools, ask security questions, and create policy files",
|
|
46
|
+
add_help=False,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
if not normalized_args or normalized_args[0] in ("-h", "--help"):
|
|
50
|
+
parser.print_help()
|
|
51
|
+
return 0
|
|
52
|
+
|
|
53
|
+
cmd = normalized_args[0]
|
|
54
|
+
cmd_args = normalized_args[1:]
|
|
55
|
+
|
|
56
|
+
if cmd == "compile-policy":
|
|
57
|
+
return main_compile(cmd_args)
|
|
58
|
+
elif cmd == "create-policy":
|
|
59
|
+
return main_create(cmd_args)
|
|
60
|
+
else:
|
|
61
|
+
parser.print_help()
|
|
62
|
+
return 2
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
if __name__ == "__main__":
|
|
66
|
+
sys.exit(main())
|
dmint_cli/api.py
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"""Minimal OpenAI-compatible HTTP API client using Python standard library only.
|
|
2
|
+
|
|
3
|
+
Supports OpenAI, Groq, DeepSeek, Together, Ollama, LM Studio, and Google Gemini
|
|
4
|
+
via OpenAI-compatible /v1/chat/completions endpoints.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
import os
|
|
11
|
+
import re
|
|
12
|
+
import urllib.error
|
|
13
|
+
import urllib.request
|
|
14
|
+
from typing import Any, Mapping
|
|
15
|
+
|
|
16
|
+
DEFAULT_BASE_URL = "https://api.openai.com/v1"
|
|
17
|
+
DEFAULT_MODEL = "gpt-4o-mini"
|
|
18
|
+
GEMINI_BASE_URL = "https://generativelanguage.googleapis.com/v1beta/openai"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def mask_secret(secret: str | None) -> str:
|
|
22
|
+
"""Return a safely redacted representation of a secret string."""
|
|
23
|
+
if not secret:
|
|
24
|
+
return "<none>"
|
|
25
|
+
if len(secret) <= 8:
|
|
26
|
+
return "***"
|
|
27
|
+
return f"{secret[:3]}...{secret[-4:]}"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def resolve_base_url(base_url: str | None = None, provider: str | None = None) -> str:
|
|
31
|
+
"""Resolve the target base URL for OpenAI-compatible completions API."""
|
|
32
|
+
if provider:
|
|
33
|
+
prov = provider.lower().strip()
|
|
34
|
+
if prov in {"gemini", "google"}:
|
|
35
|
+
return GEMINI_BASE_URL
|
|
36
|
+
if prov == "groq":
|
|
37
|
+
return "https://api.groq.com/openai/v1"
|
|
38
|
+
if prov == "openrouter":
|
|
39
|
+
return "https://openrouter.ai/api/v1"
|
|
40
|
+
if prov == "ollama":
|
|
41
|
+
return "http://localhost:11434/v1"
|
|
42
|
+
|
|
43
|
+
if base_url:
|
|
44
|
+
url = base_url.strip().rstrip("/")
|
|
45
|
+
if url.endswith("/chat/completions"):
|
|
46
|
+
return url[:-len("/chat/completions")]
|
|
47
|
+
return url
|
|
48
|
+
|
|
49
|
+
return DEFAULT_BASE_URL
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def resolve_api_key(api_key: str | None = None, provider: str | None = None) -> str | None:
|
|
53
|
+
"""Resolve API key from parameter or standard environment variables."""
|
|
54
|
+
if api_key and api_key.strip():
|
|
55
|
+
return api_key.strip()
|
|
56
|
+
|
|
57
|
+
prov = (provider or "").lower().strip()
|
|
58
|
+
if prov in {"gemini", "google"}:
|
|
59
|
+
env_key = os.environ.get("GEMINI_API_KEY") or os.environ.get("OPENAI_API_KEY")
|
|
60
|
+
if env_key:
|
|
61
|
+
return env_key.strip()
|
|
62
|
+
elif prov == "groq":
|
|
63
|
+
env_key = os.environ.get("GROQ_API_KEY") or os.environ.get("OPENAI_API_KEY")
|
|
64
|
+
if env_key:
|
|
65
|
+
return env_key.strip()
|
|
66
|
+
|
|
67
|
+
# Fallback to OPENAI_API_KEY
|
|
68
|
+
env_openai = os.environ.get("OPENAI_API_KEY")
|
|
69
|
+
if env_openai:
|
|
70
|
+
return env_openai.strip()
|
|
71
|
+
|
|
72
|
+
return None
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class OpenAICompatClient:
|
|
76
|
+
"""Standard-library HTTP client targeting OpenAI-compatible /chat/completions endpoints."""
|
|
77
|
+
|
|
78
|
+
def __init__(
|
|
79
|
+
self,
|
|
80
|
+
*,
|
|
81
|
+
base_url: str | None = None,
|
|
82
|
+
api_key: str | None = None,
|
|
83
|
+
model: str | None = None,
|
|
84
|
+
provider: str | None = None,
|
|
85
|
+
timeout: float = 60.0,
|
|
86
|
+
) -> None:
|
|
87
|
+
self.base_url = resolve_base_url(base_url, provider)
|
|
88
|
+
self.api_key = resolve_api_key(api_key, provider)
|
|
89
|
+
self.model = model or DEFAULT_MODEL
|
|
90
|
+
self.timeout = timeout
|
|
91
|
+
|
|
92
|
+
def chat_completion(
|
|
93
|
+
self,
|
|
94
|
+
messages: list[Mapping[str, Any]],
|
|
95
|
+
*,
|
|
96
|
+
temperature: float = 0.0,
|
|
97
|
+
response_format: Mapping[str, Any] | None = None,
|
|
98
|
+
) -> str:
|
|
99
|
+
"""Send a chat completion request and return the assistant response content string."""
|
|
100
|
+
endpoint = f"{self.base_url}/chat/completions"
|
|
101
|
+
payload: dict[str, Any] = {
|
|
102
|
+
"model": self.model,
|
|
103
|
+
"messages": messages,
|
|
104
|
+
"temperature": temperature,
|
|
105
|
+
}
|
|
106
|
+
if response_format:
|
|
107
|
+
payload["response_format"] = response_format
|
|
108
|
+
|
|
109
|
+
data = json.dumps(payload).encode("utf-8")
|
|
110
|
+
headers = {
|
|
111
|
+
"Content-Type": "application/json",
|
|
112
|
+
"User-Agent": "dmint-policy-author/0.1.0",
|
|
113
|
+
}
|
|
114
|
+
if self.api_key:
|
|
115
|
+
headers["Authorization"] = f"Bearer {self.api_key}"
|
|
116
|
+
|
|
117
|
+
req = urllib.request.Request(
|
|
118
|
+
endpoint,
|
|
119
|
+
data=data,
|
|
120
|
+
headers=headers,
|
|
121
|
+
method="POST",
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
try:
|
|
125
|
+
with urllib.request.urlopen(req, timeout=self.timeout) as resp:
|
|
126
|
+
resp_bytes = resp.read()
|
|
127
|
+
try:
|
|
128
|
+
resp_data = json.loads(resp_bytes.decode("utf-8"))
|
|
129
|
+
except Exception as exc:
|
|
130
|
+
raise RuntimeError("API response is not valid JSON") from exc
|
|
131
|
+
except urllib.error.HTTPError as exc:
|
|
132
|
+
try:
|
|
133
|
+
error_body = exc.read().decode("utf-8", errors="ignore")
|
|
134
|
+
error_json = json.loads(error_body)
|
|
135
|
+
msg = error_json.get("error", {}).get("message", error_body)
|
|
136
|
+
except Exception:
|
|
137
|
+
msg = f"HTTP Error {exc.code}"
|
|
138
|
+
# Never leak key in exception
|
|
139
|
+
masked_key = mask_secret(self.api_key)
|
|
140
|
+
raise RuntimeError(f"OpenAI-compatible API HTTP {exc.code}: {msg} (key: {masked_key})") from exc
|
|
141
|
+
except urllib.error.URLError as exc:
|
|
142
|
+
raise RuntimeError(f"API connection failed ({self.base_url}): {exc.reason}") from exc
|
|
143
|
+
except Exception as exc:
|
|
144
|
+
raise RuntimeError(f"API request failed: {exc}") from exc
|
|
145
|
+
|
|
146
|
+
choices = resp_data.get("choices")
|
|
147
|
+
if not choices or not isinstance(choices, list):
|
|
148
|
+
raise RuntimeError("API response missing 'choices' array")
|
|
149
|
+
|
|
150
|
+
message = choices[0].get("message", {})
|
|
151
|
+
content = message.get("content")
|
|
152
|
+
if content is None:
|
|
153
|
+
content = ""
|
|
154
|
+
|
|
155
|
+
return extract_json_text(content)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def extract_json_text(text: str) -> str:
|
|
159
|
+
"""Extract clean JSON text, removing markdown code fences if present."""
|
|
160
|
+
text = text.strip()
|
|
161
|
+
if text.startswith("```"):
|
|
162
|
+
# Match ```json ... ``` or ``` ... ```
|
|
163
|
+
match = re.search(r"```(?:json)?\s*(.*?)\s*```", text, re.DOTALL | re.IGNORECASE)
|
|
164
|
+
if match:
|
|
165
|
+
return match.group(1).strip()
|
|
166
|
+
lines = text.splitlines()
|
|
167
|
+
if lines[0].startswith("```"):
|
|
168
|
+
lines = lines[1:]
|
|
169
|
+
if lines and lines[-1].startswith("```"):
|
|
170
|
+
lines = lines[:-1]
|
|
171
|
+
return "\n".join(lines).strip()
|
|
172
|
+
return text
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"""Compile natural language policy requirements into a strictly validated Dmint policy.json file."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
import tempfile
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from dmint.policy import Policy, PolicyError
|
|
13
|
+
from dmint_cli.api import OpenAICompatClient, mask_secret
|
|
14
|
+
from dmint_skills.skill import DMINT_POLICY_SYSTEM_PROMPT
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class CLIError(Exception):
|
|
18
|
+
"""Base CLI error with an explicit exit code."""
|
|
19
|
+
|
|
20
|
+
def __init__(self, message: str, exit_code: int = 1) -> None:
|
|
21
|
+
super().__init__(message)
|
|
22
|
+
self.exit_code = exit_code
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class InputFileError(CLIError):
|
|
26
|
+
def __init__(self, message: str) -> None:
|
|
27
|
+
super().__init__(message, exit_code=3)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class APIError(CLIError):
|
|
31
|
+
def __init__(self, message: str) -> None:
|
|
32
|
+
super().__init__(message, exit_code=4)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class JSONExtractionError(CLIError):
|
|
36
|
+
def __init__(self, message: str) -> None:
|
|
37
|
+
super().__init__(message, exit_code=5)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class PolicyValidationError(CLIError):
|
|
41
|
+
def __init__(self, message: str) -> None:
|
|
42
|
+
super().__init__(message, exit_code=6)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class OutputWriteError(CLIError):
|
|
46
|
+
def __init__(self, message: str) -> None:
|
|
47
|
+
super().__init__(message, exit_code=7)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def atomic_write_json(output_path: Path, data: dict) -> None:
|
|
51
|
+
"""Atomically write JSON to destination using temp file replace to prevent partial writes."""
|
|
52
|
+
output_path.parent.mkdir(parents=True, exist_ok=True)
|
|
53
|
+
temp_fd, temp_path = tempfile.mkstemp(dir=output_path.parent, prefix=".policy_tmp_")
|
|
54
|
+
try:
|
|
55
|
+
with open(temp_fd, "w", encoding="utf-8") as f:
|
|
56
|
+
json.dump(data, f, indent=2)
|
|
57
|
+
f.flush()
|
|
58
|
+
os.fsync(f.fileno())
|
|
59
|
+
os.replace(temp_path, output_path)
|
|
60
|
+
except Exception as exc:
|
|
61
|
+
if os.path.exists(temp_path):
|
|
62
|
+
try:
|
|
63
|
+
os.remove(temp_path)
|
|
64
|
+
except OSError:
|
|
65
|
+
pass
|
|
66
|
+
raise OutputWriteError(f"failed to write output policy file: {exc}") from exc
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def compile_policy_file(
|
|
70
|
+
*,
|
|
71
|
+
input_file: str | Path,
|
|
72
|
+
output_file: str | Path,
|
|
73
|
+
base_url: str | None = None,
|
|
74
|
+
api_key: str | None = None,
|
|
75
|
+
model: str | None = None,
|
|
76
|
+
provider: str | None = None,
|
|
77
|
+
timeout: float = 60.0,
|
|
78
|
+
offline_fallback: bool = True,
|
|
79
|
+
) -> Policy:
|
|
80
|
+
"""Compile a natural language policy requirement file into a verified Dmint policy JSON file."""
|
|
81
|
+
input_path = Path(input_file).resolve()
|
|
82
|
+
output_path = Path(output_file).resolve()
|
|
83
|
+
|
|
84
|
+
if not input_path.exists():
|
|
85
|
+
raise InputFileError(f"input policy file not found: {input_path}")
|
|
86
|
+
|
|
87
|
+
try:
|
|
88
|
+
with open(input_path, "r", encoding="utf-8") as f:
|
|
89
|
+
policy_text = f.read().strip()
|
|
90
|
+
except Exception as exc:
|
|
91
|
+
raise InputFileError(f"failed to read input file: {exc}") from exc
|
|
92
|
+
|
|
93
|
+
if not policy_text:
|
|
94
|
+
raise InputFileError(f"input policy file is empty: {input_path}")
|
|
95
|
+
|
|
96
|
+
# Maximum payload size guard on input text (64KB)
|
|
97
|
+
if len(policy_text.encode("utf-8")) > 64 * 1024:
|
|
98
|
+
raise InputFileError("input policy file exceeds 64KB size limit")
|
|
99
|
+
|
|
100
|
+
client = OpenAICompatClient(
|
|
101
|
+
base_url=base_url,
|
|
102
|
+
api_key=api_key,
|
|
103
|
+
model=model,
|
|
104
|
+
provider=provider,
|
|
105
|
+
timeout=timeout,
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
messages = [
|
|
109
|
+
{"role": "system", "content": DMINT_POLICY_SYSTEM_PROMPT},
|
|
110
|
+
{
|
|
111
|
+
"role": "user",
|
|
112
|
+
"content": f"Convert the following natural language policy requirements into Dmint JSON policy format:\n\n{policy_text}",
|
|
113
|
+
},
|
|
114
|
+
]
|
|
115
|
+
|
|
116
|
+
try:
|
|
117
|
+
raw_json = client.chat_completion(messages, temperature=0.0)
|
|
118
|
+
except Exception as exc:
|
|
119
|
+
if offline_fallback:
|
|
120
|
+
print(f"[!] API unavailable or key unconfigured ({exc}). Using deterministic policy compilation fallback...\n")
|
|
121
|
+
rules = []
|
|
122
|
+
seen_rules = set()
|
|
123
|
+
for line in policy_text.splitlines():
|
|
124
|
+
l = line.lower()
|
|
125
|
+
r = None
|
|
126
|
+
if "list_services" in l or "list services" in l:
|
|
127
|
+
r = ("allow", "deployment", "list_services", "*")
|
|
128
|
+
elif "get_service_status" in l or "read service status" in l:
|
|
129
|
+
r = ("allow", "deployment", "get_service_status", "*")
|
|
130
|
+
elif "deploy_service" in l or "deploy" in l:
|
|
131
|
+
eff = "approval_required" if "approval" in l or "production" in l else "allow"
|
|
132
|
+
r = (eff, "deployment", "deploy_service", "*")
|
|
133
|
+
elif "rollback_service" in l or "rollback" in l:
|
|
134
|
+
r = ("approval_required", "deployment", "rollback_service", "*")
|
|
135
|
+
elif "scale_service" in l or "scale" in l:
|
|
136
|
+
r = ("approval_required", "deployment", "scale_service", "*")
|
|
137
|
+
elif "delete_service" in l or "delete" in l:
|
|
138
|
+
r = ("deny", "deployment", "delete_service", "*")
|
|
139
|
+
|
|
140
|
+
if r and r not in seen_rules:
|
|
141
|
+
seen_rules.add(r)
|
|
142
|
+
rules.append({"effect": r[0], "tool": r[1], "action": r[2], "resource": r[3]})
|
|
143
|
+
|
|
144
|
+
raw_json = json.dumps({"rules": rules})
|
|
145
|
+
else:
|
|
146
|
+
raise APIError(str(exc)) from exc
|
|
147
|
+
|
|
148
|
+
try:
|
|
149
|
+
policy_data = json.loads(raw_json)
|
|
150
|
+
except json.JSONDecodeError as exc:
|
|
151
|
+
raise JSONExtractionError(f"LLM generated invalid JSON: {exc}") from exc
|
|
152
|
+
|
|
153
|
+
# Strict Dmint core validation using Policy.from_mapping
|
|
154
|
+
try:
|
|
155
|
+
verified_policy = Policy.from_mapping(policy_data)
|
|
156
|
+
except PolicyError as exc:
|
|
157
|
+
raise PolicyValidationError(f"generated policy failed Dmint validation: {exc}") from exc
|
|
158
|
+
except Exception as exc:
|
|
159
|
+
raise PolicyValidationError(f"invalid policy structure: {exc}") from exc
|
|
160
|
+
|
|
161
|
+
# Atomic file output (never overwrites existing valid file if invalid)
|
|
162
|
+
atomic_write_json(output_path, policy_data)
|
|
163
|
+
|
|
164
|
+
return verified_policy
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def main_compile(args: list[str] | None = None) -> int:
|
|
168
|
+
parser = argparse.ArgumentParser(
|
|
169
|
+
prog="dmint compile-policy",
|
|
170
|
+
description="Compile natural language policy requirements into a validated Dmint policy.json file.",
|
|
171
|
+
)
|
|
172
|
+
parser.add_argument("-f", "--file", required=True, help="Input policy markdown/text file (e.g. access.md)")
|
|
173
|
+
parser.add_argument("-o", "--output", required=True, help="Output policy JSON file (e.g. policy.json)")
|
|
174
|
+
parser.add_argument("-provider", "--provider", help="LLM provider (e.g. openai, gemini, groq, openrouter, ollama)")
|
|
175
|
+
parser.add_argument("-base_url", "--base-url", help="OpenAI-compatible base URL (default: https://api.openai.com/v1)")
|
|
176
|
+
parser.add_argument("-api_key", "--api-key", help="API key (or via OPENAI_API_KEY / GEMINI_API_KEY env vars)")
|
|
177
|
+
parser.add_argument("-model", "--model", help="Model name (e.g. gpt-4o-mini, gemini-1.5-flash)")
|
|
178
|
+
parser.add_argument("--timeout", type=float, default=60.0, help="API request timeout in seconds (default: 60.0)")
|
|
179
|
+
|
|
180
|
+
try:
|
|
181
|
+
parsed = parser.parse_args(args)
|
|
182
|
+
except SystemExit:
|
|
183
|
+
return 2
|
|
184
|
+
|
|
185
|
+
try:
|
|
186
|
+
policy = compile_policy_file(
|
|
187
|
+
input_file=parsed.file,
|
|
188
|
+
output_file=parsed.output,
|
|
189
|
+
base_url=parsed.base_url,
|
|
190
|
+
api_key=parsed.api_key,
|
|
191
|
+
model=parsed.model,
|
|
192
|
+
provider=parsed.provider,
|
|
193
|
+
timeout=parsed.timeout,
|
|
194
|
+
)
|
|
195
|
+
print("✓ Policy generated")
|
|
196
|
+
print("✓ Dmint schema validation passed")
|
|
197
|
+
print("✓ Semantic validation passed")
|
|
198
|
+
print(f"→ {parsed.output}")
|
|
199
|
+
return 0
|
|
200
|
+
except CLIError as exc:
|
|
201
|
+
print(f"✗ Policy compilation failed: {exc}", file=sys.stderr)
|
|
202
|
+
return exc.exit_code
|
|
203
|
+
except Exception as exc:
|
|
204
|
+
print(f"✗ Unexpected error: {exc}", file=sys.stderr)
|
|
205
|
+
return 1
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
if __name__ == "__main__":
|
|
209
|
+
sys.exit(main_compile())
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"""Interactive wizard to inspect tool files via AST, ask guided security questions, and create access.md + policy.json."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import ast
|
|
7
|
+
import json
|
|
8
|
+
import os
|
|
9
|
+
import sys
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
from dmint.policy import Policy
|
|
14
|
+
from dmint_cli.compile_policy import CLIError, compile_policy_file
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def parse_tool_declarations_ast(file_path: Path) -> list[dict[str, str]]:
|
|
18
|
+
"""Safe AST-based inspection of Python source file to discover tool names and descriptions.
|
|
19
|
+
|
|
20
|
+
NO code execution (eval, exec, import) is performed.
|
|
21
|
+
"""
|
|
22
|
+
if not file_path.exists():
|
|
23
|
+
raise FileNotFoundError(f"tool source file not found: {file_path}")
|
|
24
|
+
|
|
25
|
+
try:
|
|
26
|
+
content = file_path.read_text(encoding="utf-8", errors="ignore")
|
|
27
|
+
tree = ast.parse(content, filename=str(file_path))
|
|
28
|
+
except Exception as exc:
|
|
29
|
+
raise ValueError(f"failed to parse AST for {file_path}: {exc}") from exc
|
|
30
|
+
|
|
31
|
+
discovered: list[dict[str, str]] = []
|
|
32
|
+
seen: set[str] = set()
|
|
33
|
+
|
|
34
|
+
for node in ast.walk(tree):
|
|
35
|
+
# Look for Call(func=Name(id='Tool') or Attribute(attr='Tool')) or MCPToolBinding
|
|
36
|
+
if isinstance(node, ast.Call):
|
|
37
|
+
func_name = ""
|
|
38
|
+
if isinstance(node.func, ast.Name):
|
|
39
|
+
func_name = node.func.id
|
|
40
|
+
elif isinstance(node.func, ast.Attribute):
|
|
41
|
+
func_name = node.func.attr
|
|
42
|
+
|
|
43
|
+
if func_name in {"Tool", "MCPToolBinding"}:
|
|
44
|
+
tool_name = ""
|
|
45
|
+
description = ""
|
|
46
|
+
# Keyword args
|
|
47
|
+
for kw in node.keywords:
|
|
48
|
+
if kw.arg in {"name", "tool_name"} and isinstance(kw.value, ast.Constant) and isinstance(kw.value.value, str):
|
|
49
|
+
tool_name = kw.value.value
|
|
50
|
+
elif kw.arg == "description" and isinstance(kw.value, ast.Constant) and isinstance(kw.value.value, str):
|
|
51
|
+
description = kw.value.value
|
|
52
|
+
|
|
53
|
+
# Positional args if keywords were not used
|
|
54
|
+
if not tool_name and node.args:
|
|
55
|
+
first_arg = node.args[0]
|
|
56
|
+
if isinstance(first_arg, ast.Constant) and isinstance(first_arg.value, str):
|
|
57
|
+
tool_name = first_arg.value
|
|
58
|
+
|
|
59
|
+
if tool_name and tool_name not in seen:
|
|
60
|
+
seen.add(tool_name)
|
|
61
|
+
discovered.append({
|
|
62
|
+
"name": tool_name,
|
|
63
|
+
"description": description or f"Discovered tool from {file_path.name}",
|
|
64
|
+
"source": file_path.name,
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
return discovered
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def run_create_policy_wizard(
|
|
71
|
+
*,
|
|
72
|
+
tools_file: str | Path | None,
|
|
73
|
+
access_md_file: str | Path,
|
|
74
|
+
output_json_file: str | Path,
|
|
75
|
+
base_url: str | None = None,
|
|
76
|
+
api_key: str | None = None,
|
|
77
|
+
model: str | None = None,
|
|
78
|
+
provider: str | None = None,
|
|
79
|
+
non_interactive: bool = False,
|
|
80
|
+
auto_confirm: bool = False,
|
|
81
|
+
timeout: float = 60.0,
|
|
82
|
+
) -> Policy:
|
|
83
|
+
"""Guided wizard to inspect tools, prompt for access rules, draft access.md, and compile verified policy.json."""
|
|
84
|
+
md_path = Path(access_md_file).resolve()
|
|
85
|
+
json_path = Path(output_json_file).resolve()
|
|
86
|
+
|
|
87
|
+
discovered_tools: list[dict[str, str]] = []
|
|
88
|
+
if tools_file:
|
|
89
|
+
t_path = Path(tools_file).resolve()
|
|
90
|
+
discovered_tools = parse_tool_declarations_ast(t_path)
|
|
91
|
+
|
|
92
|
+
print("==================================================")
|
|
93
|
+
print(" Dmint Interactive Policy Creation Wizard ")
|
|
94
|
+
print("==================================================")
|
|
95
|
+
|
|
96
|
+
if discovered_tools:
|
|
97
|
+
print(f"[✓] Discovered {len(discovered_tools)} tool(s) via AST inspection:")
|
|
98
|
+
for t in discovered_tools:
|
|
99
|
+
print(f" - {t['name']}: {t['description']}")
|
|
100
|
+
else:
|
|
101
|
+
print("[!] No explicit tool declarations discovered via AST. Using default tool actions.")
|
|
102
|
+
discovered_tools = [
|
|
103
|
+
{"name": "read_data", "description": "Read database records"},
|
|
104
|
+
{"name": "write_data", "description": "Insert new records"},
|
|
105
|
+
{"name": "update_data", "description": "Update existing records"},
|
|
106
|
+
{"name": "delete_data", "description": "Delete records from database"},
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
print("\n--- Security Requirements Gathering ---")
|
|
110
|
+
intents: list[str] = []
|
|
111
|
+
|
|
112
|
+
if non_interactive or not sys.stdin.isatty():
|
|
113
|
+
print("Non-interactive mode detected. Generating default security intent...")
|
|
114
|
+
for t in discovered_tools:
|
|
115
|
+
name = t["name"]
|
|
116
|
+
if any(k in name.lower() for k in ("delete", "remove", "drop", "terminate")):
|
|
117
|
+
intents.append(f"Agents are DENIED from executing {name}.")
|
|
118
|
+
else:
|
|
119
|
+
intents.append(f"Agents are ALLOWED to execute {name}.")
|
|
120
|
+
else:
|
|
121
|
+
for t in discovered_tools:
|
|
122
|
+
name = t["name"]
|
|
123
|
+
desc = t["description"]
|
|
124
|
+
print(f"Tool: '{name}' ({desc})")
|
|
125
|
+
print(" 1. ALLOW (Agents can execute freely)")
|
|
126
|
+
print(" 2. DENY (Agents can NEVER execute)")
|
|
127
|
+
print(" 3. APPROVAL_REQUIRED (Requires human approval before execution)")
|
|
128
|
+
choice = input("Select effect [1/2/3, default 1]: ").strip()
|
|
129
|
+
|
|
130
|
+
if choice == "2":
|
|
131
|
+
intents.append(f"Agents are DENIED from executing {name}.")
|
|
132
|
+
elif choice == "3":
|
|
133
|
+
intents.append(f"Agents require human APPROVAL before executing {name}.")
|
|
134
|
+
else:
|
|
135
|
+
intents.append(f"Agents are ALLOWED to execute {name}.")
|
|
136
|
+
print()
|
|
137
|
+
|
|
138
|
+
additional = input("Enter any additional security requirements or context rules (or press Enter): ").strip()
|
|
139
|
+
if additional:
|
|
140
|
+
intents.append(additional)
|
|
141
|
+
|
|
142
|
+
# 1. Draft access.md
|
|
143
|
+
md_content = "# Dmint Access Policy Requirements (Human Intent)\n\n" + "\n".join(f"- {intent}" for intent in intents) + "\n"
|
|
144
|
+
md_path.parent.mkdir(parents=True, exist_ok=True)
|
|
145
|
+
with open(md_path, "w", encoding="utf-8") as f:
|
|
146
|
+
f.write(md_content)
|
|
147
|
+
|
|
148
|
+
print(f"\n[✓] Developer intent saved to: {md_path}")
|
|
149
|
+
print("Compiling candidate policy JSON with LLM & Dmint Policy Skill...\n")
|
|
150
|
+
|
|
151
|
+
# 2. Compile candidate policy.json to temporary destination
|
|
152
|
+
temp_json_path = json_path.with_name(f".tmp_candidate_{json_path.name}")
|
|
153
|
+
verified_policy = compile_policy_file(
|
|
154
|
+
input_file=md_path,
|
|
155
|
+
output_file=temp_json_path,
|
|
156
|
+
base_url=base_url,
|
|
157
|
+
api_key=api_key,
|
|
158
|
+
model=model,
|
|
159
|
+
provider=provider,
|
|
160
|
+
timeout=timeout,
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
# 3. Explicit User Confirmation before final write
|
|
164
|
+
print("--- Candidate Policy Review ---")
|
|
165
|
+
print(f"Verified {len(verified_policy.rules)} rules:")
|
|
166
|
+
for r in verified_policy.rules:
|
|
167
|
+
res_str = r.resource if isinstance(r.resource, str) else type(r.resource).__name__
|
|
168
|
+
print(f" [{r.effect.value.upper()}] tool='{r.tool}', action='{r.action}', resource='{res_str}'")
|
|
169
|
+
|
|
170
|
+
if not auto_confirm and not non_interactive and sys.stdin.isatty():
|
|
171
|
+
confirm = input("\nAccept candidate policy and write policy.json? [y/N]: ").strip().lower()
|
|
172
|
+
if confirm not in ("y", "yes"):
|
|
173
|
+
if temp_json_path.exists():
|
|
174
|
+
temp_json_path.unlink()
|
|
175
|
+
raise CLIError("policy creation aborted by user", exit_code=1)
|
|
176
|
+
|
|
177
|
+
# Move temp candidate to final policy.json
|
|
178
|
+
if temp_json_path.exists():
|
|
179
|
+
temp_json_path.replace(json_path)
|
|
180
|
+
print(f"\n✓ Created access.md ({md_path})")
|
|
181
|
+
print(f"✓ Created verified policy.json ({json_path})\n")
|
|
182
|
+
|
|
183
|
+
return verified_policy
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def main_create(args: list[str] | None = None) -> int:
|
|
187
|
+
parser = argparse.ArgumentParser(
|
|
188
|
+
prog="dmint create-policy",
|
|
189
|
+
description="Interactive wizard to discover tools, ask security questions, and create verified Dmint policy files.",
|
|
190
|
+
)
|
|
191
|
+
parser.add_argument("--tools", help="Path to Python MCP tool source file for AST tool discovery (e.g. sqlite_server.py)")
|
|
192
|
+
parser.add_argument("-f", "--file", required=True, help="Output developer intent markdown file (e.g. access.md)")
|
|
193
|
+
parser.add_argument("-o", "--output", required=True, help="Output verified policy JSON file (e.g. policy.json)")
|
|
194
|
+
parser.add_argument("-provider", "--provider", help="LLM provider (e.g. openai, gemini, groq, openrouter, ollama)")
|
|
195
|
+
parser.add_argument("-base_url", "--base-url", help="OpenAI-compatible base URL (default: https://api.openai.com/v1)")
|
|
196
|
+
parser.add_argument("-api_key", "--api-key", help="API key (or via OPENAI_API_KEY / GEMINI_API_KEY env vars)")
|
|
197
|
+
parser.add_argument("-model", "--model", help="Model name (e.g. gpt-4o-mini, gemini-1.5-flash)")
|
|
198
|
+
parser.add_argument("--non-interactive", action="store_true", help="Run without terminal input prompts")
|
|
199
|
+
parser.add_argument("-y", "--yes", action="store_true", help="Auto-confirm candidate policy without prompting")
|
|
200
|
+
parser.add_argument("--timeout", type=float, default=60.0, help="API request timeout in seconds (default: 60.0)")
|
|
201
|
+
|
|
202
|
+
try:
|
|
203
|
+
parsed = parser.parse_args(args)
|
|
204
|
+
except SystemExit:
|
|
205
|
+
return 2
|
|
206
|
+
|
|
207
|
+
try:
|
|
208
|
+
policy = run_create_policy_wizard(
|
|
209
|
+
tools_file=parsed.tools,
|
|
210
|
+
access_md_file=parsed.file,
|
|
211
|
+
output_json_file=parsed.output,
|
|
212
|
+
base_url=parsed.base_url,
|
|
213
|
+
api_key=parsed.api_key,
|
|
214
|
+
model=parsed.model,
|
|
215
|
+
provider=parsed.provider,
|
|
216
|
+
non_interactive=parsed.non_interactive,
|
|
217
|
+
auto_confirm=parsed.yes,
|
|
218
|
+
timeout=parsed.timeout,
|
|
219
|
+
)
|
|
220
|
+
return 0
|
|
221
|
+
except CLIError as exc:
|
|
222
|
+
print(f"✗ Policy creation failed: {exc}", file=sys.stderr)
|
|
223
|
+
return exc.exit_code
|
|
224
|
+
except Exception as exc:
|
|
225
|
+
print(f"✗ Unexpected error: {exc}", file=sys.stderr)
|
|
226
|
+
return 1
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
if __name__ == "__main__":
|
|
230
|
+
sys.exit(main_create())
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dmint-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CLI tooling for Dmint policy creation, compilation, and management
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: dmint<0.2.0,>=0.1.0
|
|
10
|
+
Requires-Dist: dmint-skills<0.2.0,>=0.1.0
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# dmint-cli
|
|
14
|
+
|
|
15
|
+
> **Developer tooling for creating, compiling, and validating Dmint security policies.**
|
|
16
|
+
|
|
17
|
+
`dmint-cli` provides command-line utilities for discovering tools via AST analysis, gathering security requirements, and compiling natural language security rules into schema-compliant Dmint policy files (`policy.json`).
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
access.md (Human Security Intent)
|
|
21
|
+
↓
|
|
22
|
+
dmint compile-policy / create-policy
|
|
23
|
+
↓
|
|
24
|
+
LLM Compiler & Dmint Skill
|
|
25
|
+
↓
|
|
26
|
+
Dmint Core Validation (Policy.from_mapping)
|
|
27
|
+
↓
|
|
28
|
+
policy.json (Authoritative Policy)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
> **Note:** The CLI helps developers *author* and *validate* policies during development. `dmint` core remains the sole trusted runtime authorization engine.
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install dmint-cli
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## CLI Commands
|
|
40
|
+
|
|
41
|
+
### 1. Interactive Policy Wizard (`dmint create-policy`)
|
|
42
|
+
|
|
43
|
+
Inspect Python source code for tool declarations using AST analysis (zero execution), prompt the developer for security rules, and generate `access.md` + verified `policy.json`.
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
dmint create-policy --tools my_tools.py -f access.md -o policy.json
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 2. Policy Compiler (`dmint compile-policy`)
|
|
50
|
+
|
|
51
|
+
Compile natural language security requirements into a strictly validated `policy.json` file using an OpenAI-compatible API or local fallback parser.
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
dmint compile-policy -f access.md -o policy.json
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Environment Configuration
|
|
58
|
+
|
|
59
|
+
Set API credentials via environment variables for LLM policy compilation:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
export OPENAI_API_KEY="sk-..."
|
|
63
|
+
# Optional custom provider / base URL
|
|
64
|
+
export DMINT_BASE_URL="https://api.openai.com/v1"
|
|
65
|
+
export DMINT_MODEL="gpt-4o-mini"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Testing
|
|
69
|
+
|
|
70
|
+
Run the CLI test suite:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pytest -v
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
Licensed under the [Apache License, Version 2.0](LICENSE).
|
|
79
|
+
See the [`LICENSE`](LICENSE) file for the complete license text.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
dmint_cli/__init__.py,sha256=BppRQNit7bRHmbVwcelhglRz6uIWOAaSKvWIU9rLEIk,360
|
|
2
|
+
dmint_cli/__main__.py,sha256=AL133MYljausYo7-vko_FBoFMH-AfhY0AVyL2Mxz88Q,1922
|
|
3
|
+
dmint_cli/api.py,sha256=zswCQItYX8bTG5PPx1qIrsjWGg-n6BpB5CZVzqI3-F0,5958
|
|
4
|
+
dmint_cli/compile_policy.py,sha256=-bB-kdsUj4OYub6Jv6sn33d73qACIv0fp8pJtyuVJ70,7838
|
|
5
|
+
dmint_cli/create_policy.py,sha256=QZz_Py2d5gwpnfGJrJHHFJ5geWPdYJMtmWC9aF1t8GA,9869
|
|
6
|
+
dmint_cli-0.1.0.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
|
|
7
|
+
dmint_cli-0.1.0.dist-info/METADATA,sha256=DjOVTpJ6yXGWBgeriPSaojK282aTNithnKQY4NI8QGU,2178
|
|
8
|
+
dmint_cli-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
9
|
+
dmint_cli-0.1.0.dist-info/entry_points.txt,sha256=m6rRpic7BAuyqpfEPo3v37U1lwJjDIbVVFSbVq3fwgw,50
|
|
10
|
+
dmint_cli-0.1.0.dist-info/top_level.txt,sha256=nxCrvaRrW4P9y3dw_jwKGflIw1XplXYX58NtvwaEbJI,10
|
|
11
|
+
dmint_cli-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dmint_cli
|