From 0d2963016ac5e939e3a6bf2fe46a04e077a37ad4 Mon Sep 17 00:00:00 2001 From: Danathar Date: Fri, 6 Nov 2026 07:36:26 -0500 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=90=9B=20fix(adminmcp):=20reads=20sto?= =?UTF-8?q?p=20masking=20values=20that=20cannot=20be=20a=20credential?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A read masked every value under a key containing token, secret, password, credential or authorization, booleans and *tokens counts excepted. settings_read therefore hid the name of the environment variable that supplies a secret (token_env, gitlabTokenEnv, webhookSecretEnv), a numeric rate (tokens_per_coin), the whole per-repo self-authorization hold policy, and showed [masked:token] for a secret that is not set. contributors_list hid token_expires_at and its sibling timestamps. readMaskExempt keeps, in read results only: null and empty values, a timestamp, a token count or rate with the unit after the word, an upper-case environment variable name under a key ending in env, and the self-authorization hold settings. Kept strings are still scrubbed by shape. maskExempt, which the pending-confirmation scrub shares, is unchanged, so what a write preview may store is as strict as before. Co-Authored-By: Claude Fable 5.1 Signed-off-by: Danathar --- ...ed-admin-mcp-read-scrub-false-positives.md | 1 + src/docs/admin-mcp.md | 21 +++ src/pkg/adminmcp/adminmcp.go | 148 +++++++++++++++++- src/pkg/adminmcp/scrub_read_test.go | 130 +++++++++++++++ 4 files changed, 298 insertions(+), 2 deletions(-) create mode 100644 changelog.d/fixed-admin-mcp-read-scrub-false-positives.md create mode 100644 src/pkg/adminmcp/scrub_read_test.go diff --git a/changelog.d/fixed-admin-mcp-read-scrub-false-positives.md b/changelog.d/fixed-admin-mcp-read-scrub-false-positives.md new file mode 100644 index 0000000000..c6c2c97da2 --- /dev/null +++ b/changelog.d/fixed-admin-mcp-read-scrub-false-positives.md @@ -0,0 +1 @@ +- Admin MCP reads no longer mask values that cannot hold a credential. A read masked everything under a key containing `token`, `secret`, `password`, `credential` or `authorization` (booleans and `*tokens` counts excepted), so `settings_read` returned `[masked:token]` for the name of the environment variable that supplies a secret (`token_env`, `gitlabTokenEnv`, `webhookSecretEnv`), which the tool promises to show; for a numeric rate (`tokens_per_coin`); for the whole per-repository self-authorization hold policy (`repoSelfAuthorizationHold`); and for a secret that is not set at all, which read the same as one that is. `contributors_list` hid `token_expires_at`, `token_issued_at` and `token_last_used_at`. These are now shown: an empty value or `null`, an empty list or object, a timestamp, a token count or rate, an upper-case environment variable name under a key ending in `env`, and the self-authorization hold settings. Everything else under those keys is masked as before, kept values are still scrubbed by shape, and the stricter rule that decides what a write preview may store is unchanged. diff --git a/src/docs/admin-mcp.md b/src/docs/admin-mcp.md index f823ac7bb4..572c77c223 100644 --- a/src/docs/admin-mcp.md +++ b/src/docs/admin-mcp.md @@ -259,6 +259,27 @@ configuration and its provenance), an agent's export bundle (the `agent` and presentational. A test fails when the dashboard serves a new `GET /api/config` route that is neither a section nor one of these exclusions. +### What a read masks + +Every read result is scrubbed in two ways. Strings are scrubbed by shape: +GitHub tokens, JWTs, bearer tokens, private keys and similar are replaced +wherever they appear. Values are also masked by key: a value under a key that +contains `token`, `secret`, `password`, `credential` or `authorization` is +replaced by `[masked:...]`, unless it cannot hold a credential: + +- `true` or `false`, `null`, or an empty string, list or object; +- a timestamp (`token_expires_at`); +- a token count or rate (`totalTokens`, `tokens_per_coin`); +- the name of an environment variable under a key ending in `env` + (`token_env`, `webhookSecretEnv`), when it is written in upper case; +- the self-authorization hold settings (`selfAuthorizationHold`, + `repoSelfAuthorizationHold`), which are a merge policy and not a header. + +So `[masked:token]` means a value is there and was withheld, and an empty +value means nothing is set. A list or object with content under such a key is +masked whole (for example `credentialWarnings` when there are warnings); read +it on the dashboard. + Meta tools: - `exclusion_catalogue` lists what the admin MCP will never do, and why. diff --git a/src/pkg/adminmcp/adminmcp.go b/src/pkg/adminmcp/adminmcp.go index 38cb05a6a1..43b7623b31 100644 --- a/src/pkg/adminmcp/adminmcp.go +++ b/src/pkg/adminmcp/adminmcp.go @@ -14,6 +14,7 @@ import ( "strconv" "strings" "time" + "unicode" "github.com/hivecommons/hive/crux/logscrub" ) @@ -827,7 +828,7 @@ func maskSensitive(b []byte) []byte { case map[string]any: out := map[string]any{} for k, val := range x { - if sensitiveKey(k) && !maskExempt(k, val) { + if sensitiveKey(k) && !readMaskExempt(k, val) { out[k] = "[masked:" + maskLabel(k) + "]" } else { out[k] = walk(val) @@ -857,7 +858,150 @@ func maskSensitive(b []byte) []byte { func sensitiveKey(k string) bool { k = strings.ToLower(k) - return strings.Contains(k, "token") || strings.Contains(k, "secret") || strings.Contains(k, "password") || strings.Contains(k, "credential") || strings.Contains(k, "authorization") + return strings.Contains(k, "token") || strings.Contains(k, "secret") || strings.Contains(k, "password") || strings.Contains(k, "credential") || authorizationKey(k) +} + +// authorizationKey reports whether a lower-cased key names an Authorization +// header or its value. The self-authorization hold (selfAuthorizationHold, +// repoSelfAuthorizationHold, self_authorization_hold) is a merge policy, the +// rule on whether a hive may approve its own pull requests, and not a header. +func authorizationKey(lower string) bool { + if !strings.Contains(lower, "authorization") { + return false + } + squashed := strings.ReplaceAll(strings.ReplaceAll(lower, "_", ""), "-", "") + return !strings.HasSuffix(squashed, "selfauthorizationhold") +} + +// readMaskExempt reports whether a value under a sensitive-looking key can be +// shown in a read result because it cannot hold a credential. It adds to +// maskExempt, which the pending-confirmation scrub shares and which stays as +// strict as it was: +// +// - nothing at all: null, "", {} and []. Masking those made a secret that +// is not set look set. +// - a timestamp (token_expires_at). +// - a token count or rate with its unit after the word (tokens_per_coin). +// - the name of an environment variable under a key ending in "env" +// (token_env, webhookSecretEnv). Settings name the variable that supplies +// a secret and never return the secret. +// +// A string kept this way is still scrubbed by shape like any other string. +func readMaskExempt(k string, v any) bool { + if maskExempt(k, v) { + return true + } + switch x := v.(type) { + case nil: + return true + case string: + return x == "" || isTimestamp(x) || (envNameKey(k) && envNameShaped(x)) + case []any: + return len(x) == 0 + case map[string]any: + return len(x) == 0 || tokenRateKey(k) + case float64: + return tokenRateKey(k) + default: + return false + } +} + +func isTimestamp(s string) bool { + _, err := time.Parse(time.RFC3339Nano, s) + return err == nil +} + +// keyWords splits a JSON key into lower-case words at "_", "-", "." and +// camelCase boundaries: "webhookSecretEnv" is webhook, secret, env. +func keyWords(k string) []string { + var words []string + var cur []rune + flush := func() { + if len(cur) > 0 { + words = append(words, strings.ToLower(string(cur))) + cur = cur[:0] + } + } + var prev rune + for _, r := range k { + switch { + case r == '_' || r == '-' || r == '.' || r == ' ': + flush() + case unicode.IsUpper(r) && (unicode.IsLower(prev) || unicode.IsDigit(prev)): + flush() + cur = append(cur, r) + default: + cur = append(cur, r) + } + prev = r + } + flush() + return words +} + +// tokenRateKey reports whether k has "tokens" as a whole word with more after +// it (tokens_per_coin, tokensIn): a count or rate like the keys tokenCountKey +// accepts, with the unit after the word. A credential qualifier before the +// word (access_tokens_revoked) or another sensitive word in the key rules it +// out. +func tokenRateKey(k string) bool { + lower := strings.ToLower(k) + for _, word := range []string{"secret", "password", "credential", "authorization"} { + if strings.Contains(lower, word) { + return false + } + } + words := keyWords(k) + for i, word := range words { + if word != "tokens" { + continue + } + stem := strings.Join(words[:i], "") + for _, q := range credentialTokenQualifiers { + if strings.HasSuffix(stem, q) { + return false + } + } + return true + } + return false +} + +// envNameKey reports whether k names an environment variable: its last word +// is "env", or its last two are "env var" or "env name". +func envNameKey(k string) bool { + words := keyWords(k) + n := len(words) + switch { + case n >= 2 && words[n-1] == "env": + return true + case n >= 3 && words[n-2] == "env" && (words[n-1] == "var" || words[n-1] == "name"): + return true + default: + return false + } +} + +// envNameShaped reports whether s is written as environment variable names +// are: upper-case letters, digits and underscores. A value pasted into such a +// field by mistake rarely has that shape, and stays masked when it does not. +func envNameShaped(s string) bool { + if s == "" || len(s) > 128 { + return false + } + for i, r := range s { + switch { + case r >= 'A' && r <= 'Z', r == '_': + case r >= '0' && r <= '9': + if i == 0 { + return false + } + default: + return false + } + } + return true } // credentialTokenQualifiers mark a plural "*tokens" key as a collection of diff --git a/src/pkg/adminmcp/scrub_read_test.go b/src/pkg/adminmcp/scrub_read_test.go new file mode 100644 index 0000000000..101cf3a945 --- /dev/null +++ b/src/pkg/adminmcp/scrub_read_test.go @@ -0,0 +1,130 @@ +package adminmcp + +import ( + "reflect" + "testing" +) + +// A read masked every value under a key containing token, secret, password, +// credential or authorization. settings_read then hid the name of the +// environment variable that supplies a secret (which the tool promises to +// show), a numeric token rate, token timestamps, a whole merge-policy block, +// and showed "[masked:token]" for a secret that is not set at all. +func TestScrubShowsValuesThatCannotBeASecret(t *testing.T) { + hold := map[string]any{"org/repo": map[string]any{"enabled": true, "source": "config"}} + for key, value := range map[string]any{ + // the name of the environment variable, not its value + "token_env": "GITLAB_TOKEN", + "gitlabTokenEnv": "GITLAB_TOKEN", + "webhookSecretEnv": "HIVE_WEBHOOK_SECRET", + "password_env_var": "SMTP_PASSWORD", + "apiTokenEnvName": "X_API_TOKEN_2", + // counts and rates + "tokens_per_coin": float64(1000), + "tokensIn": float64(5), + "max_tokens_per_day": float64(100), + "tokens_by_model": map[string]any{"opus": float64(7)}, + // timestamps + "token_expires_at": "2026-12-01T00:00:00Z", + "token_issued_at": "2026-11-01T10:00:00.123456789-05:00", + "token_last_used_at": "2026-11-06T12:13:51Z", + // nothing to mask + "auth_token": "", + "registration_token": nil, + "credentialWarnings": []any{}, + "client_secret": map[string]any{}, + // the self-authorization hold is a merge policy + "repoSelfAuthorizationHold": hold, + "self_authorization_hold": map[string]any{"enabled": false}, + } { + out := Scrub(map[string]any{key: value}).(map[string]any) + if !reflect.DeepEqual(out[key], value) { + t.Errorf("%s: read shows %#v, want %#v", key, out[key], value) + } + } +} + +func TestScrubStillMasksWhatCouldBeASecret(t *testing.T) { + for name, tc := range map[string]struct { + key string + value any + }{ + "token": {"token", "opaque-value"}, + "auth token": {"auth_token", "abc123"}, + "registration token": {"registration_token", "r-1"}, + "password": {"password", "hunter2"}, + "client secret": {"client_secret", "s3"}, + "authorization header": {"Authorization", "opaque"}, + "proxy authorization": {"proxy_authorization", "opaque"}, + "authorization hold, no self": {"authorizationHold", "opaque"}, + "hold key that names a token": {"self_authorization_hold_token", "opaque"}, + "env key, lower-case value": {"token_env", "a3f1c9d2e4b5"}, + "env key, value with a dash": {"tokenEnv", "sk-live-abc"}, + "env key, value with a space": {"token_env", "MY TOKEN"}, + "env key, leading digit": {"token_env", "9ABC"}, + "env-shaped value, not env key": {"api_token", "GITLAB_TOKEN"}, + "env as the whole key": {"secretenv", "GITLAB_TOKEN"}, + "credential count": {"access_tokens_per_user", float64(5)}, + "refresh token map": {"refresh_tokens_by_user", map[string]any{"a": "b"}}, + "tokens with secret": {"tokens_secret", map[string]any{"a": "b"}}, + "numeric under token secret": {"token_secret", float64(123456)}, + "number under password": {"password", float64(12345678)}, + "list of tokens": {"refresh_tokens", []any{"opaque"}}, + "warnings with text": {"credentialWarnings", []any{"a warning"}}, + "credential block": {"credentialInjection", map[string]any{"enabled": true}}, + "almost a timestamp": {"token", "2026-13-45T00:00:00Z"}, + "date only": {"token", "2026-11-06"}, + } { + out := Scrub(map[string]any{tc.key: tc.value}).(map[string]any) + got, _ := out[tc.key].(string) + if len(got) < len("[masked:") || got[:len("[masked:")] != "[masked:" { + t.Errorf("%s: %s is shown as %#v, want it masked", name, tc.key, out[tc.key]) + } + } +} + +// A value kept because of its key is still scrubbed by shape. +func TestScrubStillScrubsKeptValuesByShape(t *testing.T) { + out := Scrub(map[string]any{ + "repoSelfAuthorizationHold": map[string]any{"org/repo": map[string]any{"reason": "see Bearer abcdefghijklmnopqrstuvwxyz012345", "api_token": "opaque"}}, + }).(map[string]any) + repo := out["repoSelfAuthorizationHold"].(map[string]any)["org/repo"].(map[string]any) + if repo["api_token"] != "[masked:token]" { + t.Errorf("a token inside a shown block is not masked: %#v", repo) + } + if reason, _ := repo["reason"].(string); reason == "see Bearer abcdefghijklmnopqrstuvwxyz012345" { + t.Errorf("a bearer token inside a shown block is not scrubbed: %q", reason) + } +} + +// The pending-confirmation scrub decides what a write may store. It is not +// loosened: these stay refused there. +func TestPendingScrubIsAsStrictAsBefore(t *testing.T) { + out := scrubPendingMap(map[string]any{ + "token_env": "GITLAB_TOKEN", + "tokens_per_coin": 1000, + "token_expires_at": "2026-12-01T00:00:00Z", + "api_key": "", + "otelHeaders": map[string]any{}, + }).(map[string]any) + for key, value := range out { + if text, _ := value.(string); len(text) < len("[masked:") || text[:len("[masked:")] != "[masked:" { + t.Errorf("pending scrub now keeps %s = %#v", key, value) + } + } +} + +func TestKeyWords(t *testing.T) { + for key, want := range map[string][]string{ + "webhookSecretEnv": {"webhook", "secret", "env"}, + "token_env": {"token", "env"}, + "TOKENS_PER_COIN": {"tokens", "per", "coin"}, + "tokens-in": {"tokens", "in"}, + "tokensecret": {"tokensecret"}, + "oauth2Token": {"oauth2", "token"}, + } { + if got := keyWords(key); !reflect.DeepEqual(got, want) { + t.Errorf("keyWords(%q) = %v, want %v", key, got, want) + } + } +} From ed3dcf0f1b8c037b9aca33a7b0ef04ca86e51c17 Mon Sep 17 00:00:00 2001 From: Danathar Date: Fri, 6 Nov 2026 07:51:00 -0500 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=96=20docs(adminmcp):=20a=20token?= =?UTF-8?q?=20count=20block=20is=20read,=20not=20masked=20whole?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review note on #16889: the new "What a read masks" section said every list or object with content under a sensitive key is masked whole. An object under a token count key (tokens, tokens_by_model) is walked, as it was before this PR; the section now says so. Co-Authored-By: Claude Fable 5.1 Signed-off-by: Danathar --- src/docs/admin-mcp.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/docs/admin-mcp.md b/src/docs/admin-mcp.md index 572c77c223..b32a4daeea 100644 --- a/src/docs/admin-mcp.md +++ b/src/docs/admin-mcp.md @@ -278,7 +278,9 @@ replaced by `[masked:...]`, unless it cannot hold a credential: So `[masked:token]` means a value is there and was withheld, and an empty value means nothing is set. A list or object with content under such a key is masked whole (for example `credentialWarnings` when there are warnings); read -it on the dashboard. +it on the dashboard. The one exception is a token count block, an object under +a count key such as `tokens`: it is read like any other object, and the keys +inside it are judged by the same rules. Meta tools: From 723fe7faf0267406a9b547dd2adced67d80bd9cb Mon Sep 17 00:00:00 2001 From: Danathar Date: Fri, 6 Nov 2026 08:24:47 -0500 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=90=9B=20fix(adminmcp):=20leave=20env?= =?UTF-8?q?ironment=20variable=20names=20masked=20in=20this=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The review asked for the owner's decision on one of the rules: showing an upper-case value under a key ending in env. That is a policy call, so the rule is taken out of this change and will be proposed on its own. A value under token_env and the like stays masked, as it was. What remains shown under a sensitive-looking key: nothing (null, empty string, list or object), a timestamp, a token count or rate, and the self-authorization hold settings. Co-Authored-By: Claude Fable 5.1 Signed-off-by: Danathar --- ...ed-admin-mcp-read-scrub-false-positives.md | 2 +- src/docs/admin-mcp.md | 5 ++- src/pkg/adminmcp/adminmcp.go | 41 +------------------ src/pkg/adminmcp/scrub_read_test.go | 19 +++------ 4 files changed, 10 insertions(+), 57 deletions(-) diff --git a/changelog.d/fixed-admin-mcp-read-scrub-false-positives.md b/changelog.d/fixed-admin-mcp-read-scrub-false-positives.md index c6c2c97da2..2a5a66ae21 100644 --- a/changelog.d/fixed-admin-mcp-read-scrub-false-positives.md +++ b/changelog.d/fixed-admin-mcp-read-scrub-false-positives.md @@ -1 +1 @@ -- Admin MCP reads no longer mask values that cannot hold a credential. A read masked everything under a key containing `token`, `secret`, `password`, `credential` or `authorization` (booleans and `*tokens` counts excepted), so `settings_read` returned `[masked:token]` for the name of the environment variable that supplies a secret (`token_env`, `gitlabTokenEnv`, `webhookSecretEnv`), which the tool promises to show; for a numeric rate (`tokens_per_coin`); for the whole per-repository self-authorization hold policy (`repoSelfAuthorizationHold`); and for a secret that is not set at all, which read the same as one that is. `contributors_list` hid `token_expires_at`, `token_issued_at` and `token_last_used_at`. These are now shown: an empty value or `null`, an empty list or object, a timestamp, a token count or rate, an upper-case environment variable name under a key ending in `env`, and the self-authorization hold settings. Everything else under those keys is masked as before, kept values are still scrubbed by shape, and the stricter rule that decides what a write preview may store is unchanged. +- Admin MCP reads no longer mask values that cannot hold a credential. A read masked everything under a key containing `token`, `secret`, `password`, `credential` or `authorization` (booleans and `*tokens` counts excepted), so `settings_read` returned `[masked:token]` for a numeric rate (`tokens_per_coin`); `[masked:authorization]` for the whole per-repository self-authorization hold policy (`repoSelfAuthorizationHold`); and a mask for a secret that is not set at all, which read the same as one that is. `contributors_list` hid `token_expires_at`, `token_issued_at` and `token_last_used_at`. These are now shown: an empty value or `null`, an empty list or object, a timestamp, a token count or rate, and the self-authorization hold settings. Everything else under those keys is masked as before, kept values are still scrubbed by shape, and the stricter rule that decides what a write preview may store is unchanged. diff --git a/src/docs/admin-mcp.md b/src/docs/admin-mcp.md index b32a4daeea..30ba6d3983 100644 --- a/src/docs/admin-mcp.md +++ b/src/docs/admin-mcp.md @@ -270,11 +270,12 @@ replaced by `[masked:...]`, unless it cannot hold a credential: - `true` or `false`, `null`, or an empty string, list or object; - a timestamp (`token_expires_at`); - a token count or rate (`totalTokens`, `tokens_per_coin`); -- the name of an environment variable under a key ending in `env` - (`token_env`, `webhookSecretEnv`), when it is written in upper case; - the self-authorization hold settings (`selfAuthorizationHold`, `repoSelfAuthorizationHold`), which are a merge policy and not a header. +The name of an environment variable under a key such as `token_env` is a +string like any other there, so it is masked too when it is set. + So `[masked:token]` means a value is there and was withheld, and an empty value means nothing is set. A list or object with content under such a key is masked whole (for example `credentialWarnings` when there are warnings); read diff --git a/src/pkg/adminmcp/adminmcp.go b/src/pkg/adminmcp/adminmcp.go index 43b7623b31..83071277d4 100644 --- a/src/pkg/adminmcp/adminmcp.go +++ b/src/pkg/adminmcp/adminmcp.go @@ -882,9 +882,6 @@ func authorizationKey(lower string) bool { // is not set look set. // - a timestamp (token_expires_at). // - a token count or rate with its unit after the word (tokens_per_coin). -// - the name of an environment variable under a key ending in "env" -// (token_env, webhookSecretEnv). Settings name the variable that supplies -// a secret and never return the secret. // // A string kept this way is still scrubbed by shape like any other string. func readMaskExempt(k string, v any) bool { @@ -895,7 +892,7 @@ func readMaskExempt(k string, v any) bool { case nil: return true case string: - return x == "" || isTimestamp(x) || (envNameKey(k) && envNameShaped(x)) + return x == "" || isTimestamp(x) case []any: return len(x) == 0 case map[string]any: @@ -968,42 +965,6 @@ func tokenRateKey(k string) bool { return false } -// envNameKey reports whether k names an environment variable: its last word -// is "env", or its last two are "env var" or "env name". -func envNameKey(k string) bool { - words := keyWords(k) - n := len(words) - switch { - case n >= 2 && words[n-1] == "env": - return true - case n >= 3 && words[n-2] == "env" && (words[n-1] == "var" || words[n-1] == "name"): - return true - default: - return false - } -} - -// envNameShaped reports whether s is written as environment variable names -// are: upper-case letters, digits and underscores. A value pasted into such a -// field by mistake rarely has that shape, and stays masked when it does not. -func envNameShaped(s string) bool { - if s == "" || len(s) > 128 { - return false - } - for i, r := range s { - switch { - case r >= 'A' && r <= 'Z', r == '_': - case r >= '0' && r <= '9': - if i == 0 { - return false - } - default: - return false - } - } - return true -} - // credentialTokenQualifiers mark a plural "*tokens" key as a collection of // credentials (refresh_tokens, access_tokens) rather than a usage count. var credentialTokenQualifiers = []string{ diff --git a/src/pkg/adminmcp/scrub_read_test.go b/src/pkg/adminmcp/scrub_read_test.go index 101cf3a945..3bf563f9c5 100644 --- a/src/pkg/adminmcp/scrub_read_test.go +++ b/src/pkg/adminmcp/scrub_read_test.go @@ -6,19 +6,12 @@ import ( ) // A read masked every value under a key containing token, secret, password, -// credential or authorization. settings_read then hid the name of the -// environment variable that supplies a secret (which the tool promises to -// show), a numeric token rate, token timestamps, a whole merge-policy block, -// and showed "[masked:token]" for a secret that is not set at all. +// credential or authorization. settings_read then hid a numeric token rate, +// token timestamps and a whole merge-policy block, and showed "[masked:token]" +// for a secret that is not set at all. func TestScrubShowsValuesThatCannotBeASecret(t *testing.T) { hold := map[string]any{"org/repo": map[string]any{"enabled": true, "source": "config"}} for key, value := range map[string]any{ - // the name of the environment variable, not its value - "token_env": "GITLAB_TOKEN", - "gitlabTokenEnv": "GITLAB_TOKEN", - "webhookSecretEnv": "HIVE_WEBHOOK_SECRET", - "password_env_var": "SMTP_PASSWORD", - "apiTokenEnvName": "X_API_TOKEN_2", // counts and rates "tokens_per_coin": float64(1000), "tokensIn": float64(5), @@ -58,12 +51,10 @@ func TestScrubStillMasksWhatCouldBeASecret(t *testing.T) { "proxy authorization": {"proxy_authorization", "opaque"}, "authorization hold, no self": {"authorizationHold", "opaque"}, "hold key that names a token": {"self_authorization_hold_token", "opaque"}, + "env key, variable name": {"token_env", "GITLAB_TOKEN"}, + "env key, camel case": {"webhookSecretEnv", "HIVE_WEBHOOK_SECRET"}, "env key, lower-case value": {"token_env", "a3f1c9d2e4b5"}, - "env key, value with a dash": {"tokenEnv", "sk-live-abc"}, - "env key, value with a space": {"token_env", "MY TOKEN"}, - "env key, leading digit": {"token_env", "9ABC"}, "env-shaped value, not env key": {"api_token", "GITLAB_TOKEN"}, - "env as the whole key": {"secretenv", "GITLAB_TOKEN"}, "credential count": {"access_tokens_per_user", float64(5)}, "refresh token map": {"refresh_tokens_by_user", map[string]any{"a": "b"}}, "tokens with secret": {"tokens_secret", map[string]any{"a": "b"}},