Skip to content

Commit 0ebaa56

Browse files
Mask ACR token on Windows when System.Debug is true (#4868)
* Mask ACR token on Windows when System.Debug is true -- Added refresh token to secret masker -- Added FF to use --password-stdin on windows * Mask ACR token on Windows when System.Debug is true -- Removed PipelineFeatureSource -- Fixed review points * Mask ACR token on Windows when System.Debug is true -- Removed Env source
1 parent 7a2b78c commit 0ebaa56

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/Agent.Sdk/Knob/AgentKnobs.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,5 +730,12 @@ public class AgentKnobs
730730
"Checks if the PSModulePath environment variable contains locations specific to PowerShell Core.",
731731
new EnvironmentKnobSource("AZP_AGENT_CHECK_PSMODULES_LOCATIONS"),
732732
new BuiltInDefaultKnobSource("false"));
733+
734+
public static readonly Knob UseDockerStdinPasswordOnWindows = new Knob(
735+
nameof(UseDockerStdinPasswordOnWindows),
736+
"If true, use --password-stdin for docker login on Windows.",
737+
new RuntimeKnobSource("AZP_AGENT_USE_DOCKER_STDIN_PASSWORD_WINDOWS"),
738+
new PipelineFeatureSource("UseDockerStdinPasswordOnWindows"),
739+
new BuiltInDefaultKnobSource("false"));
733740
}
734741
}

src/Agent.Worker/Container/DockerCommandManager.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ public async Task<int> DockerLogin(IExecutionContext context, string server, str
100100
ArgUtil.NotNull(username, nameof(username));
101101
ArgUtil.NotNull(password, nameof(password));
102102

103-
var action = new Func<Task<int>>(async () => PlatformUtil.RunningOnWindows
103+
var useDockerStdinPasswordOnWindows = AgentKnobs.UseDockerStdinPasswordOnWindows.GetValue(context).AsBoolean();
104+
105+
var action = new Func<Task<int>>(async () => PlatformUtil.RunningOnWindows && !useDockerStdinPasswordOnWindows
104106
// Wait for 17.07 to switch using stdin for docker registry password.
105107
? await ExecuteDockerCommandAsync(context, "login", $"--username \"{username}\" --password \"{password.Replace("\"", "\\\"")}\" {server}", new List<string>() { password }, context.CancellationToken)
106108
: await ExecuteDockerCommandAsync(context, "login", $"--username \"{username}\" --password-stdin {server}", new List<string>() { password }, context.CancellationToken)

src/Agent.Worker/ContainerOperationProvider.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ private async Task<string> GetAcrPasswordFromAADToken(IExecutionContext executio
296296
{
297297
throw new NotSupportedException("Could not acquire ACR token from given AAD token. Please check that the necessary access is provided and try again.");
298298
}
299+
300+
// Mark retrieved password as secret
301+
HostContext.SecretMasker.AddValue(AcrPassword);
302+
299303
return AcrPassword;
300304
}
301305

0 commit comments

Comments
 (0)