feat: add links to security advisories for vulnerabilities page

This commit is contained in:
Dorian Niemiec 2024-09-07 21:39:44 +02:00
parent 7138b618e4
commit 092926523c
3 changed files with 63 additions and 27 deletions

View file

@ -35,7 +35,10 @@ import {
interface VulnerabiltyEntry {
_id: string;
version: string;
bullets: { point: string }[];
bullets: {
point: string;
securityAdvisoryUrl: string;
}[];
}
type VulnerabiltiesForm = z.infer<typeof vulnerabilitiesSchema>;
@ -50,7 +53,7 @@ const AdminLogPage = () => {
resolver: zodResolver(vulnerabilitiesSchema),
defaultValues: {
version: "",
bullets: [{ point: "" }]
bullets: [{ point: "", securityAdvisoryUrl: "" }]
}
});
@ -136,6 +139,7 @@ const AdminLogPage = () => {
/>
{fields.map((field, index) => (
<>
<FormField
key={field.id}
control={form.control}
@ -147,6 +151,22 @@ const AdminLogPage = () => {
<Input {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
key={field.id + "-securityAdvisory"}
control={form.control}
name={`bullets.${index}.securityAdvisoryUrl`}
render={({ field }) => (
<FormItem>
<FormLabel>
Security Advisory URL for Key Point {index + 1}
</FormLabel>
<FormControl>
<Input {...field} />
</FormControl>
<FormMessage />
<Button
type="button"
className="mt-2"
@ -158,13 +178,14 @@ const AdminLogPage = () => {
</FormItem>
)}
/>
</>
))}
<Button
type="button"
className="mb-4"
size={"icon"}
variant={"outline"}
onClick={() => append({ point: "" })}
onClick={() => append({ point: "", securityAdvisoryUrl: "" })}
>
+
</Button>

View file

@ -3,9 +3,11 @@ import { VULNERABILITY } from "@/constants/guidelines";
import { useEffect, useState } from "react";
import { Skeleton } from "@/components/ui/skeleton";
import clientPromise from "@/lib/db";
import Link from "next/link";
interface Bullet {
point: string;
securityAdvisoryUrl: string;
}
interface Vulnerabilities {
@ -80,7 +82,19 @@ const Vulnerabilities = async () => {
<h2 className="font-semibold text-3xl -mb-2">{download.version}</h2>
<ul className="list-disc pl-5">
{(download.bullets ?? []).map((bullet, index) => (
<li key={index}>{bullet.point}</li>
<li key={index}>
{bullet.point}
{bullet.securityAdvisoryUrl ? (
<>
{" "}
<Link href={bullet.securityAdvisoryUrl}>
View security advisory
</Link>
</>
) : (
""
)}
</li>
))}
</ul>
</div>

View file

@ -28,7 +28,8 @@ export const vulnerabilitiesSchema = z.object({
version: z.string(),
bullets: z.array(
z.object({
point: z.string()
point: z.string(),
securityAdvisoryUrl: z.string()
})
)
});