souleyez 2.28.0__py3-none-any.whl → 2.32.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.
souleyez/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = '2.28.0'
1
+ __version__ = '2.32.0'
@@ -1759,6 +1759,20 @@ class ToolChaining:
1759
1759
  )
1760
1760
  )
1761
1761
 
1762
+ # Database Admin → SQLMap (gentler settings for phpMyAdmin/Adminer)
1763
+ # These panels are slow and easily overwhelmed - use single thread and basic tests
1764
+ self.rules.append(
1765
+ ChainRule(
1766
+ trigger_tool='gobuster',
1767
+ trigger_condition='category:database_admin',
1768
+ target_tool='sqlmap',
1769
+ priority=6, # Lower priority than CVE/exploit scans
1770
+ args_template=['-u', '{target}', '--batch', '--forms', '--threads=1', '--time-sec=10',
1771
+ '--level=1', '--risk=1', '--technique=BEU', '--timeout=30'],
1772
+ description='Database admin panel detected, testing login form for SQL injection (low intensity)'
1773
+ )
1774
+ )
1775
+
1762
1776
  # WordPress → WPScan enumeration
1763
1777
  self.rules.append(
1764
1778
  ChainRule(
@@ -5017,6 +5031,7 @@ class ToolChaining:
5017
5031
  label=f"Auto-retry: gobuster (wildcard {exclude_length}b)",
5018
5032
  engagement_id=engagement_id,
5019
5033
  parent_id=job.get('id'),
5034
+ reason=f"Auto-triggered by gobuster: Wildcard response detected, retrying with --exclude-length {exclude_length}",
5020
5035
  metadata={'retry_attempt': 1, 'retry_parent_job_id': job.get('id')}
5021
5036
  )
5022
5037
 
@@ -5116,7 +5131,8 @@ class ToolChaining:
5116
5131
  args=sqlmap_args,
5117
5132
  label=f"Auto-chain: SQLMap testing {endpoint_url}",
5118
5133
  engagement_id=engagement_id,
5119
- parent_id=job.get('id')
5134
+ parent_id=job.get('id'),
5135
+ reason=f"Auto-triggered by ffuf: Database/dynamic endpoint detected ({status_code} response)"
5120
5136
  )
5121
5137
 
5122
5138
  job_ids.append(sqlmap_job_id)
@@ -5144,6 +5160,7 @@ class ToolChaining:
5144
5160
  label=f"Auto-chain: ffuf recursive {endpoint_url}",
5145
5161
  engagement_id=engagement_id,
5146
5162
  parent_id=job.get('id'),
5163
+ reason=f"Auto-triggered by ffuf: {status_code} response suggests deeper path, fuzzing recursively",
5147
5164
  metadata={'ffuf_depth': current_depth + 1}
5148
5165
  )
5149
5166
 
@@ -5367,7 +5384,8 @@ class ToolChaining:
5367
5384
  args=['-m', '18200', '-a', '0', 'data/wordlists/top100.txt'],
5368
5385
  label='CRACK_ASREP',
5369
5386
  engagement_id=engagement_id,
5370
- parent_id=job.get('id')
5387
+ parent_id=job.get('id'),
5388
+ reason="Auto-triggered by impacket-getnpusers: AS-REP hash extracted, attempting to crack"
5371
5389
  )
5372
5390
 
5373
5391
  job_ids.append(job_id)
@@ -5412,7 +5430,8 @@ class ToolChaining:
5412
5430
  args=['-m', '1000', '-a', '0', 'data/wordlists/top100.txt'],
5413
5431
  label='CRACK_NTLM',
5414
5432
  engagement_id=engagement_id,
5415
- parent_id=job.get('id')
5433
+ parent_id=job.get('id'),
5434
+ reason="Auto-triggered by impacket-secretsdump: NTLM hash extracted, attempting to crack"
5416
5435
  )
5417
5436
 
5418
5437
  job_ids.append(job_id)
@@ -5452,7 +5471,8 @@ class ToolChaining:
5452
5471
  args=[cred_str],
5453
5472
  label='EXTRACT_CREDS',
5454
5473
  engagement_id=engagement_id,
5455
- parent_id=job.get('id')
5474
+ parent_id=job.get('id'),
5475
+ reason="Auto-triggered by hydra: Valid credentials found, attempting to extract domain secrets"
5456
5476
  )
5457
5477
 
5458
5478
  job_ids.append(job_id)
souleyez/docs/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SoulEyez Documentation
2
2
 
3
- **Version:** 2.28.0
3
+ **Version:** 2.32.0
4
4
  **Last Updated:** January 9, 2026
5
5
  **Organization:** CyberSoul Security
6
6
 
@@ -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
- cursor.execute("""
44
- SELECT api_url, api_user, api_password, indexer_url, indexer_user,
45
- indexer_password, verify_ssl, enabled, siem_type, config_json
46
- FROM wazuh_config
47
- WHERE engagement_id = ?
48
- """, (engagement_id,))
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
- siem_type = excluded.siem_type,
211
- config_json = excluded.config_json
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
- """Delete Wazuh config for an engagement."""
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
- cursor.execute("DELETE FROM wazuh_config WHERE engagement_id = ?", (engagement_id,))
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 Wazuh is configured for an engagement."""
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.28.0')
176
+ @click.version_option(version='2.32.0')
177
177
  def cli():
178
178
  """SoulEyez - AI-Powered Pentesting Platform by CyberSoul Security"""
179
179
  from souleyez.log_config import init_logging
@@ -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 pending migrations after schema.sql loads
233
- try:
234
- from .migrations.migration_manager import MigrationManager
235
- manager = MigrationManager(self.db_path)
236
- pending = manager.get_pending_migrations()
237
- if pending:
238
- logger.info("Running pending migrations for fresh database", extra={
239
- "pending_count": len(pending)
240
- })
241
- manager.migrate()
242
- logger.info("Migrations completed successfully", extra={
243
- "count": len(pending)
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
 
@@ -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 UNIQUE,
506
- api_url TEXT NOT NULL,
507
- api_user TEXT NOT NULL,
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);