@@ -5271,11 +5271,24 @@ function prepareExistingDirectory(git, repositoryPath, repositoryUrl, clean) {
5271
5271
}
5272
5272
function configureAuthToken(git, authToken) {
5273
5273
return __awaiter(this, void 0, void 0, function* () {
5274
- // Add extraheader (auth)
5275
- const base64Credentials = Buffer.from(`x-access-token:${authToken}`, 'utf8').toString('base64');
5276
- core.setSecret(base64Credentials);
5277
- const authConfigValue = `AUTHORIZATION: basic ${base64Credentials}`;
5278
- yield git.config(authConfigKey, authConfigValue);
5274
+ // Configure a placeholder value. This approach avoids the credential being captured
5275
+ // by process creation audit events, which are commonly logged. For more information,
5276
+ // refer to https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/manage/component-updates/command-line-process-auditing
5277
+ const placeholder = `AUTHORIZATION: basic ***`;
5278
+ yield git.config(authConfigKey, placeholder);
5279
+ // Determine the basic credential value
5280
+ const basicCredential = Buffer.from(`x-access-token:${authToken}`, 'utf8').toString('base64');
5281
+ core.setSecret(basicCredential);
5282
+ // Replace the value in the config file
5283
+ const configPath = path.join(git.getWorkingDirectory(), '.git', 'config');
5284
+ let content = (yield fs.promises.readFile(configPath)).toString();
5285
+ const placeholderIndex = content.indexOf(placeholder);
5286
+ if (placeholderIndex < 0 ||
5287
+ placeholderIndex != content.lastIndexOf(placeholder)) {
5288
+ throw new Error('Unable to replace auth placeholder in .git/config');
5289
+ }
5290
+ content = content.replace(placeholder, `AUTHORIZATION: basic ${basicCredential}`);
5291
+ yield fs.promises.writeFile(configPath, content);
5279
5292
});
5280
5293
}
5281
5294
function removeGitConfig(git, configKey) {
0 commit comments