From fff2519ad3ebb6555d569e5751cb3fe07a76b38f Mon Sep 17 00:00:00 2001 From: maogeigei Date: Tue, 15 Sep 2026 21:21:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(cost):=20journalctl=20=E8=AE=A4=20`--since`?= =?UTF-8?q?=20=E4=B8=BA=E9=99=90=E6=B5=81=EF=BC=88=E5=9B=9E=E6=94=BE?= =?UTF-8?q?=E9=87=8C=E6=9C=80=E5=90=8E=201=20=E6=9D=A1=E8=BD=BB=E5=BE=AE?= =?UTF-8?q?=E8=AF=AF=E4=BC=A4=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 回放 4051 条真实命令后 soft 档剩 3 条 DENY,逐条核对: - `ls -R $B` → 真阳性(真递归) - `find /d/AI技能 /d/github … -maxdepth 7 -type d` → 真阳性(4 个盘符级根) - `journalctl -u dshs --since "-2 min" --no-pager` → **轻微误伤**:`--since` 本身就是时间窗限流 ⇒ 在 journalctl 规则的否定前瞻里补 `--since`(与 `-n\s*\d` / `head` 同类)。 改后 soft 档 DENY = **2 / 4051 = 0.05%**,两条均为真阳性 ⇒ **对 AI 正常会话零影响**(0 误拦)。 --- dsh-server-docs/scripts/bash-output-guard.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dsh-server-docs/scripts/bash-output-guard.py b/dsh-server-docs/scripts/bash-output-guard.py index aadd486..eb2df52 100644 --- a/dsh-server-docs/scripts/bash-output-guard.py +++ b/dsh-server-docs/scripts/bash-output-guard.py @@ -57,8 +57,8 @@ RULES = [ '`ls -R` 递归全树', '改用 `ls -la 目录 | head -20`,或 `ls 目录 | wc -l`'), (True, r'\bfind\s+(/[A-Za-z]|[A-Za-z]:)', '`find` 从盘符/根起全树扫', '改用 `find 具体目录 -maxdepth 3 … | head -20`'), - (True, r'\bjournalctl\b(?!.*(-n\s*\d|head))', - '`journalctl` 无行数限制', '改用 `journalctl -u X -n 50 --no-pager`'), + (True, r'\bjournalctl\b(?!.*(-n\s*\d|head|--since))', + '`journalctl` 无行数/时间限制', '改用 `journalctl -u X -n 50 --no-pager`(`--since` 也算限流,放行)'), (True, r'\bdmesg\b(?!.*head)', '`dmesg` 无行数限制', '改用 `dmesg | tail -30`'), (False, r'(^|[|;&]\s*)rg\b(?!.*\|)',