DurgaDeepak commited on
Commit
08c9cf1
·
verified ·
1 Parent(s): 760be27

Update core/input_handler.py

Browse files
Files changed (1) hide show
  1. core/input_handler.py +14 -13
core/input_handler.py CHANGED
@@ -1,16 +1,17 @@
1
- def is_public_ip(url):
2
- """
3
- Checks whether the resolved IP address of a URL is public (non-local).
4
- Prevents SSRF by blocking internal addresses like 127.0.0.1 or 192.168.x.x.
5
- """
6
- try:
7
- hostname = urlparse(url).hostname
8
- ip = socket.gethostbyname(hostname)
9
- ip_obj = ipaddress.ip_address(ip)
10
- return ip_obj.is_global # Only allow globally routable IPs
11
- except Exception as e:
12
- logger.warning(f"URL IP validation failed: {e}")
13
- return False
 
14
 
15
 
16
  def fetch_media_from_url(url):
 
1
+ import logging
2
+ import os
3
+ import io
4
+ import tempfile
5
+ import requests
6
+ from PIL import Image
7
+ import cv2
8
+ from urllib.parse import urlparse
9
+ import socket
10
+ import ipaddress
11
+
12
+ # Setup logging
13
+ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
14
+ logger = logging.getLogger(__name__)
15
 
16
 
17
  def fetch_media_from_url(url):