Skip to content

Commit 1255e09

Browse files
committed
remove validation output
1 parent dfd5541 commit 1255e09

File tree

1 file changed

+0
-10
lines changed

1 file changed

+0
-10
lines changed

rubberduckvba.Server/WebhookSignatureValidationService.cs

-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using rubberduckvba.Server.Api.Admin;
2-
using System.Diagnostics;
32
using System.Security.Cryptography;
43
using System.Text;
54

@@ -19,52 +18,43 @@ string[] xHubSignature256
1918
if (!(userAgent ?? string.Empty).StartsWith("GitHub-Hookshot/"))
2019
{
2120
// user agent must be GitHub hookshot
22-
LogMissingHeader("USER-AGENT");
2321
return false;
2422
}
2523

2624
if (!xGitHubEvent.Contains("push"))
2725
{
2826
// only authenticate push events
29-
LogMissingHeader("X-GITHUB-EVENT");
3027
return false;
3128
}
3229

3330
if (!Guid.TryParse(xGitHubDelivery.SingleOrDefault(), out _))
3431
{
3532
// delivery should parse as a GUID
36-
LogMissingHeader("X-GITHUB-DELIVERY");
3733
return false;
3834
}
3935

4036
if (!xHubSignature.Any())
4137
{
4238
// SHA-1 signature header must be present
43-
LogMissingHeader("X-HUB-SIGNATURE");
4439
return false;
4540
}
4641

4742
var signature = xHubSignature256.SingleOrDefault();
4843
if (signature == default)
4944
{
5045
// SHA-256 signature header must be present
51-
LogMissingHeader("X-HUB-SIGNATURE-256");
5246
return false;
5347
}
5448

5549
if (!IsValidSignature(signature, payload))
5650
{
5751
// SHA-256 signature must match
58-
Debug.WriteLine("Signature validation failed");
5952
return false;
6053
}
6154

6255
return true;
6356
}
6457

65-
//[Conditional("DEBUG")]
66-
private void LogMissingHeader(string header) => Console.WriteLine($"** Webhook validation failed. Missing header: [{header}]");
67-
6858
private bool IsValidSignature(string? signature, string payload)
6959
{
7060
if (string.IsNullOrWhiteSpace(signature))

0 commit comments

Comments
 (0)