Skip to content

Commit bf08527

Browse files
jokreliablejsoref
andauthored
wrap pipeline commands for submoduleForeach in quotes (#964)
* wrap pipeline commands for submoduleForeach in quotes * Update src/git-auth-helper.ts drop extraneous space. Co-authored-by: Josh Soref <[email protected]> * Followed CONTRIBUTING.md instructions, updating dist/index.js * fixed package-lock.json * updating the pipeline so it runs from sh Co-authored-by: Josh Soref <[email protected]>
1 parent 5c3ccc2 commit bf08527

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

dist/index.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -7121,7 +7121,9 @@ class GitAuthHelper {
71217121
// Configure a placeholder value. This approach avoids the credential being captured
71227122
// by process creation audit events, which are commonly logged. For more information,
71237123
// refer to https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/manage/component-updates/command-line-process-auditing
7124-
const output = yield this.git.submoduleForeach(`git config --local '${this.tokenConfigKey}' '${this.tokenPlaceholderConfigValue}' && git config --local --show-origin --name-only --get-regexp remote.origin.url`, this.settings.nestedSubmodules);
7124+
const output = yield this.git.submoduleForeach(
7125+
// wrap the pipeline in quotes to make sure it's handled properly by submoduleForeach, rather than just the first part of the pipeline
7126+
`sh -c "git config --local '${this.tokenConfigKey}' '${this.tokenPlaceholderConfigValue}' && git config --local --show-origin --name-only --get-regexp remote.origin.url"`, this.settings.nestedSubmodules);
71257127
// Replace the placeholder
71267128
const configPaths = output.match(/(?<=(^|\n)file:)[^\t]+(?=\tremote\.origin\.url)/g) || [];
71277129
for (const configPath of configPaths) {
@@ -7288,7 +7290,9 @@ class GitAuthHelper {
72887290
}
72897291
}
72907292
const pattern = regexpHelper.escape(configKey);
7291-
yield this.git.submoduleForeach(`git config --local --name-only --get-regexp '${pattern}' && git config --local --unset-all '${configKey}' || :`, true);
7293+
yield this.git.submoduleForeach(
7294+
// wrap the pipeline in quotes to make sure it's handled properly by submoduleForeach, rather than just the first part of the pipeline
7295+
`sh -c "git config --local --name-only --get-regexp '${pattern}' && git config --local --unset-all '${configKey}' || :"`, true);
72927296
});
72937297
}
72947298
}

src/git-auth-helper.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ class GitAuthHelper {
157157
// by process creation audit events, which are commonly logged. For more information,
158158
// refer to https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/manage/component-updates/command-line-process-auditing
159159
const output = await this.git.submoduleForeach(
160-
`git config --local '${this.tokenConfigKey}' '${this.tokenPlaceholderConfigValue}' && git config --local --show-origin --name-only --get-regexp remote.origin.url`,
160+
// wrap the pipeline in quotes to make sure it's handled properly by submoduleForeach, rather than just the first part of the pipeline
161+
`sh -c "git config --local '${this.tokenConfigKey}' '${this.tokenPlaceholderConfigValue}' && git config --local --show-origin --name-only --get-regexp remote.origin.url"`,
161162
this.settings.nestedSubmodules
162163
)
163164

@@ -365,7 +366,8 @@ class GitAuthHelper {
365366

366367
const pattern = regexpHelper.escape(configKey)
367368
await this.git.submoduleForeach(
368-
`git config --local --name-only --get-regexp '${pattern}' && git config --local --unset-all '${configKey}' || :`,
369+
// wrap the pipeline in quotes to make sure it's handled properly by submoduleForeach, rather than just the first part of the pipeline
370+
`sh -c "git config --local --name-only --get-regexp '${pattern}' && git config --local --unset-all '${configKey}' || :"`,
369371
true
370372
)
371373
}

0 commit comments

Comments
 (0)