A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
feat: fetch graph from graph id
dextmorgncec0ff2295f2
diff --git a/flowsint-api/app/main.py b/flowsint-api/app/main.pyindex 43183c83..fa2ed7fd 100644--- a/flowsint-api/app/main.py+++ b/flowsint-api/app/main.py@@ -19,6 +19,7 @@ import randomfrom uuid import uuid4from typing import List, Dictfrom decimal import Decimal+from fastapi.middleware.cors import CORSMiddlewarefrom app.populate import generate_random_sketchload_dotenv()@@ -26,10 +27,30 @@ URI = os.getenv("NEO4J_URI_BOLT")USERNAME = os.getenv("NEO4J_USERNAME")PASSWORD = os.getenv("NEO4J_PASSWORD")+origins = [+ "http://localhost:3000",+ "http://127.0.0.1:3000",+ "http://localhost:3001",+ "http://127.0.0.1:3001",+ "http://app.flowsint.localhost",+ "https://app.flowsint.localhost",+ "http://localhost:5173",+ "http://127.0.0.1:5173",+]+++app = FastAPI()neo4j_connection = Neo4jConnection(URI, USERNAME, PASSWORD)-+app.add_middleware(+ CORSMiddleware,+ allow_origins=origins, # Ou ["*"] pour tout autoriser en dev+ allow_credentials=True,+ allow_methods=["*"],+ allow_headers=["*"],+)+@app.get("/scanners")async def get_scans_list():return {"scanners": ScannerRegistry.list()}diff --git a/flowsint-api/requirements.txt b/flowsint-api/requirements.txtindex 9f8b74a0..28a8a6d4 100644--- a/flowsint-api/requirements.txt+++ b/flowsint-api/requirements.txt@@ -18,4 +18,5 @@ ignoranthibpwnedphonenumberspydantic[email]+fastapi[all]neo4j\ No newline at end of filediff --git a/flowsint-web/src/app/dashboard/investigations/test/actions.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/actions.tsxsimilarity index 100%rename from flowsint-web/src/app/dashboard/investigations/test/actions.tsxrename to flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/actions.tsxdiff --git a/flowsint-web/src/app/dashboard/investigations/test/client.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/client.tsxsimilarity index 78%rename from flowsint-web/src/app/dashboard/investigations/test/client.tsxrename to flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/client.tsxindex 7ea8d532..d11bafff 100644--- a/flowsint-web/src/app/dashboard/investigations/test/client.tsx+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/client.tsx@@ -9,12 +9,14 @@ import { Toolbar } from './toolbar'import { LeftPanel } from './left-panel'import { GraphPanel } from './graph-panel'import { RightPanel } from './right-panel'+import { useQueryState } from 'nuqs'+import { useQuery } from '@tanstack/react-query'-const Client = ({ data }: { data: any }) => {+const Client = () => {const [open, setOpen] = useState(false)const [isLeftPanelCollapsed, setIsLeftPanelCollapsed] = useState(false)const [isRightPanelCollapsed, setIsRightPanelCollapsed] = useState(false)- const [activeTab, setActiveTab] = useState("graph1")+ const [activeTab, setActiveTab] = useQueryState("graph1")const stateSelector = (state: { currentNode: any; setCurrentNode: any }) => ({currentNode: state.currentNode,@@ -26,6 +28,19 @@ const Client = ({ data }: { data: any }) => {setCurrentNode} = useFlowStore(stateSelector, shallow)++ const query = useQuery({+ queryKey: ["sketch", "sketch", activeTab],+ queryFn: async () => {+ const res = await fetch(`${process.env.NEXT_PUBLIC_DOCKER_FLOWSINT_API}/sketch/nodes`)+ if (!res.ok || res.status === 404) {+ throw Error()+ }+ return res.json()+ },+ refetchOnWindowFocus: true,+ })+return (<><Toolbar />@@ -43,12 +58,12 @@ const Client = ({ data }: { data: any }) => {{/* Center Panel with Tabs and Graph */}<ResizablePanel defaultSize={65}><GraphPanel- activeTab={activeTab}+ activeTab={activeTab as string}setActiveTab={setActiveTab}currentNode={currentNode}setCurrentNode={setCurrentNode}setOpenDialog={setOpen}- data={data}+ query={query}/></ResizablePanel>diff --git a/flowsint-web/src/app/dashboard/investigations/test/console-panel.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/console-panel.tsxsimilarity index 98%rename from flowsint-web/src/app/dashboard/investigations/test/console-panel.tsxrename to flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/console-panel.tsxindex 25432aa6..591e3799 100644--- a/flowsint-web/src/app/dashboard/investigations/test/console-panel.tsx+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/console-panel.tsx@@ -15,7 +15,7 @@ export function ConsolePanel() {]return (- <div className="flex h-full flex-col border-t">+ <div className="flex h-full flex-col"><div className="flex h-8 items-center justify-between border-b px-4 bg-card"><h2 className="font-medium text-sm">Console</h2><div className="flex items-center gap-1">diff --git a/flowsint-web/src/app/dashboard/investigations/test/graph-panel.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/graph-panel.tsxsimilarity index 80%rename from flowsint-web/src/app/dashboard/investigations/test/graph-panel.tsxrename to flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/graph-panel.tsxindex 0b5ea7c1..93c5d02f 100644--- a/flowsint-web/src/app/dashboard/investigations/test/graph-panel.tsx+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/graph-panel.tsx@@ -1,7 +1,7 @@import { Button } from '@/components/ui/button'import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@/components/ui/resizable'import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'-import { Network, Plus } from 'lucide-react'+import { Loader, Network, Plus } from 'lucide-react'import Graph from './graph'import { ConsolePanel } from './console-panel'import { useState } from 'react'@@ -12,19 +12,19 @@ interface GraphPanelProps {currentNode: anysetCurrentNode: (node: any) => voidsetOpenDialog: (open: boolean) => void- data: any+ query: any}-export function GraphPanel({ activeTab, setActiveTab, currentNode, setCurrentNode, setOpenDialog, data }: GraphPanelProps) {+export function GraphPanel({ activeTab, setActiveTab, currentNode, setCurrentNode, setOpenDialog, query }: GraphPanelProps) {const [isBottomPanelCollapsed, setIsBottomPanelCollapsed] = useState(false)-+ console.log(query.error)return (<div className="flex flex-col h-full">{/* Tabs header */}- <div className="border-b bg-card">- <div className="flex items-center px-2">+ <div className="border-b bg-muted">+ <div className="flex items-center"><Tabs value={activeTab} onValueChange={setActiveTab} className="w-full">- <TabsList className="bg-muted h-9">+ <TabsList className="bg-background h-8 w-full"><TabsTrigger value="graph1" className="text-xs">Investigation 1</TabsTrigger><TabsTrigger value="graph2" className="text-xs">OSINT Analysis</TabsTrigger><TabsTrigger value="graph3" className="text-xs">Network Map</TabsTrigger>@@ -43,7 +43,10 @@ export function GraphPanel({ activeTab, setActiveTab, currentNode, setCurrentNod{/* Tab content */}<Tabs value={activeTab} className="h-full"><TabsContent value="graph1" className="h-full w-full m-0 p-0">- <Graph currentNode={currentNode} setOpenDialog={setOpenDialog} data={data} setCurrentNode={setCurrentNode} />+ {query.isLoading ? <div className='flex items-center justify-center w-full h-full'><Loader className='animate-spin' /></div> :+ !query.error && <Graph currentNode={currentNode} setOpenDialog={setOpenDialog} data={query.data} setCurrentNode={setCurrentNode} />+ }+ {!query.isLoading && query.error && <div className='flex items-center justify-center w-full h-full'>An error occured fetching graph data.</div>}</TabsContent><TabsContent value="graph2" className="h-full m-0 p-0 data-[state=active]:block"><div className="flex h-full items-center justify-center text-muted-foreground">diff --git a/flowsint-web/src/app/dashboard/investigations/test/graph.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/graph.tsxsimilarity index 100%rename from flowsint-web/src/app/dashboard/investigations/test/graph.tsxrename to flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/graph.tsxdiff --git a/flowsint-web/src/app/dashboard/investigations/test/left-panel.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/left-panel.tsxsimilarity index 99%rename from flowsint-web/src/app/dashboard/investigations/test/left-panel.tsxrename to flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/left-panel.tsxindex 18e6f4c3..3803d125 100644--- a/flowsint-web/src/app/dashboard/investigations/test/left-panel.tsx+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/left-panel.tsx@@ -38,7 +38,7 @@ export function LeftPanel({ isCollapsed, setIsCollapsed }: LeftPanelProps) {maxSize={25}className="h-full bg-card"collapsible={true}- collapsedSize={4}+ collapsedSize={2}onCollapse={() => setIsCollapsed(true)}onExpand={() => setIsCollapsed(false)}>diff --git a/flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/page.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/page.tsxnew file mode 100644index 00000000..020c9266--- /dev/null+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/page.tsx@@ -0,0 +1,6 @@+import Client from "./client"+export default async function Home() {+ return (+ <Client />+ )+}diff --git a/flowsint-web/src/app/dashboard/investigations/test/right-panel.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/right-panel.tsxsimilarity index 98%rename from flowsint-web/src/app/dashboard/investigations/test/right-panel.tsxrename to flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/right-panel.tsxindex 6368a9b6..72ff3bcd 100644--- a/flowsint-web/src/app/dashboard/investigations/test/right-panel.tsx+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/right-panel.tsx@@ -18,7 +18,7 @@ export function RightPanel({ isCollapsed, setIsCollapsed, currentNode }: RightPamaxSize={40}className="h-full bg-card"collapsible={true}- collapsedSize={4}+ collapsedSize={2}onCollapse={() => setIsCollapsed(true)}onExpand={() => setIsCollapsed(false)}>diff --git a/flowsint-web/src/app/dashboard/investigations/test/toolbar.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/toolbar.tsxsimilarity index 94%rename from flowsint-web/src/app/dashboard/investigations/test/toolbar.tsxrename to flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/toolbar.tsxindex 6d0b2094..024a853b 100644--- a/flowsint-web/src/app/dashboard/investigations/test/toolbar.tsx+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/test/toolbar.tsx@@ -134,17 +134,7 @@ export function Toolbar() {<TooltipContent>Layers</TooltipContent></Tooltip></TooltipProvider>-<div className="ml-auto flex items-center gap-2">- <div className="relative w-40">- <Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" />- <input- type="search"- placeholder="Search..."- className="w-full rounded-md border bg-background pl-8 h-8 text-sm"- />- </div>-<TooltipProvider><Tooltip><TooltipTrigger asChild>diff --git a/flowsint-web/src/app/dashboard/investigations/test/page.tsx b/flowsint-web/src/app/dashboard/investigations/test/page.tsxdeleted file mode 100644index 941d4fc1..00000000--- a/flowsint-web/src/app/dashboard/investigations/test/page.tsx+++ /dev/null@@ -1,21 +0,0 @@-import Client from "./client"-async function getGraphData() {- try {- const res = await fetch(`${process.env.NEXT_PUBLIC_DOCKER_FLOWSINT_API}/sketch/nodes`, {- cache: "no-store",- })- if (!res.ok) {- return { nodes: [], edges: [] }- }- return res.json()- } catch (error) {- console.error("Erreur:", error)- return { nodes: [], edges: [] }- }-}-export default async function Home() {- const initialData = await getGraphData()- return (- <Client data={initialData} />- )-}diff --git a/flowsint-web/src/components/ui/tabs.tsx b/flowsint-web/src/components/ui/tabs.tsxindex 76c45faf..0f2c35e9 100644--- a/flowsint-web/src/components/ui/tabs.tsx+++ b/flowsint-web/src/components/ui/tabs.tsx@@ -12,7 +12,7 @@ function Tabs({return (<TabsPrimitive.Rootdata-slot="tabs"- className={cn("flex flex-col gap-2", className)}+ className={cn("flex flex-col", className)} // Removed gap-2 for tighter connection between tabs and content{...props}/>)@@ -26,7 +26,7 @@ function TabsList({<TabsPrimitive.Listdata-slot="tabs-list"className={cn(- "bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-1",+ "inline-flex p-0 items-center border-border bg-background", // Text editor style tab listclassName)}{...props}@@ -42,7 +42,14 @@ function TabsTrigger({<TabsPrimitive.Triggerdata-slot="tabs-trigger"className={cn(- "data-[state=active]:bg-background data-[state=active]:text-foreground ring-ring/10 dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 inline-flex items-center justify-center gap-2 rounded-md px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-4 focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 aria-invalid:focus-visible:ring-0 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ "inline-flex items-center justify-center gap-2 px-3 py-1.5 h-full text-xs font-medium whitespace-nowrap transition-all",+ "border-r border-border",+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset",+ "disabled:pointer-events-none disabled:opacity-50",+ "data-[state=inactive]:bg-muted/30 data-[state=inactive]:text-muted-foreground data-[state=inactive]:hover:bg-muted/50",+ "data-[state=active]:bg-card data-[state=active]:text-foreground data-[state=active]:border-b-0 data-[state=active]:relative",+ "data-[state=active]:after:absolute data-[state=active]:after:bottom-[-1px] data-[state=active]:after:left-0 data-[state=active]:after:right-0 data-[state=active]:after:h-[1px] data-[state=active]:after:bg-card", // Creates the connection to content+ "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",className)}{...props}@@ -58,7 +65,7 @@ function TabsContent({<TabsPrimitive.Contentdata-slot="tabs-content"className={cn(- "ring-ring/10 dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 flex-1 transition-[color,box-shadow] focus-visible:ring-4 focus-visible:outline-1 aria-invalid:focus-visible:ring-0",+ "flex-1 outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset", // Simplified focus stylingclassName)}{...props}@@ -66,4 +73,4 @@ function TabsContent({)}-export { Tabs, TabsList, TabsTrigger, TabsContent }+export { Tabs, TabsList, TabsTrigger, TabsContent }\ No newline at end of file