From 19c3dc6d39a2aa2878ee444eec164a7a84639671 Mon Sep 17 00:00:00 2001 From: Priyam Sahoo <42550351+priyamsahoo@users.noreply.github.com> Date: Tue, 7 Jun 2022 19:05:14 +0530 Subject: [PATCH] Add check to validate mount path before passing it as an arg in EE (#345) --- docs/changelog-fragments.d/345.bugfix.md | 2 ++ src/services/executionEnvironment.ts | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 docs/changelog-fragments.d/345.bugfix.md diff --git a/docs/changelog-fragments.d/345.bugfix.md b/docs/changelog-fragments.d/345.bugfix.md new file mode 100644 index 00000000..7e7ef843 --- /dev/null +++ b/docs/changelog-fragments.d/345.bugfix.md @@ -0,0 +1,2 @@ +Added validation of mount path before passing it as an argument to wrap the +commands in execution environment -- by {user}`priyamsahoo` diff --git a/src/services/executionEnvironment.ts b/src/services/executionEnvironment.ts index ea62e3e5..25683283 100644 --- a/src/services/executionEnvironment.ts +++ b/src/services/executionEnvironment.ts @@ -214,6 +214,14 @@ export class ExecutionEnvironment { ); for (const mountPath of mountPaths || []) { + // push to array only if mount path is valid + if (mountPath === "" || !fs.existsSync(mountPath)) { + this.connection.console.error( + `Volume mount source path '${mountPath}' does not exist. Ignoring this volume mount entry.` + ); + continue; + } + const volumeMountPath = `${mountPath}:${mountPath}`; if (containerCommand.includes(volumeMountPath)) { continue;