Skip to content

A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.

feat(core): update graph repo and tasks to support passing whole node object to transforms

dextmorgn6fcc75346ac3
diff --git a/flowsint-core/src/flowsint_core/core/graph_repository.py b/flowsint-core/src/flowsint_core/core/graph_repository.py
index f167d6a2..95cf1565 100644
--- a/flowsint-core/src/flowsint_core/core/graph_repository.py
+++ b/flowsint-core/src/flowsint_core/core/graph_repository.py
@@ -581,6 +581,38 @@ class GraphRepository:
result = self._connection.query(query, params)
return result[0]["updated_count"] if result else 0
+ def get_nodes_by_ids(
+ self,
+ node_ids: List[str],
+ sketch_id: str
+ ) -> List[Dict[str, Any]]:
+ """
+ Get nodes by their element IDs.
+
+ Args:
+ node_ids: List of Neo4j element IDs
+ sketch_id: Investigation sketch ID (for safety)
+
+ Returns:
+ List of node properties dictionaries
+ """
+ if not self._connection or not node_ids:
+ return []
+
+ query = """
+ UNWIND $node_ids AS node_id
+ MATCH (n)
+ WHERE elementId(n) = node_id AND n.sketch_id = $sketch_id
+ RETURN properties(n) as data
+ """
+
+ result = self._connection.query(
+ query,
+ {"node_ids": node_ids, "sketch_id": sketch_id}
+ )
+
+ return [record["data"] for record in result] if result else []
+
def __enter__(self):
"""Context manager entry."""
return self
diff --git a/flowsint-core/src/flowsint_core/tasks/flow.py b/flowsint-core/src/flowsint_core/tasks/flow.py
index 26fcd52e..5e3ad6ce 100644
--- a/flowsint-core/src/flowsint_core/tasks/flow.py
+++ b/flowsint-core/src/flowsint_core/tasks/flow.py
@@ -29,7 +29,7 @@ db: Session = next(get_db())
def run_flow(
self,
transform_branches,
- values: List[str],
+ serialized_objects: List[dict],
sketch_id: str | None,
owner_id: Optional[str] = None,
):
@@ -69,7 +69,8 @@ def run_flow(
)
# Use the synchronous scan method which internally handles the async operations
- results = transform.scan(values=values)
+ # Pass serialized objects instead of strings - the preprocess will handle them
+ results = transform.scan(values=serialized_objects)
scan.status = EventLevel.COMPLETED
scan.results = to_json_serializable(results)
diff --git a/flowsint-core/src/flowsint_core/tasks/transform.py b/flowsint-core/src/flowsint_core/tasks/transform.py
index 0c6e657b..a3d9b753 100644
--- a/flowsint-core/src/flowsint_core/tasks/transform.py
+++ b/flowsint-core/src/flowsint_core/tasks/transform.py
@@ -29,7 +29,7 @@ db: Session = next(get_db())
def run_transform(
self,
transform_name: str,
- values: List[str],
+ serialized_objects: List[dict],
sketch_id: str | None,
owner_id: Optional[str] = None,
):
@@ -68,7 +68,9 @@ def run_transform(
vault=vault,
)
- results = asyncio.run(transform.execute(values=values))
+ # Deserialize objects back into Pydantic models
+ # The preprocess method in Transform will handle these already-parsed objects
+ results = asyncio.run(transform.execute(values=serialized_objects))
scan.status = EventLevel.COMPLETED
scan.results = to_json_serializable(results)