iflow-mcp-m507_ai-soc-agent 1.0.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.
Files changed (85) hide show
  1. iflow_mcp_m507_ai_soc_agent-1.0.0.dist-info/METADATA +410 -0
  2. iflow_mcp_m507_ai_soc_agent-1.0.0.dist-info/RECORD +85 -0
  3. iflow_mcp_m507_ai_soc_agent-1.0.0.dist-info/WHEEL +5 -0
  4. iflow_mcp_m507_ai_soc_agent-1.0.0.dist-info/entry_points.txt +2 -0
  5. iflow_mcp_m507_ai_soc_agent-1.0.0.dist-info/licenses/LICENSE +21 -0
  6. iflow_mcp_m507_ai_soc_agent-1.0.0.dist-info/top_level.txt +1 -0
  7. src/__init__.py +8 -0
  8. src/ai_controller/README.md +139 -0
  9. src/ai_controller/__init__.py +12 -0
  10. src/ai_controller/agent_executor.py +596 -0
  11. src/ai_controller/cli/__init__.py +2 -0
  12. src/ai_controller/cli/main.py +243 -0
  13. src/ai_controller/session_manager.py +409 -0
  14. src/ai_controller/web/__init__.py +2 -0
  15. src/ai_controller/web/server.py +1181 -0
  16. src/ai_controller/web/static/css/README.md +102 -0
  17. src/api/__init__.py +13 -0
  18. src/api/case_management.py +271 -0
  19. src/api/edr.py +187 -0
  20. src/api/kb.py +136 -0
  21. src/api/siem.py +308 -0
  22. src/core/__init__.py +10 -0
  23. src/core/config.py +242 -0
  24. src/core/config_storage.py +684 -0
  25. src/core/dto.py +50 -0
  26. src/core/errors.py +36 -0
  27. src/core/logging.py +128 -0
  28. src/integrations/__init__.py +8 -0
  29. src/integrations/case_management/__init__.py +5 -0
  30. src/integrations/case_management/iris/__init__.py +11 -0
  31. src/integrations/case_management/iris/iris_client.py +885 -0
  32. src/integrations/case_management/iris/iris_http.py +274 -0
  33. src/integrations/case_management/iris/iris_mapper.py +263 -0
  34. src/integrations/case_management/iris/iris_models.py +128 -0
  35. src/integrations/case_management/thehive/__init__.py +8 -0
  36. src/integrations/case_management/thehive/thehive_client.py +193 -0
  37. src/integrations/case_management/thehive/thehive_http.py +147 -0
  38. src/integrations/case_management/thehive/thehive_mapper.py +190 -0
  39. src/integrations/case_management/thehive/thehive_models.py +125 -0
  40. src/integrations/cti/__init__.py +6 -0
  41. src/integrations/cti/local_tip/__init__.py +10 -0
  42. src/integrations/cti/local_tip/local_tip_client.py +90 -0
  43. src/integrations/cti/local_tip/local_tip_http.py +110 -0
  44. src/integrations/cti/opencti/__init__.py +10 -0
  45. src/integrations/cti/opencti/opencti_client.py +101 -0
  46. src/integrations/cti/opencti/opencti_http.py +418 -0
  47. src/integrations/edr/__init__.py +6 -0
  48. src/integrations/edr/elastic_defend/__init__.py +6 -0
  49. src/integrations/edr/elastic_defend/elastic_defend_client.py +351 -0
  50. src/integrations/edr/elastic_defend/elastic_defend_http.py +162 -0
  51. src/integrations/eng/__init__.py +10 -0
  52. src/integrations/eng/clickup/__init__.py +8 -0
  53. src/integrations/eng/clickup/clickup_client.py +513 -0
  54. src/integrations/eng/clickup/clickup_http.py +156 -0
  55. src/integrations/eng/github/__init__.py +8 -0
  56. src/integrations/eng/github/github_client.py +169 -0
  57. src/integrations/eng/github/github_http.py +158 -0
  58. src/integrations/eng/trello/__init__.py +8 -0
  59. src/integrations/eng/trello/trello_client.py +207 -0
  60. src/integrations/eng/trello/trello_http.py +162 -0
  61. src/integrations/kb/__init__.py +12 -0
  62. src/integrations/kb/fs_kb_client.py +313 -0
  63. src/integrations/siem/__init__.py +6 -0
  64. src/integrations/siem/elastic/__init__.py +6 -0
  65. src/integrations/siem/elastic/elastic_client.py +3319 -0
  66. src/integrations/siem/elastic/elastic_http.py +165 -0
  67. src/mcp/README.md +183 -0
  68. src/mcp/TOOLS.md +2827 -0
  69. src/mcp/__init__.py +13 -0
  70. src/mcp/__main__.py +18 -0
  71. src/mcp/agent_profiles.py +408 -0
  72. src/mcp/flow_agent_profiles.py +424 -0
  73. src/mcp/mcp_server.py +4086 -0
  74. src/mcp/rules_engine.py +487 -0
  75. src/mcp/runbook_manager.py +264 -0
  76. src/orchestrator/__init__.py +11 -0
  77. src/orchestrator/incident_workflow.py +244 -0
  78. src/orchestrator/tools_case.py +1085 -0
  79. src/orchestrator/tools_cti.py +359 -0
  80. src/orchestrator/tools_edr.py +315 -0
  81. src/orchestrator/tools_eng.py +378 -0
  82. src/orchestrator/tools_kb.py +156 -0
  83. src/orchestrator/tools_siem.py +1709 -0
  84. src/web/__init__.py +8 -0
  85. src/web/config_server.py +511 -0
@@ -0,0 +1,90 @@
1
+ """
2
+ Local TIP (Threat Intelligence Platform) implementation of CTI client.
3
+
4
+ This client provides hash lookup capabilities via the local TIP API.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from typing import Any, Dict, Optional
10
+
11
+ from ....core.config import SamiConfig
12
+ from ....core.errors import IntegrationError
13
+ from ....core.logging import get_logger
14
+ from .local_tip_http import LocalTipHttpClient
15
+
16
+
17
+ logger = get_logger("sami.integrations.cti.local_tip.client")
18
+
19
+
20
+ class LocalTipCTIClient:
21
+ """
22
+ CTI client backed by Local TIP.
23
+
24
+ Provides threat intelligence lookup capabilities for hashes.
25
+ """
26
+
27
+ def __init__(self, http_client: LocalTipHttpClient) -> None:
28
+ """
29
+ Initialize the Local TIP CTI client.
30
+
31
+ Args:
32
+ http_client: HTTP client for making API requests
33
+ """
34
+ self._http = http_client
35
+
36
+ @classmethod
37
+ def from_config(cls, config: SamiConfig) -> "LocalTipCTIClient":
38
+ """
39
+ Factory to construct a client from SamiConfig.
40
+
41
+ Args:
42
+ config: SamiConfig instance with CTI configuration
43
+
44
+ Returns:
45
+ LocalTipCTIClient instance
46
+
47
+ Raises:
48
+ IntegrationError: If CTI configuration is not set
49
+ """
50
+ if not config.cti:
51
+ raise IntegrationError("CTI configuration is not set in SamiConfig")
52
+
53
+ if config.cti.cti_type != "local_tip":
54
+ raise IntegrationError(
55
+ f"CTI type '{config.cti.cti_type}' is not supported. Only 'local_tip' is supported."
56
+ )
57
+
58
+ http_client = LocalTipHttpClient(
59
+ base_url=config.cti.base_url,
60
+ timeout_seconds=config.cti.timeout_seconds,
61
+ verify_ssl=config.cti.verify_ssl,
62
+ )
63
+ return cls(http_client=http_client)
64
+
65
+ def lookup_hash(self, hash_value: str) -> Dict[str, Any]:
66
+ """
67
+ Look up a hash in the threat intelligence platform.
68
+
69
+ Args:
70
+ hash_value: The hash value to look up (MD5, SHA1, SHA256, SHA512)
71
+
72
+ Returns:
73
+ Dictionary containing hash intelligence information
74
+
75
+ Raises:
76
+ IntegrationError: If lookup fails
77
+ """
78
+ try:
79
+ result = self._http.lookup_hash(hash_value)
80
+
81
+ if result is None:
82
+ raise IntegrationError(f"Hash lookup returned no result for {hash_value[:16]}...")
83
+
84
+ return result
85
+ except Exception as e:
86
+ logger.exception(f"Error looking up hash {hash_value[:16]}...: {e}")
87
+ if isinstance(e, IntegrationError):
88
+ raise
89
+ raise IntegrationError(f"Failed to lookup hash: {e}") from e
90
+
@@ -0,0 +1,110 @@
1
+ """
2
+ Low-level HTTP client for Local TIP (Threat Intelligence Platform).
3
+
4
+ This module handles HTTP requests to the local TIP API for hash lookups.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import json
10
+ from typing import Any, Dict, Optional
11
+
12
+ import requests
13
+
14
+ from ....core.errors import IntegrationError
15
+ from ....core.logging import get_logger
16
+
17
+
18
+ logger = get_logger("sami.integrations.cti.local_tip.http")
19
+
20
+
21
+ class LocalTipHttpClient:
22
+ """
23
+ HTTP client for Local TIP API.
24
+
25
+ Handles hash lookups via POST /hashes endpoint.
26
+ """
27
+
28
+ def __init__(
29
+ self,
30
+ base_url: str,
31
+ timeout_seconds: int = 30,
32
+ verify_ssl: bool = True,
33
+ ) -> None:
34
+ """
35
+ Initialize the Local TIP HTTP client.
36
+
37
+ Args:
38
+ base_url: Base URL of the TIP API (e.g., "http://10.10.10.95:8084")
39
+ timeout_seconds: Request timeout in seconds
40
+ verify_ssl: Whether to verify SSL certificates
41
+ """
42
+ self.base_url = base_url.rstrip("/")
43
+ self.timeout_seconds = timeout_seconds
44
+ self.verify_ssl = verify_ssl
45
+
46
+ def _headers(self) -> Dict[str, str]:
47
+ """Build request headers."""
48
+ return {
49
+ "Content-Type": "application/json",
50
+ "Accept": "application/json",
51
+ }
52
+
53
+ def lookup_hash(self, hash_value: str) -> Optional[Dict[str, Any]]:
54
+ """
55
+ Look up a hash via the API endpoint.
56
+
57
+ Uses POST /hashes which acts as an upsert - returns existing hash or creates new one.
58
+
59
+ Args:
60
+ hash_value: The hash value to look up (MD5, SHA1, SHA256, SHA512)
61
+
62
+ Returns:
63
+ Dictionary containing hash information, or None if lookup failed
64
+
65
+ Raises:
66
+ IntegrationError: If the API request fails
67
+ """
68
+ url = f"{self.base_url}/hashes"
69
+ payload = {"value": hash_value.strip()}
70
+
71
+ try:
72
+ logger.debug(f"Looking up hash: {hash_value[:16]}... (POST {url})")
73
+
74
+ response = requests.post(
75
+ url,
76
+ json=payload,
77
+ headers=self._headers(),
78
+ timeout=self.timeout_seconds,
79
+ verify=self.verify_ssl,
80
+ )
81
+
82
+ response.raise_for_status()
83
+ result = response.json()
84
+
85
+ logger.debug(f"Hash lookup successful for {hash_value[:16]}...")
86
+ return result
87
+
88
+ except requests.exceptions.Timeout as e:
89
+ logger.error(f"Timeout looking up hash {hash_value[:16]}...: {e}")
90
+ raise IntegrationError(f"Timeout looking up hash: {e}") from e
91
+ except requests.exceptions.RequestException as e:
92
+ logger.error(f"API request failed for hash {hash_value[:16]}...: {e}")
93
+
94
+ # Try to extract error details from response
95
+ error_detail = None
96
+ if hasattr(e, "response") and e.response is not None:
97
+ try:
98
+ error_detail = e.response.json()
99
+ if "detail" in error_detail:
100
+ error_detail = error_detail["detail"]
101
+ except Exception:
102
+ if e.response.text:
103
+ error_detail = e.response.text[:200]
104
+
105
+ error_msg = f"API request failed: {e}"
106
+ if error_detail:
107
+ error_msg += f" - {error_detail}"
108
+
109
+ raise IntegrationError(error_msg) from e
110
+
@@ -0,0 +1,10 @@
1
+ """
2
+ OpenCTI (Open Cyber Threat Intelligence Platform) integration.
3
+
4
+ This module provides integration with OpenCTI for hash lookups and threat intelligence.
5
+ """
6
+
7
+ from .opencti_client import OpenCTIClient
8
+
9
+ __all__ = ["OpenCTIClient"]
10
+
@@ -0,0 +1,101 @@
1
+ """
2
+ OpenCTI (Open Cyber Threat Intelligence Platform) implementation of CTI client.
3
+
4
+ This client provides hash lookup capabilities via the OpenCTI GraphQL API.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from typing import Any, Dict, Optional
10
+
11
+ from ....core.config import SamiConfig
12
+ from ....core.errors import IntegrationError
13
+ from ....core.logging import get_logger
14
+ from .opencti_http import OpenCTIHttpClient
15
+
16
+
17
+ logger = get_logger("sami.integrations.cti.opencti.client")
18
+
19
+
20
+ class OpenCTIClient:
21
+ """
22
+ CTI client backed by OpenCTI.
23
+
24
+ Provides threat intelligence lookup capabilities for hashes.
25
+ """
26
+
27
+ def __init__(self, http_client: OpenCTIHttpClient) -> None:
28
+ """
29
+ Initialize the OpenCTI CTI client.
30
+
31
+ Args:
32
+ http_client: HTTP client for making API requests
33
+ """
34
+ self._http = http_client
35
+
36
+ @classmethod
37
+ def from_config(cls, config: SamiConfig) -> "OpenCTIClient":
38
+ """
39
+ Factory to construct a client from SamiConfig.
40
+
41
+ Args:
42
+ config: SamiConfig instance with CTI configuration
43
+
44
+ Returns:
45
+ OpenCTIClient instance
46
+
47
+ Raises:
48
+ IntegrationError: If CTI configuration is not set or invalid
49
+ """
50
+ if not config.cti:
51
+ raise IntegrationError("CTI configuration is not set in SamiConfig")
52
+
53
+ if config.cti.cti_type != "opencti":
54
+ raise IntegrationError(
55
+ f"CTI type '{config.cti.cti_type}' is not supported. Only 'opencti' is supported."
56
+ )
57
+
58
+ if not config.cti.api_key:
59
+ raise IntegrationError("OpenCTI requires an API key. Set 'api_key' in CTI configuration.")
60
+
61
+ http_client = OpenCTIHttpClient(
62
+ base_url=config.cti.base_url,
63
+ api_key=config.cti.api_key,
64
+ timeout_seconds=config.cti.timeout_seconds,
65
+ verify_ssl=config.cti.verify_ssl,
66
+ )
67
+ return cls(http_client=http_client)
68
+
69
+ def lookup_hash(self, hash_value: str) -> Dict[str, Any]:
70
+ """
71
+ Look up a hash in the threat intelligence platform.
72
+
73
+ Args:
74
+ hash_value: The hash value to look up (MD5, SHA1, SHA256, SHA512)
75
+
76
+ Returns:
77
+ Dictionary containing hash intelligence information
78
+
79
+ Raises:
80
+ IntegrationError: If lookup fails
81
+ """
82
+ try:
83
+ result = self._http.lookup_hash(hash_value)
84
+
85
+ if result is None:
86
+ # Return a structured response even when hash is not found
87
+ return {
88
+ "value": hash_value.strip(),
89
+ "found": False,
90
+ "indicators": [],
91
+ }
92
+
93
+ # Add found flag
94
+ result["found"] = True
95
+ return result
96
+ except Exception as e:
97
+ logger.exception(f"Error looking up hash {hash_value[:16]}...: {e}")
98
+ if isinstance(e, IntegrationError):
99
+ raise
100
+ raise IntegrationError(f"Failed to lookup hash: {e}") from e
101
+