Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mask ACR token on Windows when System.Debug is true #4868

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Agent.Sdk/Knob/AgentKnobs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -730,5 +730,12 @@ public class AgentKnobs
"Checks if the PSModulePath environment variable contains locations specific to PowerShell Core.",
new EnvironmentKnobSource("AZP_AGENT_CHECK_PSMODULES_LOCATIONS"),
new BuiltInDefaultKnobSource("false"));

public static readonly Knob UseDockerStdinPasswordOnWindows = new Knob(
nameof(UseDockerStdinPasswordOnWindows),
"If true, use --password-stdin for docker login on Windows.",
new RuntimeKnobSource("AZP_AGENT_USE_DOCKER_STDIN_PASSWORD_WINDOWS"),
new PipelineFeatureSource("UseDockerStdinPasswordOnWindows"),
new BuiltInDefaultKnobSource("false"));
}
}
4 changes: 3 additions & 1 deletion src/Agent.Worker/Container/DockerCommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ public async Task<int> DockerLogin(IExecutionContext context, string server, str
ArgUtil.NotNull(username, nameof(username));
ArgUtil.NotNull(password, nameof(password));

var action = new Func<Task<int>>(async () => PlatformUtil.RunningOnWindows
var useDockerStdinPasswordOnWindows = AgentKnobs.UseDockerStdinPasswordOnWindows.GetValue(context).AsBoolean();

var action = new Func<Task<int>>(async () => PlatformUtil.RunningOnWindows && !useDockerStdinPasswordOnWindows
// Wait for 17.07 to switch using stdin for docker registry password.
? await ExecuteDockerCommandAsync(context, "login", $"--username \"{username}\" --password \"{password.Replace("\"", "\\\"")}\" {server}", new List<string>() { password }, context.CancellationToken)
: await ExecuteDockerCommandAsync(context, "login", $"--username \"{username}\" --password-stdin {server}", new List<string>() { password }, context.CancellationToken)
Expand Down
4 changes: 4 additions & 0 deletions src/Agent.Worker/ContainerOperationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ private async Task<string> GetAcrPasswordFromAADToken(IExecutionContext executio
{
throw new NotSupportedException("Could not acquire ACR token from given AAD token. Please check that the necessary access is provided and try again.");
}

// Mark retrieved password as secret
HostContext.SecretMasker.AddValue(AcrPassword);

return AcrPassword;
}

Expand Down
Loading