feat: Add SentinelOne integration
- Add SentinelOne API client (lib/services/sentinelone-client.ts) - Paginated fetching for sites, agents, threats - JWT token auth via S1_API_URL / S1_API_TOKEN env vars - Add SentinelOne sync service (lib/services/sentinelone-sync-service.ts) - Full sync: sites, agents, threats into s1_* tables - Sync history tracking with per-entity results - Add DB migration 038: s1_sites, s1_agents, s1_threats, s1_company_mappings, s1_sync_history tables - Add API routes: - POST/GET /api/sentinelone/sync - GET/POST/DELETE /api/sentinelone/company-mappings - GET /api/sentinelone/coverage (fixed Cartesian product bug) - Add UI pages: - /admin/sync/sentinelone — sync admin with history + stats - /sentinelone/coverage — AV coverage report per site - /sentinelone/mappings — map S1 sites to Autotask companies - Wire SentinelOne into admin sync overview card grid - Add SentinelOne Sync to app navigation - Fix docker-compose: remove explicit S1 env var entries that were overwriting env_file values with empty strings
This commit is contained in:
parent
d7c3dc7168
commit
ed6c4a8b65
12 changed files with 1637 additions and 7 deletions
|
|
@ -16,17 +16,20 @@ interface IntegrationCard {
|
|||
}
|
||||
|
||||
const INTEGRATIONS: IntegrationCard[] = [
|
||||
{ id: 'autotask', category: 'PSA', product: 'Autotask', description: 'Tickets, companies, contacts, time entries, configuration items', href: '/admin/sync/autotask', logo: '/logos/autotask.ico', color: 'red' },
|
||||
{ id: 'veeam', category: 'Backup', product: 'Veeam VSPC', description: 'Agent jobs, backup jobs, protected workloads, compliance', href: '/admin/sync/veeam', logo: '/logos/veeam.ico', color: 'green' },
|
||||
{ id: 'datto-rmm', category: 'RMM', product: 'Datto RMM', description: 'Device monitoring, alerts, patch management, remote access', href: '/admin/sync/datto-rmm', logo: '/logos/datto-rmm.ico', color: 'blue' },
|
||||
{ id: 'auvik', category: 'NMS', product: 'Auvik', description: 'Network devices, topology, tenant mappings', href: '/admin/sync/auvik', logo: '/logos/auvik.ico', color: 'purple' },
|
||||
{ id: 'addigy', category: 'Apple RMM', product: 'Addigy', description: 'macOS/iOS device management, policies, compliance', href: '/admin/sync/addigy', logo: '/logos/addigy.ico', color: 'gray' },
|
||||
{ id: 'autotask', category: 'PSA', product: 'Autotask', description: 'Tickets, companies, contacts, time entries, configuration items', href: '/admin/sync/autotask', logo: '/logos/autotask.ico', color: 'red' },
|
||||
{ id: 'itglue', category: 'Documentation', product: 'IT Glue', description: 'Organizations, configurations, contacts, passwords, flexible assets, documents, domains', href: '/admin/sync/itglue', logo: '/logos/itglue.ico', color: 'blue' },
|
||||
{ id: 'veeam', category: 'Backup', product: 'Veeam VSPC', description: 'Agent jobs, backup jobs, protected workloads, compliance', href: '/admin/sync/veeam', logo: '/logos/veeam.ico', color: 'green' },
|
||||
{ id: 'datto-rmm', category: 'RMM', product: 'Datto RMM', description: 'Device monitoring, alerts, patch management, remote access', href: '/admin/sync/datto-rmm', logo: '/logos/datto-rmm.ico', color: 'orange' },
|
||||
{ id: 'auvik', category: 'NMS', product: 'Auvik', description: 'Network devices, topology, tenant mappings', href: '/admin/sync/auvik', logo: '/logos/auvik.ico', color: 'purple' },
|
||||
{ id: 'addigy', category: 'Apple RMM', product: 'Addigy', description: 'macOS/iOS device management, policies, compliance', href: '/admin/sync/addigy', logo: '/logos/addigy.ico', color: 'gray' },
|
||||
{ id: 'sentinelone', category: 'EDR/AV', product: 'SentinelOne', description: 'Endpoint agents, threat detections, site coverage, AV health', href: '/admin/sync/sentinelone', logo: '/logos/sentinelone.ico', color: 'purple' },
|
||||
];
|
||||
|
||||
const COLOR_MAP: Record<string, { bg: string; border: string }> = {
|
||||
red: { bg: 'bg-red-500/5', border: 'border-red-500/20' },
|
||||
green: { bg: 'bg-green-500/5', border: 'border-green-500/20' },
|
||||
blue: { bg: 'bg-blue-500/5', border: 'border-blue-500/20' },
|
||||
orange: { bg: 'bg-orange-500/5', border: 'border-orange-500/20' },
|
||||
purple: { bg: 'bg-purple-500/5', border: 'border-purple-500/20' },
|
||||
gray: { bg: 'bg-muted/20', border: 'border-border' },
|
||||
};
|
||||
|
|
@ -48,17 +51,24 @@ export default function SyncOverviewPage() {
|
|||
const [autotaskSync, setAutotaskSync] = useState<any>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
const [itglueSyncData, setItglueSyncData] = useState<any>(null);
|
||||
const [s1SyncData, setS1SyncData] = useState<any>(null);
|
||||
|
||||
const fetchAll = async () => {
|
||||
try {
|
||||
const [intRes, atRes] = await Promise.all([
|
||||
const [intRes, atRes, itgRes, s1Res] = await Promise.all([
|
||||
fetch('/api/integrations/status'),
|
||||
fetch('/api/sync/last-sync'),
|
||||
fetch('/api/itglue/sync'),
|
||||
fetch('/api/sentinelone/sync'),
|
||||
]);
|
||||
if (intRes.ok) setStatus(await intRes.json());
|
||||
if (atRes.ok) {
|
||||
const d = await atRes.json();
|
||||
setAutotaskSync(d.lastSync || {});
|
||||
}
|
||||
if (itgRes.ok) setItglueSyncData(await itgRes.json());
|
||||
if (s1Res.ok) setS1SyncData(await s1Res.json());
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
} finally {
|
||||
|
|
@ -110,6 +120,31 @@ export default function SyncOverviewPage() {
|
|||
critical: d.openAlerts?.critical ?? 0,
|
||||
};
|
||||
}
|
||||
if (id === 'itglue') {
|
||||
if (!itglueSyncData) return null;
|
||||
const h = itglueSyncData.history?.[0];
|
||||
const c = itglueSyncData.counts ?? {};
|
||||
return {
|
||||
lastSync: h?.completed_at ?? null,
|
||||
organizations: Number(c.organizations ?? 0),
|
||||
configurations: Number(c.configurations ?? 0),
|
||||
totalUpserted: h?.total_upserted ?? 0,
|
||||
status: h?.status ?? null,
|
||||
};
|
||||
}
|
||||
if (id === 'sentinelone') {
|
||||
if (!s1SyncData) return null;
|
||||
const h = s1SyncData.history?.[0];
|
||||
const c = s1SyncData.counts ?? {};
|
||||
return {
|
||||
lastSync: h?.completed_at ?? null,
|
||||
status: h?.status ?? null,
|
||||
sites: Number(c.sites ?? 0),
|
||||
agents: Number(c.agents ?? 0),
|
||||
infected: Number(c.infected ?? 0),
|
||||
threats: Number(c.threats ?? 0),
|
||||
};
|
||||
}
|
||||
if (id === 'auvik') return { lastSync: status.auvik?.lastSync, configured: status.auvik?.configured };
|
||||
if (id === 'addigy') return { lastSync: status.addigy?.lastSync, configured: status.addigy?.configured };
|
||||
return null;
|
||||
|
|
@ -131,6 +166,16 @@ export default function SyncOverviewPage() {
|
|||
if (summary.openAlerts > 0) return <AlertTriangle className="w-4 h-4 text-yellow-500" />;
|
||||
return <CheckCircle2 className="w-4 h-4 text-green-500" />;
|
||||
}
|
||||
if (id === 'itglue') {
|
||||
if (!summary.lastSync) return <Clock className="w-4 h-4 text-muted-foreground" />;
|
||||
if (summary.status === 'failed') return <XCircle className="w-4 h-4 text-red-500" />;
|
||||
return <CheckCircle2 className="w-4 h-4 text-green-500" />;
|
||||
}
|
||||
if (id === 'sentinelone') {
|
||||
if (!summary.lastSync) return <Clock className="w-4 h-4 text-muted-foreground" />;
|
||||
if (summary.infected > 0) return <AlertTriangle className="w-4 h-4 text-red-500" />;
|
||||
return <CheckCircle2 className="w-4 h-4 text-green-500" />;
|
||||
}
|
||||
return <CheckCircle2 className="w-4 h-4 text-green-500" />;
|
||||
};
|
||||
|
||||
|
|
@ -243,6 +288,40 @@ export default function SyncOverviewPage() {
|
|||
)}
|
||||
</>
|
||||
)}
|
||||
{intg.id === 'itglue' && summary && (
|
||||
<>
|
||||
<div className="flex justify-between">
|
||||
<span>Last sync</span>
|
||||
<span className="font-medium text-foreground">{fmtDate(summary.lastSync)}</span>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<span>Organizations</span>
|
||||
<span className="font-medium text-foreground">{(summary as any).organizations?.toLocaleString()}</span>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<span>Configurations</span>
|
||||
<span className="font-medium text-foreground">{(summary as any).configurations?.toLocaleString()}</span>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{intg.id === 'sentinelone' && summary && (
|
||||
<>
|
||||
<div className="flex justify-between">
|
||||
<span>Last sync</span>
|
||||
<span className="font-medium text-foreground">{fmtDate(summary.lastSync)}</span>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<span>Sites / Agents</span>
|
||||
<span className="font-medium text-foreground">{(summary as any).sites} / {(summary as any).agents?.toLocaleString()}</span>
|
||||
</div>
|
||||
{(summary as any).infected > 0 && (
|
||||
<div className="flex justify-between text-red-600">
|
||||
<span>Infected</span>
|
||||
<span className="font-medium">{(summary as any).infected}</span>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{(intg.id === 'auvik' || intg.id === 'addigy') && (
|
||||
<div className="flex justify-between">
|
||||
<span>Status</span>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue