refactor(gateway): centralize node.invoke param sanitization

This commit is contained in:
Peter Steinberger
2026-02-14 13:26:15 +01:00
parent c15946274e
commit 0af76f5f0e
3 changed files with 121 additions and 9 deletions

View File

@@ -10,7 +10,7 @@ import {
verifyNodeToken,
} from "../../infra/node-pairing.js";
import { isNodeCommandAllowed, resolveNodeCommandAllowlist } from "../node-command-policy.js";
import { sanitizeSystemRunParamsForForwarding } from "../node-invoke-system-run-approval.js";
import { sanitizeNodeInvokeParamsForForwarding } from "../node-invoke-sanitize.js";
import {
ErrorCodes,
errorShape,
@@ -418,14 +418,12 @@ export const nodeHandlers: GatewayRequestHandlers = {
);
return;
}
const forwardedParams =
command === "system.run"
? sanitizeSystemRunParamsForForwarding({
rawParams: p.params,
client,
execApprovalManager: context.execApprovalManager,
})
: ({ ok: true, params: p.params } as const);
const forwardedParams = sanitizeNodeInvokeParamsForForwarding({
command,
rawParams: p.params,
client,
execApprovalManager: context.execApprovalManager,
});
if (!forwardedParams.ok) {
respond(
false,