Skip to content

Commit

Permalink
Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nodeselector committed Jun 8, 2021
1 parent 6dbb661 commit 9d5e458
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
5 changes: 2 additions & 3 deletions src/Runner.Common/ProcessChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public void StartClient(string pipeNameInput, string pipeNameOutput)

public async Task SendAsync(MessageType messageType, string body, CancellationToken cancellationToken)
{
body = $"{{\"asdfasdf\": \"{String.Concat((System.Collections.Generic.IEnumerable<string>)System.Linq.Enumerable.Repeat("asdf", 6000000))}\"}}";
Trace.Info($"Sending message of length {body.Length}, with hash '{GetMessageHash(body)}'");
await _writeStream.WriteInt32Async((int)messageType, cancellationToken);
await _writeStream.WriteStringAsync(body, cancellationToken);
Expand Down Expand Up @@ -103,9 +102,9 @@ private void Dispose(bool disposing)
// Create a deterministic hash for a string to ensure that the message is not malformed on delivery
private static string GetMessageHash(string message)
{
var md5 = System.Security.Cryptography.MD5.Create();
var sha = System.Security.Cryptography.SHA256.Create();
byte[] input = System.Text.Encoding.UTF8.GetBytes(message);
byte[] hash = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(message));
byte[] hash = sha.ComputeHash(System.Text.Encoding.UTF8.GetBytes(message));

var sb = new System.Text.StringBuilder();
for (int i = 0; i < hash.Length; i++)
Expand Down
4 changes: 1 addition & 3 deletions src/Runner.Listener/MessageListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ public async Task<TaskAgentMessage> GetNextMessageAsync(CancellationToken token)
}

Trace.Info($"Message '{message.MessageId}' received from session '{_session.SessionId}'.");
Trace.Info($"Message '{message.MessageId}' char length: '{message.Body.Length}', byte length '{System.Text.Encoding.UTF8.GetByteCount(message.Body)}'.");
return message;
}
}
Expand Down Expand Up @@ -320,8 +319,7 @@ private ICryptoTransform GetMessageDecryptor(
var keyManager = HostContext.GetService<IRSAKeyManager>();
using (var rsa = keyManager.GetKey())
{
var padding = _session.UseFipsEncryption ? RSAEncryptionPadding.OaepSHA256 : RSAEncryptionPadding.OaepSHA1;
return aes.CreateDecryptor(rsa.Decrypt(_session.EncryptionKey.Value, padding), message.IV);
return aes.CreateDecryptor(rsa.Decrypt(_session.EncryptionKey.Value, RSAEncryptionPadding.OaepSHA1), message.IV);
}
}
else
Expand Down
7 changes: 2 additions & 5 deletions src/Runner.Worker/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public sealed class Worker : RunnerService, IWorker
{
private readonly TimeSpan _workerStartTimeout = TimeSpan.FromSeconds(30);
private ManualResetEvent _completedCommand = new ManualResetEvent(false);

// Do not mask the values of these secrets
private static HashSet<String> SecretVariableMaskWhitelist = new HashSet<String>(StringComparer.OrdinalIgnoreCase){
private static HashSet<String> SecretVariableMaskWhitelist = new HashSet<String>(StringComparer.OrdinalIgnoreCase){
Constants.Variables.Actions.StepDebug,
Constants.Variables.Actions.RunnerDebug
};
Expand Down Expand Up @@ -59,9 +59,6 @@ public async Task<int> RunAsync(string pipeIn, string pipeOut)
channelMessage = await channel.ReceiveAsync(csChannelMessage.Token);
}

// This is useful for validating that the message wasn't truncated when being sent over the anonymous pipe.
Trace.Info($"Job Message char length: '{channelMessage.Body.Length}', byte length '{System.Text.Encoding.UTF8.GetByteCount(channelMessage.Body)}'.");

// Deserialize the job message.
Trace.Info("Message received.");
ArgUtil.Equal(MessageType.NewJobRequest, channelMessage.MessageType, nameof(channelMessage.MessageType));
Expand Down

0 comments on commit 9d5e458

Please sign in to comment.