Skip to content

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

feat(types): detect @-prefixed usernames

Mohammad Rezwan Khand0d37ee9f2cd
diff --git a/flowsint-types/src/flowsint_types/username.py b/flowsint-types/src/flowsint_types/username.py
index 25115bd4..6ccc62e6 100644
--- a/flowsint-types/src/flowsint_types/username.py
+++ b/flowsint-types/src/flowsint_types/username.py
@@ -36,7 +36,7 @@ class Username(FlowsintType):
- Hyphens (-)
"""
if v.startswith("@"):
- v = v[1:] # We remove it
+ v = v[1:]
# if not re.match(r"^[a-zA-Z0-9_-]{3,80}$", v):
# raise ValueError(
# f"Invalid username: {v}. Must be 3-80 characters and contain only letters, numbers, underscores, and hyphens."
@@ -55,16 +55,21 @@ class Username(FlowsintType):
@classmethod
def detect(cls, line: str) -> bool:
- """Detect if a line of text contains a username."""
+ """Detect whether a line of text contains a username."""
line = line.strip()
if not line:
return False
+ # Support one leading '@' prefix, which is common for social handles.
+ raw = line[1:] if line.startswith("@") else line
+ if not raw:
+ return False
+
# Don't claim file hashes (MD5/SHA1/SHA256) — those are File entities.
# This keeps hash detection independent of type-registration order.
- if len(line) in (32, 40, 64) and re.fullmatch(r"[0-9a-fA-F]+", line):
+ if len(raw) in (32, 40, 64) and re.fullmatch(r"[0-9a-fA-F]+", raw):
return False
- # Username pattern: 3-80 characters, only letters, numbers, underscores, hyphens
- # Note: This is intentionally restrictive to avoid false positives
- return bool(re.match(r"^[a-zA-Z0-9_-]{3,80}$", line))
+ # Username pattern: 3-80 characters, only letters, numbers, underscores, hyphens.
+ # This is intentionally restrictive to avoid false positives.
+ return bool(re.fullmatch(r"[a-zA-Z0-9_-]{3,80}", raw))