-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
89 lines (77 loc) · 4.3 KB
/
Copy pathconfig.py
File metadata and controls
89 lines (77 loc) · 4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
"""
Qute — Quantum Unified Threat Engine
Central configuration. All settings loaded from environment / .env file.
No values hardcoded here; see .env.example for reference.
"""
import os
import subprocess
from pathlib import Path
from dotenv import load_dotenv
load_dotenv()
# ── Host auto-detection (WSL-safe) ───────────────────────────────
def _detect_host() -> str:
"""
Auto-detect the Windows host IP when running inside WSL.
Falls back to localhost if detection fails (native Linux / macOS / Windows).
"""
try:
ip = subprocess.check_output(
"ip route show | grep default | awk '{print $3}'",
shell=True, stderr=subprocess.DEVNULL,
).decode().strip()
if ip:
return ip
except Exception:
pass
return "127.0.0.1"
def _resolve_host(env_key: str) -> str:
"""Return explicit host from env, or auto-detect.
Strips any accidental port suffix (e.g. '172.25.112.1:11434' → '172.25.112.1')."""
val = os.environ.get(env_key, "").strip()
if not val:
return _detect_host()
if ":" in val and not val.startswith("["): # ignore IPv6
val = val.split(":")[0]
return val
# ── Paths ─────────────────────────────────────────────────────────
ROOT_DIR = Path(__file__).resolve().parent
DATA_DIR = ROOT_DIR / "data"
RULES_DIR = DATA_DIR / "rules"
SAMPLE_DIR = DATA_DIR / "samples"
_db_path = os.getenv("QUTE_DB_PATH", "")
DB_PATH = Path(_db_path) if _db_path else Path.home() / ".qute" / "data.db"
# ── Ollama ────────────────────────────────────────────────────────
OLLAMA_HOST = _resolve_host("QUTE_OLLAMA_HOST")
OLLAMA_PORT = int(os.getenv("QUTE_OLLAMA_PORT", "11434"))
OLLAMA_MODEL = os.getenv("QUTE_OLLAMA_MODEL", "qwen2.5:latest")
OLLAMA_URL = f"http://{OLLAMA_HOST}:{OLLAMA_PORT}/api/generate"
# ── OpenTelemetry ─────────────────────────────────────────────────
OTLP_HOST = _resolve_host("QUTE_OTLP_HOST")
OTLP_PORT = int(os.getenv("QUTE_OTLP_PORT", "4317"))
OTLP_ENDPOINT = f"http://{OTLP_HOST}:{OTLP_PORT}"
OTLP_INSECURE = os.getenv("QUTE_OTLP_INSECURE", "true").lower() == "true"
# ── Quantum ───────────────────────────────────────────────────────
QUANTUM_BACKEND = os.getenv("QUTE_QUANTUM_BACKEND", "cpu")
QUANTUM_SHOTS = int(os.getenv("QUTE_QUANTUM_SHOTS", "1024"))
ISING_NOISE_ENABLED = os.getenv("QUTE_ISING_NOISE_ENABLED", "true").lower() == "true"
ISING_DEPOLAR_PROB = float(os.getenv("QUTE_ISING_NOISE_DEPOLAR_PROB", "0.001"))
ISING_MODEL_DIR = Path(os.getenv("QUTE_ISING_MODEL_DIR", str(Path(__file__).resolve().parent / "data" / "ising_models")))
ISING_MODEL_VARIANT = os.getenv("QUTE_ISING_MODEL_VARIANT", "fast")
# Path to vendored NVIDIA Ising-Decoding source code
ISING_CODE_PATH = str(Path(__file__).resolve().parent / "vendor" / "ising_decoding_code")
# ── Sigma ─────────────────────────────────────────────────────────
SIGMA_RULE_DIR = Path(os.getenv("QUTE_SIGMA_RULE_DIR", str(RULES_DIR)))
SIGMA_COMMUNITY_REPO = os.getenv(
"QUTE_SIGMA_COMMUNITY_REPO", "https://github.com/SigmaHQ/sigma"
)
# ── UI ────────────────────────────────────────────────────────────
UI_PORT = int(os.getenv("QUTE_UI_PORT", "8503"))
UI_THEME = os.getenv("QUTE_UI_THEME", "dark")
UI_PASSWORD_HASH = os.getenv("QUTE_UI_PASSWORD_HASH", "")
if __name__ == "__main__":
print(f"OLLAMA_URL : {OLLAMA_URL}")
print(f"OLLAMA_MODEL : {OLLAMA_MODEL}")
print(f"OTLP_ENDPOINT : {OTLP_ENDPOINT}")
print(f"QUANTUM_BACKEND : {QUANTUM_BACKEND}")
print(f"DB_PATH : {DB_PATH}")
print(f"UI_PORT : {UI_PORT}")