Skip to content

Commit d90345e

Browse files
fylornclaude
andauthored
Expanded redaction rules (core v0.85.0), saved upstream keys, rule text from core (#129)
* Redaction: provider keys as saved secrets; names and groups for the expanded rule catalog Prepares the console and gateway for thinkwatch-core's expanded redaction catalog (about 115 built-in rules in 20 kinds). - Saved secrets: the API keys in the providers' credential headers (the auth scheme stripped) and Bedrock secret access keys are collected whenever the providers load (startup, provider CRUD, the cross-instance reload), under the provider's name with its base URL host. The guards and the at-rest redactor are recompiled when they change. They reach the rule set in one place, `guard_policy::saved::with_saved`, which hands them to core once `RuleSet::with_saved` is released. - Audit: a saved-secret event names the provider (`sources`), never any part of the value, masked or not; aggregation per rule is unchanged. - Legacy PII list conversion: switch on or off only the personal rules the old list could express; new personal rules ship as they are. - Console: group headers for the new kinds in core's order, saved keys first; zh/en names for every new rule id; descriptions for the new matcher shapes (prefixes, saved, assignment, labeled) and for rules checked in code; the security log shows whose key a saved-secret hit was; the rule search also matches prefixes and field names. Temporary: the core crates are pinned to the branch `feat/redact-rules-expand` until the expanded catalog is released; re-pin to the release tag before merging. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Redaction: match saved provider keys; rule text from the core catalog - Saved secrets: the providers' keys are compiled once with core's `Saved` and handed to every rule set (`RuleSet::with_saved_set`, in `guard_policy::saved::with_saved`), to dangerous commands (`Rules::with_saved`, so a provider key sent to its own host is not flagged) and to the console's trial (`trial::run_with`). - Audit: a saved-secret event's `sources` now come from core's `Finding::source` instead of searching the request again. - Console: rule names, reasons and descriptions (`name_zh`, `why_zh`, `about` / `about_zh`) and group names (`kinds`) come from the rule view in both languages. The console's own tables of rule names, group names, check texts and card networks are removed, and so are the per-matcher descriptions the server's `about` replaces. Security log rows and trial hits look the name up by rule id. Temporary: the core crates are pinned to the branch `feat/redact-catalog` until the expanded catalog is released; re-pin to the release tag before merging. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Pin thinkwatch-core v0.85.0; changelog for the expanded redaction rules The core crates move from the temporary branch pin to the v0.85.0 tag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent df35254 commit d90345e

35 files changed

Lines changed: 1305 additions & 714 deletions

‎CHANGELOG.md‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,74 @@ target.
1111

1212
## [Unreleased]
1313

14+
Secrets and privacy recognises far more: the built-in redaction catalog
15+
grows from 30 rules to 120 in 20 groups, and the API keys saved
16+
for the providers are recognised by value, whatever their format. The
17+
console shows the rules' names and descriptions as thinkwatch-core
18+
writes them, in both languages. The thinkwatch-core crates move from
19+
v0.83.1 to v0.85.0.
20+
21+
No new setting, column or route; the redaction policy's shape is
22+
unchanged.
23+
24+
### Read before upgrading
25+
26+
- **New credential rules ship on.** Under the On state of Secrets and
27+
privacy (`security.redact` mode `enforce`), values they find start
28+
being replaced with placeholders: among them credentials in request
29+
headers, command lines, URLs and bot webhooks, and secrets assigned in
30+
`.env`-style configuration (`DB_PASSWORD=…`). Under Monitor, the
31+
factory state, they are only recorded. A rule that gets in the way can
32+
be switched off on its own in the console.
33+
- **Some keys are reported under a rule of their own.** `sk-or-v1-`
34+
(OpenRouter), `sk-lf-` (Langfuse), `sk-svcacct-`, `sk-admin-` and
35+
`sk-api-` keys were reported as `openai-api-key`; they now have their
36+
own rule ids, and so do audit events and the
37+
`gateway_redaction_found_total` metric's `kind` label, which follows
38+
the new groups (`ai-services`, `dev-platforms`, `cloud`, …) instead of
39+
`api-keys` and `personal`.
40+
41+
### Added
42+
43+
- **Expanded redaction rules** (thinkwatch-core v0.85.0): about 50 more
44+
prefixed credentials (AI services, code hosting, cloud, payments and
45+
collaboration), credentials by position (request headers, command
46+
lines, URL parameters, bot webhooks, configuration assignments),
47+
cryptocurrency recovery phrases and private keys, and personal
48+
information: identity documents, foreign ID numbers, IBAN, phone
49+
numbers, addresses and coordinates, vehicles, device identifiers and
50+
values by field name. Of the new personal-information rules only the
51+
two that can be checked digit by digit ship on (passport
52+
machine-readable zone, IBAN), alongside the resident ID and bank card
53+
numbers as before.
54+
- **Saved upstream keys are recognised by value.** The API keys in each
55+
provider's credential headers (the `Bearer` scheme left out) and a
56+
Bedrock provider's secret access key are matched wherever they appear
57+
in a request, as written or JSON-escaped; values shorter than 12
58+
characters are not. The list follows the providers: it is rebuilt when
59+
they load, when one is created, changed or deleted, and on the other
60+
instances through the router reload. The same keys count as
61+
credentials for the dangerous-commands rule "credential sent to an
62+
unknown host", each allowed to its own provider's host, and the
63+
console's trial recognises them too.
64+
- **A saved key's audit event names its provider, never the value.** The
65+
`gateway.redaction_*` event of the rule `thinkwatch-saved-secret`
66+
carries `sources` (`[{"kind": "upstream-key", "name": <provider>}]`)
67+
and no masked values; the security log shows it as the provider's API
68+
key.
69+
70+
### Changed
71+
72+
- **Rule names and descriptions come from thinkwatch-core.** The security
73+
page shows each built-in rule's name, reason and description and each
74+
group's name as the rule view gives them, in English or Chinese; the
75+
console no longer keeps its own name tables. Security-log rows and
76+
trial hits name the rule by looking its id up in the rule view. The
77+
rule search also matches prefixes, field names and descriptions.
78+
- **The conversion of the old PII pattern list** switches on or off only
79+
the four personal-information rules that list could express; the new
80+
personal-information rules keep their factory setting.
81+
1482
## [3.10.0] — 2026-10-25
1583

1684
Upstreams that fail for the moment before any of the answer reached the

‎Cargo.lock‎

Lines changed: 11 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ opt-level = 3
7070
# never re-exported through a local shim. And the reverse: something only
7171
# this side uses (the at-rest crypto, IMDSv2 credentials, the gateway error)
7272
# lives here, not in core.
73-
tw-bedrock = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.83.1" }
74-
tw-breaker = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.83.1" }
75-
tw-dialect = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.83.1" }
76-
tw-guard = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.83.1" }
73+
tw-bedrock = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.85.0" }
74+
tw-breaker = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.85.0" }
75+
tw-dialect = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.85.0" }
76+
tw-guard = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.85.0" }
7777

7878
# Web framework
7979
axum = { version = "0.8", features = ["macros", "ws"] }

‎crates/common/src/guard_policy/legacy.rs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,11 +508,13 @@ pub fn redact(patterns: Option<&Value>) -> RedactPolicy {
508508
}
509509
}
510510
}
511-
// Personal data is redacted only where the list asked for it. The
512-
// credential rules are not personal data and stay on.
511+
// The personal data the old list could express (the seeded patterns'
512+
// rules) is redacted only where the list asked for it. Credential
513+
// rules are not personal data and stay on; personal rules the old
514+
// list never knew run as they ship.
513515
for b in tw_guard::redact::rules::BUILTINS
514516
.iter()
515-
.filter(|b| b.kind == tw_guard::redact::rules::Kind::Personal)
517+
.filter(|b| b.kind.is_personal() && SEEDED_PII.iter().any(|(_, _, id)| *id == b.id))
516518
{
517519
match (covered.contains(b.id), b.on_by_default) {
518520
(true, false) => policy.enable.push(b.id.to_string()),

‎crates/common/src/guard_policy/mod.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use tw_guard::redact::rules::RuleSet;
3030
use crate::dynamic_config::DynamicConfig;
3131

3232
pub mod legacy;
33+
pub mod saved;
3334

3435
/// The settings key a guard's policy is stored under.
3536
pub fn key(guard: Guard) -> &'static str {

0 commit comments

Comments
 (0)