Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,14 @@ const RUNTIME_VARIABLE =
/^(?:HOSTNAME|YARN_VERSION|GIT_SSL_CAINFO)$|_SERVICE_(?:HOST|PORT)(?:_|$)|_PORT(?:_|$)/;

// The variable a secret-input value reads as an environment SecretRef, if any: a whole `${NAME}`
// with no fallback, the `$NAME` shorthand or an env SecretRef object. OpenClaw keeps a reference
// with no fallback, the `$NAME` shorthand or an env SecretRef object. OpenClaw trims the value
// first (`parseEnvTemplateSecretRef`), so a padded `${NAME}` counts too. It keeps a reference
// inside other text as written, and a fallback replaces an unset name, so neither stops it.
function secretInputVariable(value: unknown): string | undefined {
const reference = asRecord(value);
const name =
typeof value === "string"
? (wholeEnvironmentReferenceName(value) ?? secretInputShorthandName(value))
? (wholeEnvironmentReferenceName(value.trim()) ?? secretInputShorthandName(value))
: reference?.source === "env"
? reference.id
: undefined;
Expand Down
3 changes: 3 additions & 0 deletions tests/conformance/kubernetes-compute.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9627,6 +9627,9 @@ test("admission refuses a plugin secret input whose unset variable stops any Gat
"codex",
],
[withSearchHeader("${RELAY_TOKEN}"), searchHeader, "RELAY_TOKEN", "google"],
// OpenClaw trims a secret-input value before it reads `${NAME}`, so padding still stops the
// Gateway (finding 3046).
[withSearchHeader(" ${RELAY_TOKEN}\n"), searchHeader, "RELAY_TOKEN", "google"],
[
withSearchHeader(envRef("relay_token"), { enabled: true }),
searchHeader,
Expand Down
20 changes: 20 additions & 0 deletions tests/integration/configuration-controller.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2025,6 +2025,26 @@ test("Configuration save and Kubernetes deployment admission refuse settings pre
"google",
),
],
// OpenClaw trims a secret-input value before it reads `${NAME}`, so a padded reference stops
// the Gateway too (finding 3046). Save accepts it here: the header name marks no credential.
[
{
...valid,
plugins: {
entries: {
google: {
config: { webSearch: { headers: { "X-Goog-User-Project": " ${SEARCH_HEADER} " } } },
},
},
},
},
400,
unboundPluginSecretRefusal(
"plugins.entries.google.config.webSearch.headers.X-Goog-User-Project",
"SEARCH_HEADER",
"google",
),
],
]) {
const label = JSON.stringify(values);
const saved = await request(context.app, "PATCH", item, { body: { values } });
Expand Down
Loading