mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-31 22:11:46 +00:00
fix: canonicalize secret target array indexes
This commit is contained in:
@@ -23,6 +23,24 @@ describe("target registry pattern helpers", () => {
|
||||
tokens,
|
||||
),
|
||||
).toBeNull();
|
||||
expect(
|
||||
matchPathTokens(
|
||||
["agents", "list", "02", "memorySearch", "providers", "openai", "apiKey"],
|
||||
tokens,
|
||||
),
|
||||
).toBeNull();
|
||||
expect(
|
||||
matchPathTokens(
|
||||
["agents", "list", "+2", "memorySearch", "providers", "openai", "apiKey"],
|
||||
tokens,
|
||||
),
|
||||
).toBeNull();
|
||||
expect(
|
||||
matchPathTokens(
|
||||
["agents", "list", "4294967294", "memorySearch", "providers", "openai", "apiKey"],
|
||||
tokens,
|
||||
),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("materializes sibling ref paths from wildcard and array captures", () => {
|
||||
@@ -37,6 +55,9 @@ describe("target registry pattern helpers", () => {
|
||||
"apiKeyRef",
|
||||
]);
|
||||
expect(materializePathTokens(refTokens, ["anthropic"])).toBeNull();
|
||||
expect(materializePathTokens(refTokens, ["01", "anthropic"])).toBeNull();
|
||||
expect(materializePathTokens(refTokens, ["+1", "anthropic"])).toBeNull();
|
||||
expect(materializePathTokens(refTokens, ["4294967294", "anthropic"])).toBeNull();
|
||||
});
|
||||
|
||||
it("matches two wildcard captures in five-segment header paths", () => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { parseConfigPathArrayIndex } from "../shared/path-array-index.js";
|
||||
import { isRecord, parseDotPath } from "./shared.js";
|
||||
import type { SecretTargetRegistryEntry } from "./target-registry-types.js";
|
||||
|
||||
@@ -92,7 +93,7 @@ export function matchPathTokens(
|
||||
return null;
|
||||
}
|
||||
const next = segments[index + 1];
|
||||
if (!next || !/^\d+$/.test(next)) {
|
||||
if (!next || parseConfigPathArrayIndex(next) === undefined) {
|
||||
return null;
|
||||
}
|
||||
captures.push(next);
|
||||
@@ -122,7 +123,7 @@ export function materializePathTokens(
|
||||
continue;
|
||||
}
|
||||
const arrayIndex = captures[captureIndex];
|
||||
if (!arrayIndex || !/^\d+$/.test(arrayIndex)) {
|
||||
if (!arrayIndex || parseConfigPathArrayIndex(arrayIndex) === undefined) {
|
||||
return null;
|
||||
}
|
||||
out.push(token.field, arrayIndex);
|
||||
|
||||
Reference in New Issue
Block a user