Shuffle threat intel (#493)
* Refactor execute_singul function to change action to 'get_ioc' and update parameters for improved integration with Singul * precommit fixes
taylor_socfortress committed
Aug 20, 2025 at 11:09 UTC
0d15e88df37f35fcbd1a4d77ddd11bfa190fabbf
1 file changed
+44
-43
backend/app/connectors/shuffle/services/singul.py
+44
-43
@@ -4,6 +4,46 @@ from app.connectors.shuffle.schema.singul import SingulRequest
4
from app.connectors.shuffle.utils.universal import get_shuffle_org_id
5
from app.connectors.shuffle.utils.universal import get_singul_client
6
7
+# async def execute_singul(
8
+# request: SingulRequest,
9
+# ) -> dict:
10
+# """
11
+# Execute a Singul integration.
12
+
13
+# Args:
14
+# request (SingulRequest): The request object containing the workflow ID.
15
+
16
+# Returns:
17
+# dict: The response containing the execution ID.
18
+# """
19
+# logger.info("Executing Singul integration")
20
+
21
+# # Get Singul client from database credentials
22
+# singul = await get_singul_client()
23
+
24
+# try:
25
+# response = singul.connect(
26
+# app=request.app,
27
+# action="send_message",
28
+# org_id=await get_shuffle_org_id(),
29
+# environment="REPLACE_ME",
30
+# fields=[
31
+# {"key": "to", "value": "walton.taylor23@gmail.com"},
32
+# {"key": "subject", "value": "Test Email from Singul"},
33
+# {"key": "body", "value": "This is a test email sent from Singul."},
34
+# ],
35
+# )
36
+# logger.info(f"Singul response: {response}")
37
+# logger.info(f"Singul response success: {response.get('success', 'unknown')}")
38
+
39
+# return {
40
+# "executionId": response.get("id", "unknown"),
41
+# "message": "Singul integration executed successfully",
42
+# }
43
+# except Exception as e:
44
+# logger.error(f"Failed to execute Singul integration: {e}")
45
+# return {"executionId": "unknown", "message": f"Singul integration failed: {e}", "success": False}
46
+
47
48
async def execute_singul(
49
request: SingulRequest,
@@ -24,15 +64,11 @@ async def execute_singul(
64
65
try:
66
response = singul.connect(
27
- app=request.app,
28
- action="send_message",
67
+ app="opencti",
68
+ action="get_ioc",
69
org_id=await get_shuffle_org_id(),
30
- environment="REPLACE_ME",
31
- fields=[
32
- {"key": "to", "value": "walton.taylor23@gmail.com"},
33
- {"key": "subject", "value": "Test Email from Singul"},
34
- {"key": "body", "value": "This is a test email sent from Singul."},
35
- ],
70
+ environment="THREATINTEL",
71
+ fields=[{"key": "ip", "value": "185.215.113.75"}],
72
)
73
logger.info(f"Singul response: {response}")
74
logger.info(f"Singul response success: {response.get('success', 'unknown')}")
@@ -44,38 +80,3 @@ async def execute_singul(
80
except Exception as e:
81
logger.error(f"Failed to execute Singul integration: {e}")
82
return {"executionId": "unknown", "message": f"Singul integration failed: {e}", "success": False}
47
-
48
-
49
-# async def execute_singul(
50
-# request: SingulRequest,
51
-# ) -> dict:
52
-# """
53
-# Execute a Singul integration.
54
-
55
-# Args:
56
-# request (SingulRequest): The request object containing the workflow ID.
57
-
58
-# Returns:
59
-# dict: The response containing the execution ID.
60
-# """
61
-# logger.info("Executing Singul integration")
62
-
63
-# # Get Singul client from database credentials
64
-# singul = await get_singul_client()
65
-
66
-# try:
67
-# response = singul.intel.get_ioc(
68
-# app="opencti_dcon",
69
-# org_id=await get_shuffle_org_id(),
70
-# fields=[{"key": "ip", "value": "1.1.1.1"}],
71
-# )
72
-# logger.info(f"Singul response: {response}")
73
-# logger.info(f"Singul response success: {response.get('success', 'unknown')}")
74
-
75
-# return {
76
-# "executionId": response.get("id", "unknown"),
77
-# "message": "Singul integration executed successfully",
78
-# }
79
-# except Exception as e:
80
-# logger.error(f"Failed to execute Singul integration: {e}")
81
-# return {"executionId": "unknown", "message": f"Singul integration failed: {e}", "success": False}