Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added logs for debugging #643

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions telegram/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

import telebot
import requests
import logging


logger = logging.getLogger(__name__)


def get_telegram_safe_ips():
Expand All @@ -42,6 +46,8 @@ def telebot_respond(request):
# if client_ip not in telegram_ips:
# raise PermissionDenied("Invalid IP address")
Comment on lines 46 to 47
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 issue (security): Consider re-enabling the IP validation check for security

Commented out IP validation could expose the endpoint to requests from unauthorized sources. If there's a specific reason for disabling this check, consider implementing alternative security controls.


logger.info(request.headers)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 suggestion (security): Avoid logging raw request headers as they may contain sensitive information

Consider logging only specific headers needed for debugging or implement header filtering to redact sensitive data before logging.

    safe_headers = {k: v for k, v in request.headers.items() if k.lower() in ['user-agent', 'content-type', 'content-length']}
    logger.info(safe_headers)


if (
request.headers.get("X-Telegram-Bot-Api-Secret-Token")
!= settings.TELEGRAM_BOT_API_SECRET
Expand Down
Loading