From c31f9a2e75348962919ea375a0ee50336ff1102b Mon Sep 17 00:00:00 2001 From: gearnode Date: Mon, 31 Mar 2025 22:06:58 +0200 Subject: [PATCH] Add risk template Signed-off-by: gearnode --- .../pages/organizations/risks/NewRiskView.tsx | 117 +++++++++++++++++- 1 file changed, 116 insertions(+), 1 deletion(-) diff --git a/apps/console/src/pages/organizations/risks/NewRiskView.tsx b/apps/console/src/pages/organizations/risks/NewRiskView.tsx index 15471b0bb..3885d5e6b 100644 --- a/apps/console/src/pages/organizations/risks/NewRiskView.tsx +++ b/apps/console/src/pages/organizations/risks/NewRiskView.tsx @@ -22,6 +22,74 @@ import { SelectValue, } from "@/components/ui/select"; +// Risk template library - static definitions of common risks +const riskTemplates = [ + { + id: "data-breach", + name: "Data Breach", + description: + "Unauthorized access to sensitive data resulting in data disclosure, theft, or corruption.", + probability: "HIGH", + impact: "HIGH", + }, + { + id: "service-outage", + name: "Service Outage", + description: + "System downtime or degradation affecting availability of services to customers.", + probability: "MEDIUM", + impact: "HIGH", + }, + { + id: "compliance-violation", + name: "Compliance Violation", + description: + "Failure to meet regulatory requirements resulting in penalties or legal action.", + probability: "MEDIUM", + impact: "VERY_HIGH", + }, + { + id: "insider-threat", + name: "Insider Threat", + description: + "Malicious actions by employees or contractors with privileged access to systems or data.", + probability: "LOW", + impact: "HIGH", + }, + { + id: "third-party-risk", + name: "Third-Party Risk", + description: + "Vulnerabilities introduced through vendors, suppliers, or partners with access to systems or data.", + probability: "MEDIUM", + impact: "MEDIUM", + }, + { + id: "ransomware", + name: "Ransomware Attack", + description: + "Malware that encrypts data and demands payment for decryption keys.", + probability: "MEDIUM", + impact: "VERY_HIGH", + }, + { + id: "ddos", + name: "DDoS Attack", + description: + "Distributed denial of service attack overwhelming systems and preventing legitimate access.", + probability: "MEDIUM", + impact: "HIGH", + }, + { + id: "credential-compromise", + name: "Credential Compromise", + description: + "Unauthorized access to accounts due to weak, stolen, or improperly secured credentials.", + probability: "HIGH", + impact: "HIGH", + }, +]; + const createRiskMutation = graphql` mutation NewRiskViewCreateRiskMutation( $input: CreateRiskInput! @@ -51,6 +119,7 @@ export default function NewRiskView() { const [probability, setProbability] = useState("MEDIUM"); const [impact, setImpact] = useState("MEDIUM"); const [isSubmitting, setIsSubmitting] = useState(false); + const [selectedTemplate, setSelectedTemplate] = useState(""); const { toast } = useToast(); const [commitMutation, isInFlight] = useMutation(createRiskMutation); @@ -90,6 +159,28 @@ export default function NewRiskView() { } }; + // Handle template selection and prefill form + const handleTemplateChange = (templateId: string) => { + setSelectedTemplate(templateId); + + if (templateId === "none") { + // Clear form if "Select a template" is chosen + setName(""); + setDescription(""); + setProbability("MEDIUM"); + setImpact("MEDIUM"); + return; + } + + const template = riskTemplates.find((t) => t.id === templateId); + if (template) { + setName(template.name); + setDescription(template.description); + setProbability(template.probability); + setImpact(template.impact); + } + }; + const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); @@ -162,11 +253,35 @@ export default function NewRiskView() { Risk Details - Enter the details of the risk you want to add to your organization. + Enter the details of the risk you want to add to your organization + or select from a template.
+
+ + +

+ Select a template to prefill the form or create a custom risk. +

+
+