mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-28 01:49:00 +09:00
## Summary - **Fix** broken user profile link URL (was 404, now goes to correct detail page) - **Add** internal/test account filtering — excludes @nomadkaraoke.com, @beveridge.uk, @inbox.testmail.app from all abuse views - **New** Correlations tab (now default) showing fingerprint clusters (RED flag) and IP clusters (ORANGE flag), with user agent matching highlighted (YELLOW signal) - **Demote** old "Suspicious Accounts" to secondary tab ## Motivation The existing "Suspicious Accounts" view flagged too many false positives — legitimate users who just used their 2 free credits, internal test accounts, etc. The real abuse signal is **cross-account correlation**: multiple accounts sharing the same device fingerprint or signup IP. ## Changes | File | What | |------|------| | `backend/utils/test_data.py` | Add internal email domain filtering | | `backend/services/user_service.py` | New `find_account_correlations()`, filter suspicious accounts | | `backend/api/routes/admin.py` | New `GET /api/admin/abuse/correlations` endpoint | | `frontend/lib/api.ts` | New types + API client method | | `frontend/app/admin/abuse/page.tsx` | Fix link URL, new Correlations tab, restructure tabs | | `backend/tests/test_anti_abuse_investigation.py` | 10 new tests | ## Test plan - [x] 27 anti-abuse investigation tests pass (10 new) - [x] 2749 backend tests pass - [x] Frontend dev server starts without errors - [ ] Manual: verify correlations tab shows real data in prod @coderabbitai ignore 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
"""
|
|
Utilities for identifying test data and internal accounts.
|
|
|
|
Test data is generated by automated E2E tests and should be filterable
|
|
in admin dashboards to show only real user data by default.
|
|
|
|
Internal accounts belong to team members and should be excluded from
|
|
abuse investigation views.
|
|
"""
|
|
|
|
# Email domains used by automated testing frameworks
|
|
TEST_EMAIL_DOMAINS = [
|
|
"inbox.testmail.app", # Used by E2E happy path tests
|
|
]
|
|
|
|
# Email domains belonging to internal team members
|
|
INTERNAL_EMAIL_DOMAINS = [
|
|
"nomadkaraoke.com", # Team accounts
|
|
"beveridge.uk", # Founder's personal domain
|
|
]
|
|
|
|
|
|
def is_test_email(email: str) -> bool:
|
|
"""
|
|
Check if an email address belongs to automated test data.
|
|
|
|
Args:
|
|
email: Email address to check
|
|
|
|
Returns:
|
|
True if the email matches a test email domain pattern
|
|
"""
|
|
if not email:
|
|
return False
|
|
email_lower = email.lower()
|
|
return any(email_lower.endswith(f"@{domain}") for domain in TEST_EMAIL_DOMAINS)
|
|
|
|
|
|
def is_internal_email(email: str) -> bool:
|
|
"""Check if an email address belongs to an internal team member."""
|
|
if not email:
|
|
return False
|
|
email_lower = email.lower()
|
|
return any(email_lower.endswith(f"@{domain}") for domain in INTERNAL_EMAIL_DOMAINS)
|
|
|
|
|
|
def is_internal_or_test_email(email: str) -> bool:
|
|
"""Check if an email is internal or automated test data."""
|
|
return is_test_email(email) or is_internal_email(email)
|