"use client"; import ReactMarkdown from "react-markdown"; import { VULNERABILITY } from "@/constants/guidelines"; import { useEffect, useState } from "react"; import { Skeleton } from "@/components/ui/skeleton"; interface Bullet { point: string; } interface Vulnerabilities { _id: string; version: string; bullets?: Bullet[]; // Make bullets optional } interface ModsVulnerability { _id: string; title: string; slug: string; content: string; vulnerabilities: string; } const Vulnerabilities = () => { const [loading, setLoading] = useState(true); const [downloads, setDownloads] = useState([]); const [mods, setMods] = useState([]); const [error, setError] = useState(""); const fetchData = async () => { try { const response = await fetch("/api/vulnerabilities", { method: "GET" }); if (response.ok) { const data: Vulnerabilities[] = await response.json(); setDownloads(data); return (document.title = "Vulnerabilities - SVR.JS"); } else { throw new Error(`HTTP error! status: ${response.status}`); } } catch (error: any) { setError(error.message || "Failed to fetch downloads"); } finally { setLoading(false); } }; const fetchMods = async () => { try { const response = await fetch(`/api/mdx/pages`, { method: "GET" }); if (response.ok) { const data: ModsVulnerability[] = await response.json(); // Filter out entries where vulnerabilities is undefined or an empty string const filteredMods = data.filter( (mod) => mod.vulnerabilities && mod.vulnerabilities.trim() !== "" ); setMods(filteredMods); return (document.title = "Vulnerabilities - SVR.JS"); } else { throw new Error(`HTTP error! status: ${response.status}`); } } catch (error: any) { setError(error.message || "Failed to fetch vulnerabilities"); } finally { setLoading(false); } }; useEffect(() => { fetchData(); fetchMods(); const interval = setInterval(() => { fetchData(); fetchMods(); }, 10000); return () => clearInterval(interval); }, []); const reversedDownloads = [...downloads].reverse(); const reversedMods = [...mods].reverse(); if (loading) { return ( <> Vulnerabilities - SVR.JS
); } return (

SVR.JS Vulnerabilities

Some older versions of SVR.JS are vulnerable to cyberattacks. It's recommended to update your SVR.JS version to the newest one. If you find a security issue with SVR.JS, report it as soon as possible to vulnerability-reports[at]svrjs[dot]org. We'll mitigate that vulnerability if it is possible.

{error &&

{error}

} {reversedDownloads.map((download) => (

{download.version}

    {(download.bullets ?? []).map((bullet, index) => (
  • {bullet.point}
  • ))}
))}
{VULNERABILITY}
{/* Section with MODS content */} {reversedMods.map((mod) => (

{mod.title}

{mod.vulnerabilities && (
{mod.vulnerabilities}
)}
))}
); }; export default Vulnerabilities;