souleyez 2.28.0__py3-none-any.whl → 2.39.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.
Potentially problematic release.
This version of souleyez might be problematic. Click here for more details.
- souleyez/__init__.py +2 -1
- souleyez/core/msf_auto_mapper.py +3 -2
- souleyez/core/tool_chaining.py +77 -11
- souleyez/docs/README.md +1 -1
- souleyez/integrations/siem/__init__.py +2 -0
- souleyez/integrations/siem/factory.py +26 -5
- souleyez/integrations/siem/googlesecops.py +614 -0
- souleyez/integrations/wazuh/config.py +143 -20
- souleyez/main.py +7 -40
- souleyez/storage/database.py +59 -20
- souleyez/storage/migrations/_027_multi_siem_persistence.py +119 -0
- souleyez/storage/migrations/__init__.py +6 -0
- souleyez/storage/schema.sql +44 -4
- souleyez/ui/interactive.py +575 -237
- souleyez-2.39.0.dist-info/METADATA +265 -0
- {souleyez-2.28.0.dist-info → souleyez-2.39.0.dist-info}/RECORD +20 -18
- souleyez-2.28.0.dist-info/METADATA +0 -319
- {souleyez-2.28.0.dist-info → souleyez-2.39.0.dist-info}/WHEEL +0 -0
- {souleyez-2.28.0.dist-info → souleyez-2.39.0.dist-info}/entry_points.txt +0 -0
- {souleyez-2.28.0.dist-info → souleyez-2.39.0.dist-info}/licenses/LICENSE +0 -0
- {souleyez-2.28.0.dist-info → souleyez-2.39.0.dist-info}/top_level.txt +0 -0
|
@@ -10,8 +10,8 @@ from pathlib import Path
|
|
|
10
10
|
from souleyez.storage.database import get_db
|
|
11
11
|
from souleyez.storage.crypto import get_crypto_manager
|
|
12
12
|
|
|
13
|
-
# Supported SIEM types
|
|
14
|
-
SIEM_TYPES = ['wazuh', '
|
|
13
|
+
# Supported SIEM types (Open Source first, then Commercial)
|
|
14
|
+
SIEM_TYPES = ['wazuh', 'elastic', 'splunk', 'sentinel', 'google_secops']
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
class WazuhConfig:
|
|
@@ -22,10 +22,14 @@ class WazuhConfig:
|
|
|
22
22
|
"""
|
|
23
23
|
|
|
24
24
|
@staticmethod
|
|
25
|
-
def get_config(engagement_id: int) -> Optional[Dict[str, Any]]:
|
|
25
|
+
def get_config(engagement_id: int, siem_type: str = None) -> Optional[Dict[str, Any]]:
|
|
26
26
|
"""
|
|
27
27
|
Get SIEM config for an engagement.
|
|
28
28
|
|
|
29
|
+
Args:
|
|
30
|
+
engagement_id: Engagement ID
|
|
31
|
+
siem_type: Optional SIEM type to filter by. If None, returns first/active config.
|
|
32
|
+
|
|
29
33
|
Returns:
|
|
30
34
|
Config dict or None if not configured
|
|
31
35
|
"""
|
|
@@ -33,19 +37,31 @@ class WazuhConfig:
|
|
|
33
37
|
conn = db.get_connection()
|
|
34
38
|
cursor = conn.cursor()
|
|
35
39
|
|
|
36
|
-
# Check if new columns exist (migration 025)
|
|
40
|
+
# Check if new columns exist (migration 025+)
|
|
37
41
|
cursor.execute("PRAGMA table_info(wazuh_config)")
|
|
38
42
|
columns = [col[1] for col in cursor.fetchall()]
|
|
39
43
|
has_new_columns = 'siem_type' in columns
|
|
40
44
|
|
|
41
45
|
# Query with or without new columns
|
|
42
46
|
if has_new_columns:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
if siem_type:
|
|
48
|
+
cursor.execute("""
|
|
49
|
+
SELECT api_url, api_user, api_password, indexer_url, indexer_user,
|
|
50
|
+
indexer_password, verify_ssl, enabled, siem_type, config_json
|
|
51
|
+
FROM wazuh_config
|
|
52
|
+
WHERE engagement_id = ? AND siem_type = ?
|
|
53
|
+
""", (engagement_id, siem_type))
|
|
54
|
+
else:
|
|
55
|
+
# Get most recently updated config (the "current" selected SIEM)
|
|
56
|
+
# Not filtering by enabled - user may have selected but not configured yet
|
|
57
|
+
cursor.execute("""
|
|
58
|
+
SELECT api_url, api_user, api_password, indexer_url, indexer_user,
|
|
59
|
+
indexer_password, verify_ssl, enabled, siem_type, config_json
|
|
60
|
+
FROM wazuh_config
|
|
61
|
+
WHERE engagement_id = ?
|
|
62
|
+
ORDER BY updated_at DESC
|
|
63
|
+
LIMIT 1
|
|
64
|
+
""", (engagement_id,))
|
|
49
65
|
else:
|
|
50
66
|
cursor.execute("""
|
|
51
67
|
SELECT api_url, api_user, api_password, indexer_url, indexer_user,
|
|
@@ -190,7 +206,7 @@ class WazuhConfig:
|
|
|
190
206
|
pass
|
|
191
207
|
config_json_str = json.dumps(encrypted_config)
|
|
192
208
|
|
|
193
|
-
# Upsert config
|
|
209
|
+
# Upsert config - keyed by (engagement_id, siem_type) for multi-SIEM support
|
|
194
210
|
cursor.execute("""
|
|
195
211
|
INSERT INTO wazuh_config (
|
|
196
212
|
engagement_id, api_url, api_user, api_password, indexer_url,
|
|
@@ -198,7 +214,7 @@ class WazuhConfig:
|
|
|
198
214
|
siem_type, config_json
|
|
199
215
|
)
|
|
200
216
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
201
|
-
ON CONFLICT(engagement_id) DO UPDATE SET
|
|
217
|
+
ON CONFLICT(engagement_id, siem_type) DO UPDATE SET
|
|
202
218
|
api_url = excluded.api_url,
|
|
203
219
|
api_user = excluded.api_user,
|
|
204
220
|
api_password = excluded.api_password,
|
|
@@ -207,8 +223,8 @@ class WazuhConfig:
|
|
|
207
223
|
indexer_password = excluded.indexer_password,
|
|
208
224
|
verify_ssl = excluded.verify_ssl,
|
|
209
225
|
enabled = excluded.enabled,
|
|
210
|
-
|
|
211
|
-
|
|
226
|
+
config_json = excluded.config_json,
|
|
227
|
+
updated_at = CURRENT_TIMESTAMP
|
|
212
228
|
""", (
|
|
213
229
|
engagement_id, api_url, api_user, encrypted_api_password,
|
|
214
230
|
indexer_url, indexer_user or 'admin', encrypted_indexer_password,
|
|
@@ -262,17 +278,124 @@ class WazuhConfig:
|
|
|
262
278
|
)
|
|
263
279
|
|
|
264
280
|
@staticmethod
|
|
265
|
-
def delete_config(engagement_id: int) -> bool:
|
|
266
|
-
"""
|
|
281
|
+
def delete_config(engagement_id: int, siem_type: str = None) -> bool:
|
|
282
|
+
"""
|
|
283
|
+
Delete SIEM config for an engagement.
|
|
284
|
+
|
|
285
|
+
Args:
|
|
286
|
+
engagement_id: Engagement ID
|
|
287
|
+
siem_type: Optional SIEM type. If None, deletes ALL SIEM configs for engagement.
|
|
288
|
+
"""
|
|
267
289
|
db = get_db()
|
|
268
290
|
conn = db.get_connection()
|
|
269
291
|
cursor = conn.cursor()
|
|
270
|
-
|
|
292
|
+
if siem_type:
|
|
293
|
+
cursor.execute(
|
|
294
|
+
"DELETE FROM wazuh_config WHERE engagement_id = ? AND siem_type = ?",
|
|
295
|
+
(engagement_id, siem_type)
|
|
296
|
+
)
|
|
297
|
+
else:
|
|
298
|
+
cursor.execute("DELETE FROM wazuh_config WHERE engagement_id = ?", (engagement_id,))
|
|
271
299
|
conn.commit()
|
|
272
300
|
return cursor.rowcount > 0
|
|
273
301
|
|
|
274
302
|
@staticmethod
|
|
275
|
-
def is_configured(engagement_id: int) -> bool:
|
|
276
|
-
"""Check if
|
|
277
|
-
config = WazuhConfig.get_config(engagement_id)
|
|
303
|
+
def is_configured(engagement_id: int, siem_type: str = None) -> bool:
|
|
304
|
+
"""Check if SIEM is configured for an engagement."""
|
|
305
|
+
config = WazuhConfig.get_config(engagement_id, siem_type)
|
|
278
306
|
return config is not None and config.get("enabled", False)
|
|
307
|
+
|
|
308
|
+
@staticmethod
|
|
309
|
+
def list_configured_siems(engagement_id: int) -> List[Dict[str, Any]]:
|
|
310
|
+
"""
|
|
311
|
+
List all configured SIEMs for an engagement.
|
|
312
|
+
|
|
313
|
+
Returns:
|
|
314
|
+
List of dicts with siem_type, enabled, and api_url for each configured SIEM
|
|
315
|
+
"""
|
|
316
|
+
db = get_db()
|
|
317
|
+
conn = db.get_connection()
|
|
318
|
+
cursor = conn.cursor()
|
|
319
|
+
|
|
320
|
+
cursor.execute("PRAGMA table_info(wazuh_config)")
|
|
321
|
+
columns = [col[1] for col in cursor.fetchall()]
|
|
322
|
+
|
|
323
|
+
if 'siem_type' not in columns:
|
|
324
|
+
# Old schema - only one config possible
|
|
325
|
+
cursor.execute("""
|
|
326
|
+
SELECT 'wazuh' as siem_type, enabled, api_url
|
|
327
|
+
FROM wazuh_config
|
|
328
|
+
WHERE engagement_id = ?
|
|
329
|
+
""", (engagement_id,))
|
|
330
|
+
else:
|
|
331
|
+
cursor.execute("""
|
|
332
|
+
SELECT siem_type, enabled, api_url, updated_at
|
|
333
|
+
FROM wazuh_config
|
|
334
|
+
WHERE engagement_id = ?
|
|
335
|
+
ORDER BY siem_type
|
|
336
|
+
""", (engagement_id,))
|
|
337
|
+
|
|
338
|
+
rows = cursor.fetchall()
|
|
339
|
+
return [
|
|
340
|
+
{
|
|
341
|
+
'siem_type': row[0],
|
|
342
|
+
'enabled': bool(row[1]),
|
|
343
|
+
'api_url': row[2],
|
|
344
|
+
'updated_at': row[3] if len(row) > 3 else None
|
|
345
|
+
}
|
|
346
|
+
for row in rows
|
|
347
|
+
]
|
|
348
|
+
|
|
349
|
+
@staticmethod
|
|
350
|
+
def get_all_configs(engagement_id: int) -> Dict[str, Dict[str, Any]]:
|
|
351
|
+
"""
|
|
352
|
+
Get all SIEM configs for an engagement, keyed by siem_type.
|
|
353
|
+
|
|
354
|
+
Returns:
|
|
355
|
+
Dict mapping siem_type to config dict
|
|
356
|
+
"""
|
|
357
|
+
configs = {}
|
|
358
|
+
for siem in SIEM_TYPES:
|
|
359
|
+
config = WazuhConfig.get_config(engagement_id, siem)
|
|
360
|
+
if config:
|
|
361
|
+
configs[siem] = config
|
|
362
|
+
return configs
|
|
363
|
+
|
|
364
|
+
@staticmethod
|
|
365
|
+
def get_current_siem_type(engagement_id: int) -> str:
|
|
366
|
+
"""
|
|
367
|
+
Get the currently selected SIEM type for an engagement.
|
|
368
|
+
|
|
369
|
+
Returns the most recently selected SIEM type, even if not fully configured.
|
|
370
|
+
|
|
371
|
+
Returns:
|
|
372
|
+
SIEM type string ('wazuh', 'splunk', etc.) or 'wazuh' as default
|
|
373
|
+
"""
|
|
374
|
+
config = WazuhConfig.get_config(engagement_id)
|
|
375
|
+
if config:
|
|
376
|
+
return config.get('siem_type', 'wazuh')
|
|
377
|
+
return 'wazuh'
|
|
378
|
+
|
|
379
|
+
@staticmethod
|
|
380
|
+
def set_current_siem(engagement_id: int, siem_type: str) -> bool:
|
|
381
|
+
"""
|
|
382
|
+
Set a SIEM type as current by updating its timestamp.
|
|
383
|
+
|
|
384
|
+
This makes the specified SIEM the "active" one without changing its config.
|
|
385
|
+
|
|
386
|
+
Args:
|
|
387
|
+
engagement_id: Engagement ID
|
|
388
|
+
siem_type: SIEM type to make current
|
|
389
|
+
|
|
390
|
+
Returns:
|
|
391
|
+
True if successful
|
|
392
|
+
"""
|
|
393
|
+
db = get_db()
|
|
394
|
+
conn = db.get_connection()
|
|
395
|
+
cursor = conn.cursor()
|
|
396
|
+
cursor.execute(
|
|
397
|
+
"UPDATE wazuh_config SET updated_at = CURRENT_TIMESTAMP WHERE engagement_id = ? AND siem_type = ?",
|
|
398
|
+
(engagement_id, siem_type)
|
|
399
|
+
)
|
|
400
|
+
conn.commit()
|
|
401
|
+
return cursor.rowcount > 0
|
souleyez/main.py
CHANGED
|
@@ -173,7 +173,7 @@ def _check_privileged_tools():
|
|
|
173
173
|
|
|
174
174
|
|
|
175
175
|
@click.group()
|
|
176
|
-
@click.version_option(version='2.
|
|
176
|
+
@click.version_option(version='2.39.0')
|
|
177
177
|
def cli():
|
|
178
178
|
"""SoulEyez - AI-Powered Pentesting Platform by CyberSoul Security"""
|
|
179
179
|
from souleyez.log_config import init_logging
|
|
@@ -1512,47 +1512,14 @@ def _run_doctor(fix=False, verbose=False):
|
|
|
1512
1512
|
|
|
1513
1513
|
# Section 4: Pentesting Tools
|
|
1514
1514
|
click.echo(click.style("Pentesting Tools", bold=True))
|
|
1515
|
-
#
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
'nikto': ['nikto'],
|
|
1519
|
-
'gobuster': ['gobuster'],
|
|
1520
|
-
'ffuf': ['ffuf'],
|
|
1521
|
-
'nuclei': ['nuclei'],
|
|
1522
|
-
# Exploitation
|
|
1523
|
-
'sqlmap': ['sqlmap'],
|
|
1524
|
-
'hydra': ['hydra'],
|
|
1525
|
-
'msfconsole': ['msfconsole'],
|
|
1526
|
-
# Enumeration (enum4linux-ng on Ubuntu, netexec replaced crackmapexec)
|
|
1527
|
-
'enum4linux': ['enum4linux', 'enum4linux-ng'],
|
|
1528
|
-
'smbmap': ['smbmap'],
|
|
1529
|
-
'netexec': ['netexec', 'nxc', 'crackmapexec'],
|
|
1530
|
-
# Recon
|
|
1531
|
-
'theHarvester': ['theHarvester'],
|
|
1532
|
-
'dnsrecon': ['dnsrecon'],
|
|
1533
|
-
'whois': ['whois'],
|
|
1534
|
-
# Password cracking
|
|
1535
|
-
'hashcat': ['hashcat'],
|
|
1536
|
-
'john': ['john'],
|
|
1537
|
-
# Router/IoT (rsf.py for pipx installs)
|
|
1538
|
-
'routersploit': ['rsf', 'rsf.py', 'routersploit'],
|
|
1539
|
-
'upnpc': ['upnpc'],
|
|
1540
|
-
'binwalk': ['binwalk'],
|
|
1541
|
-
# Remote access
|
|
1542
|
-
'vncviewer': ['vncviewer'],
|
|
1543
|
-
}
|
|
1544
|
-
installed = 0
|
|
1545
|
-
for display_name, binaries in pentest_tools.items():
|
|
1546
|
-
found = any(shutil.which(b) for b in binaries)
|
|
1547
|
-
if found:
|
|
1548
|
-
installed += 1
|
|
1549
|
-
if verbose:
|
|
1550
|
-
check_pass(display_name)
|
|
1515
|
+
# Use the same tool checker as the setup wizard for consistency
|
|
1516
|
+
from souleyez.utils.tool_checker import get_tool_stats
|
|
1517
|
+
installed, total = get_tool_stats()
|
|
1551
1518
|
|
|
1552
|
-
if installed ==
|
|
1553
|
-
check_pass(f"All {
|
|
1519
|
+
if installed == total:
|
|
1520
|
+
check_pass(f"All {total} tools installed")
|
|
1554
1521
|
elif installed > 0:
|
|
1555
|
-
check_warn(f"{installed}/{
|
|
1522
|
+
check_warn(f"{installed}/{total} tools installed", "Run: souleyez setup")
|
|
1556
1523
|
else:
|
|
1557
1524
|
check_fail("No pentesting tools installed", "souleyez setup")
|
|
1558
1525
|
|
souleyez/storage/database.py
CHANGED
|
@@ -31,7 +31,7 @@ class Database:
|
|
|
31
31
|
os.makedirs(db_dir, exist_ok=True)
|
|
32
32
|
|
|
33
33
|
conn = sqlite3.connect(self.db_path, timeout=30.0)
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
# Set secure permissions (owner read/write only)
|
|
36
36
|
os.chmod(self.db_path, 0o600)
|
|
37
37
|
conn.row_factory = sqlite3.Row
|
|
@@ -46,7 +46,44 @@ class Database:
|
|
|
46
46
|
"foreign_keys": True
|
|
47
47
|
})
|
|
48
48
|
|
|
49
|
+
# Check if this is an existing database (has tables)
|
|
50
|
+
cursor = conn.execute(
|
|
51
|
+
"SELECT name FROM sqlite_master WHERE type='table' AND name='engagements'"
|
|
52
|
+
)
|
|
53
|
+
is_existing_db = cursor.fetchone() is not None
|
|
54
|
+
conn.close()
|
|
55
|
+
|
|
56
|
+
# For EXISTING databases: Run migrations FIRST
|
|
57
|
+
# This ensures new columns exist before schema.sql tries to create indexes on them
|
|
58
|
+
if is_existing_db:
|
|
59
|
+
try:
|
|
60
|
+
from .migrations.migration_manager import MigrationManager
|
|
61
|
+
manager = MigrationManager(self.db_path)
|
|
62
|
+
pending = manager.get_pending_migrations()
|
|
63
|
+
if pending:
|
|
64
|
+
logger.info("Running pending migrations for existing database", extra={
|
|
65
|
+
"pending_count": len(pending)
|
|
66
|
+
})
|
|
67
|
+
manager.migrate()
|
|
68
|
+
logger.info("Migrations completed successfully", extra={
|
|
69
|
+
"count": len(pending)
|
|
70
|
+
})
|
|
71
|
+
except Exception as migration_error:
|
|
72
|
+
logger.error("Failed to run migrations on existing database", extra={
|
|
73
|
+
"error": str(migration_error),
|
|
74
|
+
"error_type": type(migration_error).__name__,
|
|
75
|
+
"traceback": traceback.format_exc()
|
|
76
|
+
})
|
|
77
|
+
raise # Don't continue if migrations fail for existing DB
|
|
78
|
+
|
|
79
|
+
# Reconnect for schema loading
|
|
80
|
+
conn = sqlite3.connect(self.db_path, timeout=30.0)
|
|
81
|
+
conn.row_factory = sqlite3.Row
|
|
82
|
+
conn.execute("PRAGMA foreign_keys = ON")
|
|
83
|
+
|
|
49
84
|
# Load and execute schema from the same directory as this file
|
|
85
|
+
# For fresh DBs: Creates all tables with current schema
|
|
86
|
+
# For existing DBs: CREATE TABLE IF NOT EXISTS is no-op, but ensures new tables/indexes
|
|
50
87
|
schema_path = Path(__file__).parent / "schema.sql"
|
|
51
88
|
|
|
52
89
|
if schema_path.exists():
|
|
@@ -228,26 +265,28 @@ class Database:
|
|
|
228
265
|
|
|
229
266
|
conn.commit()
|
|
230
267
|
conn.close()
|
|
231
|
-
|
|
232
|
-
# Run
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
268
|
+
|
|
269
|
+
# For FRESH databases: Run migrations after schema.sql loads
|
|
270
|
+
# (Existing DBs already had migrations run before schema.sql)
|
|
271
|
+
if not is_existing_db:
|
|
272
|
+
try:
|
|
273
|
+
from .migrations.migration_manager import MigrationManager
|
|
274
|
+
manager = MigrationManager(self.db_path)
|
|
275
|
+
pending = manager.get_pending_migrations()
|
|
276
|
+
if pending:
|
|
277
|
+
logger.info("Running pending migrations for fresh database", extra={
|
|
278
|
+
"pending_count": len(pending)
|
|
279
|
+
})
|
|
280
|
+
manager.migrate()
|
|
281
|
+
logger.info("Migrations completed successfully", extra={
|
|
282
|
+
"count": len(pending)
|
|
283
|
+
})
|
|
284
|
+
except Exception as migration_error:
|
|
285
|
+
logger.error("Failed to run migrations", extra={
|
|
286
|
+
"error": str(migration_error),
|
|
287
|
+
"error_type": type(migration_error).__name__,
|
|
288
|
+
"traceback": traceback.format_exc()
|
|
244
289
|
})
|
|
245
|
-
except Exception as migration_error:
|
|
246
|
-
logger.error("Failed to run migrations", extra={
|
|
247
|
-
"error": str(migration_error),
|
|
248
|
-
"error_type": type(migration_error).__name__,
|
|
249
|
-
"traceback": traceback.format_exc()
|
|
250
|
-
})
|
|
251
290
|
|
|
252
291
|
except Exception as e:
|
|
253
292
|
logger.error("Database initialization failed", extra={
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Migration 027: Multi-SIEM Persistence
|
|
3
|
+
|
|
4
|
+
Changes wazuh_config table to support multiple SIEM configs per engagement.
|
|
5
|
+
- Removes UNIQUE constraint on engagement_id
|
|
6
|
+
- Adds UNIQUE constraint on (engagement_id, siem_type)
|
|
7
|
+
- Allows each engagement to have separate configs for Wazuh, Splunk, etc.
|
|
8
|
+
"""
|
|
9
|
+
import os
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def upgrade(conn):
|
|
13
|
+
"""Migrate to multi-SIEM persistence."""
|
|
14
|
+
cursor = conn.cursor()
|
|
15
|
+
|
|
16
|
+
# Check if siem_type column exists (from migration 025)
|
|
17
|
+
cursor.execute("PRAGMA table_info(wazuh_config)")
|
|
18
|
+
columns = [col[1] for col in cursor.fetchall()]
|
|
19
|
+
|
|
20
|
+
if 'siem_type' not in columns:
|
|
21
|
+
cursor.execute("ALTER TABLE wazuh_config ADD COLUMN siem_type TEXT DEFAULT 'wazuh'")
|
|
22
|
+
if 'config_json' not in columns:
|
|
23
|
+
cursor.execute("ALTER TABLE wazuh_config ADD COLUMN config_json TEXT")
|
|
24
|
+
|
|
25
|
+
# Create new table with correct constraint
|
|
26
|
+
cursor.execute("""
|
|
27
|
+
CREATE TABLE IF NOT EXISTS siem_config_new (
|
|
28
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
29
|
+
engagement_id INTEGER NOT NULL,
|
|
30
|
+
siem_type TEXT NOT NULL DEFAULT 'wazuh',
|
|
31
|
+
api_url TEXT,
|
|
32
|
+
api_user TEXT,
|
|
33
|
+
api_password TEXT,
|
|
34
|
+
indexer_url TEXT,
|
|
35
|
+
indexer_user TEXT DEFAULT 'admin',
|
|
36
|
+
indexer_password TEXT,
|
|
37
|
+
verify_ssl BOOLEAN DEFAULT 0,
|
|
38
|
+
enabled BOOLEAN DEFAULT 1,
|
|
39
|
+
config_json TEXT,
|
|
40
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
41
|
+
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
42
|
+
FOREIGN KEY (engagement_id) REFERENCES engagements(id) ON DELETE CASCADE,
|
|
43
|
+
UNIQUE(engagement_id, siem_type)
|
|
44
|
+
)
|
|
45
|
+
""")
|
|
46
|
+
|
|
47
|
+
# Copy existing data
|
|
48
|
+
cursor.execute("""
|
|
49
|
+
INSERT OR IGNORE INTO siem_config_new (
|
|
50
|
+
id, engagement_id, siem_type, api_url, api_user, api_password,
|
|
51
|
+
indexer_url, indexer_user, indexer_password, verify_ssl, enabled,
|
|
52
|
+
config_json, created_at, updated_at
|
|
53
|
+
)
|
|
54
|
+
SELECT
|
|
55
|
+
id, engagement_id, COALESCE(siem_type, 'wazuh'), api_url, api_user, api_password,
|
|
56
|
+
indexer_url, indexer_user, indexer_password, verify_ssl, enabled,
|
|
57
|
+
config_json, created_at, updated_at
|
|
58
|
+
FROM wazuh_config
|
|
59
|
+
""")
|
|
60
|
+
|
|
61
|
+
# Drop old table and rename new one
|
|
62
|
+
cursor.execute("DROP TABLE wazuh_config")
|
|
63
|
+
cursor.execute("ALTER TABLE siem_config_new RENAME TO wazuh_config")
|
|
64
|
+
|
|
65
|
+
# Recreate index
|
|
66
|
+
cursor.execute("CREATE INDEX IF NOT EXISTS idx_wazuh_config_engagement ON wazuh_config(engagement_id)")
|
|
67
|
+
cursor.execute("CREATE INDEX IF NOT EXISTS idx_wazuh_config_siem_type ON wazuh_config(siem_type)")
|
|
68
|
+
|
|
69
|
+
conn.commit()
|
|
70
|
+
|
|
71
|
+
if not os.environ.get('SOULEYEZ_MIGRATION_SILENT'):
|
|
72
|
+
print("Migration 027: Multi-SIEM persistence enabled")
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def downgrade(conn):
|
|
76
|
+
"""Revert to single SIEM per engagement (lossy - keeps only first config per engagement)."""
|
|
77
|
+
cursor = conn.cursor()
|
|
78
|
+
|
|
79
|
+
cursor.execute("""
|
|
80
|
+
CREATE TABLE IF NOT EXISTS wazuh_config_old (
|
|
81
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
82
|
+
engagement_id INTEGER NOT NULL UNIQUE,
|
|
83
|
+
api_url TEXT NOT NULL,
|
|
84
|
+
api_user TEXT NOT NULL,
|
|
85
|
+
api_password TEXT,
|
|
86
|
+
indexer_url TEXT,
|
|
87
|
+
indexer_user TEXT DEFAULT 'admin',
|
|
88
|
+
indexer_password TEXT,
|
|
89
|
+
verify_ssl BOOLEAN DEFAULT 0,
|
|
90
|
+
enabled BOOLEAN DEFAULT 1,
|
|
91
|
+
siem_type TEXT DEFAULT 'wazuh',
|
|
92
|
+
config_json TEXT,
|
|
93
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
94
|
+
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
95
|
+
FOREIGN KEY (engagement_id) REFERENCES engagements(id) ON DELETE CASCADE
|
|
96
|
+
)
|
|
97
|
+
""")
|
|
98
|
+
|
|
99
|
+
# Copy only first config per engagement
|
|
100
|
+
cursor.execute("""
|
|
101
|
+
INSERT OR IGNORE INTO wazuh_config_old (
|
|
102
|
+
engagement_id, api_url, api_user, api_password,
|
|
103
|
+
indexer_url, indexer_user, indexer_password, verify_ssl, enabled,
|
|
104
|
+
siem_type, config_json, created_at, updated_at
|
|
105
|
+
)
|
|
106
|
+
SELECT
|
|
107
|
+
engagement_id, api_url, api_user, api_password,
|
|
108
|
+
indexer_url, indexer_user, indexer_password, verify_ssl, enabled,
|
|
109
|
+
siem_type, config_json, created_at, updated_at
|
|
110
|
+
FROM wazuh_config
|
|
111
|
+
GROUP BY engagement_id
|
|
112
|
+
""")
|
|
113
|
+
|
|
114
|
+
cursor.execute("DROP TABLE wazuh_config")
|
|
115
|
+
cursor.execute("ALTER TABLE wazuh_config_old RENAME TO wazuh_config")
|
|
116
|
+
cursor.execute("CREATE INDEX IF NOT EXISTS idx_wazuh_config_engagement ON wazuh_config(engagement_id)")
|
|
117
|
+
|
|
118
|
+
conn.commit()
|
|
119
|
+
print("Migration 027: Reverted to single SIEM per engagement")
|
|
@@ -29,6 +29,9 @@ from . import (
|
|
|
29
29
|
_022_wazuh_indexer_columns,
|
|
30
30
|
_023_fix_detection_results_fk,
|
|
31
31
|
_024_wazuh_vulnerabilities,
|
|
32
|
+
_025_multi_siem_support,
|
|
33
|
+
_026_add_engagement_scope,
|
|
34
|
+
_027_multi_siem_persistence,
|
|
32
35
|
)
|
|
33
36
|
|
|
34
37
|
# Migration registry - maps version to module
|
|
@@ -56,6 +59,9 @@ MIGRATIONS_REGISTRY = {
|
|
|
56
59
|
'022': _022_wazuh_indexer_columns,
|
|
57
60
|
'023': _023_fix_detection_results_fk,
|
|
58
61
|
'024': _024_wazuh_vulnerabilities,
|
|
62
|
+
'025': _025_multi_siem_support,
|
|
63
|
+
'026': _026_add_engagement_scope,
|
|
64
|
+
'027': _027_multi_siem_persistence,
|
|
59
65
|
}
|
|
60
66
|
|
|
61
67
|
|
souleyez/storage/schema.sql
CHANGED
|
@@ -6,6 +6,7 @@ CREATE TABLE IF NOT EXISTS engagements (
|
|
|
6
6
|
owner_id INTEGER,
|
|
7
7
|
estimated_hours FLOAT DEFAULT 0,
|
|
8
8
|
actual_hours FLOAT DEFAULT 0,
|
|
9
|
+
scope_enforcement TEXT DEFAULT 'off',
|
|
9
10
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
10
11
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
11
12
|
);
|
|
@@ -21,6 +22,7 @@ CREATE TABLE IF NOT EXISTS hosts (
|
|
|
21
22
|
mac_address TEXT,
|
|
22
23
|
status TEXT DEFAULT 'up',
|
|
23
24
|
access_level TEXT DEFAULT 'none',
|
|
25
|
+
scope_status TEXT DEFAULT 'unknown',
|
|
24
26
|
notes TEXT,
|
|
25
27
|
tags TEXT,
|
|
26
28
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
@@ -502,18 +504,21 @@ CREATE INDEX IF NOT EXISTS idx_msf_sessions_active ON msf_sessions(is_active);
|
|
|
502
504
|
-- Wazuh SIEM Integration (Detection Validation)
|
|
503
505
|
CREATE TABLE IF NOT EXISTS wazuh_config (
|
|
504
506
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
505
|
-
engagement_id INTEGER NOT NULL
|
|
506
|
-
|
|
507
|
-
|
|
507
|
+
engagement_id INTEGER NOT NULL,
|
|
508
|
+
siem_type TEXT NOT NULL DEFAULT 'wazuh',
|
|
509
|
+
api_url TEXT,
|
|
510
|
+
api_user TEXT,
|
|
508
511
|
api_password TEXT,
|
|
509
512
|
indexer_url TEXT,
|
|
510
513
|
indexer_user TEXT DEFAULT 'admin',
|
|
511
514
|
indexer_password TEXT,
|
|
512
515
|
verify_ssl BOOLEAN DEFAULT 0,
|
|
513
516
|
enabled BOOLEAN DEFAULT 1,
|
|
517
|
+
config_json TEXT,
|
|
514
518
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
515
519
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
516
|
-
FOREIGN KEY (engagement_id) REFERENCES engagements(id) ON DELETE CASCADE
|
|
520
|
+
FOREIGN KEY (engagement_id) REFERENCES engagements(id) ON DELETE CASCADE,
|
|
521
|
+
UNIQUE(engagement_id, siem_type)
|
|
517
522
|
);
|
|
518
523
|
|
|
519
524
|
-- Detection validation results per job
|
|
@@ -537,6 +542,41 @@ CREATE TABLE IF NOT EXISTS detection_results (
|
|
|
537
542
|
);
|
|
538
543
|
|
|
539
544
|
CREATE INDEX IF NOT EXISTS idx_wazuh_config_engagement ON wazuh_config(engagement_id);
|
|
545
|
+
CREATE INDEX IF NOT EXISTS idx_wazuh_config_siem_type ON wazuh_config(siem_type);
|
|
540
546
|
CREATE INDEX IF NOT EXISTS idx_detection_results_job ON detection_results(job_id);
|
|
541
547
|
CREATE INDEX IF NOT EXISTS idx_detection_results_engagement ON detection_results(engagement_id);
|
|
542
548
|
CREATE INDEX IF NOT EXISTS idx_detection_results_status ON detection_results(detection_status);
|
|
549
|
+
|
|
550
|
+
-- Engagement Scope Validation (from migration 026)
|
|
551
|
+
CREATE TABLE IF NOT EXISTS engagement_scope (
|
|
552
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
553
|
+
engagement_id INTEGER NOT NULL,
|
|
554
|
+
scope_type TEXT NOT NULL,
|
|
555
|
+
value TEXT NOT NULL,
|
|
556
|
+
is_excluded BOOLEAN DEFAULT 0,
|
|
557
|
+
description TEXT,
|
|
558
|
+
added_by TEXT,
|
|
559
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
560
|
+
FOREIGN KEY (engagement_id) REFERENCES engagements(id) ON DELETE CASCADE,
|
|
561
|
+
UNIQUE(engagement_id, scope_type, value)
|
|
562
|
+
);
|
|
563
|
+
|
|
564
|
+
CREATE TABLE IF NOT EXISTS scope_validation_log (
|
|
565
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
566
|
+
engagement_id INTEGER NOT NULL,
|
|
567
|
+
job_id INTEGER,
|
|
568
|
+
target TEXT NOT NULL,
|
|
569
|
+
validation_result TEXT NOT NULL,
|
|
570
|
+
action_taken TEXT NOT NULL,
|
|
571
|
+
matched_scope_id INTEGER,
|
|
572
|
+
user_id TEXT,
|
|
573
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
574
|
+
FOREIGN KEY (engagement_id) REFERENCES engagements(id) ON DELETE CASCADE
|
|
575
|
+
);
|
|
576
|
+
|
|
577
|
+
CREATE INDEX IF NOT EXISTS idx_scope_engagement ON engagement_scope(engagement_id);
|
|
578
|
+
CREATE INDEX IF NOT EXISTS idx_scope_type ON engagement_scope(scope_type);
|
|
579
|
+
CREATE INDEX IF NOT EXISTS idx_scope_log_engagement ON scope_validation_log(engagement_id);
|
|
580
|
+
CREATE INDEX IF NOT EXISTS idx_scope_log_result ON scope_validation_log(validation_result);
|
|
581
|
+
CREATE INDEX IF NOT EXISTS idx_scope_log_timestamp ON scope_validation_log(created_at DESC);
|
|
582
|
+
CREATE INDEX IF NOT EXISTS idx_hosts_scope_status ON hosts(scope_status);
|