Skip to content

Commit aa40ed5

Browse files
committed
Only allow decimal values in timeouts
This allowed users to have durations in other number systems like hexadecimal. For example `0xfd` was a valid timeout.
1 parent b49102c commit aa40ed5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

components/gitpod-protocol/src/gitpod-service.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,12 @@ const WORKSPACE_MAXIMUM_TIMEOUT_HOURS = 24;
363363
export type WorkspaceTimeoutDuration = string;
364364
export namespace WorkspaceTimeoutDuration {
365365
export function validate(duration: string): WorkspaceTimeoutDuration {
366+
duration = duration.toLowerCase();
366367
const unit = duration.slice(-1);
367368
if (!["m", "h", "d"].includes(unit)) {
368369
throw new Error(`Invalid timeout unit: ${unit}`);
369370
}
370-
const value = parseInt(duration.slice(0, -1));
371+
const value = parseInt(duration.slice(0, -1), 10);
371372
if (isNaN(value) || value <= 0) {
372373
throw new Error(`Invalid timeout value: ${duration}`);
373374
}

0 commit comments

Comments
 (0)