Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit 9c3e495

Browse files
fix(webhook): Use x-hub-signature-256 header as default (#2434)
1 parent 05fe737 commit 9c3e495

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ In case the setup does not work as intended follow the trace of events:
442442
| <a name="input_pool_lambda_timeout"></a> [pool\_lambda\_timeout](#input\_pool\_lambda\_timeout) | Time out for the pool lambda in seconds. | `number` | `60` | no |
443443
| <a name="input_pool_runner_owner"></a> [pool\_runner\_owner](#input\_pool\_runner\_owner) | The pool will deploy runners to the GitHub org ID, set this value to the org to which you want the runners deployed. Repo level is not supported. | `string` | `null` | no |
444444
| <a name="input_prefix"></a> [prefix](#input\_prefix) | The prefix used for naming resources | `string` | `"github-actions"` | no |
445+
| <a name="input_queue_encryption"></a> [queue\_encryption](#input\_queue\_encryption) | Configure how data on queues managed by the modules in ecrypted at REST. Options are encryped via SSE, non encrypted and via KMSS. By default encryptes via SSE is enabled. See for more details the Terraform `aws_sqs_queue` resource https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue. | <pre>object({<br> kms_data_key_reuse_period_seconds = number<br> kms_master_key_id = string<br> sqs_managed_sse_enabled = bool<br> })</pre> | <pre>{<br> "kms_data_key_reuse_period_seconds": null,<br> "kms_master_key_id": null,<br> "sqs_managed_sse_enabled": true<br>}</pre> | no |
445446
| <a name="input_redrive_build_queue"></a> [redrive\_build\_queue](#input\_redrive\_build\_queue) | Set options to attach (optional) a dead letter queue to the build queue, the queue between the webhook and the scale up lambda. You have the following options. 1. Disable by setting `enabled` to false. 2. Enable by setting `enabled` to `true`, `maxReceiveCount` to a number of max retries. | <pre>object({<br> enabled = bool<br> maxReceiveCount = number<br> })</pre> | <pre>{<br> "enabled": false,<br> "maxReceiveCount": null<br>}</pre> | no |
446447
| <a name="input_repository_white_list"></a> [repository\_white\_list](#input\_repository\_white\_list) | List of repositories allowed to use the github app | `list(string)` | `[]` | no |
447448
| <a name="input_role_path"></a> [role\_path](#input\_role\_path) | The path that will be added to role path for created roles, if not set the environment name will be used. | `string` | `null` | no |

Diff for: modules/webhook/lambdas/webhook/src/webhook/handler.test.ts

+10
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ describe('handler', () => {
6161
expect(sendActionRequest).toBeCalled();
6262
});
6363

64+
it('handles workflow job events with 256 hash signature', async () => {
65+
const event = JSON.stringify(workflowjob_event);
66+
const resp = await handle(
67+
{ 'X-Hub-Signature-256': await webhooks.sign(event), 'X-GitHub-Event': 'workflow_job' },
68+
event,
69+
);
70+
expect(resp.statusCode).toBe(201);
71+
expect(sendActionRequest).toBeCalled();
72+
});
73+
6474
it('does not handle other events', async () => {
6575
const event = JSON.stringify(workflowjob_event);
6676
const resp = await handle({ 'X-Hub-Signature': await webhooks.sign(event), 'X-GitHub-Event': 'push' }, event);

Diff for: modules/webhook/lambdas/webhook/src/webhook/handler.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,12 @@ async function verifySignature(
9595
body: string,
9696
environment: string,
9797
): Promise<number> {
98-
const signature = headers['x-hub-signature'] as string;
98+
let signature;
99+
if ('x-hub-signature-256' in headers) {
100+
signature = headers['x-hub-signature-256'] as string;
101+
} else {
102+
signature = headers['x-hub-signature'] as string;
103+
}
99104
if (!signature) {
100105
logger.error(
101106
"Github event doesn't have signature. This webhook requires a secret to be configured.",

0 commit comments

Comments
 (0)