Skip to content

Commit cedd846

Browse files
committed
fix: only accept version-shaped x-trigger-cli-version values
1 parent bf0ee66 commit cedd846

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

apps/webapp/app/routes/api.v1.deployments.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
4343

4444
try {
4545
const result = await service.call(authenticatedEnv, body.data, {
46-
cliVersion: request.headers.get("x-trigger-cli-version") ?? undefined,
46+
cliVersion: parseCliVersionHeader(request),
4747
});
4848
const { deployment, imageRef } = result;
4949

@@ -77,6 +77,14 @@ export async function action({ request, params }: ActionFunctionArgs) {
7777
}
7878
}
7979

80+
// Client-controlled and persisted, so only accept version-shaped values
81+
const CLI_VERSION_REGEX = /^[0-9A-Za-z.+-]{1,64}$/;
82+
83+
function parseCliVersionHeader(request: Request): string | undefined {
84+
const value = request.headers.get("x-trigger-cli-version");
85+
return value && CLI_VERSION_REGEX.test(value) ? value : undefined;
86+
}
87+
8088
export const loader = createLoaderApiRoute(
8189
{
8290
searchParams: ApiDeploymentListSearchParams,

0 commit comments

Comments
 (0)