Skip to content

Commit 7ae7e8c

Browse files
authored
Merge pull request #2843 from davidhubbell/main
Resolves Python 3.13 compatibility issues for the EventBridge webhook lambda code
2 parents 1873cd0 + 75034e7 commit 7ae7e8c

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

eventbridge-webhooks/1-stripe/src/app.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import base64
77
import hmac
88
import hashlib
9-
from cgi import parse_header
109
import boto3
1110
import botocore
1211
import botocore.session
@@ -200,7 +199,7 @@ def get_content_type(headers):
200199

201200
if raw_content_type is None:
202201
return None
203-
content_type, _ = parse_header(raw_content_type)
202+
content_type = raw_content_type.split(';')[0].strip()
204203
return content_type
205204

206205

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
boto3
1+
boto3
2+
aws-secretsmanager-caching

eventbridge-webhooks/2-github/src/app.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import base64
77
import hmac
88
import hashlib
9-
from cgi import parse_header
109
import boto3
1110
import botocore
1211
import botocore.session
@@ -160,7 +159,7 @@ def get_content_type(headers):
160159

161160
if raw_content_type is None:
162161
return None
163-
content_type, _ = parse_header(raw_content_type)
162+
content_type = raw_content_type.split(';')[0].strip()
164163
return content_type
165164

166165

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
boto3
1+
boto3
2+
aws-secretsmanager-caching

eventbridge-webhooks/3-twilio/src/app.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import hmac
88
import hashlib
99
from functools import reduce
10-
from cgi import parse_header
1110
import boto3
1211
import botocore
1312
import botocore.session
@@ -18,7 +17,7 @@
1817
cache_config = SecretCacheConfig()
1918
cache = SecretCache(config=cache_config, client=client)
2019

21-
github_webhook_secret_arn = os.environ.get('TWILIO_WEBHOOK_SECRET_ARN')
20+
twilio_webhook_secret_arn = os.environ.get('TWILIO_WEBHOOK_SECRET_ARN')
2221
event_bus_name = os.environ.get('EVENT_BUS_NAME', 'default')
2322

2423
event_bridge_client = boto3.client('events')
@@ -114,7 +113,7 @@ def contains_valid_signature(payload_object, url, event_signature):
114113
"""Check for the payload signature
115114
Twilio documentation: https://www.twilio.com/docs/usage/webhooks/webhooks-security#validating-signatures-from-twilio
116115
"""
117-
secret = cache.get_secret_string(github_webhook_secret_arn)
116+
secret = cache.get_secret_string(twilio_webhook_secret_arn)
118117
payload_bytes = get_payload_bytes(
119118
url=url,
120119
payload_object=payload_object
@@ -166,7 +165,7 @@ def get_content_type(headers):
166165

167166
if raw_content_type is None:
168167
return None
169-
content_type, _ = parse_header(raw_content_type)
168+
content_type = raw_content_type.split(';')[0].strip()
170169
return content_type
171170

172171

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
boto3
1+
boto3
2+
aws-secretsmanager-caching

0 commit comments

Comments
 (0)