mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-10 23:36:11 +01:00
This commit is contained in:
@@ -35,8 +35,12 @@ class secMiddleware:
|
|||||||
logging.writeToFile(f'Path vs the final url : {pathActual}')
|
logging.writeToFile(f'Path vs the final url : {pathActual}')
|
||||||
logging.writeToFile(FinalURL)
|
logging.writeToFile(FinalURL)
|
||||||
|
|
||||||
|
# Define webhook pattern for secure matching
|
||||||
|
import re
|
||||||
|
webhook_pattern = re.compile(r'^/websites/[^/]+/(webhook|gitNotify)/?$')
|
||||||
|
|
||||||
if pathActual == "/backup/localInitiate" or pathActual == '/' or pathActual == '/verifyLogin' or pathActual == '/logout' or pathActual.startswith('/api')\
|
if pathActual == "/backup/localInitiate" or pathActual == '/' or pathActual == '/verifyLogin' or pathActual == '/logout' or pathActual.startswith('/api')\
|
||||||
or pathActual.endswith('/webhook') or pathActual.startswith('/cloudAPI') or pathActual.endswith('/gitNotify'):
|
or webhook_pattern.match(pathActual) or pathActual.startswith('/cloudAPI'):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if os.path.exists(ProcessUtilities.debugPath):
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
@@ -102,6 +106,13 @@ class secMiddleware:
|
|||||||
logging.writeToFile('Request body detected.. scanning')
|
logging.writeToFile('Request body detected.. scanning')
|
||||||
logging.writeToFile(str(request.body))
|
logging.writeToFile(str(request.body))
|
||||||
|
|
||||||
|
# Skip validation entirely for webhook endpoints
|
||||||
|
# Webhook URLs are: /websites/<domain>/webhook or /websites/<domain>/gitNotify
|
||||||
|
# Use the same webhook pattern defined above
|
||||||
|
if webhook_pattern.match(pathActual):
|
||||||
|
response = self.get_response(request)
|
||||||
|
return response
|
||||||
|
|
||||||
# logging.writeToFile(request.body)
|
# logging.writeToFile(request.body)
|
||||||
try:
|
try:
|
||||||
data = json.loads(request.body)
|
data = json.loads(request.body)
|
||||||
@@ -115,9 +126,6 @@ class secMiddleware:
|
|||||||
logging.writeToFile(f'Key being scanned {str(key)}')
|
logging.writeToFile(f'Key being scanned {str(key)}')
|
||||||
logging.writeToFile(f'Value being scanned {str(value)}')
|
logging.writeToFile(f'Value being scanned {str(value)}')
|
||||||
|
|
||||||
if pathActual.find('gitNotify') > -1 or pathActual.endswith('/webhook') or pathActual.endswith('/gitNotify'):
|
|
||||||
break
|
|
||||||
|
|
||||||
# Skip validation for ports key to allow port ranges with colons
|
# Skip validation for ports key to allow port ranges with colons
|
||||||
if key == 'ports':
|
if key == 'ports':
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user