Skip to content

Commit

Permalink
mask secrets with double-quotes when passed to docker command line (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsciple authored Mar 5, 2021
1 parent af19823 commit 8109c96
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Runner.Common/HostContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public HostContext(string hostType, string logFile = null)
this.SecretMasker.AddValueEncoder(ValueEncoders.Base64StringEscape);
this.SecretMasker.AddValueEncoder(ValueEncoders.Base64StringEscapeShift1);
this.SecretMasker.AddValueEncoder(ValueEncoders.Base64StringEscapeShift2);
this.SecretMasker.AddValueEncoder(ValueEncoders.CommandLineArgumentEscape);
this.SecretMasker.AddValueEncoder(ValueEncoders.ExpressionStringEscape);
this.SecretMasker.AddValueEncoder(ValueEncoders.JsonStringEscape);
this.SecretMasker.AddValueEncoder(ValueEncoders.UriDataEscape);
Expand Down
6 changes: 6 additions & 0 deletions src/Sdk/DTLogging/Logging/ValueEncoders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ public static String Base64StringEscapeShift2(String value)
return Base64StringEscapeShift(value, 2);
}

// Used when we pass environment variables to docker to escape " with \"
public static String CommandLineArgumentEscape(String value)
{
return value.Replace("\"", "\\\"");
}

public static String ExpressionStringEscape(String value)
{
return Expressions2.Sdk.ExpressionUtility.StringEscape(value);
Expand Down

0 comments on commit 8109c96

Please sign in to comment.