Skip to content

Commit

Permalink
Remove unneeded base64 encoders (actions#128)
Browse files Browse the repository at this point in the history
* Remove unneeded base64 encoders

* update comment
  • Loading branch information
thboop authored and TingluoHuang committed Oct 14, 2019
1 parent b82672d commit aa379b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
3 changes: 0 additions & 3 deletions src/Runner.Common/HostContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ 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.Base64StringEscapeShift3);
this.SecretMasker.AddValueEncoder(ValueEncoders.Base64StringEscapeShift4);
this.SecretMasker.AddValueEncoder(ValueEncoders.Base64StringEscapeShift5);
this.SecretMasker.AddValueEncoder(ValueEncoders.ExpressionStringEscape);
this.SecretMasker.AddValueEncoder(ValueEncoders.JsonStringEscape);
this.SecretMasker.AddValueEncoder(ValueEncoders.UriDataEscape);
Expand Down
25 changes: 8 additions & 17 deletions src/Sdk/DTLogging/Logging/ValueEncoders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ public static String Base64StringEscape(String value)
return Convert.ToBase64String(Encoding.UTF8.GetBytes(value));
}

// Base64 is 6 bytes -> char
// Base64 is 6 bits -> char
// A byte is 8 bits
// When end user doing somthing like base64(user:password)
// The length of the leading content will cause different base64 encoding result on the password
// So we add base64(value - 1/2/3/4/5 bytes) as secret as well.
// So we add base64(value shifted 1 and two bytes) as secret as well.
// B1 B2 B3 B4 B5 B6 B7
// 000000|00 0000|0000 00|000000| 000000|00 0000|0000 00|000000|
// Char1 Char2 Char3 Char4
// See the above, the first byte has a character beginning at index 0, the second byte has a character beginning at index 4, the third byte has a character beginning at index 2 and then the pattern repeats
// We register byte offsets for all these possible values
public static String Base64StringEscapeShift1(String value)
{
return Base64StringEscapeShift(value, 1);
Expand All @@ -31,21 +37,6 @@ public static String Base64StringEscapeShift2(String value)
return Base64StringEscapeShift(value, 2);
}

public static String Base64StringEscapeShift3(String value)
{
return Base64StringEscapeShift(value, 3);
}

public static String Base64StringEscapeShift4(String value)
{
return Base64StringEscapeShift(value, 4);
}

public static String Base64StringEscapeShift5(String value)
{
return Base64StringEscapeShift(value, 5);
}

public static String ExpressionStringEscape(String value)
{
return Expressions.ExpressionUtil.StringEscape(value);
Expand Down

0 comments on commit aa379b7

Please # to comment.