From e41a76da99f8ff1e667986a1ae54139218cb7346 Mon Sep 17 00:00:00 2001 From: Radomir Stevanovic Date: Fri, 4 Feb 2022 13:24:00 -0800 Subject: [PATCH 1/2] Add env var name/value length validation Also, decrease maxlen for value from ~64k*3/4 to a nice round 32k. --- components/gitpod-protocol/src/protocol.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/gitpod-protocol/src/protocol.ts b/components/gitpod-protocol/src/protocol.ts index 84388565b790f1..b8d72c547b9d8e 100644 --- a/components/gitpod-protocol/src/protocol.ts +++ b/components/gitpod-protocol/src/protocol.ts @@ -242,12 +242,18 @@ export namespace UserEnvVar { if (name.trim() === "") { return "Name must not be empty."; } + if (name.length > 255) { + return 'Name too long. Maximum name length is 255 characters.'; + } if (!/^[a-zA-Z_]+[a-zA-Z0-9_]*$/.test(name)) { return "Name must match /^[a-zA-Z_]+[a-zA-Z0-9_]*$/."; } if (variable.value.trim() === "") { return "Value must not be empty."; } + if (variable.value.length > 32768) { + return 'Value too long. Maximum value length is 32768 characters.'; + } if (pattern.trim() === "") { return "Scope must not be empty."; } From 72ad89c44a84e396954382539ebc53062926f1be Mon Sep 17 00:00:00 2001 From: Radomir Stevanovic Date: Wed, 16 Feb 2022 11:15:21 -0800 Subject: [PATCH 2/2] Reduce env var value UI limit to 32k-1 for consistency Co-authored-by: Jan Keromnes --- components/gitpod-protocol/src/protocol.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/gitpod-protocol/src/protocol.ts b/components/gitpod-protocol/src/protocol.ts index b8d72c547b9d8e..ec8b4e459c1314 100644 --- a/components/gitpod-protocol/src/protocol.ts +++ b/components/gitpod-protocol/src/protocol.ts @@ -251,8 +251,8 @@ export namespace UserEnvVar { if (variable.value.trim() === "") { return "Value must not be empty."; } - if (variable.value.length > 32768) { - return 'Value too long. Maximum value length is 32768 characters.'; + if (variable.value.length > 32767) { + return 'Value too long. Maximum value length is 32767 characters.'; } if (pattern.trim() === "") { return "Scope must not be empty.";