diff --git a/CyberCP/secMiddleware.py b/CyberCP/secMiddleware.py index a945a41cb..9210149db 100644 --- a/CyberCP/secMiddleware.py +++ b/CyberCP/secMiddleware.py @@ -167,14 +167,14 @@ class secMiddleware: if os.path.exists(ProcessUtilities.debugPath): logging.writeToFile(f'Item type detected as list') for items in value: - if items.find('- -') > -1 or items.find('\n') > -1 or items.find(';') > -1 or items.find( + if isinstance(items, str) and (items.find('- -') > -1 or items.find('\n') > -1 or items.find(';') > -1 or items.find( '&&') > -1 or items.find('|') > -1 or items.find('...') > -1 \ or items.find("`") > -1 or items.find("$") > -1 or items.find( "(") > -1 or items.find(")") > -1 \ or items.find("'") > -1 or items.find("[") > -1 or items.find( "]") > -1 or items.find("{") > -1 or items.find("}") > -1 \ or items.find(":") > -1 or items.find("<") > -1 or items.find( - ">") > -1 or items.find("&") > -1: + ">") > -1 or items.find("&") > -1): logging.writeToFile(request.body) final_dic = { 'error_message': "Data supplied is not accepted, following characters are not allowed in the input ` $ & ( ) [ ] { } ; : ‘ < >.", @@ -202,7 +202,7 @@ class secMiddleware: if isAPIEndpoint: # For API endpoints, still check for the most dangerous command injection characters - if (value.find('- -') > -1 or value.find('\n') > -1 or value.find(';') > -1 or + if isinstance(value, (str, bytes)) and (value.find('- -') > -1 or value.find('\n') > -1 or value.find(';') > -1 or value.find('&&') > -1 or value.find('||') > -1 or value.find('|') > -1 or value.find('...') > -1 or value.find("`") > -1 or value.find("$") > -1 or value.find('../') > -1 or value.find('../../') > -1): diff --git a/aiScanner/aiScannerManager.py b/aiScanner/aiScannerManager.py index 4867ff836..3e32c1017 100644 --- a/aiScanner/aiScannerManager.py +++ b/aiScanner/aiScannerManager.py @@ -81,7 +81,7 @@ class AIScannerManager: # Get user's websites for scan selection using ACL-aware method try: websites = ACLManager.findWebsiteObjects(currentACL, userID) - self.logger.writeToFile(f'[AIScannerManager.scannerHome] Found {websites.count()} websites for {admin.userName}') + self.logger.writeToFile(f'[AIScannerManager.scannerHome] Found {len(websites)} websites for {admin.userName}') except Exception as e: self.logger.writeToFile(f'[AIScannerManager.scannerHome] Error fetching websites: {str(e)}') websites = [] diff --git a/aiScanner/templates/aiScanner/scanner.html b/aiScanner/templates/aiScanner/scanner.html index c278ca8f3..a80b374bf 100644 --- a/aiScanner/templates/aiScanner/scanner.html +++ b/aiScanner/templates/aiScanner/scanner.html @@ -1563,6 +1563,19 @@ setInterval(() => { // Scheduled Scans Functions function showScheduleModal() { + // Reset form for new schedule + document.getElementById('scheduleForm').reset(); + document.getElementById('scheduleId').value = ''; + + // Uncheck all domain checkboxes + document.querySelectorAll('input[name="domains"]').forEach(cb => cb.checked = false); + + // Reset checkboxes to their defaults + document.getElementById('emailNotifications').checked = true; + document.getElementById('notifyOnThreats').checked = true; + document.getElementById('notifyOnCompletion').checked = false; + document.getElementById('notifyOnFailure').checked = true; + $('#scheduleModal').modal('show'); } @@ -1631,8 +1644,16 @@ function displayScheduledScans(scans) { } function saveScheduledScan() { - const formData = new FormData(document.getElementById('scheduleForm')); - const data = Object.fromEntries(formData); + const form = document.getElementById('scheduleForm'); + const formData = new FormData(form); + const data = {}; + + // Process form data, excluding checkboxes and multi-select fields + for (let [key, value] of formData.entries()) { + if (!['email_notifications', 'notify_on_threats', 'notify_on_completion', 'notify_on_failure', 'domains'].includes(key)) { + data[key] = value; + } + } // Get selected domains const selectedDomains = Array.from(document.querySelectorAll('input[name="domains"]:checked')) @@ -1652,6 +1673,12 @@ function saveScheduledScan() { data.notification_emails = notificationEmails; + // Convert checkbox values to booleans explicitly + data.email_notifications = document.getElementById('emailNotifications').checked; + data.notify_on_threats = document.getElementById('notifyOnThreats').checked; + data.notify_on_completion = document.getElementById('notifyOnCompletion').checked; + data.notify_on_failure = document.getElementById('notifyOnFailure').checked; + fetch('/aiscanner/scheduled-scans/', { method: 'POST', headers: {