From 4bc84717ffce3745c6a055ce450262891d5880ed Mon Sep 17 00:00:00 2001 From: CieanYau Date: Fri, 6 Nov 2026 01:36:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=89=E5=85=A8=E7=BB=84?= =?UTF-8?q?=E8=A7=84=E5=88=99=E6=96=B9=E5=90=91=E6=A0=A1=E9=AA=8C=E4=B8=8E?= =?UTF-8?q?=E6=97=A7=E5=B7=A5=E5=8D=95=E5=88=87=E6=8D=A2=E9=94=99=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/pages/security/groups/index.vue | 12 +- app/pages/tickets/ticket.vue | 5 +- tests/review-routes.e2e.test.mjs | 310 ++++++++++++++++++++++++++++ 3 files changed, 323 insertions(+), 4 deletions(-) create mode 100644 tests/review-routes.e2e.test.mjs diff --git a/app/pages/security/groups/index.vue b/app/pages/security/groups/index.vue index 900046e..6321911 100644 --- a/app/pages/security/groups/index.vue +++ b/app/pages/security/groups/index.vue @@ -579,7 +579,7 @@ var Te = { let Q = ref(!1), $ = ref(``), Lt = ref(!1); - // 每行按方向、协议、端口、IP 和可选描述解析;空行忽略,不足四列明确报格式错误。 + // 先把自由文本收敛为方向、协议的封闭枚举;任一行无效就拒绝整批,不能猜成入站规则。 function Rt(e) { let t = []; for (let n of e.split(` @@ -589,9 +589,15 @@ var Te = { let r = e.split(/\s+/); if (r.length < 4) throw Error(`格式不正确:${e}`); let [ee, i, te = ``, a = ``, ...o] = r; + let direction = ee.toLowerCase(), + protocol = i.toLowerCase(); + if (!["in", "out"].includes(direction)) + throw Error(`规则方向必须为 in 或 out:${ee}`); + if (!["tcp", "udp", "icmp", "all"].includes(protocol)) + throw Error(`规则协议必须为 tcp、udp、icmp 或 all:${i}`); t.push({ - direction: ee === `out` ? `out` : `in`, - protocol: (i || `tcp`).toLowerCase(), + direction, + protocol, port: te, ip: a, description: o.join(` `) || void 0, diff --git a/app/pages/tickets/ticket.vue b/app/pages/tickets/ticket.vue index 4b646a1..44f114d 100644 --- a/app/pages/tickets/ticket.vue +++ b/app/pages/tickets/ticket.vue @@ -1,10 +1,13 @@