A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
fix: sherlock + holehe
dextmorgnc9f7ed6b1878
diff --git a/flowsint-api/app/main.py b/flowsint-api/app/main.pyindex a8085a95..4313281d 100644--- a/flowsint-api/app/main.py+++ b/flowsint-api/app/main.py@@ -1,8 +1,7 @@-from fastapi import FastAPI, Depends, HTTPException+from fastapi import FastAPI, HTTPExceptionfrom pydantic import BaseModel-from app.core.db import get_dbfrom app.core.celery import celery_app-from supabase import Client+from app.scanners.registry import ScannerRegistryapp = FastAPI()@@ -12,17 +11,19 @@ class ScanRequest(BaseModel):scanner: str@app.post("/scan")-async def scan(item: ScanRequest, db: Client = Depends(get_db)):+async def scan(item: ScanRequest):try:- assert item.value is not None- assert item.sketch_id is not None- assert item.scanner is not None-- task = celery_app.send_task("run_scan", args=[item.scanner, item.value])-- return {"id": task.id }+ if not item.value or not item.sketch_id or not item.scanner:+ raise HTTPException(status_code=400, detail="Missing required fields")+ if not ScannerRegistry.scanner_exists(name=item.scanner):+ raise HTTPException(status_code=400, detail="Scanner not found")+ task = celery_app.send_task("run_scan", args=[item.scanner, item.value, item.sketch_id])+ return {"id": task.id}+ except HTTPException as e:+ raise eexcept Exception as e:+ print(e)raise HTTPException(status_code=500, detail=f"Server error: {str(e)}")diff --git a/flowsint-api/app/scanners/base.py b/flowsint-api/app/scanners/base.pyindex 5a7d98e3..3c2ecbd6 100644--- a/flowsint-api/app/scanners/base.py+++ b/flowsint-api/app/scanners/base.py@@ -23,18 +23,22 @@ class Scanner(ABC):return resultsdef execute(self, value: str, db: Optional[Client] = None, sketch_id: Optional[str] = None) -> Dict[str, Any]:+ try:+ if db and sketch_id:+ db.table("scans").insert({+ "id": self.scan_id,+ "status": "pending",+ "scan_name": self.name,+ "value": value,+ "sketch_id": sketch_id,+ "results": []+ }).execute()+ except Exception as e:+ raise e+preprocessed = self.preprocess(value)results = self.scan(preprocessed)results = self.postprocess(results)- if db and sketch_id:- db.table("scans").insert({- "id": self.scan_id,- "status": "completed" if "error" not in results else "error",- "scan_name": self.name,- "value": value,- "sketch_id": sketch_id,- "data": results- }).execute()-return results+diff --git a/flowsint-api/app/scanners/holehe_scanner.py b/flowsint-api/app/scanners/holehe_scanner.pyindex cd52e239..d3912969 100644--- a/flowsint-api/app/scanners/holehe_scanner.py+++ b/flowsint-api/app/scanners/holehe_scanner.py@@ -153,7 +153,7 @@ class HoleheScanner(Scanner):nike.nike]- results = {}+ results = []for module in modules:module_result = []try:diff --git a/flowsint-api/app/scanners/registry.py b/flowsint-api/app/scanners/registry.pyindex 0c0ee0e2..505b3452 100644--- a/flowsint-api/app/scanners/registry.py+++ b/flowsint-api/app/scanners/registry.py@@ -14,10 +14,16 @@ class ScannerRegistry:instance = scanner_class("")cls._scanners[instance.name] = scanner_class+ @classmethod+ def scanner_exists(cls, name: str) -> bool:+ if name not in cls._scanners:+ return False+ return True+@classmethoddef get_scanner(cls, name: str, scan_id: str) -> Scanner:if name not in cls._scanners:- raise KeyError(f"Scanner '{name}' not found")+ raise Exception(f"Scanner '{name}' not found")return cls._scanners[name](scan_id)ScannerRegistry.register(SherlockScanner)diff --git a/flowsint-api/app/tasks/scanner.py b/flowsint-api/app/tasks/scanner.pyindex cdf566a3..f3afc171 100644--- a/flowsint-api/app/tasks/scanner.py+++ b/flowsint-api/app/tasks/scanner.py@@ -1,24 +1,24 @@from app.core.celery import celery_app-from app.core.db import get_dbfrom app.scanners.registry import ScannerRegistryimport tracebackfrom celery import states-+from app.core.db import get_db@celery_app.task(name="run_scan", bind=True)-def run_scan(self, scanner_name: str, value: str):- db = get_db()+def run_scan(self, scanner_name: str, value: str, sketch_id: str):+ db=get_db()try:scanner = ScannerRegistry.get_scanner(scanner_name, self.request.id)- results = scanner.execute(value)- status = "finished" if "error" not in results else "error"+ results = scanner.execute(value, db=db, sketch_id=sketch_id)+ # status = "finished" if "error" not in results else "error"db.table("scans").update({- "status": status,+ "status": "finished","results": results}).eq("id", self.request.id).execute()return {"result": results}except Exception as ex:- error_logs = traceback.format_exc().split("\n")+ # error_logs = traceback.format_exc().split("\n")+ error_logs= "an error occured"print(f"Error in task: {error_logs}")db.table("scans").update({"status": "error",@@ -26,9 +26,5 @@ def run_scan(self, scanner_name: str, value: str):}).eq("id", self.request.id).execute()self.update_state(state=states.FAILURE,- meta={- "exc_type": type(ex).__name__,- "exc_message": error_logs,- },)raise ex\ No newline at end of filediff --git a/flowsint-web/src/app/dashboard/investigations/page.tsx b/flowsint-web/src/app/dashboard/investigations/page.tsxindex babdbd66..a7376746 100644--- a/flowsint-web/src/app/dashboard/investigations/page.tsx+++ b/flowsint-web/src/app/dashboard/investigations/page.tsx@@ -153,7 +153,7 @@ const DashboardPage = () => {filteredInvestigations.map((investigation: Investigation) => (<TableRow key={investigation.id}><TableCell>- <Link href={`dashboard/investigations/${investigation.id}`} className="flex items-center gap-2 hover:underline font-medium">+ <Link href={`/dashboard/investigations/${investigation.id}`} className="flex items-center gap-2 hover:underline font-medium"><FolderLockIcon className="h-5 w-5 text-muted-foreground opacity-60" /><span>{investigation.name}</span></Link>diff --git a/flowsint-web/src/app/dashboard/page.tsx b/flowsint-web/src/app/dashboard/page.tsxindex 27414dd2..37ef43ab 100644--- a/flowsint-web/src/app/dashboard/page.tsx+++ b/flowsint-web/src/app/dashboard/page.tsx@@ -134,7 +134,7 @@ const DashboardPage = () => {filteredInvestigations.map((investigation: Investigation) => (<TableRow key={investigation.id}><TableCell>- <Link href={`dashboard/investigations/${investigation.id}`} className="flex items-center gap-2 hover:underline font-medium">+ <Link href={`/dashboard/investigations/${investigation.id}`} className="flex items-center gap-2 hover:underline font-medium"><FolderLockIcon className="h-5 w-5 text-muted-foreground opacity-60" /><span>{investigation.name}</span></Link>diff --git a/flowsint-web/src/components/organigrams/graph.tsx b/flowsint-web/src/components/organigrams/graph.tsxindex 5a1a3b15..8806ca8d 100644--- a/flowsint-web/src/components/organigrams/graph.tsx+++ b/flowsint-web/src/components/organigrams/graph.tsx@@ -133,7 +133,7 @@ const FlowControls = memo(({</Tooltip><Tooltip><TooltipTrigger asChild>- <Button size="icon" variant="outline" onClick={() => setView("large-graph")}>+ <Button disabled size="icon" variant="outline" onClick={() => setView("large-graph")}><WorkflowIcon className="h-4 w-4" /></Button></TooltipTrigger>diff --git a/flowsint-web/src/components/sketches/scan-drawer.tsx b/flowsint-web/src/components/sketches/scan-drawer.tsxindex 701556c3..20d8bc7a 100644--- a/flowsint-web/src/components/sketches/scan-drawer.tsx+++ b/flowsint-web/src/components/sketches/scan-drawer.tsx@@ -1,6 +1,6 @@"use client"-import { useEffect, useState } from "react"+import { memo, useEffect, useState } from "react"import {AlertCircle,CheckCircle2,@@ -51,6 +51,7 @@ export type Scan = {results: (ScanResult | ErrorResult)[]}created_at: string+ scan_name: string}export function ScanDrawer() {@@ -84,47 +85,37 @@ export function ScanDrawer() {const isErrorResult = (result: ScanResult | ErrorResult): result is ErrorResult => {return "error" in result}-- const filteredResults = currentScan?.results ? currentScan?.results?.results.filter((result: any) => {- if (isErrorResult(result)) {- return result.error.toLowerCase().includes(searchQuery.toLowerCase())- }- return (- result.name.toLowerCase().includes(searchQuery.toLowerCase()) ||- result.domain.toLowerCase().includes(searchQuery.toLowerCase())- )- }) : null-- const stats = currentScan?.results ? currentScan?.results.results.reduce(- (acc: any, result: any) => {+ const HoleheDrawer = memo(() => {+ const filteredResults = currentScan?.results ? currentScan?.results?.results.filter((result: any) => {if (isErrorResult(result)) {- acc.errors++- } else {- if (result.exists) acc.exists++- if (result.rateLimit) acc.rateLimited+++ return result.error.toLowerCase().includes(searchQuery.toLowerCase())}- return acc- },- { exists: 0, rateLimited: 0, errors: 0 },- ) : null+ return (+ result.name.toLowerCase().includes(searchQuery.toLowerCase()) ||+ result.domain.toLowerCase().includes(searchQuery.toLowerCase())+ )+ }) : null- return (- <Drawer open={open} onOpenChange={setOpen}>- <DrawerContent className="h-[90vh] !max-h-none border">- {isLoading &&- <DrawerHeader className="border-b pb-4 p-4">- <DrawerTitle className="flex items-center gap-2 mb-2">- Scan Results- <Badge variant={currentScan?.status === "error" ? "destructive" : "outline"}>{currentScan?.status}</Badge>- </DrawerTitle>- <p className="opacity-60 mb-2 mt-2">{currentScan?.value}</p>- <div className="h-[400px] w-full flex items-center justify-center gap-1"><Loader /> Loading results...</div>- </DrawerHeader>}+ const stats = currentScan?.results ? currentScan?.results.results.reduce(+ (acc: any, result: any) => {+ if (isErrorResult(result)) {+ acc.errors+++ } else {+ if (result.exists) acc.exists+++ if (result.rateLimit) acc.rateLimited+++ }+ return acc+ },+ { exists: 0, rateLimited: 0, errors: 0 },+ ) : null++ return (+ <>{!isLoading && stats && filteredResults ?<><DrawerHeader className="border-b pb-4 p-4"><DrawerTitle className="flex items-center gap-2 mb-2">- Scan Results <span className="font-normal">({format(new Date(currentScan?.created_at as string), 'dd MMMM, HH:mm')})</span>+ Scan Results ({currentScan?.scan_name}) <span className="font-normal">({format(new Date(currentScan?.created_at as string), 'dd MMMM, HH:mm')})</span><Badge variant={currentScan?.status === "error" ? "destructive" : "outline"}>{currentScan?.status}</Badge></DrawerTitle><p className="opacity-60 mb-2 mt-2">{currentScan?.value}</p>@@ -309,13 +300,46 @@ export function ScanDrawer() {</div></> : !isLoading && <div><DrawerHeader className="border-b pb-4 p-4"><DrawerTitle className="flex items-center gap-2 mb-2">- Scan Results+ Scan Results ({currentScan?.scan_name})<Badge variant={currentScan?.status === "error" ? "destructive" : "outline"}>{currentScan?.status}</Badge></DrawerTitle><p className="opacity-60 mb-2 mt-2">{currentScan?.value}</p><div>Results are not there yet. They should appear soon.</div></DrawerHeader>- </div>}+ </div>+ }+ </>+ )+ })++ const SherlockDrawer = memo(() => (+ <><DrawerHeader className="border-b pb-4 p-4">+ <DrawerTitle className="flex items-center gap-2 mb-2">+ Scan Results ({currentScan?.scan_name})+ <Badge variant={currentScan?.status === "error" ? "destructive" : "outline"}>{currentScan?.status}</Badge>+ </DrawerTitle>+ <p className="opacity-60 mb-2 mt-2">{currentScan?.value}</p>+ <div>Results are not there yet. They should appear soon.</div>+ </DrawerHeader>+ <div className="p-4">+ <pre className="overflow-auto max-h-[500px] rounded-md p-3 border"><code>{JSON.stringify(currentScan?.results, null, 2)}</code></pre>+ </div>+ </>+ ))++ return (+ <Drawer open={open} onOpenChange={setOpen}>+ <DrawerContent className="h-[90vh] !max-h-none border flex flex-col">+ {isLoading &&+ <DrawerHeader className="border-b pb-4 p-4">+ <DrawerTitle className="flex items-center gap-2 mb-2">+ Scan Results+ <Badge variant={currentScan?.status === "error" ? "destructive" : "outline"}>{currentScan?.status}</Badge>+ </DrawerTitle>+ <p className="opacity-60 mb-2 mt-2">{currentScan?.value}</p>+ <div className="h-[400px] w-full flex items-center justify-center gap-1"><Loader /> Loading results...</div>+ </DrawerHeader>}+ {currentScan?.scan_name === "holehe_scanner" ? <HoleheDrawer /> : <SherlockDrawer />}</DrawerContent></Drawer>)diff --git a/flowsint-web/src/components/sketches/sketch/graph.tsx b/flowsint-web/src/components/sketches/sketch/graph.tsxindex 0acc4a38..15ce1cdb 100644--- a/flowsint-web/src/components/sketches/sketch/graph.tsx+++ b/flowsint-web/src/components/sketches/sketch/graph.tsx@@ -134,7 +134,7 @@ const FlowControls = memo(({</Tooltip><Tooltip><TooltipTrigger asChild>- <Button size="icon" variant="outline" onClick={() => setView("large-graph")}>+ <Button disabled size="icon" variant="outline" onClick={() => setView("large-graph")}><WorkflowIcon className="h-4 w-4" /></Button></TooltipTrigger>diff --git a/flowsint-web/src/lib/actions/search.ts b/flowsint-web/src/lib/actions/search.tsindex da28bc3f..4cbf88f5 100644--- a/flowsint-web/src/lib/actions/search.ts+++ b/flowsint-web/src/lib/actions/search.ts@@ -16,7 +16,9 @@ export async function performSearch(value: string, task_name: string, sketch_id:})},);- return response.json();+ const resp = await response.json()+ if (response.status !== 200) throw Error(`Error: received status ${response.status}`)+ return { ...resp, status: response.status };}