Skip to content

Commit 4859241

Browse files
committed
sanitize input before using it
1 parent 3b21a12 commit 4859241

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

app/intercom.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ def get_text(self):
2323

2424
# Retrieve a conversation from Intercom API by its ID
2525
def fetch_intercom_conversation(conversation_id):
26+
# Sanitize conversation_id to allow only digits (Intercom conversation IDs are numeric)
27+
if not conversation_id.isdigit():
28+
logger.error(f"Invalid conversation_id: {conversation_id}")
29+
return jsonify({"error": f"Invalid conversation_id: {conversation_id}"}), 400
30+
2631
url = "https://api.intercom.io/conversations/" + conversation_id
2732
token = os.getenv('INTERCOM_TOKEN')
2833
if not token:

0 commit comments

Comments
 (0)