mirror of
https://github.com/actions/runner-container-hooks.git
synced 2025-12-14 00:26:44 +00:00
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:
@@ -111,11 +111,13 @@ export function writeEntryPointScript(
|
||||
if (environmentVariables && Object.entries(environmentVariables).length) {
|
||||
const envBuffer: string[] = []
|
||||
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(
|
||||
`"${key}=${value
|
||||
.replace(/\\/g, '\\\\')
|
||||
.replace(/"/g, '\\"')
|
||||
.replace(/=/g, '\\=')}"`
|
||||
`"${key}=${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`
|
||||
)
|
||||
}
|
||||
environmentPrefix = `env ${envBuffer.join(' ')} `
|
||||
|
||||
Reference in New Issue
Block a user