Add further input validation/sanitization for ssh params

This commit is contained in:
Tuan Dang
2024-12-10 12:44:08 -08:00
parent c5816014a6
commit 3b2154bab4
5 changed files with 150 additions and 49 deletions
@@ -1,6 +1,7 @@
import { useEffect, useState } from "react";
import { Controller, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import ms from "ms";
import { z } from "zod";
import { createNotification } from "@app/components/notifications";
@@ -39,7 +40,11 @@ const schema = z.object({
]),
certType: z.nativeEnum(SshCertType),
principals: z.string(),
ttl: z.string().optional(),
ttl: z
.string()
.trim()
.refine((val) => ms(val) > 0, "TTL must be a valid time string such as 2 days, 1d, 2h 1y, ...")
.optional(),
keyId: z.string().optional()
});