From fae8d9f03252111904934c11069ecbdf1234c6c4 Mon Sep 17 00:00:00 2001 From: fylorn <249551762+fylorn@users.noreply.github.com> Date: Tue, 24 Nov 2026 00:38:19 +0800 Subject: [PATCH 1/2] feat(i18n): ship English security metadata in Core 0.100.0 --- CONTRIBUTING.md | 9 + Cargo.lock | 44 +-- Cargo.toml | 2 +- bin/twcore/src/main.rs | 10 +- bin/twcore/tests/copy.rs | 7 +- bin/twcore/tests/msg_codes.rs | 17 + crates/tw-api/src/lib.rs | 6 +- crates/tw-api/src/ts.rs | 8 +- crates/tw-config/tests/manual/schema.rs | 6 +- crates/tw-guard/build.rs | 71 ++--- crates/tw-guard/data/content.yaml | 39 +-- crates/tw-guard/data/redact.yaml | 222 +------------ crates/tw-guard/data/rules.yaml | 50 +-- crates/tw-guard/src/content.rs | 12 +- crates/tw-guard/src/redact/catalog_tests.rs | 39 +-- crates/tw-guard/src/redact/rules.rs | 10 - crates/tw-guard/src/tools/rules.rs | 29 +- crates/tw-guard/src/view.rs | 86 ++--- docs/config.zh-CN.md | 334 ++++++++++---------- release-notes/0.100.0.md | 3 + 20 files changed, 310 insertions(+), 694 deletions(-) create mode 100644 release-notes/0.100.0.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d19c5481..38daeec2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -63,6 +63,15 @@ desktop app runs on, so they live in the desktop app (its `tw-adopt` and `tw-scan` crates), and the only control-plane endpoint they use is `POST /clients/{id}/key`, which issues a client its own gateway key. +## Runtime text + +Core-authored runtime text is written in English. Use a stable message +code and named arguments for messages the clients translate. Built-in +security rules expose stable IDs, group slugs, and English display text. +Client applications own the translations for those IDs and slugs. Rule +patterns, user-supplied names, and upstream text retain their original +language. + ## Commit messages Conventional Commits (`fix(scope): subject`), in **English** — this is a diff --git a/Cargo.lock b/Cargo.lock index 5adcf83b..f4cc5521 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4148,7 +4148,7 @@ dependencies = [ [[package]] name = "tw-api" -version = "0.99.0" +version = "0.100.0" dependencies = [ "serde", "serde_json", @@ -4159,7 +4159,7 @@ dependencies = [ [[package]] name = "tw-bedrock" -version = "0.99.0" +version = "0.100.0" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -4180,7 +4180,7 @@ dependencies = [ [[package]] name = "tw-breaker" -version = "0.99.0" +version = "0.100.0" dependencies = [ "serde", "serde_json", @@ -4188,7 +4188,7 @@ dependencies = [ [[package]] name = "tw-config" -version = "0.99.0" +version = "0.100.0" dependencies = [ "blake3", "icu_locale_core", @@ -4216,7 +4216,7 @@ dependencies = [ [[package]] name = "tw-control" -version = "0.99.0" +version = "0.100.0" dependencies = [ "axum", "base64 0.22.1", @@ -4262,7 +4262,7 @@ dependencies = [ [[package]] name = "tw-dialect" -version = "0.99.0" +version = "0.100.0" dependencies = [ "memchr", "serde", @@ -4271,7 +4271,7 @@ dependencies = [ [[package]] name = "tw-engine" -version = "0.99.0" +version = "0.100.0" dependencies = [ "chrono", "serde", @@ -4285,7 +4285,7 @@ dependencies = [ [[package]] name = "tw-gateway" -version = "0.99.0" +version = "0.100.0" dependencies = [ "arc-swap", "async-stream", @@ -4340,7 +4340,7 @@ dependencies = [ [[package]] name = "tw-guard" -version = "0.99.0" +version = "0.100.0" dependencies = [ "aho-corasick", "base64 0.22.1", @@ -4361,7 +4361,7 @@ dependencies = [ [[package]] name = "tw-handover" -version = "0.99.0" +version = "0.100.0" dependencies = [ "libc", "serde", @@ -4374,7 +4374,7 @@ dependencies = [ [[package]] name = "tw-link" -version = "0.99.0" +version = "0.100.0" dependencies = [ "serde", "serde_json", @@ -4388,7 +4388,7 @@ dependencies = [ [[package]] name = "tw-observe" -version = "0.99.0" +version = "0.100.0" dependencies = [ "tokio", "tracing", @@ -4397,7 +4397,7 @@ dependencies = [ [[package]] name = "tw-pack" -version = "0.99.0" +version = "0.100.0" dependencies = [ "age", "blake3", @@ -4421,7 +4421,7 @@ dependencies = [ [[package]] name = "tw-plugin" -version = "0.99.0" +version = "0.100.0" dependencies = [ "libc", "rand 0.10.2", @@ -4437,7 +4437,7 @@ dependencies = [ [[package]] name = "tw-pricing" -version = "0.99.0" +version = "0.100.0" dependencies = [ "arc-swap", "flate2", @@ -4450,14 +4450,14 @@ dependencies = [ [[package]] name = "tw-secret" -version = "0.99.0" +version = "0.100.0" dependencies = [ "thiserror 2.0.20", ] [[package]] name = "tw-store" -version = "0.99.0" +version = "0.100.0" dependencies = [ "blake3", "bytes", @@ -4477,7 +4477,7 @@ dependencies = [ [[package]] name = "tw-sync" -version = "0.99.0" +version = "0.100.0" dependencies = [ "age", "axum", @@ -4505,7 +4505,7 @@ dependencies = [ [[package]] name = "tw-types" -version = "0.99.0" +version = "0.100.0" dependencies = [ "serde", "serde_json", @@ -4514,7 +4514,7 @@ dependencies = [ [[package]] name = "tw-watch" -version = "0.99.0" +version = "0.100.0" dependencies = [ "libc", "notify", @@ -4525,7 +4525,7 @@ dependencies = [ [[package]] name = "tw-yaml" -version = "0.99.0" +version = "0.100.0" dependencies = [ "saphyr-parser", "serde_yaml_ng", @@ -4535,7 +4535,7 @@ dependencies = [ [[package]] name = "twcore" -version = "0.99.0" +version = "0.100.0" dependencies = [ "anyhow", "axum", diff --git a/Cargo.toml b/Cargo.toml index 3fe09b7e..5cff4f79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,7 +61,7 @@ categories = ["network-programming", "web-programming::http-server"] # 二进制走 CalVer,crate 走 SemVer —— 两者是两回事,卖给不同的人。 # 这里是 crate 的版本。 -version = "0.99.0" +version = "0.100.0" [workspace.dependencies] # ── 内部 crate ─────────────────────────────────────────── diff --git a/bin/twcore/src/main.rs b/bin/twcore/src/main.rs index 6b99cd40..c4c8f59f 100644 --- a/bin/twcore/src/main.rs +++ b/bin/twcore/src/main.rs @@ -622,8 +622,8 @@ fn cmd_remote(path: &Path, what: RemoteCmd) -> Result<()> { fn cmd_init(path: &Path, force: bool) -> Result<()> { if path.exists() && !force { anyhow::bail!( - "{} 已存在。如需重新生成,请添加 --force。\n\ - 这会覆盖当前配置,其中的密钥也将丢失", + "{} already exists. To regenerate it, pass --force.\n\ + This will overwrite the current configuration and discard the keys in it.", path.display() ); } @@ -784,9 +784,9 @@ fn cmd_check(path: &Path) -> Result<()> { fn already_running(dir: &Path, pid: u32) -> anyhow::Error { anyhow::anyhow!( - "已有 twcore 实例正在运行(pid {pid})。\n\ - 两个实例无法共用同一个网关端口,请先停止该实例。\n\ - 如果该进程实际已退出,请删除 {} 后重试", + "A twcore instance is already running (PID {pid}).\n\ + Stop it before starting another instance on the same gateway port.\n\ + If that process has already exited, remove {} and retry.", dir.join("twcore.lock").display() ) } diff --git a/bin/twcore/tests/copy.rs b/bin/twcore/tests/copy.rs index 467873a1..92d9a618 100644 --- a/bin/twcore/tests/copy.rs +++ b/bin/twcore/tests/copy.rs @@ -245,6 +245,11 @@ fn product_text_is_written_not_spoken() { if FORMAT.contains(&lit.as_str()) || lit.contains("CREATE TABLE") { continue; } + if rel_path.starts_with("bin/twcore/src") + && lit.chars().any(|c| matches!(c, '\u{3400}'..='\u{9fff}')) + { + found.push(format!("{rel}:{line}: write CLI output in English")); + } for w in SPOKEN.iter().filter(|w| lit.contains(**w)) { found.push(format!("{rel}:{line} 「{w}」 {lit}")); } @@ -267,7 +272,7 @@ fn product_text_is_written_not_spoken() { assert!( found.is_empty(), - "这些文字用了口语或人称:\n{}", + "Product copy violations:\n{}", found.join("\n") ); } diff --git a/bin/twcore/tests/msg_codes.rs b/bin/twcore/tests/msg_codes.rs index f681e363..b7e8321e 100644 --- a/bin/twcore/tests/msg_codes.rs +++ b/bin/twcore/tests/msg_codes.rs @@ -402,6 +402,23 @@ fn only_placeholders(t: &str) -> bool { rest.is_empty() } +#[test] +fn core_message_templates_do_not_include_client_translations() { + let (sites, _) = scan(&workspace()); + for site in sites.iter().filter(|site| !site.test) { + if let Some(template) = &site.template { + assert!( + !template + .chars() + .any(|c| matches!(c, '\u{3400}'..='\u{9fff}')), + "{}:{}: write Core message templates in English", + site.file, + site.line, + ); + } + } +} + /// 按源码生成的清单全文。 fn manifest(root: &Path) -> String { let (sites, consts) = scan(root); diff --git a/crates/tw-api/src/lib.rs b/crates/tw-api/src/lib.rs index c8623f07..912dc0d2 100644 --- a/crates/tw-api/src/lib.rs +++ b/crates/tw-api/src/lib.rs @@ -1226,7 +1226,9 @@ pub const MSG_CODES: &str = include_str!("../msg-codes.txt"); /// [`SpecSource::Upstream`] 表示上游报告的规格。请求库 SCHEMA 不变。 /// **61 起支持 Core 执行联网工具**:新增 `WebTools`、`SaveWebTools` 和 `TestWebTool`。 /// 搜索、网页读取和页内查找共用当前连接 Core 的配置。请求库 SCHEMA 不变。 -pub const CONTROL_API_VERSION: u32 = 61; +/// **62 起防护规则和分组视图只返回英文说明**:客户端用规则 ID 和分组 slug 查译文。 +/// 请求库 SCHEMA 不变。 +pub const CONTROL_API_VERSION: u32 = 62; /// `/live` 的速度看最近多久(见 [`LiveView::tokens_per_sec`]),毫秒 pub const LIVE_RATE_WINDOW_MS: u64 = 3_000; @@ -6627,7 +6629,7 @@ pub struct RuleSnapshot { pub builtin: bool, /// 内置规则的 id,或者自定义规则的名字 pub id: String, - /// 显示的名字:内置规则的英文名(中文名按 id 在规则视图里取 `name_zh`),自定义规则就是它的名字 + /// The built-in rule's English name, or the custom rule's original name. pub name: String, /// 自定义规则写的样子,原样(正则、关键词、码位)。内置规则没有 #[serde(default, skip_serializing_if = "Option::is_none")] diff --git a/crates/tw-api/src/ts.rs b/crates/tw-api/src/ts.rs index fd518ab0..7b16595e 100644 --- a/crates/tw-api/src/ts.rs +++ b/crates/tw-api/src/ts.rs @@ -514,11 +514,8 @@ mod tests { "matcher: Matcher", "scope?: Array", "replacement?: string", - // 名字、说明由 core 给,中英文各一个字段 - "name_zh?: string", - "why_zh?: string", + "name: string", "about?: string", - "about_zh?: string", ] { assert!(rule.contains(field), "{field}: {rule}"); } @@ -528,9 +525,10 @@ mod tests { decl_of(&ts, "GuardDetail") ); let kind = decl_of(&ts, "SecurityKindView"); - for field in ["slug: string", "name: string", "name_zh: string"] { + for field in ["slug: string", "name: string"] { assert!(kind.contains(field), "{field}: {kind}"); } + assert!(!rule.contains("_zh") && !kind.contains("_zh")); assert_eq!( decl_of(&ts, "ContentScope"), "export type ContentScope = \"request\" | \"response\"" diff --git a/crates/tw-config/tests/manual/schema.rs b/crates/tw-config/tests/manual/schema.rs index 31c31549..915455ab 100644 --- a/crates/tw-config/tests/manual/schema.rs +++ b/crates/tw-config/tests/manual/schema.rs @@ -2505,7 +2505,7 @@ pub fn rules(kind: &str, l: Lang) -> Option { }; for b in tw_guard::redact::rules::BUILTINS { let on = if b.on_by_default { yes } else { no }; - let name = if zh { b.name_zh } else { b.name }; + let name = b.name; out += &format!("| `{}` | {name} | {on} |\n", b.id); } } @@ -2517,7 +2517,7 @@ pub fn rules(kind: &str, l: Lang) -> Option { }; for s in &tw_guard::tools::rules::builtin().dangerous { let a = ToolAction::factory(s).slug(); - let name = if zh { &s.name_zh } else { &s.name }; + let name = &s.name; out += &format!("| `{}` | {name} | `{a}` |\n", s.id); } } @@ -2530,7 +2530,7 @@ pub fn rules(kind: &str, l: Lang) -> Option { for b in tw_guard::content::builtins() { let on = if b.on_by_default { yes } else { no }; let a = ContentAction::factory(b).slug(); - let name = if zh { &b.name_zh } else { &b.name }; + let name = &b.name; out += &format!("| `{}` | {name} | {} | {on} | `{a}` |\n", b.id, b.group); } } diff --git a/crates/tw-guard/build.rs b/crates/tw-guard/build.rs index 346c8dea..c7440d0c 100644 --- a/crates/tw-guard/build.rs +++ b/crates/tw-guard/build.rs @@ -30,7 +30,6 @@ struct File { struct KindSpec { slug: String, name: String, - name_zh: String, } #[derive(Deserialize)] @@ -43,12 +42,9 @@ struct RuleSpec { #[serde(default)] label: Option, name: String, - name_zh: String, #[serde(default)] about: Option, #[serde(default)] - about_zh: Option, - #[serde(default)] hosts: Vec, #[serde(default)] prefix: Option, @@ -96,13 +92,6 @@ impl Tail { Tail::Alnum => "letters or digits", } } - fn zh(self) -> &'static str { - match self { - Tail::Any => "字符", - Tail::Hex => "十六进制字符", - Tail::Alnum => "字母或数字", - } - } } const SOURCE: &str = "data/redact.yaml"; @@ -134,18 +123,16 @@ fn variant(slug: &str) -> String { fn kinds(file: &File) -> String { let mut s = String::from("&[\n"); for k in &file.kinds { - let ok = |t: &str| !t.trim().is_empty(); assert!( - ok(&k.name) && ok(&k.name_zh), - "{SOURCE}: kind `{}` needs both names", + !k.name.trim().is_empty(), + "{SOURCE}: kind `{}` needs a name", k.slug ); writeln!( s, - " KindName {{ kind: Kind::{}, name: {:?}, name_zh: {:?} }},", + " KindName {{ kind: Kind::{}, name: {:?} }},", variant(&k.slug), - k.name, - k.name_zh + k.name ) .unwrap(); } @@ -166,8 +153,8 @@ fn builtins(file: &File) -> String { r.kind ); let ok = |t: &str| !t.trim().is_empty(); - assert!(ok(&r.name) && ok(&r.name_zh), "{at} needs both names"); - let (matcher, about, about_zh) = match (&r.prefix, &r.prefixes) { + assert!(ok(&r.name), "{at} needs a name"); + let (matcher, about) = match (&r.prefix, &r.prefixes) { (Some(_), Some(_)) => panic!("{at}: `prefix` or `prefixes`, not both"), (Some(p), None) => { assert!(!p.prefix.is_empty(), "{at}: empty prefix"); @@ -176,14 +163,12 @@ fn builtins(file: &File) -> String { min_tail: p.min_tail, tail: Tail::Any, }]; - let (en, zh) = describe(&one); ( format!( "Matcher::Prefix {{ prefix: {:?}, min_tail: {} }}", p.prefix, p.min_tail ), - en, - zh, + describe(&one), ) } (None, Some(list)) => { @@ -201,27 +186,22 @@ fn builtins(file: &File) -> String { .unwrap(); } m.push_str("] }"); - let (en, zh) = describe(list); - (m, en, zh) + (m, describe(list)) } // 代码里的判据:`detector` 是 const fn,查不到这个 id 就是编译错误 - (None, None) => ( - format!("detector({:?})", r.id), - String::new(), - String::new(), - ), + (None, None) => (format!("detector({:?})", r.id), String::new()), }; - let (about, about_zh) = if matcher.starts_with("detector") { - match (&r.about, &r.about_zh) { - (Some(en), Some(zh)) if ok(en) && ok(zh) => (en.clone(), zh.clone()), - _ => panic!("{at}: a rule whose check is in code needs `about` and `about_zh`"), + let about = if matcher.starts_with("detector") { + match &r.about { + Some(about) if ok(about) => about.clone(), + _ => panic!("{at}: a rule whose check is in code needs `about`"), } } else { assert!( - r.about.is_none() && r.about_zh.is_none(), + r.about.is_none(), "{at}: a prefix rule's description is generated from its prefixes; drop `about`" ); - (about, about_zh) + about }; let label = match &r.label { Some(l) => format!("Some({l:?})"), @@ -229,14 +209,12 @@ fn builtins(file: &File) -> String { }; writeln!( s, - " Builtin {{ id: {:?}, kind: Kind::{}, name: {:?}, name_zh: {:?}, about: {:?}, \ - about_zh: {:?}, on_by_default: {}, matcher: {matcher}, label: {label}, hosts: &{:?} }},", + " Builtin {{ id: {:?}, kind: Kind::{}, name: {:?}, about: {:?}, \ + on_by_default: {}, matcher: {matcher}, label: {label}, hosts: &{:?} }},", r.id, variant(&r.kind), r.name, - r.name_zh, about, - about_zh, r.on_by_default, r.hosts, ) @@ -246,9 +224,9 @@ fn builtins(file: &File) -> String { s } -/// 前缀类规则的说明,英文和中文。尾巴要求(最短几个、什么字符)一样的前缀连成一段,段的先后 +/// 前缀类规则的英文说明。尾巴要求(最短几个、什么字符)一样的前缀连成一段,段的先后 /// 按各自第一次出现的位置(`hvs.`、`hvb.` 尾长不同就是两段) -fn describe(list: &[Prefix]) -> (String, String) { +fn describe(list: &[Prefix]) -> String { let mut runs: Vec<(usize, Tail, Vec)> = Vec::new(); for p in list { let code = format!("`{}`", p.prefix); @@ -260,8 +238,7 @@ fn describe(list: &[Prefix]) -> (String, String) { None => runs.push((p.min_tail, p.tail, vec![code])), } } - let en = runs - .iter() + runs.iter() .enumerate() .map(|(i, (n, t, ps))| { // 分号后面接着的一段不大写 @@ -273,13 +250,7 @@ fn describe(list: &[Prefix]) -> (String, String) { ) }) .collect::>() - .join("; "); - let zh = runs - .iter() - .map(|(n, t, ps)| format!("{} 开头,其后至少 {n} 个{}", ps.join("、"), t.zh())) - .collect::>() - .join(";"); - (en, zh) + .join("; ") } /// `a`、`a or b`、`a, b or c` diff --git a/crates/tw-guard/data/content.yaml b/crates/tw-guard/data/content.yaml index f34508f4..472ea167 100644 --- a/crates/tw-guard/data/content.yaml +++ b/crates/tw-guard/data/content.yaml @@ -6,8 +6,7 @@ # 每条规则: # # - `id`:配置按它引用,**改了就是另一条规则**; -# - `name` / `name_zh`:英文名、中文名。**名字和说明只在这里写一份**,两个产品的界面都 -# 显示规则视图带过去的文字; +# - `name`:英文名,客户端按规则 ID 选取译文; # - `match`:`contains`(不分大小写的子串)、`regex`(不分大小写的正则)或 # `codepoints`(按字符本身认,写成 `U+200B`、`U+E0000–U+E007F`)。 # `contains` 的首尾空格有意义(` dan ` 靠它不误伤 `dance`); @@ -16,7 +15,7 @@ # (改换身份、套提示词)/ `chinese`(中文的说法); # - `on_by_default`:出厂时开不开。**只开误报极少的那几条** —— 「act as」 # 「system prompt」在写代码的对话里天天出现,出厂就开等于让记录变成噪音; -# - `why` / `why_zh`:规则名说不清的,一句说明,英文、中文。 +# - `why`:规则名说不清的,一句说明,英文。 # # `kinds` 是分组的名字,界面按这个顺序分组;`group` 写其中一个。用户自己加的规则在 # 「自定义」组,那个组的名字和另两项防护共用,在 redact.yaml 里。 @@ -28,60 +27,47 @@ kinds: - slug: invisible name: Hidden characters - name_zh: 隐藏字符 - slug: injection name: Instruction override - name_zh: 指令覆盖 - slug: persona name: Identity and prompts - name_zh: 身份与提示词 - slug: chinese name: Chinese phrasing - name_zh: 中文说法 rules: - id: unicode-tags name: Unicode tag characters - name_zh: Unicode 标签字符 pattern: 'U+E0000–U+E007F' match: codepoints action: strip group: invisible on_by_default: true why: Entirely invisible in an editor, yet carried into the model's context as they are, so they can hide a whole instruction. - why_zh: 在编辑器中完全不可见,但会原样进入模型上下文,可用于隐藏整段指令。 - id: bidi-controls name: Bidirectional controls - name_zh: 双向控制符 pattern: 'U+202A–U+202E, U+2066–U+2069' match: codepoints action: strip group: invisible on_by_default: true why: They can make the order shown on screen differ from the actual order of the characters. - why_zh: 可使屏幕上的显示顺序与实际字符顺序不一致。 - id: zero-width name: Zero-width characters - name_zh: 零宽字符 pattern: 'U+200B–U+200D, U+2060, U+FEFF' match: codepoints action: strip group: invisible why: Invisible in an editor, and read by the model. Emoji, Persian and other ordinary writing use them too. - why_zh: 在编辑器中不可见,但会被模型读到。表情符号、波斯文等正常文字也会用到。 - id: private-use name: Private-use characters - name_zh: 私用区字符 pattern: 'U+E000–U+F8FF, U+F0000–U+FFFFD, U+100000–U+10FFFD' match: codepoints action: strip group: invisible why: They have no standard meaning. Some icon fonts use them. - why_zh: 没有标准含义。部分图标字体会用到。 - id: ignore-previous-instructions name: Ignore previous instructions - name_zh: 要求忽略先前的指令 pattern: 'ignore previous instructions' match: contains action: block @@ -89,7 +75,6 @@ rules: on_by_default: true - id: ignore-all-previous name: Ignore all previous - name_zh: 要求忽略之前的全部内容 pattern: 'ignore all previous' match: contains action: block @@ -97,7 +82,6 @@ rules: on_by_default: true - id: disregard-your-instructions name: Disregard your instructions - name_zh: 要求无视指令 pattern: 'disregard your instructions' match: contains action: block @@ -105,21 +89,18 @@ rules: on_by_default: true - id: jailbreak name: Jailbreak - name_zh: 越狱 pattern: 'jailbreak' match: contains action: block group: injection - id: dan name: DAN - name_zh: DAN pattern: ' dan ' match: contains action: block group: injection - id: developer-mode name: Developer mode - name_zh: 开发者模式 pattern: 'developer mode' match: contains action: block @@ -127,56 +108,48 @@ rules: - id: you-are-now name: Persona manipulation - name_zh: 重新设定身份 pattern: 'you are now' match: contains action: block group: persona - id: new-persona name: New persona - name_zh: 新的人设 pattern: 'new persona' match: contains action: record group: persona - id: act-as name: Act as - name_zh: 要求扮演角色 pattern: 'act as' match: contains action: record group: persona - id: pretend-to-be name: Pretend to be - name_zh: 要求假装身份 pattern: 'pretend to be' match: contains action: record group: persona - id: system-prompt name: System prompt extraction - name_zh: 索取系统提示词 pattern: 'system prompt' match: contains action: record group: persona - id: reveal-your-instructions name: Reveal instructions - name_zh: 要求透露指令 pattern: 'reveal your instructions' match: contains action: record group: persona - id: what-are-your-rules name: What are your rules - name_zh: 询问规则 pattern: 'what are your rules' match: contains action: record group: persona - id: base64-wall name: Base64 smuggling - name_zh: 长串 Base64 pattern: '[A-Za-z0-9+/=]{50,}' match: regex action: record @@ -184,56 +157,48 @@ rules: - id: zh-ignore-previous name: Ignore previous instructions (Chinese) - name_zh: 要求忽略先前的指令(中文) pattern: '忽略之前' match: contains action: block group: chinese - id: zh-forget-your name: Forget your instructions (Chinese) - name_zh: 要求忘记指令(中文) pattern: '忘记你' match: contains action: block group: chinese - id: zh-do-not-follow name: Do not follow (Chinese) - name_zh: 要求不要遵循(中文) pattern: '不要遵循' match: contains action: block group: chinese - id: zh-you-are-now name: You are now (Chinese) - name_zh: 重新设定身份(中文) pattern: '现在你是' match: contains action: block group: chinese - id: zh-role-play name: Role-play (Chinese) - name_zh: 要求扮演角色(中文) pattern: '扮演' match: contains action: record group: chinese - id: zh-reveal-your name: Reveal your instructions (Chinese) - name_zh: 要求透露指令(中文) pattern: '透露你的' match: contains action: record group: chinese - id: zh-system-prompt name: System prompt (Chinese) - name_zh: 系统提示词(中文) pattern: '系统提示词' match: contains action: record group: chinese - id: zh-jailbreak name: Jailbreak (Chinese) - name_zh: 越狱(中文) pattern: '越狱' match: contains action: block diff --git a/crates/tw-guard/data/redact.yaml b/crates/tw-guard/data/redact.yaml index a3889875..1307a5e2 100644 --- a/crates/tw-guard/data/redact.yaml +++ b/crates/tw-guard/data/redact.yaml @@ -1,8 +1,6 @@ # 出站脱敏的内置规则目录。 # -# **规则的名字、说明、分组只在这里写一份**,桌面版和企业版的界面都显示规则视图里带过去的 -# 文字(`name` / `name_zh`、`about` / `about_zh`,分组见 `kinds`),不再各存一张名称表 —— -# 三处各存一份时,每加一条规则要改四处,漏一处界面上就只剩一个 id。 +# Core 提供稳定的规则 ID 和英文说明,客户端按 ID 查自己的译文。 # # 编译时由 build.rs 读进来,生成 `rules::BUILTINS`(`&'static [Builtin]`):快速排除的 # `KEY_MIN` / `KEY_FIRST` 是对着 BUILTINS 在编译期算的常量,目录必须在编译期就定下来。 @@ -21,8 +19,8 @@ # - `kind`:分组,`kinds` 里的一个; # - `on_by_default`:出厂开不开,不写是关。**写漏了是「没开」**,宁可漏,不可吵; # - `label`:占位符里的标签(`TW_ID_NUMBER`),不写用账本的默认标签; -# - `name` / `name_zh`:英文名、中文名; -# - `about` / `about_zh`:认什么,给人看的一句话。按位置认的写明只换哪一段。反引号括起来的 +# - `name`:英文名; +# - `about`:认什么,给人看的一句话。按位置认的写明只换哪一段。反引号括起来的 # 一段界面按代码样式显示; # - `hosts`:这把凭据正当地会送往哪些服务商域名(后缀匹配,含子域)。危险命令「凭据发往 # 陌生主机」用它:没写的(私钥、加密货币私钥)送往任何非本机地址都算外传。**别写人人都能 @@ -50,64 +48,44 @@ kinds: - slug: saved name: Saved credentials - name_zh: 保存的密钥 - slug: ai-services name: AI services - name_zh: AI 服务 - slug: dev-platforms name: Code hosting and publishing - name_zh: 代码托管与软件发布 - slug: cloud name: Cloud and infrastructure - name_zh: 云服务与基础设施 - slug: business name: Payments, messaging and collaboration - name_zh: 支付、通信与协作 - slug: private-keys name: Private keys - name_zh: 私钥 - slug: jwt name: JWTs - name_zh: JWT - slug: conn-strings name: Connection strings - name_zh: 连接串 - slug: in-context name: Credentials by position - name_zh: 固定位置的凭据 - slug: crypto name: Cryptocurrency - name_zh: 加密货币 - slug: id-documents name: ID documents - name_zh: 证件号码 - slug: foreign-ids name: Foreign ID numbers - name_zh: 境外证件号码 - slug: financial name: Financial accounts - name_zh: 金融账户 - slug: contact name: Contact details - name_zh: 联系方式 - slug: location name: Addresses and locations - name_zh: 住址与位置 - slug: vehicle name: Vehicles - name_zh: 车辆 - slug: device name: Device and network identifiers - name_zh: 设备与网络标识 - slug: labeled-personal name: Personal information by field name - name_zh: 带字段名的个人信息 - slug: internal name: Internal addresses - name_zh: 内网地址 - slug: custom name: Custom - name_zh: 自定义 rules: @@ -116,229 +94,186 @@ rules: kind: ai-services on_by_default: true name: Anthropic API key - name_zh: Anthropic API 密钥 prefix: { prefix: 'sk-ant-', min_tail: 20 } hosts: [anthropic.com] - id: openai-project-key kind: ai-services on_by_default: true name: OpenAI project key - name_zh: OpenAI 项目密钥 prefix: { prefix: 'sk-proj-', min_tail: 20 } hosts: [openai.com] - id: openai-api-key kind: ai-services on_by_default: true name: OpenAI API key - name_zh: OpenAI API 密钥 about: 'Starts with `sk-`, at least 40 characters, with both letters and digits' - about_zh: '`sk-` 开头,全长至少 40 个字符,同时含字母和数字' hosts: [openai.com] - id: github-personal-token kind: dev-platforms on_by_default: true name: GitHub personal access token - name_zh: GitHub 个人令牌 prefix: { prefix: 'ghp_', min_tail: 30 } hosts: [github.com, githubusercontent.com] - id: github-oauth-token kind: dev-platforms on_by_default: true name: GitHub OAuth token - name_zh: GitHub OAuth 令牌 prefix: { prefix: 'gho_', min_tail: 30 } hosts: [github.com, githubusercontent.com] - id: github-server-token kind: dev-platforms on_by_default: true name: GitHub server token - name_zh: GitHub 服务器令牌 prefix: { prefix: 'ghs_', min_tail: 30 } hosts: [github.com, githubusercontent.com] - id: github-user-token kind: dev-platforms on_by_default: true name: GitHub user token - name_zh: GitHub 用户令牌 prefix: { prefix: 'ghu_', min_tail: 30 } hosts: [github.com, githubusercontent.com] - id: github-fine-grained-token kind: dev-platforms on_by_default: true name: GitHub fine-grained token - name_zh: GitHub 细粒度令牌 prefix: { prefix: 'github_pat_', min_tail: 30 } hosts: [github.com, githubusercontent.com] - id: slack-bot-token kind: business on_by_default: true name: Slack bot token - name_zh: Slack 机器人令牌 prefix: { prefix: 'xoxb-', min_tail: 20 } hosts: [slack.com] - id: slack-user-token kind: business on_by_default: true name: Slack user token - name_zh: Slack 用户令牌 prefix: { prefix: 'xoxp-', min_tail: 20 } hosts: [slack.com] - id: slack-app-token kind: business on_by_default: true name: Slack app token - name_zh: Slack 应用令牌 prefix: { prefix: 'xoxa-', min_tail: 20 } hosts: [slack.com] - id: aws-access-key-id kind: cloud on_by_default: true name: AWS access key ID - name_zh: AWS 访问密钥 ID prefix: { prefix: 'AKIA', min_tail: 12 } hosts: [amazonaws.com] - id: aws-temporary-key-id kind: cloud on_by_default: true name: AWS temporary access key ID - name_zh: AWS 临时访问密钥 ID prefix: { prefix: 'ASIA', min_tail: 12 } hosts: [amazonaws.com] - id: google-api-key kind: cloud on_by_default: true name: Google API key - name_zh: Google API 密钥 prefix: { prefix: 'AIza', min_tail: 30 } hosts: [googleapis.com, google.com] - id: google-oauth-token kind: cloud on_by_default: true name: Google OAuth token - name_zh: Google OAuth 令牌 prefix: { prefix: 'ya29.', min_tail: 20 } hosts: [googleapis.com, google.com] - id: gitlab-token kind: dev-platforms on_by_default: true name: GitLab token - name_zh: GitLab 令牌 prefix: { prefix: 'glpat-', min_tail: 15 } hosts: [gitlab.com] - id: stripe-live-key kind: business on_by_default: true name: Stripe live key - name_zh: Stripe 生产密钥 prefix: { prefix: 'sk_live_', min_tail: 20 } hosts: [stripe.com] - id: stripe-restricted-key kind: business on_by_default: true name: Stripe restricted key - name_zh: Stripe 受限密钥 prefix: { prefix: 'rk_live_', min_tail: 20 } hosts: [stripe.com] - id: npm-token kind: dev-platforms on_by_default: true name: npm token - name_zh: npm 令牌 prefix: { prefix: 'npm_', min_tail: 30 } hosts: [npmjs.org, npmjs.com] - id: digitalocean-token kind: cloud on_by_default: true name: DigitalOcean token - name_zh: DigitalOcean 令牌 prefix: { prefix: 'dop_v1_', min_tail: 30 } hosts: [digitalocean.com] - id: sendgrid-key kind: business on_by_default: true name: SendGrid key - name_zh: SendGrid 密钥 prefix: { prefix: 'SG.', min_tail: 30 } hosts: [sendgrid.com] - id: private-key kind: private-keys on_by_default: true name: Private key - name_zh: 私钥 about: 'From `-----BEGIN … PRIVATE KEY-----` to its END, as a whole' - about_zh: '`-----BEGIN … PRIVATE KEY-----` 至对应的 END,整段' - id: jwt kind: jwt on_by_default: true name: 'JWT' - name_zh: 'JWT' about: 'Three base64url parts; the first decodes to text containing `"alg"`' - about_zh: '三段 base64url,首段解码后含 `"alg"`' - id: conn-string-password kind: conn-strings on_by_default: true name: Connection string password - name_zh: 连接串口令 about: 'The password in `scheme://user:password@host`; only the password is replaced' - about_zh: '`协议://用户:口令@主机` 中的口令;只换口令' - id: cn-resident-id kind: id-documents on_by_default: true label: TW_ID_NUMBER name: Chinese resident ID number - name_zh: 居民身份证号 about: 'An 18-character resident ID number, including residence permits for Hong Kong, Macau and Taiwan residents and foreign permanent residence ID cards, whose region code, birth date since 1900 and check character all check out' - about_zh: '18 位居民身份证号(含港澳台居民居住证、外国人永久居留身份证):地区码、1900 年以来的出生日期和校验码都对得上' - id: bank-card kind: financial on_by_default: true label: TW_CARD_NUMBER name: Bank card number - name_zh: 银行卡号 about: 'A UnionPay, Visa, Mastercard, American Express, JCB, Discover or Diners Club card number whose prefix and length match and that passes the Luhn check; public test card numbers excepted' - about_zh: '银联、Visa、Mastercard、American Express、JCB、Discover、Diners Club 的卡号:号段、位数对得上并通过 Luhn 校验;公开的测试卡号除外' - id: email kind: contact label: TW_EMAIL name: Email address - name_zh: 邮箱地址 about: 'Email addresses: `name@domain`' - about_zh: '邮箱地址:`名称@域名`' - id: cn-mobile-phone kind: contact label: TW_PHONE name: Chinese mainland mobile number - name_zh: 中国大陆手机号 about: 'Chinese mainland mobile numbers: 11 digits starting with `1`, the second 3 to 9, not run together with other digits; a `+86`, `0086` or `86-` prefix and 3-4-4 groups separated by spaces or hyphens are allowed' - about_zh: '中国大陆手机号:`1` 开头的 11 位数字,第二位为 3 到 9,前后不紧挨其他数字;可带 `+86`、`0086`、`86-` 前缀,可按 3-4-4 以空格或连字符分隔' - id: internal-ip kind: internal name: Internal IP address - name_zh: 内网地址 about: 'Addresses starting with `10.`, `172.16–31.`, `192.168.` or `100.64–127.`, and IPv6 addresses in `fc00::/7`; not 127.0.0.1' - about_zh: '`10.`、`172.16–31.`、`192.168.`、`100.64–127.` 开头的地址与 `fc00::/7` 内的 IPv6 地址,不含 127.0.0.1' - id: internal-domain kind: internal name: Internal domain - name_zh: 内部域名 about: 'Domains ending in `.local`, `.internal`, `.lan`, `.corp`, `.home.arpa` or `.intranet`' - about_zh: '以 `.local`、`.internal`、`.lan`、`.corp`、`.home.arpa`、`.intranet` 结尾的域名' # ---- 扩充的凭据规则(判据在 src/redact/secrets/) - id: thinkwatch-saved-secret kind: saved on_by_default: true name: Credentials saved in ThinkWatch - name_zh: ThinkWatch 中保存的密钥 about: 'Recognized by value, whatever the format: credentials saved in ThinkWatch, namely upstream keys and header values, gateway keys, proxy passwords, the remote control key, and sync and backup credentials. Values shorter than 12 characters are not matched' - about_zh: '按值识别 ThinkWatch 中保存的密钥,与格式无关:上游密钥与请求头中的值、网关密钥、代理密码、远程控制密钥、同步与备份凭据。不足 12 个字符的值不识别' # AI 服务 - id: openai-service-key kind: ai-services on_by_default: true name: OpenAI service account or admin key - name_zh: OpenAI 服务账号与管理密钥 prefixes: - { prefix: 'sk-svcacct-', min_tail: 58 } - { prefix: 'sk-admin-', min_tail: 58 } @@ -347,7 +282,6 @@ rules: kind: ai-services on_by_default: true name: OpenRouter API key - name_zh: OpenRouter API 密钥 prefixes: - { prefix: 'sk-or-v1-', min_tail: 64, tail: hex } hosts: [openrouter.ai] @@ -355,7 +289,6 @@ rules: kind: ai-services on_by_default: true name: xAI API key - name_zh: xAI API 密钥 prefixes: - { prefix: 'xai-', min_tail: 70, tail: alnum } hosts: [x.ai] @@ -363,7 +296,6 @@ rules: kind: ai-services on_by_default: true name: Groq API key - name_zh: Groq API 密钥 prefixes: - { prefix: 'gsk_', min_tail: 52, tail: alnum } hosts: [groq.com] @@ -371,7 +303,6 @@ rules: kind: ai-services on_by_default: true name: Hugging Face token - name_zh: Hugging Face 令牌 prefixes: - { prefix: 'hf_', min_tail: 34, tail: alnum } - { prefix: 'api_org_', min_tail: 34, tail: alnum } @@ -380,7 +311,6 @@ rules: kind: ai-services on_by_default: true name: Replicate token - name_zh: Replicate 令牌 prefixes: - { prefix: 'r8_', min_tail: 37, tail: alnum } hosts: [replicate.com] @@ -388,7 +318,6 @@ rules: kind: ai-services on_by_default: true name: Perplexity API key - name_zh: Perplexity API 密钥 prefixes: - { prefix: 'pplx-', min_tail: 48, tail: alnum } hosts: [perplexity.ai] @@ -396,7 +325,6 @@ rules: kind: ai-services on_by_default: true name: Amazon Bedrock API key - name_zh: Amazon Bedrock API 密钥 prefixes: - { prefix: 'ABSK', min_tail: 100 } hosts: [amazonaws.com] @@ -404,7 +332,6 @@ rules: kind: ai-services on_by_default: true name: Fireworks AI API key - name_zh: Fireworks AI API 密钥 prefixes: - { prefix: 'fw_', min_tail: 20, tail: alnum } hosts: [fireworks.ai] @@ -412,7 +339,6 @@ rules: kind: ai-services on_by_default: true name: Cerebras API key - name_zh: Cerebras API 密钥 prefixes: - { prefix: 'csk-', min_tail: 48, tail: alnum } hosts: [cerebras.ai] @@ -420,7 +346,6 @@ rules: kind: ai-services on_by_default: true name: LangSmith API key - name_zh: LangSmith API 密钥 prefixes: - { prefix: 'lsv2_pt_', min_tail: 43 } - { prefix: 'lsv2_sk_', min_tail: 43 } @@ -429,7 +354,6 @@ rules: kind: ai-services on_by_default: true name: Langfuse secret key - name_zh: Langfuse 私密密钥 prefixes: - { prefix: 'sk-lf-', min_tail: 36 } hosts: [langfuse.com] @@ -437,7 +361,6 @@ rules: kind: ai-services on_by_default: true name: Pinecone API key - name_zh: Pinecone API 密钥 prefixes: - { prefix: 'pcsk_', min_tail: 69 } hosts: [pinecone.io] @@ -445,7 +368,6 @@ rules: kind: ai-services on_by_default: true name: Tavily API key - name_zh: Tavily API 密钥 prefixes: - { prefix: 'tvly-', min_tail: 32 } hosts: [tavily.com] @@ -453,7 +375,6 @@ rules: kind: ai-services on_by_default: true name: MiniMax API key - name_zh: MiniMax API 密钥 prefixes: - { prefix: 'sk-api-', min_tail: 100 } hosts: [minimax.io, minimaxi.com, minimax.chat] @@ -461,17 +382,13 @@ rules: kind: ai-services on_by_default: true name: Zhipu API key - name_zh: 智谱 API 密钥 about: '32 hex characters, `.` and 16 letters or digits, run together' - about_zh: '32 个十六进制字符、`.` 与 16 个字母或数字相连' hosts: [bigmodel.cn, z.ai] - id: qianfan-api-key kind: ai-services on_by_default: true name: Baidu Qianfan API key - name_zh: 百度千帆 API 密钥 about: 'Starts with `bce-v3/ALTAK-`, followed by 21 letters or digits, `/` and 40 hex characters, as a whole' - about_zh: '`bce-v3/ALTAK-` 开头,其后为 21 个字母或数字、`/` 与 40 个十六进制字符,整段' # 只发往千帆的 API 主机:`baidubce.com` 下还有人人可开的云函数(`*.cfc-execute.*.baidubce.com`) hosts: [qianfan.baidubce.com] @@ -483,9 +400,7 @@ rules: kind: ai-services on_by_default: true name: OpenAI-compatible API key - name_zh: OpenAI 兼容格式 API 密钥 about: 'Starts with `sk-`, followed by exactly 32 letters and digits (both present) or exactly 48 lowercase letters' - about_zh: '`sk-` 开头,其后恰为 32 个字母和数字(两者都有),或恰为 48 个小写字母' hosts: - api.deepseek.com - dashscope.aliyuncs.com @@ -499,7 +414,6 @@ rules: kind: dev-platforms on_by_default: true name: GitHub refresh token - name_zh: GitHub 刷新令牌 prefixes: - { prefix: 'ghr_', min_tail: 36, tail: alnum } hosts: [github.com] @@ -507,7 +421,6 @@ rules: kind: dev-platforms on_by_default: true name: Other GitLab token - name_zh: GitLab 其他令牌 prefixes: - { prefix: 'glptt-', min_tail: 20 } - { prefix: 'gldt-', min_tail: 20 } @@ -523,7 +436,6 @@ rules: kind: dev-platforms on_by_default: true name: PyPI token - name_zh: PyPI 令牌 prefixes: - { prefix: 'pypi-AgEIcHlwaS5vcmc', min_tail: 50 } hosts: [pypi.org] @@ -531,7 +443,6 @@ rules: kind: dev-platforms on_by_default: true name: RubyGems token - name_zh: RubyGems 令牌 prefixes: - { prefix: 'rubygems_', min_tail: 48, tail: hex } hosts: [rubygems.org] @@ -539,7 +450,6 @@ rules: kind: dev-platforms on_by_default: true name: Clojars token - name_zh: Clojars 令牌 prefixes: - { prefix: 'CLOJARS_', min_tail: 60, tail: alnum } hosts: [clojars.org] @@ -547,7 +457,6 @@ rules: kind: dev-platforms on_by_default: true name: Docker Hub token - name_zh: Docker Hub 令牌 prefixes: - { prefix: 'dckr_pat_', min_tail: 27 } - { prefix: 'dckr_oat_', min_tail: 32 } @@ -556,7 +465,6 @@ rules: kind: dev-platforms on_by_default: true name: JFrog Artifactory key - name_zh: JFrog Artifactory 密钥 prefixes: - { prefix: 'AKCp', min_tail: 69, tail: alnum } hosts: [jfrog.io] @@ -564,7 +472,6 @@ rules: kind: dev-platforms on_by_default: true name: Databricks token - name_zh: Databricks 令牌 prefixes: - { prefix: 'dapi', min_tail: 32, tail: hex } hosts: [databricks.com, azuredatabricks.net] @@ -572,7 +479,6 @@ rules: kind: dev-platforms on_by_default: true name: Sentry token - name_zh: Sentry 令牌 prefixes: - { prefix: 'sntrys_', min_tail: 40 } - { prefix: 'sntryu_', min_tail: 64, tail: hex } @@ -581,7 +487,6 @@ rules: kind: dev-platforms on_by_default: true name: Grafana token - name_zh: Grafana 令牌 prefixes: - { prefix: 'glsa_', min_tail: 41 } - { prefix: 'glc_', min_tail: 32 } @@ -590,7 +495,6 @@ rules: kind: dev-platforms on_by_default: true name: Postman API key - name_zh: Postman API 密钥 prefixes: - { prefix: 'PMAK-', min_tail: 59 } hosts: [getpostman.com, postman.com] @@ -600,7 +504,6 @@ rules: kind: cloud on_by_default: true name: Other AWS access key ID - name_zh: AWS 其他访问密钥 ID prefixes: - { prefix: 'ABIA', min_tail: 16, tail: alnum } - { prefix: 'ACCA', min_tail: 16, tail: alnum } @@ -609,7 +512,6 @@ rules: kind: cloud on_by_default: true name: Alibaba Cloud AccessKey ID - name_zh: 阿里云 AccessKey ID prefixes: - { prefix: 'LTAI', min_tail: 12, tail: alnum } hosts: [aliyuncs.com] @@ -617,7 +519,6 @@ rules: kind: cloud on_by_default: true name: Tencent Cloud SecretId - name_zh: 腾讯云 SecretId prefixes: - { prefix: 'AKID', min_tail: 32, tail: alnum } hosts: [tencentcloudapi.com] @@ -625,7 +526,6 @@ rules: kind: cloud on_by_default: true name: Volcengine AccessKey ID - name_zh: 火山引擎 AccessKey ID prefixes: - { prefix: 'AKLT', min_tail: 40 } - { prefix: 'AKTP', min_tail: 40 } @@ -634,15 +534,12 @@ rules: kind: cloud on_by_default: true name: Azure AD client secret - name_zh: Azure AD 客户端密码 about: 'Three characters, a digit and `Q~`, followed by 31 to 34 characters' - about_zh: '3 个字符、1 位数字与 `Q~`,其后 31 至 34 个字符' hosts: [microsoftonline.com] - id: digitalocean-other-token kind: cloud on_by_default: true name: Other DigitalOcean token - name_zh: DigitalOcean 其他令牌 prefixes: - { prefix: 'doo_v1_', min_tail: 64, tail: hex } - { prefix: 'dor_v1_', min_tail: 64, tail: hex } @@ -651,7 +548,6 @@ rules: kind: cloud on_by_default: true name: Cloudflare Origin CA key - name_zh: Cloudflare Origin CA 密钥 prefixes: - { prefix: 'v1.0-', min_tail: 171 } hosts: [cloudflare.com] @@ -659,7 +555,6 @@ rules: kind: cloud on_by_default: true name: HashiCorp Vault token - name_zh: HashiCorp Vault 令牌 prefixes: - { prefix: 'hvs.', min_tail: 90 } - { prefix: 'hvb.', min_tail: 138 } @@ -668,15 +563,12 @@ rules: kind: cloud on_by_default: true name: Terraform Cloud token - name_zh: Terraform Cloud 令牌 about: '14 letters or digits and `.atlasv1.`, followed by 60 to 70 characters' - about_zh: '14 个字母或数字与 `.atlasv1.`,其后 60 至 70 个字符' hosts: [terraform.io, hashicorp.cloud] - id: doppler-token kind: cloud on_by_default: true name: Doppler token - name_zh: Doppler 令牌 prefixes: - { prefix: 'dp.pt.', min_tail: 43, tail: alnum } hosts: [doppler.com] @@ -684,7 +576,6 @@ rules: kind: cloud on_by_default: true name: Pulumi token - name_zh: Pulumi 令牌 prefixes: - { prefix: 'pul-', min_tail: 40, tail: hex } hosts: [pulumi.com] @@ -692,7 +583,6 @@ rules: kind: cloud on_by_default: true name: Heroku API key - name_zh: Heroku API 密钥 prefixes: - { prefix: 'HRKU-AA', min_tail: 58 } hosts: [heroku.com] @@ -700,7 +590,6 @@ rules: kind: cloud on_by_default: true name: Fly.io token - name_zh: Fly.io 令牌 prefixes: - { prefix: 'fo1_', min_tail: 43 } hosts: [fly.io, machines.dev] @@ -708,7 +597,6 @@ rules: kind: cloud on_by_default: true name: Supabase key - name_zh: Supabase 密钥 prefixes: - { prefix: 'sbp_', min_tail: 40, tail: alnum } - { prefix: 'sb_secret_', min_tail: 31 } @@ -717,14 +605,12 @@ rules: kind: cloud on_by_default: true name: age secret key - name_zh: age 私钥 prefixes: - { prefix: 'AGE-SECRET-KEY-1', min_tail: 58, tail: alnum } - id: onepassword-token kind: cloud on_by_default: true name: 1Password service account token - name_zh: 1Password 服务账号令牌 prefixes: - { prefix: 'ops_eyJ', min_tail: 200 } hosts: [1password.com] @@ -734,7 +620,6 @@ rules: kind: business on_by_default: true name: Stripe webhook signing secret - name_zh: Stripe Webhook 签名密钥 prefixes: - { prefix: 'whsec_', min_tail: 32 } hosts: [stripe.com] @@ -742,7 +627,6 @@ rules: kind: business on_by_default: true name: Shopify token - name_zh: Shopify 令牌 prefixes: - { prefix: 'shpat_', min_tail: 32, tail: hex } - { prefix: 'shpca_', min_tail: 32, tail: hex } @@ -753,7 +637,6 @@ rules: kind: business on_by_default: true name: Twilio API key - name_zh: Twilio API 密钥 prefixes: - { prefix: 'SK', min_tail: 32, tail: hex } hosts: [twilio.com] @@ -761,7 +644,6 @@ rules: kind: business on_by_default: true name: Brevo API key - name_zh: Brevo API 密钥 prefixes: - { prefix: 'xkeysib-', min_tail: 81 } hosts: [brevo.com, sendinblue.com] @@ -769,7 +651,6 @@ rules: kind: business on_by_default: true name: Other Slack token - name_zh: Slack 其他令牌 prefixes: - { prefix: 'xapp-', min_tail: 20 } - { prefix: 'xoxe-', min_tail: 20 } @@ -781,7 +662,6 @@ rules: kind: business on_by_default: true name: Linear API key - name_zh: Linear API 密钥 prefixes: - { prefix: 'lin_api_', min_tail: 40, tail: alnum } hosts: [linear.app] @@ -789,7 +669,6 @@ rules: kind: business on_by_default: true name: Notion token - name_zh: Notion 令牌 prefixes: - { prefix: 'ntn_', min_tail: 46, tail: alnum } hosts: [notion.com, notion.so] @@ -800,7 +679,6 @@ rules: kind: business on_by_default: true name: Atlassian API token - name_zh: Atlassian API 令牌 prefixes: - { prefix: 'ATATT3', min_tail: 150 } hosts: [atlassian.net, atlassian.com] @@ -810,336 +688,242 @@ rules: kind: in-context on_by_default: true name: Credential in a request header - name_zh: 请求头中的凭据 about: 'The value of an `Authorization`, `X-Api-Key`, `Api-Key` or `X-Goog-Api-Key` header, in curl `-H`, raw HTTP or code; only the value is replaced' - about_zh: '`Authorization`、`X-Api-Key`、`Api-Key`、`X-Goog-Api-Key` 请求头的值,包括 curl 的 `-H`、HTTP 原文与代码中的写法;只换值' - id: command-line-password kind: in-context on_by_default: true name: Password on a command line - name_zh: 命令行中的口令 about: 'Passwords on a command line: `curl -u user:password`, `--user`, `mysql -ppassword`, `PGPASSWORD=… psql`; only the password is replaced' - about_zh: '命令行中的口令:`curl -u 用户:口令`、`--user`、`mysql -p口令`、`PGPASSWORD=… psql`;只换口令' - id: url-token kind: in-context on_by_default: true name: Token in a URL - name_zh: URL 中的令牌 about: 'The value of the URL query parameter `access_token`, `api_key`, `apikey`, `client_secret`, `sig`, `X-Amz-Signature` or `X-Goog-Signature`; only the parameter value is replaced' - about_zh: 'URL 查询参数 `access_token`、`api_key`、`apikey`、`client_secret`、`sig`、`X-Amz-Signature`、`X-Goog-Signature` 的值;只换参数值' - id: bot-webhook kind: in-context on_by_default: true name: Bot webhook - name_zh: 机器人 Webhook about: 'The token in a Feishu / Lark, DingTalk, WeCom, Slack, Discord or Microsoft Teams bot webhook URL; only the token is replaced' - about_zh: '飞书 / Lark、钉钉、企业微信、Slack、Discord、Microsoft Teams 机器人 Webhook 地址中的令牌;只换令牌段' - id: telegram-bot-token kind: in-context on_by_default: true name: Telegram bot token - name_zh: Telegram 机器人令牌 about: '8 to 10 digits and `:AA`, followed by 33 characters' - about_zh: '8 至 10 位数字与 `:AA`,其后 33 个字符' - id: config-assignment kind: in-context on_by_default: true name: Secret assigned in a config file - name_zh: 配置文件中的密钥赋值 about: 'Assignments in `.env`, YAML, TOML, INI or JSON whose variable name ends in `SECRET`, `SECRET_KEY`, `PASSWORD`, `PASSWD`, `PWD`, `TOKEN`, `API_KEY`, `APIKEY`, `ACCESS_KEY`, `PRIVATE_KEY` or `CLIENT_SECRET` (ignoring case) and whose value is a literal of at least 8 characters; only the value is replaced. Expressions, variable references and placeholders do not count' - about_zh: '`.env`、YAML、TOML、INI、JSON 中变量名以 `SECRET`、`SECRET_KEY`、`PASSWORD`、`PASSWD`、`PWD`、`TOKEN`、`API_KEY`、`APIKEY`、`ACCESS_KEY`、`PRIVATE_KEY`、`CLIENT_SECRET` 结尾(不区分大小写)、值为至少 8 个字符的字面量的赋值;只换值,表达式、变量引用和占位写法不算' # 加密货币 - id: crypto-mnemonic kind: crypto on_by_default: true name: Recovery phrase - name_zh: 助记词 about: '12, 15, 18, 21 or 24 consecutive words from the BIP39 English or Simplified Chinese word list that pass the checksum; numbering allowed, replaced as a whole' - about_zh: '连续 12、15、18、21 或 24 个 BIP39 英文或简体中文词表中的词,并通过校验和;可带编号,整段' - id: crypto-wif-key kind: crypto on_by_default: true name: WIF private key - name_zh: WIF 私钥 about: 'A WIF private key of 51 or 52 characters that passes Base58Check with a valid version byte' - about_zh: '51 或 52 个字符的 WIF 私钥:Base58Check 校验通过,版本字节对得上' - id: crypto-extended-key kind: crypto on_by_default: true name: Extended private key - name_zh: 扩展私钥 about: 'BIP32 / SLIP-0132 extended private keys: `xprv`, `tprv`, `yprv`, `Yprv`, `zprv`, `Zprv`, `uprv`, `Uprv`, `vprv` or `Vprv`; valid Base58Check, private marker and secp256k1 scalar' - about_zh: 'BIP32 / SLIP-0132 扩展私钥:`xprv`、`tprv`、`yprv`、`Yprv`、`zprv`、`Zprv`、`uprv`、`Uprv`、`vprv`、`Vprv`;Base58Check、私钥标记及 secp256k1 标量均有效' - id: uuid kind: device on_by_default: true name: UUID / compact identifier - name_zh: UUID/紧凑标识符 about: 'Hyphenated UUIDs and 32 hexadecimal characters, ignoring case and without version restrictions, including order and trace IDs; compact hashes of the same shape are also replaced' - about_zh: '带连字符的 UUID 和 32 位十六进制串,不区分大小写、不限制版本,包括订单号和追踪 ID;同形状的紧凑哈希也替换' - id: crypto-hex-key kind: crypto on_by_default: true name: Raw wallet key / 32-byte hash - name_zh: 裸钱包私钥/32 字节哈希 about: '64 hexadecimal characters with an optional `0x` prefix; covers EVM and TRON private keys as well as indistinguishable transaction hashes and digests' - about_zh: '64 位十六进制串,可带 `0x` 前缀;覆盖 EVM、TRON 裸私钥以及格式无法区分的交易哈希和摘要' - id: crypto-solana-key kind: crypto on_by_default: true name: Solana keypair - name_zh: Solana 密钥对 about: '64-byte Ed25519 seed and public key encoded as Base58 or a pasted JSON byte array; the public half must match the seed, excluding signatures of the same length' - about_zh: 'Base58 编码或作为文本粘贴的 JSON 字节数组,含 64 字节 Ed25519 种子与公钥;由种子派生的公钥须一致,排除同长度签名' - id: crypto-sui-key kind: crypto on_by_default: true name: Sui private key - name_zh: Sui 私钥 about: '`suiprivkey1` Bech32 encoding with a valid checksum, a supported signature scheme and 32 key bytes' - about_zh: '`suiprivkey1` Bech32 编码,校验和有效,含支持的签名方案和 32 字节密钥' - id: crypto-stellar-key kind: crypto on_by_default: true name: Stellar secret seed - name_zh: Stellar 私密种子 about: 'Stellar `S` StrKey seed with the correct version, 32-byte payload and CRC16-XModem checksum' - about_zh: 'Stellar `S` StrKey 种子,版本、32 字节载荷和 CRC16-XModem 校验均有效' - id: crypto-xrp-seed kind: crypto on_by_default: true name: XRP family seed - name_zh: XRP 账户种子 about: 'XRP-alphabet Base58Check family seeds, including secp256k1 and Ed25519 version encodings' - about_zh: 'XRP 字母表的 Base58Check 账户种子,包括 secp256k1 和 Ed25519 版本' - id: crypto-address kind: financial on_by_default: true name: Blockchain account / extended public key - name_zh: 区块链账户/扩展公钥 about: 'EVM hex addresses, checksummed Bitcoin/TRON/XRP/Stellar addresses, Bitcoin witness addresses and BIP32 / SLIP-0132 extended public keys; also 32-byte Base58 account shapes such as Solana, which lack a checksum' - about_zh: 'EVM 十六进制地址,经校验的 Bitcoin/TRON/XRP/Stellar 地址、Bitcoin 隔离见证地址和 BIP32/SLIP-0132 扩展公钥;也覆盖 Solana 等无校验和的 32 字节 Base58 账户格式' - id: crypto-secret-field kind: in-context on_by_default: true name: Wallet secret in a field - name_zh: 字段中的钱包机密 about: 'Literal private keys, seeds, mnemonic/recovery phrases, passphrases, recovery codes and MPC/backup shares in named fields, including `pk`, `privateKey`, `PRIVY_WALLET_PRIVATE_KEY` and Chinese labels; only the value is replaced, with no guessed key length' - about_zh: '按字段识别私钥、种子、助记词、恢复短语、口令、恢复码和 MPC/备份份额,包括 `pk`、`privateKey`、`PRIVY_WALLET_PRIVATE_KEY` 和中文标签;只换值,不猜测密钥长度' - id: exchange-credential kind: in-context on_by_default: true name: Trading API / signed authentication credential - name_zh: 交易 API/签名鉴权凭证 about: 'Literal API keys, secrets, passphrases, signing memos, OTPs and authentication signatures in SDK/config fields or trading headers; Binance, OKX, Bybit, Coinbase, Kraken, KuCoin, Bitget, Gate, MEXC, Gemini, Bitfinex, HTX, BitMart, Phemex, Bitstamp, Polymarket and predict.fun; only the value is replaced' - about_zh: 'SDK/配置字段或交易请求头中的 API key、secret、passphrase、签名 Memo、OTP 和鉴权签名;覆盖 Binance、OKX、Bybit、Coinbase、Kraken、KuCoin、Bitget、Gate、MEXC、Gemini、Bitfinex、HTX、BitMart、Phemex、Bitstamp、Polymarket 和 predict.fun;只换值' - id: crypto-keystore kind: in-context on_by_default: true name: Wallet keystore / ciphertext - name_zh: 钱包密钥库/密文 about: 'Literal `keystore` or `ciphertext` fields, including Ethereum V3 encrypted key material; pasted JSON objects are protected as text and only the value is replaced' - about_zh: '字面量 `keystore` 或 `ciphertext` 字段,包括 Ethereum V3 加密密钥材料;作为文本粘贴的 JSON 对象也保护,只换值' - id: crypto-rpc-key kind: in-context on_by_default: true name: Blockchain RPC URL credential - name_zh: 区块链 RPC 地址凭证 about: 'API credentials in Infura `/v3/`, Alchemy `/v2/`, QuickNode token paths and Helius `api-key` URLs; only the credential part is replaced' - about_zh: 'Infura `/v3/`、Alchemy `/v2/`、QuickNode 令牌路径及 Helius `api-key` URL 中的 API 凭据;只换凭据部分' # ---- 扩充的个人信息规则(判据在 src/redact/personal/) - id: cn-resident-id-15 kind: id-documents label: TW_ID_NUMBER name: 15-digit legacy resident ID number - name_zh: 15 位旧身份证号 about: 'A 15-digit legacy resident ID number with a valid region code and 6-digit birth date, followed by a 3-digit sequence' - about_zh: '15 位旧身份证号:地区码、6 位出生日期都对得上,其后 3 位顺序码' - id: passport-mrz kind: id-documents on_by_default: true label: TW_PASSPORT name: Passport machine-readable zone - name_zh: 护照机读区 about: 'Two lines of 44 characters starting with `P`, with all four check digits and the composite check digit correct; replaced as a whole' - about_zh: '两行各 44 个字符、以 `P` 开头,四处校验位与综合校验位都对得上;整段' - id: cn-passport kind: id-documents label: TW_PASSPORT name: Chinese passport number - name_zh: 中国护照号 about: 'Starts with `E`, or `E` and a letter, followed by 7 or 8 digits, with “护照” or “passport” in the 20 characters before it' - about_zh: '`E` 或 `E` 加一个字母开头、其后 7 至 8 位数字,且前 20 个字符内出现「护照」或「passport」' - id: hk-macau-taiwan-id kind: id-documents label: TW_ID_NUMBER name: Hong Kong, Macau or Taiwan ID number - name_zh: 港澳台身份证号 about: 'Hong Kong, Macau and Taiwan ID numbers: Hong Kong and Taiwan ones with a correct check character; Macau ones only when the document is named just before' - about_zh: '香港、澳门、台湾身份证号:香港、台湾的校验码对得上;澳门的须前文写明证件名称' - id: mainland-travel-permit kind: id-documents label: TW_ID_NUMBER name: Mainland travel permit number - name_zh: 港澳台往来内地通行证号 about: 'Mainland travel permits for Hong Kong and Macau residents (`H` or `M` and 8 digits) and for Taiwan residents (8 digits), with “通行证”, “回乡证” or “台胞证” in the 20 characters before it' - about_zh: '港澳居民来往内地通行证(`H` 或 `M` 加 8 位数字)与台湾居民来往大陆通行证(8 位数字),且前 20 个字符内出现「通行证」「回乡证」或「台胞证」' - id: us-ssn kind: foreign-ids label: TW_ID_NUMBER name: US Social Security number - name_zh: 美国社会安全号 about: 'A US Social Security number written as `ddd-dd-dddd`, excluding area, group and serial numbers never issued' - about_zh: '`ddd-dd-dddd` 写法的美国社会安全号,不会分配的区号、组号与序号除外' - id: uk-nino kind: foreign-ids label: TW_ID_NUMBER name: UK National Insurance number - name_zh: 英国国民保险号 about: 'A UK National Insurance number: 2 letters, 6 digits and one of A to D, excluding letter pairs never issued' - about_zh: '2 个字母、6 位数字与 A 至 D 之一组成的英国国民保险号,不会分配的字母组合除外' - id: sg-nric kind: foreign-ids label: TW_ID_NUMBER name: Singapore NRIC / FIN - name_zh: 新加坡 NRIC / FIN about: 'Starts with S, T, F or G, followed by 7 digits and a correct check letter' - about_zh: 'S、T、F、G 之一开头,7 位数字加校验字母,校验字母对得上' - id: kr-rrn kind: foreign-ids label: TW_ID_NUMBER name: Korean resident registration number - name_zh: 韩国居民登录号 about: 'A 6-digit birth date, `-` and 7 digits, with a valid date and an 8th digit from 1 to 8' - about_zh: '6 位出生日期、`-` 与 7 位数字,日期有效、第 8 位为 1 至 8' - id: jp-my-number kind: foreign-ids label: TW_ID_NUMBER name: Japanese My Number - name_zh: 日本个人番号 about: '12 digits with a correct check digit, with “マイナンバー”, “個人番号” or “My Number” in the 20 characters before it' - about_zh: '12 位数字,校验位对得上,且前 20 个字符内出现「マイナンバー」「個人番号」或「My Number」' - id: in-aadhaar kind: foreign-ids label: TW_ID_NUMBER name: Indian Aadhaar number - name_zh: 印度 Aadhaar 号码 about: '12 digits (optionally in groups of four), the first from 2 to 9, passing the Verhoeff check' - about_zh: '12 位数字(可四位一组),首位为 2 至 9,Verhoeff 校验通过' - id: br-cpf kind: foreign-ids label: TW_ID_NUMBER name: Brazilian CPF - name_zh: 巴西 CPF about: 'A Brazilian CPF written as `ddd.ddd.ddd-dd`, with both check digits correct' - about_zh: '`ddd.ddd.ddd-dd` 写法的巴西 CPF,两位校验码对得上' - id: iban kind: financial on_by_default: true label: TW_ACCOUNT_NUMBER name: 'IBAN' - name_zh: 国际银行账号(IBAN) about: 'A country code, two check digits and the account number length set for that country, passing MOD 97-10; written in one run or in groups of four' - about_zh: '国家代码、两位校验码与该国规定位数的账号,MOD 97-10 校验通过;连写或四位一组' - id: cn-landline kind: contact label: TW_PHONE name: Chinese mainland landline number - name_zh: 中国大陆固定电话 about: 'A 2- or 3-digit area code starting with `0` and a 7- or 8-digit number, with a valid area code and brackets or a hyphen (`010-12345678`, `(0755)1234567`)' - about_zh: '`0` 开头的 2 至 3 位区号加 7 至 8 位号码,区号有效,须带括号或连字符(`010-12345678`、`(0755)1234567`)' - id: intl-phone kind: contact label: TW_PHONE name: International phone number - name_zh: 国际电话号码 about: 'Starts with `+`, with a valid country code and the length set for that country; spaces and hyphens allowed' - about_zh: '`+` 开头,国家码有效、位数与该国规定一致;可带空格与连字符' - id: cn-address kind: location label: TW_ADDRESS name: Chinese mainland street address - name_zh: 中国大陆详细地址 about: 'A Chinese mainland street address: administrative area names, a street, road, lane or village, and a house number; addresses that stop at the district do not count' - about_zh: '行政区划名称、街道路巷村之一与门牌号(号、栋、单元、室)组成的中国大陆详细地址;只到区县的不算' - id: geo-coordinates kind: location label: TW_LOCATION name: Precise coordinates - name_zh: 精确坐标 about: 'A latitude and longitude pair within range, each with at least 5 decimal places' - about_zh: '成对出现、在取值范围内、小数不少于 5 位的纬度与经度' - id: cn-license-plate kind: vehicle label: TW_PLATE name: Chinese mainland license plate - name_zh: 中国大陆车牌号 about: 'A province abbreviation, a letter and 5 letters or digits (6 for new-energy vehicles), without I or O' - about_zh: '省份简称、字母与 5 位字母或数字(新能源车为 6 位),不含 I、O' - id: vin kind: vehicle label: TW_VIN name: Vehicle identification number (VIN) - name_zh: 车辆识别代号(VIN) about: '17 characters without I, O or Q, with a correct check character in position 9' - about_zh: '17 个字符、不含 I、O、Q,第 9 位校验码对得上' - id: imei kind: device label: TW_DEVICE_ID name: 'IMEI' - name_zh: 'IMEI' about: '15 digits passing the Luhn check, with “IMEI” in the 20 characters before it' - about_zh: '15 位数字,Luhn 校验通过,且前 20 个字符内出现「IMEI」' - id: mac-address kind: device label: TW_DEVICE_ID name: MAC address - name_zh: MAC 地址 about: '6 pairs of hex characters separated by `:` or `-`; all-zero, broadcast and multicast addresses excepted' - about_zh: '6 组两位十六进制字符,以 `:` 或 `-` 分隔;全零、广播与组播地址除外' - id: public-ip kind: device label: TW_IP name: Public IP address - name_zh: 公网 IP 地址 about: 'Public IPv4 and IPv6 addresses; private, loopback, link-local, carrier-grade NAT, documentation and multicast addresses excepted' - about_zh: '公网 IPv4、IPv6 地址;私有、回环、链路本地、运营商级 NAT、文档示例与组播地址除外' - id: labeled-name kind: labeled-personal label: TW_NAME name: Name by field name - name_zh: 带字段名的姓名 about: 'The value of a field named `姓名`, `真实姓名`, `联系人`, `收件人`, `收货人`, `real_name`, `full_name`, `legal_name`, `first_name`, `last_name`, `given_name`, `family_name` or `name`, written as `name: value`, `"name": "value"` or under a table header; only the value is replaced' - about_zh: '字段名为 `姓名`、`真实姓名`、`联系人`、`收件人`、`收货人`、`real_name`、`full_name`、`legal_name`、`first_name`、`last_name`、`given_name`、`family_name`、`name` 的值,包括 `字段名: 值`、`"字段名": "值"` 与表格表头的写法;只换值' - id: labeled-address kind: labeled-personal label: TW_ADDRESS name: Address by field name - name_zh: 带字段名的住址 about: 'The value of a field named `住址`, `家庭住址`, `收货地址`, `联系地址`, `home_address`, `shipping_address`, `residential_address` or `address`, written as `name: value`, `"name": "value"` or under a table header; only the value is replaced' - about_zh: '字段名为 `住址`、`家庭住址`、`收货地址`、`联系地址`、`home_address`、`shipping_address`、`residential_address`、`address` 的值,包括 `字段名: 值`、`"字段名": "值"` 与表格表头的写法;只换值' - id: labeled-birth-date kind: labeled-personal label: TW_BIRTH_DATE name: Birth date by field name - name_zh: 带字段名的出生日期 about: 'The value of a field named `出生日期`, `生日`, `birthday`, `birth_date`, `date_of_birth` or `dob`, written as `name: value`, `"name": "value"` or under a table header; only the value is replaced' - about_zh: '字段名为 `出生日期`、`生日`、`birthday`、`birth_date`、`date_of_birth`、`dob` 的值,包括 `字段名: 值`、`"字段名": "值"` 与表格表头的写法;只换值' - id: labeled-account kind: labeled-personal label: TW_ACCOUNT_NUMBER name: Bank account by field name - name_zh: 带字段名的银行账号 about: 'The value of a field named `银行账号`, `开户账号`, `银行卡号`, `account_number`, `bank_account` or `bank_account_number`, written as `name: value`, `"name": "value"` or under a table header; only the value is replaced' - about_zh: '字段名为 `银行账号`、`开户账号`、`银行卡号`、`account_number`、`bank_account`、`bank_account_number` 的值,包括 `字段名: 值`、`"字段名": "值"` 与表格表头的写法;只换值' - id: labeled-health kind: labeled-personal label: TW_HEALTH name: Health information by field name - name_zh: 带字段名的健康信息 about: 'The value of a field named `病历号`, `住院号`, `诊断`, `病史`, `medical_record_number` or `diagnosis`, written as `name: value`, `"name": "value"` or under a table header; only the value is replaced' - about_zh: '字段名为 `病历号`、`住院号`、`诊断`、`病史`、`medical_record_number`、`diagnosis` 的值,包括 `字段名: 值`、`"字段名": "值"` 与表格表头的写法;只换值' diff --git a/crates/tw-guard/data/rules.yaml b/crates/tw-guard/data/rules.yaml index 067122c8..e1e72ecd 100644 --- a/crates/tw-guard/data/rules.yaml +++ b/crates/tw-guard/data/rules.yaml @@ -11,71 +11,53 @@ # - 工具调用审查只用「危险命令」那一组,用户可以逐条停用、再加自己的 # (config.yaml 的 `security.inspect_tools`)。 # -# **中英文都要覆盖。**只写英文规则等于对中文的注入完全不设防,而写 +# **匹配规则覆盖多种语言。**只写英文规则等于对中文的注入完全不设防,而写 # 中文提示词的人只多不少。 # -# 每条规则要有 `name` / `name_zh`(界面上的名字,英文、中文)和 `why` / `why_zh` -# (为什么值得看一眼)。**名字和说明只在这里写一份**:两个产品的界面都显示规则视图带过去 -# 的文字,不再各存一张名称表。 +# 每条规则要有 `name`(界面上的名字,英文)和 `why` +# (为什么值得看一眼,英文)。客户端用规则 ID 查译文。 # 工具调用审查的规则表怎么分组(界面上按这个顺序)。用户自己加的规则在「自定义」组, # 那个组的名字和另两项防护共用,在 redact.yaml 里。 kinds: - slug: command name: Built-in - name_zh: 内置 # 一、提示注入。命中只说明「这段文字在试图改变模型的行为」,不等于 # 恶意 —— 所以只报告,让人看一眼。 injection: - id: ignore-previous name: Ignore previous instructions - name_zh: 要求忽略先前的指令 pattern: '(?i)ignore\s+(all\s+)?(previous|above|prior)[^\n]{0,20}instructions' why: A prompt injection typically starts this way - why_zh: 典型的提示注入开头 - id: disregard name: Disregard the system prompt - name_zh: 要求无视系统提示 pattern: '(?i)disregard\s+(the\s+)?(system|above|previous)' why: A prompt injection typically starts this way, with a verb like disregard - why_zh: 典型的提示注入开头,使用 disregard 一类的动词 - id: you-are-now name: Reset the model's identity - name_zh: 重新设定模型身份 pattern: '(?i)you\s+are\s+now\s+(a|an)\s' why: An attempt to reset who the model is - why_zh: 试图重新设定模型的身份 - id: ignore-previous-zh name: Ignore previous instructions (Chinese) - name_zh: 要求忽略先前的指令(中文) pattern: '忽略(以上|之前|上面|前面)(的)?(所有)?(指令|要求|规则)' why: A Chinese prompt injection asking the model to ignore earlier instructions - why_zh: 中文提示注入,要求忽略先前的指令 - id: new-instructions-zh name: New instructions (Chinese) - name_zh: 声明新的指令(中文) pattern: '新的?指令[::]' why: A Chinese prompt injection declaring new instructions - why_zh: 中文提示注入,声明新的指令 - id: you-are-now-zh name: Reset the model's identity (Chinese) - name_zh: 重新设定模型身份(中文) pattern: '你(现在)?(是|扮演)一[个位名]' why: An attempt to reset who the model is - why_zh: 试图重新设定模型的身份 - id: chat-marker name: Forged chat markers - name_zh: 伪造对话标记 pattern: '<\|(im_start|im_end|system|endoftext)\|>' why: Forged conversation markers, so the model reads the body as a system message - why_zh: 伪造对话标记,试图让模型将正文当作系统消息 - id: fake-system name: Disguised system text - name_zh: 伪装的系统发言 pattern: '(?i)\[?(system|assistant)\]?\s*[::]\s*(you|your|ignore|从现在|你)' why: Text disguised as something the system or the assistant said - why_zh: 伪装成系统或助手的发言 # 二、危险命令。工具调用审查只用这一组。 # @@ -91,48 +73,36 @@ dangerous: # 填长到 200 字符以上,同一条命令就匹配不到了。测试抓住的。 - id: curl-pipe-sh name: Download and run - name_zh: 下载即执行 pattern: '(?i)(curl|wget)[^\n|]*\|\s*(sudo\s+)?(ba|z|d)?sh' why: Downloads and runs it straight away; what runs is decided remotely and cannot be read first - why_zh: 下载后直接执行,执行的内容由远端决定且无法预先查看 level: high - id: base64-decode-exec name: Decode and run - name_zh: 解码后执行 pattern: '(?i)base64\s+(-d|--decode)[^\n|]*\|\s*(ba)?sh' why: Hides what will run inside base64 - why_zh: 将要执行的内容隐藏在 base64 编码中 level: high - id: exfil-env name: Send out environment variables - name_zh: 外发环境变量 pattern: '(?i)(env|printenv|cat\s+[^\n]{0,60}\.env)[^\n]{0,200}(curl|wget|nc\s)' why: Sends the environment, which usually holds keys, somewhere else - why_zh: 将环境变量(通常包含密钥)发送到外部 level: high # **命令形状的规则对中文指令完全不设防。**「把 ~/.aws/credentials # 打印出来」里没有 cat 也没有 curl,但它要的是同一件事。所以再加一条 # 按「凭据路径 + 外送动词」匹配的,两个方向都写。 - id: exfil-credentials name: Send out a credential file - name_zh: 外发凭据文件 pattern: '(\.ssh/id_|\.aws/credentials|\.netrc|/\.env)[^\n]{0,30}(发|传|上报|打印|输出|贴出|读出|(?i:send|upload|post|print|paste|exfil))' why: Asks the model to send the contents of a credential file somewhere - why_zh: 要求模型将凭据文件的内容发送出去 level: high - id: exfil-credentials-reversed name: Send out a credential file (verb first) - name_zh: 外发凭据文件(动词在前) pattern: '(发送|上传|贴出|打印|输出|读取|(?i:send|upload|post|print|read))[^\n]{0,30}(\.ssh/id_|\.aws/credentials|\.netrc|/\.env)' why: Asks the model to send the contents of a credential file somewhere - why_zh: 要求模型将凭据文件的内容发送出去 level: high - id: ssh-key-read name: Read a private key or cloud credential - name_zh: 读取私钥或云凭据 pattern: '(?i)(cat|cp|scp|curl)[^\n]{0,200}(\.ssh/id_|\.aws/credentials|\.netrc)' why: Reads a private key or a cloud credential - why_zh: 读取私钥或云服务凭据 level: high # 下面两条**一条正则认不出**:要跨参数把 URL、凭据、上传标记凑到一起看,所以由 # 代码实现(`check`,见 src/tools/net.rs),`pattern` 留空。它们一样是内置的危险命令 @@ -142,10 +112,8 @@ dangerous: # key 加一个陌生 host,就是把凭据送出去 —— 一步就能拿走凭据,高危、拦截档下切断。 - id: secret-to-unknown-host name: Send a credential to an unknown host - name_zh: 凭据发往陌生主机 pattern: '' why: Sends a credential to a host that is neither local nor the credential's own provider - why_zh: 将凭据发往既非本机、也不是该凭据服务商的主机 level: high check: credential-to-network # ThinkWatch 自己的数据目录:里面是明文的全部上游密钥和这几项防护的设置。读它一步就 @@ -153,10 +121,8 @@ dangerous: # 回答「配置在哪」),只看路径和命令参数,所以由代码实现,见 src/tools/own_data.rs。 - id: thinkwatch-data name: Read or change ThinkWatch's own data - name_zh: 读写 ThinkWatch 自己的数据 pattern: '' why: Reads or changes ThinkWatch's data directory, which holds every upstream key in plain text and the settings of these protections - why_zh: 读写 ThinkWatch 的数据目录,其中以明文保存全部上游密钥和这几项防护的设置 level: high check: thinkwatch-data # **写入启动项**:只要写进去了,下次开终端就执行 —— 而且是在你完全 @@ -164,42 +130,32 @@ dangerous: # 一步就能拿到执行权。 - id: write-startup-item name: Write a startup item - name_zh: 写入启动项 pattern: '(>>?|tee|cp|mv|ln\s+-s)[^\n]{0,200}(\.zshrc|\.bashrc|\.bash_profile|\.profile|\.zprofile|LaunchAgents|LaunchDaemons|\.git/hooks|crontab)' why: Writes somewhere that runs at login or whenever a terminal opens - why_zh: 写入开机或打开终端时自动执行的位置 level: high # `crontab -l` 是看一眼,`crontab <文件>` / `crontab -r` / `crontab -` # 才是动手。分不开的话,这条规则会在每次「帮我看看定时任务」时误报。 - id: crontab-install name: Install a scheduled job - name_zh: 安装定时任务 pattern: 'crontab\s+(-r\b|-\s*($|["'';&|)])|[^\s-][^\n]{0,40})' why: Installs a scheduled job, or deletes every existing one - why_zh: 安装定时任务,或删除全部现有定时任务 level: high - id: rm-rf-root name: Delete home or root - name_zh: 删除主目录或根目录 pattern: 'rm\s+(-[a-zA-Z]*\s+)*-[a-zA-Z]*[rf][a-zA-Z]*\s+(/|~|\$HOME)(\s|$|["'';&|)])' why: Deletes the whole home directory or the root - why_zh: 删除整个主目录或根目录 level: medium - id: chmod-777 name: World-writable permissions - name_zh: 开放全部写权限 pattern: 'chmod\s+(-R\s+)?777' why: Makes a file writable by everyone - why_zh: 将文件权限设为所有人可写 level: medium # 把本地文件的内容上传到外部主机(`curl -T 文件`、`--data @文件`、`-F 字段=@文件` 等)。 # 开发里很常见(上传构建产物、贴日志),**出厂只记录**,先让人看见误报再说。代码实现, # 见 src/tools/net.rs。 - id: upload-file-to-host name: Upload a local file to an external host - name_zh: 上传本地文件到外部主机 pattern: '' why: Uploads the contents of a local file to an external host - why_zh: 将本地文件的内容上传到外部主机 level: medium check: file-to-network diff --git a/crates/tw-guard/src/content.rs b/crates/tw-guard/src/content.rs index 43563d03..6aa0d65b 100644 --- a/crates/tw-guard/src/content.rs +++ b/crates/tw-guard/src/content.rs @@ -148,8 +148,6 @@ pub struct Builtin { pub id: String, /// 英文名 pub name: String, - /// 中文名 - pub name_zh: String, /// 码位规则写的是码位(`U+E0000–U+E007F`) pub pattern: String, #[serde(rename = "match")] @@ -165,9 +163,6 @@ pub struct Builtin { /// 为什么值得看一眼(英文)。规则名说不清的才写 #[serde(default)] pub why: String, - /// 同上,中文。`why` 有的它都有 - #[serde(default)] - pub why_zh: String, } /// `data/content.yaml` 整个文件:分组的名字和规则。 @@ -1070,16 +1065,11 @@ mod tests { .all(|b| b.name.is_ascii() && b.why.is_ascii()), "name、why 是英文" ); - // 中文名每条都有,说明有英文的就有中文的 - for b in builtins() { - assert!(!b.name_zh.trim().is_empty(), "{} 没有中文名", b.id); - assert_eq!(b.why.is_empty(), b.why_zh.is_empty(), "{}", b.id); - } // 每条的分组都有名字 for b in builtins() { let k = kinds().iter().find(|k| k.slug == b.group); assert!( - k.is_some_and(|k| !k.name.is_empty() && !k.name_zh.is_empty()), + k.is_some_and(|k| !k.name.is_empty()), "{} 的分组 {} 没有名字", b.id, b.group diff --git a/crates/tw-guard/src/redact/catalog_tests.rs b/crates/tw-guard/src/redact/catalog_tests.rs index ffd434c1..def8cf0c 100644 --- a/crates/tw-guard/src/redact/catalog_tests.rs +++ b/crates/tw-guard/src/redact/catalog_tests.rs @@ -5,22 +5,12 @@ use std::collections::HashSet; use super::{BUILTINS, DETECTORS, KIND_NAMES, Kind, Matcher, builtin}; -/// 界面文案的规矩:书面陈述,不出现「你」「我」 -fn written(zh: &str) -> bool { - !zh.contains('你') && !zh.contains('我') -} - #[test] -fn every_rule_has_a_name_and_says_what_it_matches_in_both_languages() { +fn every_rule_has_an_english_name_and_description() { let mut ids = HashSet::new(); for b in BUILTINS { assert!(ids.insert(b.id), "{} 出现了两次", b.id); - for (field, text) in [ - ("name", b.name), - ("name_zh", b.name_zh), - ("about", b.about), - ("about_zh", b.about_zh), - ] { + for (field, text) in [("name", b.name), ("about", b.about)] { assert!(!text.trim().is_empty(), "{} 没有 {field}", b.id); // 反引号成对:界面按它切出代码样式的那几段 assert_eq!( @@ -30,7 +20,6 @@ fn every_rule_has_a_name_and_says_what_it_matches_in_both_languages() { b.id ); } - assert!(written(b.name_zh) && written(b.about_zh), "{}", b.id); } } @@ -86,12 +75,10 @@ fn every_kind_has_names_in_the_order_the_ui_groups_by() { let listed: Vec = KIND_NAMES.iter().map(|k| k.kind).collect(); assert_eq!(listed, all, "数据文件里分组的顺序就是 Kind 的顺序"); for k in KIND_NAMES { - assert!(!k.name.trim().is_empty() && !k.name_zh.trim().is_empty()); - assert!(written(k.name_zh)); + assert!(!k.name.trim().is_empty()); assert_eq!(k.kind.name(), k.name); - assert_eq!(k.kind.name_zh(), k.name_zh); } - assert_eq!(Kind::AiServices.name_zh(), "AI 服务"); + assert_eq!(Kind::AiServices.name(), "AI services"); } /// 判据在代码里的规则:数据里每一条都在 [`DETECTORS`] 里(编译期就查过,这里再对一遍值), @@ -120,17 +107,13 @@ fn every_detector_has_a_rule_in_the_data() { fn a_description_lists_what_its_detector_lists() { let quoted = |s: &str| format!("`{s}`"); for b in BUILTINS { - let (en, zh) = (b.about, b.about_zh); + let en = b.about; match b.matcher { Matcher::Assignment { suffixes: items } | Matcher::Labeled { names: items } | Matcher::DomainSuffix { suffixes: items } => { for i in items { - assert!( - en.contains("ed(i)) && zh.contains("ed(i)), - "{} 的说明里没有 {i}", - b.id - ); + assert!(en.contains("ed(i)), "{} 的说明里没有 {i}", b.id); } } Matcher::BankCard { networks } => { @@ -140,11 +123,11 @@ fn a_description_lists_what_its_detector_lists() { } Matcher::OpenaiLegacy { min_len } => { let n = min_len.to_string(); - assert!(en.contains(&n) && zh.contains(&n), "{}", b.id); + assert!(en.contains(&n), "{}", b.id); } Matcher::CnResidentId { born_since } => { let n = born_since.to_string(); - assert!(en.contains(&n) && zh.contains(&n), "{}", b.id); + assert!(en.contains(&n), "{}", b.id); } _ => {} } @@ -164,7 +147,6 @@ fn rules_that_replace_only_the_value_say_so() { ); if placed { assert!(b.about.contains("only the"), "{}:{}", b.id, b.about); - assert!(b.about_zh.contains("只换"), "{}:{}", b.id, b.about_zh); } } } @@ -178,10 +160,6 @@ fn a_prefix_rule_is_described_from_its_prefixes() { "Starts with `hvs.`, followed by at least 90 characters; \ starts with `hvb.`, followed by at least 138 characters" ); - assert_eq!( - vault.about_zh, - "`hvs.` 开头,其后至少 90 个字符;`hvb.` 开头,其后至少 138 个字符" - ); let shopify = builtin("shopify-token").unwrap(); assert_eq!( shopify.about, @@ -192,7 +170,6 @@ fn a_prefix_rule_is_described_from_its_prefixes() { key.about, "Starts with `sk-ant-`, followed by at least 20 characters" ); - assert_eq!(key.about_zh, "`sk-ant-` 开头,其后至少 20 个字符"); } /// 服务商域名只给拿到就能用的凭据写:别的规则不参与「凭据发往陌生主机」,写了也没人用 diff --git a/crates/tw-guard/src/redact/rules.rs b/crates/tw-guard/src/redact/rules.rs index 6294cc4a..8305c4d1 100644 --- a/crates/tw-guard/src/redact/rules.rs +++ b/crates/tw-guard/src/redact/rules.rs @@ -121,11 +121,6 @@ impl Kind { self.names().name } - /// 分组的中文名 - pub fn name_zh(&self) -> &'static str { - self.names().name_zh - } - fn names(&self) -> &'static KindName { KIND_NAMES .iter() @@ -252,13 +247,9 @@ pub struct Builtin { pub kind: Kind, /// 英文名 pub name: &'static str, - /// 中文名 - pub name_zh: &'static str, /// 认什么,给人看的一句话(英文)。按位置认的写明只换哪一段;反引号括起来的一段是代码。 /// 前缀类的规则由 build.rs 按前缀和长度生成 pub about: &'static str, - /// 同上,中文 - pub about_zh: &'static str, /// 出厂时开不开。**关着的是内网地址和邮箱、手机号**:它们在代码和文档里到处 /// 都是,按「长得像」认误报得多,而危害远小于一把 key,想脱的人自己开 pub on_by_default: bool, @@ -343,7 +334,6 @@ pub const BUILTINS: &[Builtin] = include!(concat!(env!("OUT_DIR"), "/redact_buil pub struct KindName { pub kind: Kind, pub name: &'static str, - pub name_zh: &'static str, } /// 每个分组的名字,按界面上的顺序(和 [`Kind`] 的定义顺序一致,测试钉着)。 diff --git a/crates/tw-guard/src/tools/rules.rs b/crates/tw-guard/src/tools/rules.rs index 4dbd3232..967148f7 100644 --- a/crates/tw-guard/src/tools/rules.rs +++ b/crates/tw-guard/src/tools/rules.rs @@ -38,15 +38,9 @@ pub struct RuleSpec { pub id: String, /// 界面上的名字(英文) pub name: String, - /// 界面上的名字(中文)。内置规则都有,测试钉着 - #[serde(default, skip_serializing_if = "String::is_empty")] - pub name_zh: String, pub pattern: String, /// **为什么它值得看一眼。**没有这一句,一条命中就只是个规则 id pub why: String, - /// 同上,中文 - #[serde(default, skip_serializing_if = "String::is_empty")] - pub why_zh: String, /// `high` 或 `medium`。不写按 medium 算。 /// /// **只有 high 会在拦截档下切断。**分级的判据是「它能不能一步拿到 @@ -346,10 +340,8 @@ fn custom_rule(c: Custom<'_>) -> Result { let spec = RuleSpec { id: c.name.to_string(), name: c.name.to_string(), - name_zh: String::new(), pattern: c.pattern.to_string(), why: String::new(), - why_zh: String::new(), level: Some(if c.cut { "high" } else { "medium" }.to_string()), check: None, }; @@ -394,33 +386,18 @@ mod tests { ); } - /// 名字和说明只在这里写一份(界面不再存名称表),中英文都要有 #[test] - fn every_builtin_rule_is_named_and_explained_in_both_languages() { + fn every_builtin_rule_has_an_english_name_and_explanation() { let f = builtin(); for x in f.injection.iter().chain(&f.dangerous) { - for (field, text) in [ - ("name", &x.name), - ("name_zh", &x.name_zh), - ("why", &x.why), - ("why_zh", &x.why_zh), - ] { + for (field, text) in [("name", &x.name), ("why", &x.why)] { assert!(!text.trim().is_empty(), "{} 没写 {field}", x.id); } assert!(x.name.is_ascii() && x.why.is_ascii(), "{}", x.id); - assert!( - !x.name_zh.contains(['你', '我']) && !x.why_zh.contains(['你', '我']), - "{}:界面文案是书面陈述", - x.id - ); } let slugs: Vec<&str> = f.kinds.iter().map(|k| k.slug.as_str()).collect(); assert_eq!(slugs, ["command"]); - assert!( - f.kinds - .iter() - .all(|k| !k.name.is_empty() && !k.name_zh.is_empty()) - ); + assert!(f.kinds.iter().all(|k| !k.name.is_empty())); } #[test] diff --git a/crates/tw-guard/src/view.rs b/crates/tw-guard/src/view.rs index 6bc0908c..a4d35894 100644 --- a/crates/tw-guard/src/view.rs +++ b/crates/tw-guard/src/view.rs @@ -168,7 +168,7 @@ pub enum Matcher { /// 代码里实现的内置检查,没有可展示的模式:工具调用审查的「凭据发往陌生主机」 /// (`credential-to-network`)、「上传本地文件到外部主机」(`file-to-network`); /// 出站脱敏里按校验位、词表、位置认的那些(`check` 就是规则 id)。 - /// `check` 是稳定的检查名。出站脱敏的说明在规则的 `about` / `about_zh` 里 + /// `check` 是稳定的检查名。出站脱敏的说明在规则的 `about` 里 Builtin { check: String }, } @@ -211,27 +211,15 @@ pub struct RuleView { pub custom: bool, /// 英文名;自定义规则就是用户起的名字 pub name: String, - /// 中文名。内置规则都有;自定义规则没有(名字原样显示,不分语言)。 - /// - /// **规则的名字和说明只在 core 写一份**(`data/redact.yaml`、`rules.yaml`、 - /// `content.yaml`),界面按自己的语言取 `name` 或 `name_zh`,不再自己存名称表 - #[serde(default, skip_serializing_if = "String::is_empty")] - pub name_zh: String, /// 为什么值得看一眼(英文):工具调用审查和内容过滤的内置规则,规则名说不清的才有。 /// 自定义规则没有 #[serde(default, skip_serializing_if = "String::is_empty")] pub why: String, - /// 同上,中文。`why` 有的它都有 - #[serde(default, skip_serializing_if = "String::is_empty")] - pub why_zh: String, /// 认什么,给人看的一句话(英文):出站脱敏的内置规则都有,别的没有。按位置认的写明只换 /// 哪一段(「only the value is replaced」)。**反引号括起来的一段是代码**(前缀、写法), /// 界面按代码样式显示、不显示反引号本身;反引号总是成对的 #[serde(default, skip_serializing_if = "String::is_empty")] pub about: String, - /// 同上,中文 - #[serde(default, skip_serializing_if = "String::is_empty")] - pub about_zh: String, /// 分组,[`GuardDetail::kinds`] 里的一个 `slug`。出站脱敏:`saved` / `ai-services` … /// `internal` / `custom`;工具调用审查:`command` / `custom`;内容过滤:`invisible` / /// `injection` / `persona` / `chinese` / `custom` @@ -270,7 +258,7 @@ pub struct GuardDetail { /// 按界面上的顺序:内置的在前,自定义的在后 pub rules: Vec, /// 规则表的分组,按界面上的顺序;`rules` 里每一条的 `kind` 都在这里,最后一组是 - /// `custom`(没有自定义规则时也在)。界面的分组名取这里的 `name` / `name_zh` + /// `custom`(没有自定义规则时也在)。界面的分组名取这里的英文名 `name`,客户端按 `slug` 查译文 #[serde(default)] pub kinds: Vec, } @@ -283,8 +271,6 @@ pub struct KindView { pub slug: String, /// 英文名 pub name: String, - /// 中文名 - pub name_zh: String, } impl KindView { @@ -292,7 +278,6 @@ impl KindView { KindView { slug: k.slug().to_string(), name: k.name().to_string(), - name_zh: k.name_zh().to_string(), } } @@ -401,11 +386,8 @@ pub fn redact(p: &RedactPolicy) -> GuardDetail { id: b.id.to_string(), custom: false, name: b.name.to_string(), - name_zh: b.name_zh.to_string(), why: String::new(), - why_zh: String::new(), about: b.about.to_string(), - about_zh: b.about_zh.to_string(), kind: b.kind.slug().to_string(), matcher: matcher(b), enabled: p.builtin_on(b), @@ -421,11 +403,8 @@ pub fn redact(p: &RedactPolicy) -> GuardDetail { id: c.name.clone(), custom: true, name: c.name.clone(), - name_zh: String::new(), why: String::new(), - why_zh: String::new(), about: String::new(), - about_zh: String::new(), kind: "custom".into(), matcher: match c.matching { ContentMatch::Regex => Matcher::Regex { @@ -467,11 +446,8 @@ pub fn inspect_tools(p: &ToolPolicy) -> GuardDetail { id: r.id.clone(), custom: false, name: r.name.clone(), - name_zh: r.name_zh.clone(), why: r.why.clone(), - why_zh: r.why_zh.clone(), about: String::new(), - about_zh: String::new(), kind: "command".into(), // 代码实现的规则没有可展示的正则,给界面一个专门的 matcher matcher: match &r.check { @@ -496,11 +472,8 @@ pub fn inspect_tools(p: &ToolPolicy) -> GuardDetail { id: c.name.clone(), custom: true, name: c.name.clone(), - name_zh: String::new(), why: String::new(), - why_zh: String::new(), about: String::new(), - about_zh: String::new(), kind: "custom".into(), matcher: Matcher::Regex { pattern: c.pattern.clone(), @@ -574,11 +547,8 @@ pub fn content(p: &ContentPolicy) -> GuardDetail { id: b.id.clone(), custom: false, name: b.name.clone(), - name_zh: b.name_zh.clone(), why: b.why.clone(), - why_zh: b.why_zh.clone(), about: String::new(), - about_zh: String::new(), kind: b.group.clone(), matcher: content_matcher(b.matching, &b.pattern, false, false), enabled: p.builtin_on(b), @@ -595,11 +565,8 @@ pub fn content(p: &ContentPolicy) -> GuardDetail { id: c.name.clone(), custom: true, name: c.name.clone(), - name_zh: String::new(), why: String::new(), - why_zh: String::new(), about: String::new(), - about_zh: String::new(), kind: "custom".into(), matcher: content_matcher(c.matching.engine(), &c.pattern, true, c.case_sensitive), enabled: !c.disabled, @@ -1156,10 +1123,17 @@ mod tests { rebuilt.check().unwrap(); } - /// 名字、说明、分组名都由 core 给:每条内置规则中英文都有,每条规则的分组都列在 `kinds` - /// 里,最后一组是「自定义」 + /// Core supplies English labels, and every rule's group is listed in `kinds`. #[test] - fn every_view_names_its_rules_and_groups_in_both_languages() { + fn every_view_names_its_rules_and_groups_in_english() { + // Quoted literals are examples of what a detector matches, and can be in any language. + let english = |text: &str| { + !text + .split(['`', '“', '”']) + .step_by(2) + .flat_map(str::chars) + .any(|c| matches!(c, '\u{3400}'..='\u{9fff}')) + }; let p = Security { redact: RedactPolicy { custom: vec![CustomRedactRule { @@ -1184,11 +1158,8 @@ mod tests { let slugs: Vec<&str> = g.kinds.iter().map(|k| k.slug.as_str()).collect(); assert_eq!(slugs.last(), Some(&"custom"), "{guard}"); for k in &g.kinds { - assert!( - !k.name.is_empty() && !k.name_zh.is_empty(), - "{guard} {}", - k.slug - ); + assert!(!k.name.is_empty(), "{guard} {}", k.slug); + assert!(english(&k.name), "{guard} {}", k.slug); } for r in &g.rules { assert!( @@ -1197,18 +1168,18 @@ mod tests { r.id ); if r.custom { - assert!(r.name_zh.is_empty() && r.why_zh.is_empty() && r.about.is_empty()); + assert_eq!(r.name, "项目号"); + assert!(r.why.is_empty() && r.about.is_empty()); continue; } + assert!(!r.name.is_empty(), "{guard} {}", r.id); assert!( - !r.name.is_empty() && !r.name_zh.is_empty(), + english(&r.name) && english(&r.why) && english(&r.about), "{guard} {}", r.id ); - assert_eq!(r.why.is_empty(), r.why_zh.is_empty(), "{guard} {}", r.id); let redact = guard == "redact"; assert_eq!(!r.about.is_empty(), redact, "{guard} {}", r.id); - assert_eq!(!r.about_zh.is_empty(), redact, "{guard} {}", r.id); } // 分组按界面顺序:规则先出现的组排在前面 let mut last = 0; @@ -1218,10 +1189,10 @@ mod tests { last = at; } } - assert_eq!(d.redact.kinds[0].name_zh, "保存的密钥"); + assert_eq!(d.redact.kinds[0].name, "Saved credentials"); assert_eq!(d.content.kinds[0].slug, "invisible"); let anthropic = d.redact.rules.iter().find(|r| r.id == "anthropic-api-key"); - assert_eq!(anthropic.unwrap().name_zh, "Anthropic API 密钥"); + assert_eq!(anthropic.unwrap().name, "Anthropic API key"); } #[test] @@ -1237,26 +1208,27 @@ mod tests { assert_eq!(key["action"], "placeholder"); assert_eq!(key["default_action"], "placeholder"); assert!(key.get("why").is_none() && key.get("scope").is_none()); - // 名字、说明中英文各一个字段;分组名在 `kinds` + // 显示文案用英文,客户端按 id 和 slug 查译文 assert_eq!(key["id"], "thinkwatch-saved-secret"); - assert_eq!(key["name_zh"], "ThinkWatch 中保存的密钥"); - for field in ["name", "about", "about_zh"] { + assert_eq!(key["name"], "Credentials saved in ThinkWatch"); + for field in ["name", "about"] { assert!( key[field].as_str().is_some_and(|s| !s.is_empty()), "{field}" ); } - assert!(key.get("why_zh").is_none(), "没有的不写"); + assert!(key.get("name_zh").is_none() && key.get("about_zh").is_none()); assert_eq!( v["redact"]["kinds"][1], - serde_json::json!({"slug": "ai-services", "name": "AI services", "name_zh": "AI 服务"}) + serde_json::json!({"slug": "ai-services", "name": "AI services"}) ); let curl = &v["inspect_tools"]["rules"][0]; - assert_eq!(curl["name_zh"], "下载即执行"); - assert!(curl["why_zh"].as_str().is_some_and(|s| !s.is_empty())); + assert_eq!(curl["name"], "Download and run"); + assert!(curl["why"].as_str().is_some_and(|s| !s.is_empty())); + assert!(curl.get("why_zh").is_none()); assert!(curl.get("about").is_none()); assert_eq!(v["inspect_tools"]["kinds"][0]["slug"], "command"); - assert_eq!(tags["name_zh"], "Unicode 标签字符"); + assert_eq!(tags["name"], "Unicode tag characters"); assert_eq!(tags["scope"], serde_json::json!(["request"])); assert_eq!(tags["replacement"], "***"); assert_eq!( diff --git a/docs/config.zh-CN.md b/docs/config.zh-CN.md index f31677ec..ade03b5e 100644 --- a/docs/config.zh-CN.md +++ b/docs/config.zh-CN.md @@ -716,137 +716,137 @@ pricing: | id | 名称 | 出厂 | |---|---|---| -| `anthropic-api-key` | Anthropic API 密钥 | 开 | -| `openai-project-key` | OpenAI 项目密钥 | 开 | -| `openai-api-key` | OpenAI API 密钥 | 开 | -| `github-personal-token` | GitHub 个人令牌 | 开 | -| `github-oauth-token` | GitHub OAuth 令牌 | 开 | -| `github-server-token` | GitHub 服务器令牌 | 开 | -| `github-user-token` | GitHub 用户令牌 | 开 | -| `github-fine-grained-token` | GitHub 细粒度令牌 | 开 | -| `slack-bot-token` | Slack 机器人令牌 | 开 | -| `slack-user-token` | Slack 用户令牌 | 开 | -| `slack-app-token` | Slack 应用令牌 | 开 | -| `aws-access-key-id` | AWS 访问密钥 ID | 开 | -| `aws-temporary-key-id` | AWS 临时访问密钥 ID | 开 | -| `google-api-key` | Google API 密钥 | 开 | -| `google-oauth-token` | Google OAuth 令牌 | 开 | -| `gitlab-token` | GitLab 令牌 | 开 | -| `stripe-live-key` | Stripe 生产密钥 | 开 | -| `stripe-restricted-key` | Stripe 受限密钥 | 开 | -| `npm-token` | npm 令牌 | 开 | -| `digitalocean-token` | DigitalOcean 令牌 | 开 | -| `sendgrid-key` | SendGrid 密钥 | 开 | -| `private-key` | 私钥 | 开 | +| `anthropic-api-key` | Anthropic API key | 开 | +| `openai-project-key` | OpenAI project key | 开 | +| `openai-api-key` | OpenAI API key | 开 | +| `github-personal-token` | GitHub personal access token | 开 | +| `github-oauth-token` | GitHub OAuth token | 开 | +| `github-server-token` | GitHub server token | 开 | +| `github-user-token` | GitHub user token | 开 | +| `github-fine-grained-token` | GitHub fine-grained token | 开 | +| `slack-bot-token` | Slack bot token | 开 | +| `slack-user-token` | Slack user token | 开 | +| `slack-app-token` | Slack app token | 开 | +| `aws-access-key-id` | AWS access key ID | 开 | +| `aws-temporary-key-id` | AWS temporary access key ID | 开 | +| `google-api-key` | Google API key | 开 | +| `google-oauth-token` | Google OAuth token | 开 | +| `gitlab-token` | GitLab token | 开 | +| `stripe-live-key` | Stripe live key | 开 | +| `stripe-restricted-key` | Stripe restricted key | 开 | +| `npm-token` | npm token | 开 | +| `digitalocean-token` | DigitalOcean token | 开 | +| `sendgrid-key` | SendGrid key | 开 | +| `private-key` | Private key | 开 | | `jwt` | JWT | 开 | -| `conn-string-password` | 连接串口令 | 开 | -| `cn-resident-id` | 居民身份证号 | 开 | -| `bank-card` | 银行卡号 | 开 | -| `email` | 邮箱地址 | 关 | -| `cn-mobile-phone` | 中国大陆手机号 | 关 | -| `internal-ip` | 内网地址 | 关 | -| `internal-domain` | 内部域名 | 关 | -| `thinkwatch-saved-secret` | ThinkWatch 中保存的密钥 | 开 | -| `openai-service-key` | OpenAI 服务账号与管理密钥 | 开 | -| `openrouter-key` | OpenRouter API 密钥 | 开 | -| `xai-key` | xAI API 密钥 | 开 | -| `groq-key` | Groq API 密钥 | 开 | -| `huggingface-token` | Hugging Face 令牌 | 开 | -| `replicate-token` | Replicate 令牌 | 开 | -| `perplexity-key` | Perplexity API 密钥 | 开 | -| `bedrock-api-key` | Amazon Bedrock API 密钥 | 开 | -| `fireworks-key` | Fireworks AI API 密钥 | 开 | -| `cerebras-key` | Cerebras API 密钥 | 开 | -| `langsmith-key` | LangSmith API 密钥 | 开 | -| `langfuse-secret-key` | Langfuse 私密密钥 | 开 | -| `pinecone-key` | Pinecone API 密钥 | 开 | -| `tavily-key` | Tavily API 密钥 | 开 | -| `minimax-key` | MiniMax API 密钥 | 开 | -| `zhipu-api-key` | 智谱 API 密钥 | 开 | -| `qianfan-api-key` | 百度千帆 API 密钥 | 开 | -| `sk-compat-key` | OpenAI 兼容格式 API 密钥 | 开 | -| `github-refresh-token` | GitHub 刷新令牌 | 开 | -| `gitlab-other-token` | GitLab 其他令牌 | 开 | -| `pypi-token` | PyPI 令牌 | 开 | -| `rubygems-token` | RubyGems 令牌 | 开 | -| `clojars-token` | Clojars 令牌 | 开 | -| `docker-hub-token` | Docker Hub 令牌 | 开 | -| `artifactory-key` | JFrog Artifactory 密钥 | 开 | -| `databricks-token` | Databricks 令牌 | 开 | -| `sentry-token` | Sentry 令牌 | 开 | -| `grafana-token` | Grafana 令牌 | 开 | -| `postman-key` | Postman API 密钥 | 开 | -| `aws-other-key-id` | AWS 其他访问密钥 ID | 开 | -| `alibaba-access-key-id` | 阿里云 AccessKey ID | 开 | -| `tencent-secret-id` | 腾讯云 SecretId | 开 | -| `volcengine-access-key-id` | 火山引擎 AccessKey ID | 开 | -| `azure-ad-client-secret` | Azure AD 客户端密码 | 开 | -| `digitalocean-other-token` | DigitalOcean 其他令牌 | 开 | -| `cloudflare-origin-ca-key` | Cloudflare Origin CA 密钥 | 开 | -| `vault-token` | HashiCorp Vault 令牌 | 开 | -| `terraform-token` | Terraform Cloud 令牌 | 开 | -| `doppler-token` | Doppler 令牌 | 开 | -| `pulumi-token` | Pulumi 令牌 | 开 | -| `heroku-key` | Heroku API 密钥 | 开 | -| `flyio-token` | Fly.io 令牌 | 开 | -| `supabase-key` | Supabase 密钥 | 开 | -| `age-secret-key` | age 私钥 | 开 | -| `onepassword-token` | 1Password 服务账号令牌 | 开 | -| `stripe-webhook-secret` | Stripe Webhook 签名密钥 | 开 | -| `shopify-token` | Shopify 令牌 | 开 | -| `twilio-api-key` | Twilio API 密钥 | 开 | -| `brevo-key` | Brevo API 密钥 | 开 | -| `slack-other-token` | Slack 其他令牌 | 开 | -| `linear-key` | Linear API 密钥 | 开 | -| `notion-token` | Notion 令牌 | 开 | -| `atlassian-token` | Atlassian API 令牌 | 开 | -| `auth-header-credential` | 请求头中的凭据 | 开 | -| `command-line-password` | 命令行中的口令 | 开 | -| `url-token` | URL 中的令牌 | 开 | -| `bot-webhook` | 机器人 Webhook | 开 | -| `telegram-bot-token` | Telegram 机器人令牌 | 开 | -| `config-assignment` | 配置文件中的密钥赋值 | 开 | -| `crypto-mnemonic` | 助记词 | 开 | -| `crypto-wif-key` | WIF 私钥 | 开 | -| `crypto-extended-key` | 扩展私钥 | 开 | -| `uuid` | UUID/紧凑标识符 | 开 | -| `crypto-hex-key` | 裸钱包私钥/32 字节哈希 | 开 | -| `crypto-solana-key` | Solana 密钥对 | 开 | -| `crypto-sui-key` | Sui 私钥 | 开 | -| `crypto-stellar-key` | Stellar 私密种子 | 开 | -| `crypto-xrp-seed` | XRP 账户种子 | 开 | -| `crypto-address` | 区块链账户/扩展公钥 | 开 | -| `crypto-secret-field` | 字段中的钱包机密 | 开 | -| `exchange-credential` | 交易 API/签名鉴权凭证 | 开 | -| `crypto-keystore` | 钱包密钥库/密文 | 开 | -| `crypto-rpc-key` | 区块链 RPC 地址凭证 | 开 | -| `cn-resident-id-15` | 15 位旧身份证号 | 关 | -| `passport-mrz` | 护照机读区 | 开 | -| `cn-passport` | 中国护照号 | 关 | -| `hk-macau-taiwan-id` | 港澳台身份证号 | 关 | -| `mainland-travel-permit` | 港澳台往来内地通行证号 | 关 | -| `us-ssn` | 美国社会安全号 | 关 | -| `uk-nino` | 英国国民保险号 | 关 | -| `sg-nric` | 新加坡 NRIC / FIN | 关 | -| `kr-rrn` | 韩国居民登录号 | 关 | -| `jp-my-number` | 日本个人番号 | 关 | -| `in-aadhaar` | 印度 Aadhaar 号码 | 关 | -| `br-cpf` | 巴西 CPF | 关 | -| `iban` | 国际银行账号(IBAN) | 开 | -| `cn-landline` | 中国大陆固定电话 | 关 | -| `intl-phone` | 国际电话号码 | 关 | -| `cn-address` | 中国大陆详细地址 | 关 | -| `geo-coordinates` | 精确坐标 | 关 | -| `cn-license-plate` | 中国大陆车牌号 | 关 | -| `vin` | 车辆识别代号(VIN) | 关 | +| `conn-string-password` | Connection string password | 开 | +| `cn-resident-id` | Chinese resident ID number | 开 | +| `bank-card` | Bank card number | 开 | +| `email` | Email address | 关 | +| `cn-mobile-phone` | Chinese mainland mobile number | 关 | +| `internal-ip` | Internal IP address | 关 | +| `internal-domain` | Internal domain | 关 | +| `thinkwatch-saved-secret` | Credentials saved in ThinkWatch | 开 | +| `openai-service-key` | OpenAI service account or admin key | 开 | +| `openrouter-key` | OpenRouter API key | 开 | +| `xai-key` | xAI API key | 开 | +| `groq-key` | Groq API key | 开 | +| `huggingface-token` | Hugging Face token | 开 | +| `replicate-token` | Replicate token | 开 | +| `perplexity-key` | Perplexity API key | 开 | +| `bedrock-api-key` | Amazon Bedrock API key | 开 | +| `fireworks-key` | Fireworks AI API key | 开 | +| `cerebras-key` | Cerebras API key | 开 | +| `langsmith-key` | LangSmith API key | 开 | +| `langfuse-secret-key` | Langfuse secret key | 开 | +| `pinecone-key` | Pinecone API key | 开 | +| `tavily-key` | Tavily API key | 开 | +| `minimax-key` | MiniMax API key | 开 | +| `zhipu-api-key` | Zhipu API key | 开 | +| `qianfan-api-key` | Baidu Qianfan API key | 开 | +| `sk-compat-key` | OpenAI-compatible API key | 开 | +| `github-refresh-token` | GitHub refresh token | 开 | +| `gitlab-other-token` | Other GitLab token | 开 | +| `pypi-token` | PyPI token | 开 | +| `rubygems-token` | RubyGems token | 开 | +| `clojars-token` | Clojars token | 开 | +| `docker-hub-token` | Docker Hub token | 开 | +| `artifactory-key` | JFrog Artifactory key | 开 | +| `databricks-token` | Databricks token | 开 | +| `sentry-token` | Sentry token | 开 | +| `grafana-token` | Grafana token | 开 | +| `postman-key` | Postman API key | 开 | +| `aws-other-key-id` | Other AWS access key ID | 开 | +| `alibaba-access-key-id` | Alibaba Cloud AccessKey ID | 开 | +| `tencent-secret-id` | Tencent Cloud SecretId | 开 | +| `volcengine-access-key-id` | Volcengine AccessKey ID | 开 | +| `azure-ad-client-secret` | Azure AD client secret | 开 | +| `digitalocean-other-token` | Other DigitalOcean token | 开 | +| `cloudflare-origin-ca-key` | Cloudflare Origin CA key | 开 | +| `vault-token` | HashiCorp Vault token | 开 | +| `terraform-token` | Terraform Cloud token | 开 | +| `doppler-token` | Doppler token | 开 | +| `pulumi-token` | Pulumi token | 开 | +| `heroku-key` | Heroku API key | 开 | +| `flyio-token` | Fly.io token | 开 | +| `supabase-key` | Supabase key | 开 | +| `age-secret-key` | age secret key | 开 | +| `onepassword-token` | 1Password service account token | 开 | +| `stripe-webhook-secret` | Stripe webhook signing secret | 开 | +| `shopify-token` | Shopify token | 开 | +| `twilio-api-key` | Twilio API key | 开 | +| `brevo-key` | Brevo API key | 开 | +| `slack-other-token` | Other Slack token | 开 | +| `linear-key` | Linear API key | 开 | +| `notion-token` | Notion token | 开 | +| `atlassian-token` | Atlassian API token | 开 | +| `auth-header-credential` | Credential in a request header | 开 | +| `command-line-password` | Password on a command line | 开 | +| `url-token` | Token in a URL | 开 | +| `bot-webhook` | Bot webhook | 开 | +| `telegram-bot-token` | Telegram bot token | 开 | +| `config-assignment` | Secret assigned in a config file | 开 | +| `crypto-mnemonic` | Recovery phrase | 开 | +| `crypto-wif-key` | WIF private key | 开 | +| `crypto-extended-key` | Extended private key | 开 | +| `uuid` | UUID / compact identifier | 开 | +| `crypto-hex-key` | Raw wallet key / 32-byte hash | 开 | +| `crypto-solana-key` | Solana keypair | 开 | +| `crypto-sui-key` | Sui private key | 开 | +| `crypto-stellar-key` | Stellar secret seed | 开 | +| `crypto-xrp-seed` | XRP family seed | 开 | +| `crypto-address` | Blockchain account / extended public key | 开 | +| `crypto-secret-field` | Wallet secret in a field | 开 | +| `exchange-credential` | Trading API / signed authentication credential | 开 | +| `crypto-keystore` | Wallet keystore / ciphertext | 开 | +| `crypto-rpc-key` | Blockchain RPC URL credential | 开 | +| `cn-resident-id-15` | 15-digit legacy resident ID number | 关 | +| `passport-mrz` | Passport machine-readable zone | 开 | +| `cn-passport` | Chinese passport number | 关 | +| `hk-macau-taiwan-id` | Hong Kong, Macau or Taiwan ID number | 关 | +| `mainland-travel-permit` | Mainland travel permit number | 关 | +| `us-ssn` | US Social Security number | 关 | +| `uk-nino` | UK National Insurance number | 关 | +| `sg-nric` | Singapore NRIC / FIN | 关 | +| `kr-rrn` | Korean resident registration number | 关 | +| `jp-my-number` | Japanese My Number | 关 | +| `in-aadhaar` | Indian Aadhaar number | 关 | +| `br-cpf` | Brazilian CPF | 关 | +| `iban` | IBAN | 开 | +| `cn-landline` | Chinese mainland landline number | 关 | +| `intl-phone` | International phone number | 关 | +| `cn-address` | Chinese mainland street address | 关 | +| `geo-coordinates` | Precise coordinates | 关 | +| `cn-license-plate` | Chinese mainland license plate | 关 | +| `vin` | Vehicle identification number (VIN) | 关 | | `imei` | IMEI | 关 | -| `mac-address` | MAC 地址 | 关 | -| `public-ip` | 公网 IP 地址 | 关 | -| `labeled-name` | 带字段名的姓名 | 关 | -| `labeled-address` | 带字段名的住址 | 关 | -| `labeled-birth-date` | 带字段名的出生日期 | 关 | -| `labeled-account` | 带字段名的银行账号 | 关 | -| `labeled-health` | 带字段名的健康信息 | 关 | +| `mac-address` | MAC address | 关 | +| `public-ip` | Public IP address | 关 | +| `labeled-name` | Name by field name | 关 | +| `labeled-address` | Address by field name | 关 | +| `labeled-birth-date` | Birth date by field name | 关 | +| `labeled-account` | Bank account by field name | 关 | +| `labeled-health` | Health information by field name | 关 | `uuid` 出厂开启:匹配带连字符的 8-4-4-4-12 或连续 32 位十六进制 UUID,不区分大小写、不限制版本。订单号、追踪 ID 和同形的紧凑哈希也替换;更长的标识符不截取,JSON 数字仍保留为数字。监控模式只记录命中。单凭 UUID 的形状不会触发工具的「凭据发往陌生主机」检查;用户保存的凭据仍按具体值检查。 @@ -908,19 +908,19 @@ pricing: | id | 名称 | `enforce` 下出厂处置 | |---|---|---| -| `curl-pipe-sh` | 下载即执行 | `cut` | -| `base64-decode-exec` | 解码后执行 | `cut` | -| `exfil-env` | 外发环境变量 | `cut` | -| `exfil-credentials` | 外发凭据文件 | `cut` | -| `exfil-credentials-reversed` | 外发凭据文件(动词在前) | `cut` | -| `ssh-key-read` | 读取私钥或云凭据 | `cut` | -| `secret-to-unknown-host` | 凭据发往陌生主机 | `cut` | -| `thinkwatch-data` | 读写 ThinkWatch 自己的数据 | `cut` | -| `write-startup-item` | 写入启动项 | `cut` | -| `crontab-install` | 安装定时任务 | `cut` | -| `rm-rf-root` | 删除主目录或根目录 | `record` | -| `chmod-777` | 开放全部写权限 | `record` | -| `upload-file-to-host` | 上传本地文件到外部主机 | `record` | +| `curl-pipe-sh` | Download and run | `cut` | +| `base64-decode-exec` | Decode and run | `cut` | +| `exfil-env` | Send out environment variables | `cut` | +| `exfil-credentials` | Send out a credential file | `cut` | +| `exfil-credentials-reversed` | Send out a credential file (verb first) | `cut` | +| `ssh-key-read` | Read a private key or cloud credential | `cut` | +| `secret-to-unknown-host` | Send a credential to an unknown host | `cut` | +| `thinkwatch-data` | Read or change ThinkWatch's own data | `cut` | +| `write-startup-item` | Write a startup item | `cut` | +| `crontab-install` | Install a scheduled job | `cut` | +| `rm-rf-root` | Delete home or root | `record` | +| `chmod-777` | World-writable permissions | `record` | +| `upload-file-to-host` | Upload a local file to an external host | `record` | #### `security.content` @@ -959,32 +959,32 @@ pricing: | id | 名称 | 分组 | 出厂 | `enforce` 下出厂处置 | |---|---|---|---|---| -| `unicode-tags` | Unicode 标签字符 | invisible | 开 | `strip` | -| `bidi-controls` | 双向控制符 | invisible | 开 | `strip` | -| `zero-width` | 零宽字符 | invisible | 关 | `strip` | -| `private-use` | 私用区字符 | invisible | 关 | `strip` | -| `ignore-previous-instructions` | 要求忽略先前的指令 | injection | 开 | `block` | -| `ignore-all-previous` | 要求忽略之前的全部内容 | injection | 开 | `block` | -| `disregard-your-instructions` | 要求无视指令 | injection | 开 | `block` | -| `jailbreak` | 越狱 | injection | 关 | `block` | +| `unicode-tags` | Unicode tag characters | invisible | 开 | `strip` | +| `bidi-controls` | Bidirectional controls | invisible | 开 | `strip` | +| `zero-width` | Zero-width characters | invisible | 关 | `strip` | +| `private-use` | Private-use characters | invisible | 关 | `strip` | +| `ignore-previous-instructions` | Ignore previous instructions | injection | 开 | `block` | +| `ignore-all-previous` | Ignore all previous | injection | 开 | `block` | +| `disregard-your-instructions` | Disregard your instructions | injection | 开 | `block` | +| `jailbreak` | Jailbreak | injection | 关 | `block` | | `dan` | DAN | injection | 关 | `block` | -| `developer-mode` | 开发者模式 | injection | 关 | `block` | -| `you-are-now` | 重新设定身份 | persona | 关 | `block` | -| `new-persona` | 新的人设 | persona | 关 | `record` | -| `act-as` | 要求扮演角色 | persona | 关 | `record` | -| `pretend-to-be` | 要求假装身份 | persona | 关 | `record` | -| `system-prompt` | 索取系统提示词 | persona | 关 | `record` | -| `reveal-your-instructions` | 要求透露指令 | persona | 关 | `record` | -| `what-are-your-rules` | 询问规则 | persona | 关 | `record` | -| `base64-wall` | 长串 Base64 | persona | 关 | `record` | -| `zh-ignore-previous` | 要求忽略先前的指令(中文) | chinese | 关 | `block` | -| `zh-forget-your` | 要求忘记指令(中文) | chinese | 关 | `block` | -| `zh-do-not-follow` | 要求不要遵循(中文) | chinese | 关 | `block` | -| `zh-you-are-now` | 重新设定身份(中文) | chinese | 关 | `block` | -| `zh-role-play` | 要求扮演角色(中文) | chinese | 关 | `record` | -| `zh-reveal-your` | 要求透露指令(中文) | chinese | 关 | `record` | -| `zh-system-prompt` | 系统提示词(中文) | chinese | 关 | `record` | -| `zh-jailbreak` | 越狱(中文) | chinese | 关 | `block` | +| `developer-mode` | Developer mode | injection | 关 | `block` | +| `you-are-now` | Persona manipulation | persona | 关 | `block` | +| `new-persona` | New persona | persona | 关 | `record` | +| `act-as` | Act as | persona | 关 | `record` | +| `pretend-to-be` | Pretend to be | persona | 关 | `record` | +| `system-prompt` | System prompt extraction | persona | 关 | `record` | +| `reveal-your-instructions` | Reveal instructions | persona | 关 | `record` | +| `what-are-your-rules` | What are your rules | persona | 关 | `record` | +| `base64-wall` | Base64 smuggling | persona | 关 | `record` | +| `zh-ignore-previous` | Ignore previous instructions (Chinese) | chinese | 关 | `block` | +| `zh-forget-your` | Forget your instructions (Chinese) | chinese | 关 | `block` | +| `zh-do-not-follow` | Do not follow (Chinese) | chinese | 关 | `block` | +| `zh-you-are-now` | You are now (Chinese) | chinese | 关 | `block` | +| `zh-role-play` | Role-play (Chinese) | chinese | 关 | `record` | +| `zh-reveal-your` | Reveal your instructions (Chinese) | chinese | 关 | `record` | +| `zh-system-prompt` | System prompt (Chinese) | chinese | 关 | `record` | +| `zh-jailbreak` | Jailbreak (Chinese) | chinese | 关 | `block` | `invisible`(隐藏字符)一组匹配人看不见、模型读得到的字符。Unicode 标签字符(U+E0000–U+E007F)和双向控制符(U+202A–U+202E、U+2066–U+2069)出厂开启;零宽字符(U+200B–U+200D、U+2060、U+FEFF)和私用区字符(U+E000–U+F8FF、U+F0000–U+FFFFD、U+100000–U+10FFFD)出厂关闭,表情符号、波斯文和图标字体也会用到它们。四条在 `enforce` 下都删除命中的字符。 diff --git a/release-notes/0.100.0.md b/release-notes/0.100.0.md new file mode 100644 index 00000000..49c04532 --- /dev/null +++ b/release-notes/0.100.0.md @@ -0,0 +1,3 @@ +- Core's built-in security rule names and descriptions are now English. Clients can provide their own translations using stable guard names, rule IDs, and group slugs. +- Core continues to return stable error codes and arguments so clients can localize the display. Custom rules keep the text supplied by their authors. +- Consumers of the Core security API should look up translations locally or use the English fields. The legacy `name_zh`, `why_zh`, and `about_zh` fields have been removed. From bc4dc69a974c4da2c34c0465e5911a5bdf3fde71 Mon Sep 17 00:00:00 2001 From: fylorn <249551762+fylorn@users.noreply.github.com> Date: Tue, 24 Nov 2026 00:43:05 +0800 Subject: [PATCH 2/2] fix(deps): update url and cookie to patched versions Address the RustSec advisories reported by the release audit. --- Cargo.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f4cc5521..306ba120 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -791,9 +791,9 @@ checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b" [[package]] name = "cookie" -version = "0.18.2" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a373e3602691c3cdea496d2f0ee5935151e6168fe87739483c463db1b2f2f87" +checksum = "d55f2d6c30eeec7d5c6f98bd4395d4abb1895629eab97ee6522d340623615f8a" dependencies = [ "percent-encoding", "time", @@ -1099,7 +1099,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d045de693cb712d0b22c6a64be5b953f67b3ce00ab5ad3dd5d8b441886ab8e1a" dependencies = [ "quote", - "syn 3.0.5", + "syn 2.0.119", ] [[package]] @@ -1382,9 +1382,9 @@ checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" [[package]] name = "form_urlencoded" -version = "1.2.2" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +checksum = "afa489199eaffb1211795df1c6236ce1ad0d41a6fa45250add73e3b02420f06e" dependencies = [ "percent-encoding", ] @@ -4654,9 +4654,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.8" +version = "2.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +checksum = "f00cd2407bb42c0ef17be88d4cf020f5cceffd121665bac9b8b9493a369b3b1a" dependencies = [ "form_urlencoded", "idna",