removed equal sign from env buffer, added defensive guard against the key (#62)

* removed equal sign from env buffer, added defensive guard against the key

* Update packages/k8s/src/k8s/utils.ts

Co-authored-by: John Sudol <24583161+johnsudol@users.noreply.github.com>

* Update packages/k8s/src/k8s/utils.ts

Co-authored-by: Ferenc Hammerl <31069338+fhammerl@users.noreply.github.com>

* fix format

---------

Co-authored-by: John Sudol <24583161+johnsudol@users.noreply.github.com>
Co-authored-by: Ferenc Hammerl <31069338+fhammerl@users.noreply.github.com>
This commit is contained in:
Nikola Jokic
2023-02-09 17:11:16 +01:00
committed by GitHub
parent 7754cb80eb
commit ae31f04223

View File

@@ -111,11 +111,13 @@ export function writeEntryPointScript(
if (environmentVariables && Object.entries(environmentVariables).length) { if (environmentVariables && Object.entries(environmentVariables).length) {
const envBuffer: string[] = [] const envBuffer: string[] = []
for (const [key, value] of Object.entries(environmentVariables)) { for (const [key, value] of Object.entries(environmentVariables)) {
if (key.includes(`=`) || key.includes(`'`) || key.includes(`"`)) {
throw new Error(
`environment key ${key} is invalid - the key must not contain =, ' or "`
)
}
envBuffer.push( envBuffer.push(
`"${key}=${value `"${key}=${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`
.replace(/\\/g, '\\\\')
.replace(/"/g, '\\"')
.replace(/=/g, '\\=')}"`
) )
} }
environmentPrefix = `env ${envBuffer.join(' ')} ` environmentPrefix = `env ${envBuffer.join(' ')} `