sharktide/shield / intelligence /username_intel.py
sharktide's picture
download
raw
1.23 kB
from __future__ import annotations
import math
import re
from collections import Counter
from typing import List
from shield.models.evidence import Evidence
def _entropy(value: str) -> float:
counts = Counter(value)
total = len(value)
return -sum((count / total) * math.log2(count / total) for count in counts.values())
def collect_username_evidence(username: str | None) -> List[Evidence]:
if not username:
return []
evidence: List[Evidence] = []
if len(username) >= 10 and _entropy(username) >= 3.2 and re.search(r"\d{4,}$", username):
evidence.append(Evidence(
source="username_intelligence",
category="synthetic_identity",
risk_score=42,
weight=0.45,
confidence=0.72,
explanation="Username resembles generated account-farm naming",
))
if re.fullmatch(r"[a-z]{1,4}\d{6,}", username):
evidence.append(Evidence(
source="username_intelligence",
category="synthetic_identity",
risk_score=48,
weight=0.5,
confidence=0.78,
explanation="Username has a compact random-prefix numeric pattern",
))
return evidence

Xet Storage Details

Size:
1.23 kB
·
Xet hash:
e99103f9e420c30ff20370b19850652438747b5047494e903fad3d409fb9dff4

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.