mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-07 04:58:44 +02:00
policies and policy on resource structure in a good place
This commit is contained in:
@@ -12,6 +12,23 @@ type TranslateFn = (
|
||||
values?: Record<string, string | number>
|
||||
) => string;
|
||||
|
||||
export const POLICY_RULE_MATCH_TYPES = [
|
||||
"CIDR",
|
||||
"IP",
|
||||
"PATH",
|
||||
"COUNTRY",
|
||||
"ASN",
|
||||
"REGION"
|
||||
] as const;
|
||||
|
||||
export type PolicyRuleMatchType = (typeof POLICY_RULE_MATCH_TYPES)[number];
|
||||
|
||||
export function createPolicyRuleMatchSchema(t: TranslateFn) {
|
||||
return z.enum(POLICY_RULE_MATCH_TYPES, {
|
||||
error: t("rulesErrorInvalidMatchTypeDescription")
|
||||
});
|
||||
}
|
||||
|
||||
export type RuleValidationToast = {
|
||||
title: string;
|
||||
description: string;
|
||||
@@ -78,7 +95,7 @@ export function createPolicyRuleSchema(t: TranslateFn) {
|
||||
return z
|
||||
.object({
|
||||
action: z.enum(["ACCEPT", "DROP", "PASS"]),
|
||||
match: z.string(),
|
||||
match: createPolicyRuleMatchSchema(t),
|
||||
value: z.string(),
|
||||
priority: z.number().int(),
|
||||
enabled: z.boolean()
|
||||
|
||||
Reference in New Issue
Block a user