Skip to content

Commit 0e1bb89

Browse files
committed
fix(ng-dev): ignore all credential helpers when using the git client (#1005)
Since all authentication is done via URL when using the GitClient, we can safely prepend all git subcommands with `-c credential.helper=` to prevent any credential helper from being used. This will have the benefit of preventing the temporary credentials created by ng-dev auth from being stored, rather than our previous method of attempting to remove them automatically. PR Close #1005
1 parent ae37b42 commit 0e1bb89

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

.github/local-actions/branch-manager/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70260,6 +70260,7 @@ var GitClient = class {
7026070260
Log.debug(`"git push" is not able to be run in dryRun mode.`);
7026170261
throw new DryRunError();
7026270262
}
70263+
args = ["-c", "credential.helper=", ...args];
7026370264
Log.debug("Executing: git", this.sanitizeConsoleOutput(args.join(" ")));
7026470265
const result = spawnSync(this.gitBinPath, args, {
7026570266
cwd: this.baseDir,

.github/local-actions/changelog/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65874,6 +65874,7 @@ var GitClient = class {
6587465874
Log.debug(`"git push" is not able to be run in dryRun mode.`);
6587565875
throw new DryRunError();
6587665876
}
65877+
args = ["-c", "credential.helper=", ...args];
6587765878
Log.debug("Executing: git", this.sanitizeConsoleOutput(args.join(" ")));
6587865879
const result = spawnSync(this.gitBinPath, args, {
6587965880
cwd: this.baseDir,

github-actions/create-pr-for-changes/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17032,6 +17032,7 @@ var GitClient = class {
1703217032
Log.debug(`"git push" is not able to be run in dryRun mode.`);
1703317033
throw new DryRunError();
1703417034
}
17035+
args = ["-c", "credential.helper=", ...args];
1703517036
Log.debug("Executing: git", this.sanitizeConsoleOutput(args.join(" ")));
1703617037
const result = spawnSync(this.gitBinPath, args, {
1703717038
cwd: this.baseDir,

github-actions/slash-commands/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63657,6 +63657,7 @@ var GitClient = class {
6365763657
Log.debug(`"git push" is not able to be run in dryRun mode.`);
6365863658
throw new DryRunError();
6365963659
}
63660+
args = ["-c", "credential.helper=", ...args];
6366063661
Log.debug("Executing: git", this.sanitizeConsoleOutput(args.join(" ")));
6366163662
const result = spawnSync(this.gitBinPath, args, {
6366263663
cwd: this.baseDir,

ng-dev/auth/shared/ng-dev-token.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,7 @@ export function configureAuthorizedGitClientWithTemporaryToken() {
157157
});
158158

159159
// Close the socket whenever the command which established it is complete.
160-
registerCompletedFunction(async () => {
161-
socket.close();
162-
163-
// After the action is done, request it to be forgotten by the local git client as it is no
164-
// longer valid.
165-
const git = await AuthenticatedGitClient.get();
166-
git.runGraceful(['credential', 'reject'], {input: `url=${git.getRepoGitUrl()}\n\n`});
167-
});
160+
registerCompletedFunction(() => socket.close());
168161

169162
// When the token is provided via the websocket message, use the token to set up
170163
// the AuthenticatedGitClient. The token is valid as long as the socket remains open,

ng-dev/utils/git/git-client.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ export class GitClient {
9090
throw new DryRunError();
9191
}
9292

93+
// Clear the credential helper that is used, preventing the temporary token from being saved as a
94+
// valid token for future use.
95+
args = ['-c', 'credential.helper=', ...args];
9396
// To improve the debugging experience in case something fails, we print all executed Git
9497
// commands at the DEBUG level to better understand the git actions occurring.
9598
// Note that we sanitize the command before printing it to the console. We do not want to

0 commit comments

Comments
 (0)