A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
fix: social_account transforms
dextmorgn9a8fe6b13916
diff --git a/flowsint-transforms/src/flowsint_transforms/social/to_maigret.py b/flowsint-transforms/src/flowsint_transforms/social/to_maigret.pyindex c22d3b18..3f5bb90e 100644--- a/flowsint-transforms/src/flowsint_transforms/social/to_maigret.py+++ b/flowsint-transforms/src/flowsint_transforms/social/to_maigret.py@@ -45,7 +45,7 @@ class MaigretTransform(Transform):)return output_file- def parse_maigret_output(self, username: str, output_file: Path) -> List[Username]:+ def parse_maigret_output(self, username_obj: Username, output_file: Path) -> List[SocialAccount]:results: List[SocialAccount] = []if not output_file.exists():return results@@ -56,7 +56,7 @@ class MaigretTransform(Transform):except Exception as e:Logger.error(self.sketch_id,- {"message": f"Failed to load output file for {username}: {e}"},+ {"message": f"Failed to load output file for {username_obj.value}: {e}"},)return results@@ -93,18 +93,25 @@ class MaigretTransform(Transform):except ValueError:followers = following = posts = None- results.append(- SocialAccount(- username=Username(value=username),- profile_url=profile_url,- platform=platform,- profile_picture_url=ids.get("image"),- bio=None,- followers_count=followers,- following_count=following,- posts_count=posts,+ try:+ results.append(+ SocialAccount(+ username=username_obj,+ profile_url=profile_url,+ platform=platform,+ profile_picture_url=ids.get("image"),+ bio=None,+ followers_count=followers,+ following_count=following,+ posts_count=posts,+ ))- )+ except Exception as e:+ Logger.error(+ self.sketch_id,+ {"message": f"Failed to create SocialAccount for {username_obj.value} on {platform}: {e}"},+ )+ continuereturn results@@ -113,9 +120,16 @@ class MaigretTransform(Transform):for profile in data:if not profile.value:continue- output_file = self.run_maigret(profile.value)- parsed = self.parse_maigret_output(profile.value, output_file)- results.extend(parsed)+ try:+ output_file = self.run_maigret(profile.value)+ parsed = self.parse_maigret_output(profile, output_file)+ results.extend(parsed)+ except Exception as e:+ Logger.error(+ self.sketch_id,+ {"message": f"Failed to process username {profile.value}: {e}"},+ )+ continuereturn resultsdef postprocess(self, results: List[OutputType], original_input: List[InputType]) -> List[OutputType]:@@ -123,16 +137,22 @@ class MaigretTransform(Transform):return resultsfor profile in results:- # Create social profile node- self.create_node(profile.username)- self.create_node(profile)- # Create username node-- # Create relationship- self.create_relationship(profile.username, profile, "HAS_SOCIAL_ACCOUNT")- self.log_graph_message(- f"{profile.username.value} -> account found on {profile.platform}"- )+ try:+ # Create username node+ self.create_node(profile.username)+ # Create social profile node+ self.create_node(profile)+ # Create relationship+ self.create_relationship(profile.username, profile, "HAS_SOCIAL_ACCOUNT")+ self.log_graph_message(+ f"{profile.username.value} -> account found on {profile.platform}"+ )+ except Exception as e:+ Logger.error(+ self.sketch_id,+ {"message": f"Failed to create graph nodes for {profile.username.value} on {profile.platform}: {e}"},+ )+ continuereturn resultsdiff --git a/flowsint-transforms/src/flowsint_transforms/social/to_sherlock.py b/flowsint-transforms/src/flowsint_transforms/social/to_sherlock.pyindex 17d58a84..98b68e8e 100644--- a/flowsint-transforms/src/flowsint_transforms/social/to_sherlock.py+++ b/flowsint-transforms/src/flowsint_transforms/social/to_sherlock.py@@ -70,7 +70,7 @@ class SherlockTransform(Transform):# Create Social objects for each found accountfor platform, url in found_accounts.items():results.append(- SocialAccount(username=username, platform=platform, url=url)+ SocialAccount(username=username, platform=platform, profile_url=url))except subprocess.TimeoutExpired:diff --git a/flowsint-types/src/flowsint_types/social_account.py b/flowsint-types/src/flowsint_types/social_account.pyindex a8954fdd..507ed7cb 100644--- a/flowsint-types/src/flowsint_types/social_account.py+++ b/flowsint-types/src/flowsint_types/social_account.py@@ -7,6 +7,12 @@ from .flowsint_base import FlowsintTypeclass SocialAccount(FlowsintType):"""Represents a social media account (the 'home' of a username)."""+ id: Optional[str] = Field(+ None,+ description="Unique identifier for this social account (username@platform)",+ title="ID",+ json_schema_extra={"primary": True}+ )username: Username = Field(..., description="Username associated with this account", title="Username")display_name: Optional[str] = Field(None, description="Display name or full name on the profile", title="Display name")profile_url: Optional[str] = Field(None, description="URL to the account profile page", title="Profile URL")@@ -25,7 +31,13 @@ class SocialAccount(FlowsintType):associated_phones: Optional[List[str]] = Field(None, description="Phone numbers associated with the account", title="Associated phones")@model_validator(mode='after')- def compute_label(self) -> Self:+ def compute_label_and_id(self) -> Self:+ # Compute unique ID from username and platform+ if self.username and self.platform:+ self.id = f"{self.username.value}@{self.platform}"+ elif self.username:+ self.id = self.username.value+# Use display name if available, otherwise usernameif self.display_name:self.label = f"{self.display_name} (@{self.username.value})"diff --git a/flowsint-types/src/flowsint_types/username.py b/flowsint-types/src/flowsint_types/username.pyindex 14c2b51c..e7064eae 100644--- a/flowsint-types/src/flowsint_types/username.py+++ b/flowsint-types/src/flowsint_types/username.py@@ -7,7 +7,12 @@ from .flowsint_base import FlowsintTypeclass Username(FlowsintType):"""Represents a username or handle on any platform."""- value: str = Field(..., description="Username or handle string", title="Username value")+ value: str = Field(+ ...,+ description="Username or handle string",+ title="Username value",+ json_schema_extra={"primary": True}+ )platform: Optional[str] = Field(None, description="Platform name, e.g., 'twitter'", title="Username platform")last_seen: Optional[str] = Field(None, description="Last time this username was observed", title="Last seen at"@@ -32,8 +37,5 @@ class Username(FlowsintType):@model_validator(mode='after')def compute_label(self) -> Self:- if self.platform:- self.label = f"@{self.value} ({self.platform})"- else:- self.label = f"@{self.value}"+ self.label = f"{self.value}"return self