v4.5 Demo initial commit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import re
|
||||
|
||||
#Function for validating DNS hostnames
|
||||
def validate_dns_hostname(dns_hostname):
|
||||
try:
|
||||
# Basic validation
|
||||
if not dns_hostname or not isinstance(dns_hostname, str):
|
||||
return False, "DNS Hostname darf nicht leer sein und muss ein String sein"
|
||||
|
||||
# Validate DNS hostname format
|
||||
dns_pattern = r'^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$'
|
||||
if not re.match(dns_pattern, dns_hostname):
|
||||
return False, "Ungültiges DNS Hostname Format"
|
||||
|
||||
# Check maximum length
|
||||
if len(dns_hostname) > 255:
|
||||
return False, "DNS Hostname ist zu lang (max. 255 Zeichen)"
|
||||
|
||||
return True, None
|
||||
|
||||
except Exception as e:
|
||||
return False, f"Fehler bei der DNS Validierung: {str(e)}"
|
||||
|
||||
|
||||
#Function for validating hash values and returning the type
|
||||
def validate_hash(hash_value):
|
||||
try:
|
||||
# Basic validation
|
||||
if not hash_value or not isinstance(hash_value, str):
|
||||
return False, None, "Hash darf nicht leer sein und muss ein String sein"
|
||||
|
||||
# Validate hash format and determine type
|
||||
hash_patterns = {
|
||||
'md5': r'^[a-fA-F0-9]{32}$',
|
||||
'sha1': r'^[a-fA-F0-9]{40}$',
|
||||
'sha256': r'^[a-fA-F0-9]{64}$'
|
||||
}
|
||||
|
||||
for type_name, pattern in hash_patterns.items():
|
||||
if re.match(pattern, hash_value):
|
||||
return True, type_name, None
|
||||
|
||||
return False, None, "Unbekanntes Hash-Format"
|
||||
|
||||
except Exception as e:
|
||||
return False, None, f"Fehler bei der Hash-Validierung: {str(e)}"
|
||||
Reference in New Issue
Block a user