Move components inside folders

Signed-off-by: Andrea Pavone <info@andreapavone.com>
This commit is contained in:
2024-11-10 19:06:42 +01:00
parent 0e18b53f91
commit eb0b894e1c
28 changed files with 1383 additions and 273 deletions

206
package-lock.json generated
View File

@ -5,13 +5,18 @@
"packages": {
"": {
"dependencies": {
"@radix-ui/react-checkbox": "^1.1.2",
"@radix-ui/react-dropdown-menu": "^2.1.2",
"@radix-ui/react-progress": "^1.1.0",
"@radix-ui/react-select": "^2.1.2",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-tabs": "^1.1.1",
"@tanstack/react-table": "^8.20.5",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"date-fns": "^3.6.0",
"lucide-react": "^0.456.0",
"react-day-picker": "^8.10.1",
"react-markdown": "^9.0.1",
"recharts": "^2.13.3",
"tailwind-merge": "^2.5.4",
@ -985,6 +990,51 @@
}
}
},
"node_modules/@radix-ui/react-checkbox": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@radix-ui/react-checkbox/-/react-checkbox-1.1.2.tgz",
"integrity": "sha512-/i0fl686zaJbDQLNKrkCbMyDm6FQMt4jg323k7HuqitoANm9sE23Ql8yOK3Wusk34HSLKDChhMux05FnP6KUkw==",
"license": "MIT",
"dependencies": {
"@radix-ui/primitive": "1.1.0",
"@radix-ui/react-compose-refs": "1.1.0",
"@radix-ui/react-context": "1.1.1",
"@radix-ui/react-presence": "1.1.1",
"@radix-ui/react-primitive": "2.0.0",
"@radix-ui/react-use-controllable-state": "1.1.0",
"@radix-ui/react-use-previous": "1.1.0",
"@radix-ui/react-use-size": "1.1.0"
},
"peerDependencies": {
"@types/react": "*",
"@types/react-dom": "*",
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"@types/react-dom": {
"optional": true
}
}
},
"node_modules/@radix-ui/react-checkbox/node_modules/@radix-ui/react-context": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@radix-ui/react-context/-/react-context-1.1.1.tgz",
"integrity": "sha512-UASk9zi+crv9WteK/NU4PLvOoL3OuE6BWVKNF6hPRBtYBDXQ2u5iu3O59zUlJiTVvkyuycnqrztsHVJwcK9K+Q==",
"license": "MIT",
"peerDependencies": {
"@types/react": "*",
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
}
},
"node_modules/@radix-ui/react-collection": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.1.0.tgz",
@ -1083,6 +1133,50 @@
}
}
},
"node_modules/@radix-ui/react-dropdown-menu": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/@radix-ui/react-dropdown-menu/-/react-dropdown-menu-2.1.2.tgz",
"integrity": "sha512-GVZMR+eqK8/Kes0a36Qrv+i20bAPXSn8rCBTHx30w+3ECnR5o3xixAlqcVaYvLeyKUsm0aqyhWfmUcqufM8nYA==",
"license": "MIT",
"dependencies": {
"@radix-ui/primitive": "1.1.0",
"@radix-ui/react-compose-refs": "1.1.0",
"@radix-ui/react-context": "1.1.1",
"@radix-ui/react-id": "1.1.0",
"@radix-ui/react-menu": "2.1.2",
"@radix-ui/react-primitive": "2.0.0",
"@radix-ui/react-use-controllable-state": "1.1.0"
},
"peerDependencies": {
"@types/react": "*",
"@types/react-dom": "*",
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"@types/react-dom": {
"optional": true
}
}
},
"node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-context": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@radix-ui/react-context/-/react-context-1.1.1.tgz",
"integrity": "sha512-UASk9zi+crv9WteK/NU4PLvOoL3OuE6BWVKNF6hPRBtYBDXQ2u5iu3O59zUlJiTVvkyuycnqrztsHVJwcK9K+Q==",
"license": "MIT",
"peerDependencies": {
"@types/react": "*",
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
}
},
"node_modules/@radix-ui/react-focus-guards": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@radix-ui/react-focus-guards/-/react-focus-guards-1.1.1.tgz",
@ -1141,6 +1235,61 @@
}
}
},
"node_modules/@radix-ui/react-menu": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/@radix-ui/react-menu/-/react-menu-2.1.2.tgz",
"integrity": "sha512-lZ0R4qR2Al6fZ4yCCZzu/ReTFrylHFxIqy7OezIpWF4bL0o9biKo0pFIvkaew3TyZ9Fy5gYVrR5zCGZBVbO1zg==",
"license": "MIT",
"dependencies": {
"@radix-ui/primitive": "1.1.0",
"@radix-ui/react-collection": "1.1.0",
"@radix-ui/react-compose-refs": "1.1.0",
"@radix-ui/react-context": "1.1.1",
"@radix-ui/react-direction": "1.1.0",
"@radix-ui/react-dismissable-layer": "1.1.1",
"@radix-ui/react-focus-guards": "1.1.1",
"@radix-ui/react-focus-scope": "1.1.0",
"@radix-ui/react-id": "1.1.0",
"@radix-ui/react-popper": "1.2.0",
"@radix-ui/react-portal": "1.1.2",
"@radix-ui/react-presence": "1.1.1",
"@radix-ui/react-primitive": "2.0.0",
"@radix-ui/react-roving-focus": "1.1.0",
"@radix-ui/react-slot": "1.1.0",
"@radix-ui/react-use-callback-ref": "1.1.0",
"aria-hidden": "^1.1.1",
"react-remove-scroll": "2.6.0"
},
"peerDependencies": {
"@types/react": "*",
"@types/react-dom": "*",
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"@types/react-dom": {
"optional": true
}
}
},
"node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-context": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@radix-ui/react-context/-/react-context-1.1.1.tgz",
"integrity": "sha512-UASk9zi+crv9WteK/NU4PLvOoL3OuE6BWVKNF6hPRBtYBDXQ2u5iu3O59zUlJiTVvkyuycnqrztsHVJwcK9K+Q==",
"license": "MIT",
"peerDependencies": {
"@types/react": "*",
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
}
},
"node_modules/@radix-ui/react-popper": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@radix-ui/react-popper/-/react-popper-1.2.0.tgz",
@ -1930,6 +2079,26 @@
"tailwindcss": ">=3.0.0 || >= 3.0.0-alpha.1 || >= 4.0.0-alpha.20"
}
},
"node_modules/@tanstack/react-table": {
"version": "8.20.5",
"resolved": "https://registry.npmjs.org/@tanstack/react-table/-/react-table-8.20.5.tgz",
"integrity": "sha512-WEHopKw3znbUZ61s9i0+i9g8drmDo6asTWbrQh8Us63DAk/M0FkmIqERew6P71HI75ksZ2Pxyuf4vvKh9rAkiA==",
"license": "MIT",
"dependencies": {
"@tanstack/table-core": "8.20.5"
},
"engines": {
"node": ">=12"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/tannerlinsley"
},
"peerDependencies": {
"react": ">=16.8",
"react-dom": ">=16.8"
}
},
"node_modules/@tanstack/react-virtual": {
"version": "3.10.9",
"resolved": "https://registry.npmjs.org/@tanstack/react-virtual/-/react-virtual-3.10.9.tgz",
@ -1948,6 +2117,19 @@
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
}
},
"node_modules/@tanstack/table-core": {
"version": "8.20.5",
"resolved": "https://registry.npmjs.org/@tanstack/table-core/-/table-core-8.20.5.tgz",
"integrity": "sha512-P9dF7XbibHph2PFRz8gfBKEXEY/HJPOhym8CHmjF8y3q5mWpKx9xtZapXQUWCgkqvsK0R46Azuz+VaxD4Xl+Tg==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/tannerlinsley"
}
},
"node_modules/@tanstack/virtual-core": {
"version": "3.10.9",
"resolved": "https://registry.npmjs.org/@tanstack/virtual-core/-/virtual-core-3.10.9.tgz",
@ -2916,6 +3098,16 @@
"node": ">=12"
}
},
"node_modules/date-fns": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-3.6.0.tgz",
"integrity": "sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/kossnocorp"
}
},
"node_modules/debug": {
"version": "4.3.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
@ -4927,6 +5119,20 @@
"node": ">=0.10.0"
}
},
"node_modules/react-day-picker": {
"version": "8.10.1",
"resolved": "https://registry.npmjs.org/react-day-picker/-/react-day-picker-8.10.1.tgz",
"integrity": "sha512-TMx7fNbhLk15eqcMt+7Z7S2KF7mfTId/XJDjKE8f+IUcFn0l08/kI4FiYTL/0yuOLmEcbR4Fwe3GJf/NiiMnPA==",
"license": "MIT",
"funding": {
"type": "individual",
"url": "https://github.com/sponsors/gpbl"
},
"peerDependencies": {
"date-fns": "^2.28.0 || ^3.0.0",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
}
},
"node_modules/react-dom": {
"version": "18.3.1",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz",

View File

@ -25,13 +25,18 @@
"vite": "^5.0"
},
"dependencies": {
"@radix-ui/react-checkbox": "^1.1.2",
"@radix-ui/react-dropdown-menu": "^2.1.2",
"@radix-ui/react-progress": "^1.1.0",
"@radix-ui/react-select": "^2.1.2",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-tabs": "^1.1.1",
"@tanstack/react-table": "^8.20.5",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"date-fns": "^3.6.0",
"lucide-react": "^0.456.0",
"react-day-picker": "^8.10.1",
"react-markdown": "^9.0.1",
"recharts": "^2.13.3",
"tailwind-merge": "^2.5.4",

View File

@ -2,15 +2,16 @@ import {SecuritySummaryReportResultType} from "@/types/security-summary";
import {Card, CardContent, CardHeader, CardTitle} from "@/Components/ui/card";
import {Check, Copy, ShieldAlert} from "lucide-react";
import {Button} from "@/Components/ui/button";
import React from "react";
import React, {useState} from "react";
import {useClipboard} from "use-clipboard-copy";
export default function DashboardHeader({ reportData }: { reportData: SecuritySummaryReportResultType }) {
const [isCopied, setIsCopied] = React.useState(false);
const [isCopied, setIsCopied] = useState(false);
const clipboard = useClipboard();
const handleCopy = () => {
clipboard.copy(reportData.idsummary)
setIsCopied(true)

View File

@ -0,0 +1,21 @@
import {SecuritySummaryReportResultType} from "@/types/security-summary";
import {Card, CardContent, CardHeader, CardTitle} from "@/Components/ui/card";
import {Database} from "lucide-react";
import React from "react";
export default function LeaksEnumerationCard({ reportData }: { reportData: SecuritySummaryReportResultType }) {
return (
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Database className="w-5 h-5"/>
Enumeration
</CardTitle>
</CardHeader>
<CardContent>
<div
className="text-3xl font-bold">{reportData.n_dataleak.enumeration}</div>
</CardContent>
</Card>
)
}

View File

@ -0,0 +1,26 @@
import {SecuritySummaryReportResultType} from "@/types/security-summary";
import {Card, CardContent, CardDescription, CardHeader, CardTitle} from "@/Components/ui/card";
import {Database} from "lucide-react";
import React from "react";
export default function LeaksResolvedCard({ reportData }: { reportData: SecuritySummaryReportResultType }) {
return (
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Database className="w-5 h-5"/>
Resolved
</CardTitle>
<CardDescription>Resolved data leak incidents</CardDescription>
</CardHeader>
<CardContent>
<div
className="text-3xl font-bold">{reportData.n_dataleak.resolved.potential_stealer}</div>
<div className="text-xs text-muted-foreground mt-1">
Including {reportData.n_dataleak.resolved.domain_stealer} domain stealer
and {reportData.n_dataleak.resolved.other_stealer} other leaks
</div>
</CardContent>
</Card>
)
}

View File

@ -0,0 +1,26 @@
import {SecuritySummaryReportResultType} from "@/types/security-summary";
import {Card, CardContent, CardDescription, CardHeader, CardTitle} from "@/Components/ui/card";
import {Database} from "lucide-react";
import React from "react";
export default function LeaksUnresolvedCard({ reportData }: { reportData: SecuritySummaryReportResultType }) {
return (
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Database className="w-5 h-5"/>
Unresolved
</CardTitle>
<CardDescription>Unresolved data leak incidents</CardDescription>
</CardHeader>
<CardContent>
<div
className="text-3xl font-bold">{reportData.n_dataleak.unresolved.potential_stealer}</div>
<div className="text-xs text-muted-foreground mt-1">
Including {reportData.n_dataleak.unresolved.domain_stealer} domain stealer
and {reportData.n_dataleak.unresolved.other_stealer} other leaks
</div>
</CardContent>
</Card>
)
}

View File

@ -0,0 +1,23 @@
import {SecuritySummaryReportResultType} from "@/types/security-summary";
import {Card, CardContent, CardDescription, CardHeader, CardTitle} from "@/Components/ui/card";
import {LockIcon} from "lucide-react";
import React from "react";
export default function OverviewCertificatesCard({ reportData }: { reportData: SecuritySummaryReportResultType }) {
return (
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<LockIcon className="w-5 h-5"/>
Certificates
</CardTitle>
<CardDescription>Number of active and expired certificates</CardDescription>
</CardHeader>
<CardContent>
<div className="text-3xl font-bold">Active: {reportData.n_cert_attivi}</div>
<div
className="text-3xl font-bold text-red-700">Expired: {reportData.n_cert_scaduti}</div>
</CardContent>
</Card>
)
}

View File

@ -0,0 +1,26 @@
import {SecuritySummaryReportResultType} from "@/types/security-summary";
import {Card, CardContent, CardDescription, CardHeader, CardTitle} from "@/Components/ui/card";
import {Database} from "lucide-react";
import React from "react";
export default function OverviewDataLeaksCard({ reportData }: { reportData: SecuritySummaryReportResultType }) {
return (
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Database className="w-5 h-5"/>
Data Leaks
</CardTitle>
<CardDescription>Total data leak incidents</CardDescription>
</CardHeader>
<CardContent>
<div
className="text-3xl font-bold">{reportData.n_dataleak.total.potential_stealer}</div>
<div className="text-xs text-muted-foreground mt-1">
Including {reportData.n_dataleak.total.domain_stealer} domain stealer
and {reportData.n_dataleak.total.other_stealer} other leaks
</div>
</CardContent>
</Card>
)
}

View File

@ -0,0 +1,31 @@
import {SecuritySummaryReportResultType} from "@/types/security-summary";
import {Card, CardContent, CardDescription, CardHeader, CardTitle} from "@/Components/ui/card";
import {LockIcon} from "lucide-react";
import React from "react";
export default function OverviewEmailSecurityCard({ reportData }: { reportData: SecuritySummaryReportResultType }) {
return (
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<LockIcon className="w-5 h-5"/>
Email Security
</CardTitle>
<CardDescription>Email security overview</CardDescription>
</CardHeader>
<CardContent>
<div className="text-3xl font-bold">{reportData.email_security.spoofable}</div>
<div className="flex flex-col gap-3 mt-1">
<span><span
className="font-bold">DMARC Policy:</span> {reportData.email_security.dmarc_policy}</span>
</div>
<div className="text-xs text-muted-foreground mt-1">
Black List Detections: <span
className="font-bold">{reportData.email_security.blacklist_detections}</span> and
Black Lists Total List: <span
className="font-bold">{reportData.email_security.blacklist_total_list}</span>
</div>
</CardContent>
</Card>
)
}

View File

@ -0,0 +1,26 @@
import {SecuritySummaryReportResultType} from "@/types/security-summary";
import {Card, CardContent, CardDescription, CardHeader, CardTitle} from "@/Components/ui/card";
import {Globe} from "lucide-react";
import React from "react";
export default function OverviewNetworkAssetsCard({ reportData }: { reportData: SecuritySummaryReportResultType }) {
return (
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Globe className="w-5 h-5"/>
Network Assets
</CardTitle>
<CardDescription>Total assets and IP addresses</CardDescription>
</CardHeader>
<CardContent>
<div className="text-3xl font-bold">{reportData.n_asset}</div>
<div className="flex justify-between text-xs text-muted-foreground mt-1">
<span>IPv4: {reportData.unique_ipv4}</span>
<span>IPv6: {reportData.unique_ipv6}</span>
</div>
</CardContent>
</Card>
)
}

View File

@ -0,0 +1,21 @@
import {SecuritySummaryReportResultType} from "@/types/security-summary";
import {Card, CardContent, CardDescription, CardHeader, CardTitle} from "@/Components/ui/card";
import {Globe} from "lucide-react";
import React from "react";
export default function OverviewSimilarDomainsCard({ reportData }: { reportData: SecuritySummaryReportResultType }) {
return (
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Globe className="w-5 h-5"/>
Similar Domains
</CardTitle>
<CardDescription>Number of similar Domains</CardDescription>
</CardHeader>
<CardContent>
<div className="text-3xl font-bold">{reportData.n_similar_domains}</div>
</CardContent>
</Card>
)
}

View File

@ -0,0 +1,35 @@
import {SecuritySummaryReportResultType} from "@/types/security-summary";
import {Card, CardContent, CardDescription, CardHeader, CardTitle} from "@/Components/ui/card";
import {ShieldAlert} from "lucide-react";
import {Progress} from "@/Components/ui/progress";
import React from "react";
export default function OverviewVulnerabilityScoreCard({ reportData }: { reportData: SecuritySummaryReportResultType }) {
return (
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<ShieldAlert className="w-5 h-5"/>
Vulnerability Score
</CardTitle>
<CardDescription>Active and passive vulnerability scores</CardDescription>
</CardHeader>
<CardContent>
<div className="space-y-2">
<div>
<div className="text-xs text-muted-foreground">Active Score</div>
<Progress value={reportData.vulnerability_score_active} className="mt-1"/>
<div className="text-sm font-medium">{reportData.vulnerability_score_active}%
</div>
</div>
<div>
<div className="text-xs text-muted-foreground">Passive Score</div>
<Progress value={reportData.vulnerability_score_passive} className="mt-1"/>
<div className="text-sm font-medium">{reportData.vulnerability_score_passive}%
</div>
</div>
</div>
</CardContent>
</Card>
)
}

View File

@ -0,0 +1,30 @@
import {SecuritySummaryReportResultType} from "@/types/security-summary";
import {Card, CardContent, CardHeader, CardTitle} from "@/Components/ui/card";
import {DatabaseZap} from "lucide-react";
import React from "react";
export default function ServicesCdnCard({ reportData }: { reportData: SecuritySummaryReportResultType }) {
return (
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<DatabaseZap className="w-5 h-5"/>
CDN
</CardTitle>
</CardHeader>
<CardContent>
<div
className="text-3xl font-bold">{reportData.cdn.count}</div>
<div className="text-xs text-muted-foreground mt-1">
<div><span className="font-bold">CDN assets:</span></div>
<div className="flex flex-col gap-2 mt-3">
{reportData.cdn.assets.map((cdn_asset,index) => (
<code key={index}>{cdn_asset}</code>
))}
</div>
</div>
</CardContent>
</Card>
)
}

View File

@ -9,9 +9,8 @@ import {
} from "@/Components/ui/card";
import { SecuritySummaryReportResultType } from "@/types/security-summary";
export default function PortExposureAnalysis({ reportData }: { reportData: SecuritySummaryReportResultType }) {
export default function ServicesPortExposureCard({ reportData }: { reportData: SecuritySummaryReportResultType }) {
// Transform n_port data for chart
const portData = Object.entries(reportData.n_port).map(([port, data]) => ({
name: `Port ${port}`,
value: data.n
@ -47,6 +46,9 @@ export default function PortExposureAnalysis({ reportData }: { reportData: Secur
className="fill-primary"
/>
<Tooltip
cursor={{
fill: 'rgba(0, 0, 0, 0.1)',
}}
content={({active, payload}) => {
if (active && payload && payload.length) {
return (

View File

@ -0,0 +1,30 @@
import {SecuritySummaryReportResultType} from "@/types/security-summary";
import {Card, CardContent, CardHeader, CardTitle} from "@/Components/ui/card";
import {BrickWall} from "lucide-react";
import React from "react";
export default function ServicesWafCard({ reportData }: { reportData: SecuritySummaryReportResultType }) {
return (
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<BrickWall className="w-5 h-5"/>
WAF
</CardTitle>
</CardHeader>
<CardContent>
<div
className="text-3xl font-bold">{reportData.waf.count}</div>
<div className="text-xs text-muted-foreground mt-1">
<div><span className="font-bold">WAF assets:</span></div>
<div className="flex flex-col gap-2 mt-3">
{reportData.waf.assets.map((waf_asset,index) => (
<code key={index}>{waf_asset}</code>
))}
</div>
</div>
</CardContent>
</Card>
)
}

View File

@ -0,0 +1,90 @@
import React, { useState, useMemo } from 'react';
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/Components/ui/card";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/Components/ui/select";
import {SecuritySummaryReportResultType} from "@/types/security-summary";
import VulnerabilityPieChart from "@/Components/VulnerabilityPieChart";
export default function VulnerabilitiesActiveCard({reportData}: { reportData: SecuritySummaryReportResultType }) {
const vulnerabilityData = useMemo(() => [
{ name: 'Critical', value: reportData.n_vulns.active.critical, fill: 'hsl(var(--chart-1))' },
{ name: 'High', value: reportData.n_vulns.active.high, fill: 'hsl(var(--chart-2))' },
{ name: 'Medium', value: reportData.n_vulns.active.medium, fill: 'hsl(var(--chart-3))' },
], [reportData]);
const [activeMetric, setActiveMetric] = useState(vulnerabilityData[0].name);
const activeIndex = useMemo(
() => vulnerabilityData.findIndex((item) => item.name === activeMetric),
[activeMetric, vulnerabilityData]
);
const metrics = useMemo(() => vulnerabilityData.map((item) => item.name), [vulnerabilityData]);
const chartConfig: any = {
'Critical': {
label: "Critical",
color: 'hsl(var(--chart-1))'
},
'High': {
label: "High",
color: 'hsl(var(--chart-2))'
},
'Medium': {
label: "Medium",
color: 'hsl(var(--chart-3))'
},
};
return (
<Card>
<CardHeader className="flex flex-row items-start justify-between space-y-0 pb-0">
<div className="grid gap-1">
<CardTitle>Active Vulnerabilities</CardTitle>
<CardDescription>Number of Active Vulnerabilities</CardDescription>
</div>
<Select value={activeMetric} onValueChange={setActiveMetric}>
<SelectTrigger
className="ml-auto h-8 w-[180px] rounded-lg"
aria-label="Select security metric"
>
<SelectValue placeholder="Select metric" />
</SelectTrigger>
<SelectContent align="end" className="rounded-lg">
{metrics.map((metric) => (
<SelectItem
key={metric}
value={metric}
className="rounded-lg [&_span]:flex"
>
<div className="flex items-center gap-2 text-xs">
<span
className="h-3 w-3 rounded-sm"
style={{
backgroundColor: chartConfig[metric]?.color
}}
/>
{chartConfig[metric].label}
</div>
</SelectItem>
))}
</SelectContent>
</Select>
</CardHeader>
<CardContent className="flex flex-1 justify-center pb-0">
<VulnerabilityPieChart vulnerabilityData={vulnerabilityData} activeIndex={activeIndex} />
</CardContent>
</Card>
);
}

View File

@ -0,0 +1,85 @@
import React, { useState, useMemo } from 'react';
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/Components/ui/card";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/Components/ui/select";
import {SecuritySummaryReportResultType} from "@/types/security-summary";
import VulnerabilityPieChart from "@/Components/VulnerabilityPieChart";
export default function VulnerabilitiesPassiveCard({reportData}: { reportData: SecuritySummaryReportResultType }) {
const vulnerabilityData = useMemo(() => [
{ name: 'High', value: reportData.n_vulns.passive.high, fill: 'hsl(var(--chart-4))' },
{ name: 'Medium', value: reportData.n_vulns.passive.medium, fill: 'hsl(var(--chart-5))' }
], [reportData]);
const [activeMetric, setActiveMetric] = useState(vulnerabilityData[0].name);
const activeIndex = useMemo(
() => vulnerabilityData.findIndex((item) => item.name === activeMetric),
[activeMetric, vulnerabilityData]
);
const metrics = useMemo(() => vulnerabilityData.map((item) => item.name), [vulnerabilityData]);
const chartConfig: any = {
'High': {
label: "High",
color: 'hsl(var(--chart-4))'
},
'Medium': {
label: "Medium",
color: 'hsl(var(--chart-5))'
}
};
return (
<Card>
<CardHeader className="flex flex-row items-start justify-between space-y-0 pb-0">
<div className="grid gap-1">
<CardTitle>Passive Vulnerabilities</CardTitle>
<CardDescription>Number of Passive Vulnerabilities</CardDescription>
</div>
<Select value={activeMetric} onValueChange={setActiveMetric}>
<SelectTrigger
className="ml-auto h-8 w-[180px] rounded-lg"
aria-label="Select security metric"
>
<SelectValue placeholder="Select metric" />
</SelectTrigger>
<SelectContent align="end" className="rounded-lg">
{metrics.map((metric) => (
<SelectItem
key={metric}
value={metric}
className="rounded-lg [&_span]:flex"
>
<div className="flex items-center gap-2 text-xs">
<span
className="h-3 w-3 rounded-sm"
style={{
backgroundColor: chartConfig[metric]?.color
}}
/>
{chartConfig[metric].label}
</div>
</SelectItem>
))}
</SelectContent>
</Select>
</CardHeader>
<CardContent className="flex flex-1 justify-center pb-0">
<VulnerabilityPieChart vulnerabilityData={vulnerabilityData} activeIndex={activeIndex} />
</CardContent>
</Card>
);
}

View File

@ -1,157 +0,0 @@
import React, { useState, useMemo } from 'react';
import { PieChart, Pie, Sector, Label } from 'recharts';
import { PieSectorDataItem } from "recharts/types/polar/Pie";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/Components/ui/card";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/Components/ui/select";
import {SecuritySummaryReportResultType} from "@/types/security-summary";
export default function NumberOfVulnerabilitiesPieChart({reportData}: { reportData: SecuritySummaryReportResultType }) {
const vulnerabilityData = useMemo(() => [
{ name: 'Active Critical', value: reportData.n_vulns.active.critical, fill: 'hsl(var(--chart-1))' },
{ name: 'Active High', value: reportData.n_vulns.active.high, fill: 'hsl(var(--chart-2))' },
{ name: 'Active Medium', value: reportData.n_vulns.active.medium, fill: 'hsl(var(--chart-3))' },
{ name: 'Passive High', value: reportData.n_vulns.passive.high, fill: 'hsl(var(--chart-4))' },
{ name: 'Passive Medium', value: reportData.n_vulns.passive.medium, fill: 'hsl(var(--chart-5))' }
], [reportData]);
const [activeMetric, setActiveMetric] = useState(vulnerabilityData[0].name);
const activeIndex = useMemo(
() => vulnerabilityData.findIndex((item) => item.name === activeMetric),
[activeMetric, vulnerabilityData]
);
const metrics = useMemo(() => vulnerabilityData.map((item) => item.name), [vulnerabilityData]);
const chartConfig: any = {
'Active Critical': {
label: "Active Critical",
color: 'hsl(var(--chart-1))'
},
'Active High': {
label: "Active High",
color: 'hsl(var(--chart-2))'
},
'Active Medium': {
label: "Active Medium",
color: 'hsl(var(--chart-3))'
},
'Passive High': {
label: "Passive High",
color: 'hsl(var(--chart-4))'
},
'Passive Medium': {
label: "Passive Medium",
color: 'hsl(var(--chart-5))'
}
};
return (
<Card>
<CardHeader className="flex flex-row items-start justify-between space-y-0 pb-0">
<div className="grid gap-1">
<CardTitle>Number of Vulnerabilities</CardTitle>
<CardDescription>Vulnerabilities details</CardDescription>
</div>
<Select value={activeMetric} onValueChange={setActiveMetric}>
<SelectTrigger
className="ml-auto h-8 w-[180px] rounded-lg"
aria-label="Select security metric"
>
<SelectValue placeholder="Select metric" />
</SelectTrigger>
<SelectContent align="end" className="rounded-lg">
{metrics.map((metric) => (
<SelectItem
key={metric}
value={metric}
className="rounded-lg [&_span]:flex"
>
<div className="flex items-center gap-2 text-xs">
<span
className="h-3 w-3 rounded-sm"
style={{
backgroundColor: chartConfig[metric]?.color
}}
/>
{chartConfig[metric].label}
</div>
</SelectItem>
))}
</SelectContent>
</Select>
</CardHeader>
<CardContent className="flex flex-1 justify-center pb-0">
<div className="mx-auto aspect-square w-full max-w-[400px]">
<PieChart width={400} height={400}>
<Pie
data={vulnerabilityData}
dataKey="value"
nameKey="name"
cx="50%"
cy="50%"
innerRadius={60}
outerRadius={80}
activeIndex={activeIndex}
activeShape={({
outerRadius = 0,
...props
}: PieSectorDataItem) => (
<g>
<Sector {...props} outerRadius={outerRadius + 10} />
<Sector
{...props}
outerRadius={outerRadius + 25}
innerRadius={outerRadius + 12}
/>
</g>
)}
>
<Label
content={({ viewBox }) => {
if (viewBox && "cx" in viewBox && "cy" in viewBox) {
return (
<text
x={viewBox.cx}
y={viewBox.cy}
textAnchor="middle"
dominantBaseline="middle"
>
<tspan
x={viewBox.cx}
y={viewBox.cy}
className="fill-foreground text-3xl font-bold"
>
{vulnerabilityData[activeIndex].value}
</tspan>
<tspan
x={viewBox.cx}
y={(viewBox.cy || 0) + 24}
className="fill-muted-foreground text-sm"
>
{vulnerabilityData[activeIndex].name}
</tspan>
</text>
)
}
}}
/>
</Pie>
</PieChart>
</div>
</CardContent>
</Card>
);
}

View File

@ -27,9 +27,7 @@ export default function SecurityScoresOverviewBarChart({ reportData }: { reportD
{ metric: 'Spoofing', score: reportData.spoofing_score },
{ metric: 'Open Port', score: reportData.open_ports_score },
{ metric: 'Blacklist', score: reportData.blacklist_score },
{ metric: 'Certificate', score: reportData.certificate_score },
{ metric: 'Active Vulnerability', score: reportData.vulnerability_score_active },
{ metric: 'Passive Vulnerability', score: reportData.vulnerability_score_passive },
{ metric: 'Certificate', score: reportData.certificate_score }
], [reportData]);
@ -43,7 +41,6 @@ export default function SecurityScoresOverviewBarChart({ reportData }: { reportD
},
} satisfies ChartConfig;
// Calculate average score and trend
const averageScore = useMemo(() => {
const sum = chartData.reduce((acc, curr) => acc + curr.score, 0);
return Math.round(sum / chartData.length);

View File

@ -0,0 +1,78 @@
import {SecuritySummaryReportResultType} from "@/types/security-summary";
import {Label, Pie, PieChart, Sector} from "recharts";
import {PieSectorDataItem} from "recharts/types/polar/Pie";
import React from "react";
type ChartData = {
name: string,
value: number,
fill: string
}
export default function VulnerabilityPieChart({
vulnerabilityData, activeIndex
}: {
vulnerabilityData: ChartData[],
activeIndex: number
}) {
return (
<>
<div className="mx-auto aspect-square w-full max-w-[400px]">
<PieChart width={400} height={400}>
<Pie
data={vulnerabilityData}
dataKey="value"
nameKey="name"
cx="50%"
cy="50%"
innerRadius={60}
outerRadius={80}
activeIndex={activeIndex}
activeShape={({
outerRadius = 0,
...props
}: PieSectorDataItem) => (
<g>
<Sector {...props} outerRadius={outerRadius + 10}/>
<Sector
{...props}
outerRadius={outerRadius + 25}
innerRadius={outerRadius + 12}
/>
</g>
)}
>
<Label
content={({viewBox}) => {
if (viewBox && "cx" in viewBox && "cy" in viewBox) {
return (
<text
x={viewBox.cx}
y={viewBox.cy}
textAnchor="middle"
dominantBaseline="middle"
>
<tspan
x={viewBox.cx}
y={viewBox.cy}
className="fill-foreground text-3xl font-bold"
>
{vulnerabilityData[activeIndex].value}
</tspan>
<tspan
x={viewBox.cx}
y={(viewBox.cy || 0) + 24}
className="fill-muted-foreground text-sm"
>
{vulnerabilityData[activeIndex].name}
</tspan>
</text>
)
}
}}
/>
</Pie>
</PieChart>
</div>
</>
)
}

View File

@ -0,0 +1,70 @@
import * as React from "react"
import { ChevronLeft, ChevronRight } from "lucide-react"
import { DayPicker } from "react-day-picker"
import { cn } from "@/lib/utils"
import { buttonVariants } from "@/components/ui/button"
export type CalendarProps = React.ComponentProps<typeof DayPicker>
function Calendar({
className,
classNames,
showOutsideDays = true,
...props
}: CalendarProps) {
return (
<DayPicker
showOutsideDays={showOutsideDays}
className={cn("p-3", className)}
classNames={{
months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
month: "space-y-4",
caption: "flex justify-center pt-1 relative items-center",
caption_label: "text-sm font-medium",
nav: "space-x-1 flex items-center",
nav_button: cn(
buttonVariants({ variant: "outline" }),
"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"
),
nav_button_previous: "absolute left-1",
nav_button_next: "absolute right-1",
table: "w-full border-collapse space-y-1",
head_row: "flex",
head_cell:
"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",
row: "flex w-full mt-2",
cell: cn(
"relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",
props.mode === "range"
? "[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md"
: "[&:has([aria-selected])]:rounded-md"
),
day: cn(
buttonVariants({ variant: "ghost" }),
"h-8 w-8 p-0 font-normal aria-selected:opacity-100"
),
day_range_start: "day-range-start",
day_range_end: "day-range-end",
day_selected:
"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
day_today: "bg-accent text-accent-foreground",
day_outside:
"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",
day_disabled: "text-muted-foreground opacity-50",
day_range_middle:
"aria-selected:bg-accent aria-selected:text-accent-foreground",
day_hidden: "invisible",
...classNames,
}}
components={{
IconLeft: ({ ...props }) => <ChevronLeft className="h-4 w-4" />,
IconRight: ({ ...props }) => <ChevronRight className="h-4 w-4" />,
}}
{...props}
/>
)
}
Calendar.displayName = "Calendar"
export { Calendar }

View File

@ -0,0 +1,28 @@
import * as React from "react"
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
import { Check } from "lucide-react"
import { cn } from "@/lib/utils"
const Checkbox = React.forwardRef<
React.ElementRef<typeof CheckboxPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
>(({ className, ...props }, ref) => (
<CheckboxPrimitive.Root
ref={ref}
className={cn(
"peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
className
)}
{...props}
>
<CheckboxPrimitive.Indicator
className={cn("flex items-center justify-center text-current")}
>
<Check className="h-4 w-4" />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
))
Checkbox.displayName = CheckboxPrimitive.Root.displayName
export { Checkbox }

View File

@ -0,0 +1,199 @@
import * as React from "react"
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
import { Check, ChevronRight, Circle } from "lucide-react"
import { cn } from "@/lib/utils"
const DropdownMenu = DropdownMenuPrimitive.Root
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger
const DropdownMenuGroup = DropdownMenuPrimitive.Group
const DropdownMenuPortal = DropdownMenuPrimitive.Portal
const DropdownMenuSub = DropdownMenuPrimitive.Sub
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup
const DropdownMenuSubTrigger = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
inset?: boolean
}
>(({ className, inset, children, ...props }, ref) => (
<DropdownMenuPrimitive.SubTrigger
ref={ref}
className={cn(
"flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
inset && "pl-8",
className
)}
{...props}
>
{children}
<ChevronRight className="ml-auto" />
</DropdownMenuPrimitive.SubTrigger>
))
DropdownMenuSubTrigger.displayName =
DropdownMenuPrimitive.SubTrigger.displayName
const DropdownMenuSubContent = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
>(({ className, ...props }, ref) => (
<DropdownMenuPrimitive.SubContent
ref={ref}
className={cn(
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className
)}
{...props}
/>
))
DropdownMenuSubContent.displayName =
DropdownMenuPrimitive.SubContent.displayName
const DropdownMenuContent = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
>(({ className, sideOffset = 4, ...props }, ref) => (
<DropdownMenuPrimitive.Portal>
<DropdownMenuPrimitive.Content
ref={ref}
sideOffset={sideOffset}
className={cn(
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className
)}
{...props}
/>
</DropdownMenuPrimitive.Portal>
))
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
const DropdownMenuItem = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
inset?: boolean
}
>(({ className, inset, ...props }, ref) => (
<DropdownMenuPrimitive.Item
ref={ref}
className={cn(
"relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",
inset && "pl-8",
className
)}
{...props}
/>
))
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
const DropdownMenuCheckboxItem = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
>(({ className, children, checked, ...props }, ref) => (
<DropdownMenuPrimitive.CheckboxItem
ref={ref}
className={cn(
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
className
)}
checked={checked}
{...props}
>
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<DropdownMenuPrimitive.ItemIndicator>
<Check className="h-4 w-4" />
</DropdownMenuPrimitive.ItemIndicator>
</span>
{children}
</DropdownMenuPrimitive.CheckboxItem>
))
DropdownMenuCheckboxItem.displayName =
DropdownMenuPrimitive.CheckboxItem.displayName
const DropdownMenuRadioItem = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
>(({ className, children, ...props }, ref) => (
<DropdownMenuPrimitive.RadioItem
ref={ref}
className={cn(
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
className
)}
{...props}
>
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<DropdownMenuPrimitive.ItemIndicator>
<Circle className="h-2 w-2 fill-current" />
</DropdownMenuPrimitive.ItemIndicator>
</span>
{children}
</DropdownMenuPrimitive.RadioItem>
))
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName
const DropdownMenuLabel = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
inset?: boolean
}
>(({ className, inset, ...props }, ref) => (
<DropdownMenuPrimitive.Label
ref={ref}
className={cn(
"px-2 py-1.5 text-sm font-semibold",
inset && "pl-8",
className
)}
{...props}
/>
))
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName
const DropdownMenuSeparator = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
>(({ className, ...props }, ref) => (
<DropdownMenuPrimitive.Separator
ref={ref}
className={cn("-mx-1 my-1 h-px bg-muted", className)}
{...props}
/>
))
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
const DropdownMenuShortcut = ({
className,
...props
}: React.HTMLAttributes<HTMLSpanElement>) => {
return (
<span
className={cn("ml-auto text-xs tracking-widest opacity-60", className)}
{...props}
/>
)
}
DropdownMenuShortcut.displayName = "DropdownMenuShortcut"
export {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuCheckboxItem,
DropdownMenuRadioItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuShortcut,
DropdownMenuGroup,
DropdownMenuPortal,
DropdownMenuSub,
DropdownMenuSubContent,
DropdownMenuSubTrigger,
DropdownMenuRadioGroup,
}

View File

@ -0,0 +1,22 @@
import * as React from "react"
import { cn } from "@/lib/utils"
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
({ className, type, ...props }, ref) => {
return (
<input
type={type}
className={cn(
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
className
)}
ref={ref}
{...props}
/>
)
}
)
Input.displayName = "Input"
export { Input }

View File

@ -0,0 +1,120 @@
import * as React from "react"
import { cn } from "@/lib/utils"
const Table = React.forwardRef<
HTMLTableElement,
React.HTMLAttributes<HTMLTableElement>
>(({ className, ...props }, ref) => (
<div className="relative w-full overflow-auto">
<table
ref={ref}
className={cn("w-full caption-bottom text-sm", className)}
{...props}
/>
</div>
))
Table.displayName = "Table"
const TableHeader = React.forwardRef<
HTMLTableSectionElement,
React.HTMLAttributes<HTMLTableSectionElement>
>(({ className, ...props }, ref) => (
<thead ref={ref} className={cn("[&_tr]:border-b", className)} {...props} />
))
TableHeader.displayName = "TableHeader"
const TableBody = React.forwardRef<
HTMLTableSectionElement,
React.HTMLAttributes<HTMLTableSectionElement>
>(({ className, ...props }, ref) => (
<tbody
ref={ref}
className={cn("[&_tr:last-child]:border-0", className)}
{...props}
/>
))
TableBody.displayName = "TableBody"
const TableFooter = React.forwardRef<
HTMLTableSectionElement,
React.HTMLAttributes<HTMLTableSectionElement>
>(({ className, ...props }, ref) => (
<tfoot
ref={ref}
className={cn(
"border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
className
)}
{...props}
/>
))
TableFooter.displayName = "TableFooter"
const TableRow = React.forwardRef<
HTMLTableRowElement,
React.HTMLAttributes<HTMLTableRowElement>
>(({ className, ...props }, ref) => (
<tr
ref={ref}
className={cn(
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
className
)}
{...props}
/>
))
TableRow.displayName = "TableRow"
const TableHead = React.forwardRef<
HTMLTableCellElement,
React.ThHTMLAttributes<HTMLTableCellElement>
>(({ className, ...props }, ref) => (
<th
ref={ref}
className={cn(
"h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
className
)}
{...props}
/>
))
TableHead.displayName = "TableHead"
const TableCell = React.forwardRef<
HTMLTableCellElement,
React.TdHTMLAttributes<HTMLTableCellElement>
>(({ className, ...props }, ref) => (
<td
ref={ref}
className={cn(
"p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
className
)}
{...props}
/>
))
TableCell.displayName = "TableCell"
const TableCaption = React.forwardRef<
HTMLTableCaptionElement,
React.HTMLAttributes<HTMLTableCaptionElement>
>(({ className, ...props }, ref) => (
<caption
ref={ref}
className={cn("mt-4 text-sm text-muted-foreground", className)}
{...props}
/>
))
TableCaption.displayName = "TableCaption"
export {
Table,
TableHeader,
TableBody,
TableFooter,
TableHead,
TableRow,
TableCell,
TableCaption,
}

View File

@ -4,36 +4,43 @@ import {
Card,
CardContent,
CardHeader,
CardTitle,
CardDescription
CardTitle
} from '@/Components/ui/card';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/Components/ui/tabs';
import { Button } from "@/Components/ui/button";
import { Progress } from '@/Components/ui/progress';
import { Alert, AlertDescription, AlertTitle } from '@/Components/ui/alert';
import { ShieldAlert, Globe, Database, ChevronLeft, ChevronRight, Check, Copy } from 'lucide-react';
import { Alert, AlertDescription } from '@/Components/ui/alert';
import { ShieldAlert, ChevronLeft, ChevronRight } from 'lucide-react';
import Markdown from 'react-markdown';
import {
SecuritySummaryReportResultType, SecuritySummaryResponseType,
} from '@/types/security-summary';
import NumberOfVulnerabilitiesPieChart from "@/Components/NumberOfVulnerabilitiesPieChart";
import VulnerabilitiesActiveCard from "@/Components/Dashboard/Vulnerabilities/VulnerabilitiesActiveCard";
import VulnerabilitiesPassiveCard from "@/Components/Dashboard/Vulnerabilities/VulnerabilitiesPassiveCard";
import SecurityScoresOverviewBarChart from "@/Components/SecurityScoresOverviewBarChart";
import PortExposureAnalysis from "@/Components/PortExposureAnalysis";
import { useClipboard } from "use-clipboard-copy"
import DashboardHeader from "@/Components/DashboardHeader";
import ServicesPortExposureCard from "@/Components/Dashboard/Services/ServicesPortExposureCard";
import DashboardHeader from "@/Components/Dashboard/DashboardHeader";
import OverviewNetworkAssetsCard from "@/Components/Dashboard/Overview/OverviewNetworkAssetsCard";
import OverviewSimilarDomainsCard from "@/Components/Dashboard/Overview/OverviewSimilarDomainsCard";
import OverviewEmailSecurityCard from "@/Components/Dashboard/Overview/OverviewEmailSecurityCard";
import OverviewCertificatesCard from "@/Components/Dashboard/Overview/OverviewCertificatesCard";
import OverviewDataLeaksCard from "@/Components/Dashboard/Overview/OverviewDataLeaksCard";
import ServicesWafCard from "@/Components/Dashboard/Services/ServicesWafCard";
import ServicesCdnCard from "@/Components/Dashboard/Services/ServicesCdnCard";
import LeaksEnumerationCard from "@/Components/Dashboard/Leaks/LeaksEnumerationCard";
import LeaksResolvedCard from "@/Components/Dashboard/Leaks/LeaksResolvedCard";
import LeaksUnresolvedCard from "@/Components/Dashboard/Leaks/LeaksUnresolvedCard";
import OverviewVulnerabilityScoreCard from "@/Components/Dashboard/Overview/OverviewVulnerabilityScoreCard";
export default function Dashboard() {
export default function Dashboard({ page }: { page:number }) {
const [securitySummaryResponse, setSecuritySummaryResponse] = useState<SecuritySummaryResponseType | null>(null);
const [reportData, setReportData] = useState<SecuritySummaryReportResultType | null>(null);
const [currentPage, setCurrentPage] = useState<number>(0);
const [currentPage, setCurrentPage] = useState<number>(page);
useEffect(() => {
axios.get<SecuritySummaryResponseType>('/api/v1/security/summary')
.then(response => {
setSecuritySummaryResponse(response.data);
// Set initial report data
setReportData(response.data.results[0] ?? null);
})
.catch(error => {
@ -41,7 +48,6 @@ export default function Dashboard() {
});
}, []);
// Handle page changes
useEffect(() => {
if (securitySummaryResponse) {
setReportData(securitySummaryResponse.results[currentPage] ?? null);
@ -62,9 +68,9 @@ export default function Dashboard() {
return (
<div className="container mx-auto p-4">
<DashboardHeader reportData={reportData} />
<DashboardHeader reportData={reportData}/>
<Tabs defaultValue="overview" className="space-y-4">
<Tabs defaultValue="overview">
<TabsList>
<TabsTrigger value="overview">Overview</TabsTrigger>
<TabsTrigger value="vulnerabilities">Vulnerabilities</TabsTrigger>
@ -72,74 +78,17 @@ export default function Dashboard() {
<TabsTrigger value="leaks">Data Leaks</TabsTrigger>
</TabsList>
<TabsContent value="overview">
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<ShieldAlert className="w-5 h-5"/>
Vulnerability Score
</CardTitle>
<CardDescription>Active and passive vulnerability scores</CardDescription>
</CardHeader>
<CardContent>
<div className="space-y-2">
<div>
<div className="text-xs text-muted-foreground">Active Score</div>
<Progress value={reportData.vulnerability_score_active} className="mt-1"/>
<div className="text-sm font-medium">{reportData.vulnerability_score_active}%
</div>
</div>
<div>
<div className="text-xs text-muted-foreground">Passive Score</div>
<Progress value={reportData.vulnerability_score_passive} className="mt-1"/>
<div className="text-sm font-medium">{reportData.vulnerability_score_passive}%
</div>
</div>
</div>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Globe className="w-5 h-5"/>
Network Assets
</CardTitle>
<CardDescription>Total assets and IP addresses</CardDescription>
</CardHeader>
<CardContent>
<div className="text-3xl font-bold">{reportData.n_asset}</div>
<div className="flex justify-between text-xs text-muted-foreground mt-1">
<span>IPv4: {reportData.unique_ipv4}</span>
<span>IPv6: {reportData.unique_ipv6}</span>
</div>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Database className="w-5 h-5"/>
Data Leaks
</CardTitle>
<CardDescription>Unresolved data leak incidents</CardDescription>
</CardHeader>
<CardContent>
<div
className="text-3xl font-bold">{reportData.n_dataleak.unresolved.potential_stealer}</div>
<div className="text-xs text-muted-foreground mt-1">
Including {reportData.n_dataleak.unresolved.domain_stealer} domain stealer
and {reportData.n_dataleak.unresolved.other_stealer} other leaks
</div>
</CardContent>
</Card>
<TabsContent value="overview" className="space-y-6">
<div>
<h3 className="text-xl">Overview</h3>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4 mt-6">
<PortExposureAnalysis reportData={reportData}/>
<NumberOfVulnerabilitiesPieChart reportData={reportData}/>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<OverviewNetworkAssetsCard reportData={reportData}/>
<OverviewVulnerabilityScoreCard reportData={reportData}/>
<OverviewSimilarDomainsCard reportData={reportData} />
<OverviewEmailSecurityCard reportData={reportData}/>
<OverviewCertificatesCard reportData={reportData}/>
<OverviewDataLeaksCard reportData={reportData}/>
</div>
<div className="grid grid-cols-1 gap-4 mt-6">
@ -172,33 +121,66 @@ export default function Dashboard() {
</CardContent>
</Tabs>
</Card>
<div className="flex items-center justify-center gap-4 mt-6">
<Button
onClick={handlePrevPage}
disabled={currentPage === 0}
variant="outline"
className="flex items-center gap-2"
>
<ChevronLeft className="w-4 h-4"/>
Previous
</Button>
</TabsContent>
<div className="text-sm text-muted-foreground">
Page {currentPage + 1} of {securitySummaryResponse?.results.length}
</div>
<TabsContent value="services">
<div>
<h3 className="text-xl">Data Leaks Details</h3>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4 mt-6">
<ServicesPortExposureCard reportData={reportData}/>
<ServicesWafCard reportData={reportData} />
<ServicesCdnCard reportData={reportData} />
</div>
</TabsContent>
<Button
onClick={handleNextPage}
disabled={!securitySummaryResponse || currentPage === securitySummaryResponse.results.length - 1}
variant="outline"
className="flex items-center gap-2"
>
Next
<ChevronRight className="w-4 h-4"/>
</Button>
<TabsContent value="vulnerabilities">
<div>
<h3 className="text-xl">Data Leaks Details</h3>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4 mt-6">
<VulnerabilitiesActiveCard reportData={reportData}/>
<VulnerabilitiesPassiveCard reportData={reportData}/>
</div>
</TabsContent>
<TabsContent value="leaks" className="space-y-6">
<div>
<h3 className="text-xl">Data Leaks Details</h3>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<LeaksEnumerationCard reportData={reportData} />
<LeaksResolvedCard reportData={reportData} />
<LeaksUnresolvedCard reportData={reportData} />
</div>
</TabsContent>
</Tabs>
<div className="flex items-center justify-center gap-4 mt-6">
<Button
onClick={handlePrevPage}
disabled={currentPage === 0}
variant="outline"
className="flex items-center gap-2"
>
<ChevronLeft className="w-4 h-4"/>
Previous
</Button>
<div className="text-sm text-muted-foreground">
Page {currentPage + 1} of {securitySummaryResponse?.results.length}
</div>
<Button
onClick={handleNextPage}
disabled={!securitySummaryResponse || currentPage === securitySummaryResponse.results.length - 1}
variant="outline"
className="flex items-center gap-2"
>
Next
<ChevronRight className="w-4 h-4"/>
</Button>
</div>
</div>
);
};

View File

@ -0,0 +1,85 @@
import React, { useEffect, useState } from 'react';
import axios from 'axios';
import {
SecuritySummaryResponseType,
} from '@/types/security-summary';
import { TextSearchIcon } from 'lucide-react';
import {
Table,
TableBody,
TableCaption,
TableCell,
TableFooter,
TableHead,
TableHeader,
TableRow,
} from "@/Components/ui/table"
import {Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle} from "@/Components/ui/card";
export default function Home() {
const [securitySummaryResponse, setSecuritySummaryResponse] = useState<SecuritySummaryResponseType | null>(null);
useEffect(() => {
axios.get<SecuritySummaryResponseType>('/api/v1/security/summary')
.then(response => {
setSecuritySummaryResponse(response.data);
})
.catch(error => {
console.error("Error fetching the report data", error);
});
}, []);
return (
<div className="container mx-auto p-4 space-y-6">
<Card>
<CardHeader>
<CardTitle className="text-3xl">Scan Reports</CardTitle>
<CardDescription>Pick a scan to see the dashboard, you can also navigate trough dashboard using prev and next arrow at the end of each report overview</CardDescription>
</CardHeader>
<CardContent>
<Table>
<TableHeader>
<TableRow>
<TableHead>Domain</TableHead>
<TableHead>UUID</TableHead>
<TableHead>Method</TableHead>
<TableHead>Score</TableHead>
<TableHead></TableHead>
</TableRow>
</TableHeader>
<TableBody>
{securitySummaryResponse?.results.map((data, index) => (
<TableRow key={index}>
<TableCell className="font-medium">
<a href={`/report/${index}/dashboard`}>{data.domain_name}</a>
</TableCell>
<TableCell>{data.idsummary}</TableCell>
<TableCell>{data.creation_date}</TableCell>
<TableCell>{data.risk_score}</TableCell>
<TableCell>
<a href={`/report/${index}/dashboard`}>
<TextSearchIcon className="w-5 h-5"/>
</a>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle className="text-3xl">Upload Password Leak</CardTitle>
<CardDescription></CardDescription>
</CardHeader>
<CardContent>
--todo
</CardContent>
</Card>
</div>
);
};

View File

@ -6,9 +6,11 @@ use Illuminate\Support\Facades\Route;
use Inertia\Inertia;
Route::get('/', function () {
return redirect('/dashboard');
return Inertia::render('Home');
});
Route::get('/dashboard', function () {
return Inertia::render('Dashboard');
Route::get('/report/{page}/dashboard', function (int $page = 0) {
return Inertia::render('Dashboard', [
'page' => $page
]);
})->name('dashboard');