MCPcopy Create free account
hub / github.com/TheSecuredAnalyst/security-suite / init_db

Function init_db

core/db.py:56–124  ·  view source on GitHub ↗

Create tables if they don't exist.

()

Source from the content-addressed store, hash-verified

54
55
56def init_db() -> None:
57 """Create tables if they don't exist."""
58 with get_db() as conn:
59 conn.executescript("""
60 CREATE TABLE IF NOT EXISTS runs (
61 id TEXT PRIMARY KEY,
62 engagement_id TEXT NOT NULL,
63 operator TEXT NOT NULL,
64 target TEXT NOT NULL,
65 mode TEXT NOT NULL,
66 started_at TEXT NOT NULL,
67 completed_at TEXT,
68 risk_score INTEGER DEFAULT 0,
69 risk_color TEXT DEFAULT 'UNKNOWN',
70 total_hosts INTEGER DEFAULT 0,
71 total_services INTEGER DEFAULT 0,
72 total_cves INTEGER DEFAULT 0,
73 confirmed_exploitable INTEGER DEFAULT 0,
74 already_exploited INTEGER DEFAULT 0,
75 remediations_generated INTEGER DEFAULT 0,
76 remediations_applied INTEGER DEFAULT 0,
77 verified_closed INTEGER DEFAULT 0,
78 errors TEXT DEFAULT '[]',
79 report_path TEXT
80 );
81
82 CREATE TABLE IF NOT EXISTS findings (
83 id INTEGER PRIMARY KEY AUTOINCREMENT,
84 run_id TEXT NOT NULL REFERENCES runs(id),
85 ip TEXT NOT NULL,
86 port INTEGER NOT NULL,
87 service TEXT NOT NULL,
88 version TEXT,
89 cve_id TEXT,
90 cvss_score REAL DEFAULT 0,
91 exploit_status TEXT DEFAULT 'NOT_CHECKED',
92 attack_tags TEXT DEFAULT '[]',
93 already_exploited INTEGER DEFAULT 0,
94 hunt_evidence TEXT DEFAULT '[]',
95 created_at TEXT NOT NULL,
96 UNIQUE(run_id, ip, port)
97 );
98
99 CREATE TABLE IF NOT EXISTS remediations (
100 id INTEGER PRIMARY KEY AUTOINCREMENT,
101 run_id TEXT NOT NULL REFERENCES runs(id),
102 finding_id INTEGER REFERENCES findings(id),
103 ip TEXT NOT NULL,
104 port INTEGER NOT NULL,
105 service TEXT NOT NULL,
106 cve_id TEXT,
107 safe INTEGER DEFAULT 0,
108 explanation TEXT,
109 immediate_mitigation TEXT,
110 permanent_fix TEXT,
111 rollback_script TEXT,
112 verification_command TEXT,
113 warnings TEXT DEFAULT '[]',

Callers 1

db.pyFile · 0.85

Calls 1

get_dbFunction · 0.85

Tested by

no test coverage detected