Skip to content

Commit 6511bfd

Browse files
authored
Change regex definitions to use raw strings (#285)
Change regex definitions to use raw strings in order to avoid e.g. pylint throwing `SyntaxError` due to invalid escape sequences like `'\.'` which should either be written as `'\\.'` or `r'\.'` instead. Please refer to https://docs.python.org/3/howto/regex.html for further details. We already have implicit unit tests to cover this change as the regex raw strings are used e.g. in the `migerrors` cronjob, which is automatically generated and checked against the constant fixture version in `tests/test_mig_shared_install.py`.
2 parents e9df079 + 70e9eb5 commit 6511bfd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mig/shared/defaults.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,11 @@
497497

498498
# Detect and ban cracking attempts and unauthorized vulnerability scans
499499
# A pattern to match usernames unambiguously identifying cracking attempts
500-
CRACK_USERNAME_REGEX = '(root|bin|daemon|adm|admin|administrator|superadmin|localadmin|mysqladmin|lp|operator|controller|ftp|irc|nobody|sys|pi|guest|financeiro|Management|www|www-data|mysql|postgres|oracle|mongodb|sybase|redis|hadoop|zimbra|cpanel|plesk|openhabian|tomcat|exim|postfix|sendmail|mailnull|postmaster|mail|uucp|news|teamspeak|git|svn|cvs|user|ftpuser|ubuntu|ubnt|supervisor|csgoserver|device|laboratory|deploy|lighthouse|TO BE ANNOUNCED|support|info|test[0-9]*|user[0-9]*|[0-9]+|root;[a-z0-9]+)'
500+
# NOTE: use raw strings to avoid escapes causing SyntaxError on recent python
501+
CRACK_USERNAME_REGEX = r'(root|bin|daemon|adm|admin|administrator|superadmin|localadmin|mysqladmin|lp|operator|controller|ftp|irc|nobody|sys|pi|guest|financeiro|Management|www|www-data|mysql|postgres|oracle|mongodb|sybase|redis|hadoop|zimbra|cpanel|plesk|openhabian|tomcat|exim|postfix|sendmail|mailnull|postmaster|mail|uucp|news|teamspeak|git|svn|cvs|user|ftpuser|ubuntu|ubnt|supervisor|csgoserver|device|laboratory|deploy|lighthouse|TO BE ANNOUNCED|support|info|test[0-9]*|user[0-9]*|[0-9]+|root;[a-z0-9]+)'
501502
# A pattern to match failed web access prefixes unambiguously identifying
502503
# unauthorized vulnerability scans
503-
CRACK_WEB_REGEX = '((HNAP1|GponForm|provisioning|provision|prov|polycom|yealink|CertProv|phpmyadmin|admin|cfg|wp|wordpress|cms|blog|old|new|test|dev|tmp|temp|remote|mgmt|properties|authenticate|tmui|ddem|a2billing|vtigercrm|secure|rpc|recordings|dana-na)(/.*|)|.*(Login|login|logon|configuration|header|admin|index)\.(php|jsp|asp)|(api/v1/pods|Telerik.Web.UI.WebResource.axd))'
504+
CRACK_WEB_REGEX = r'((HNAP1|GponForm|provisioning|provision|prov|polycom|yealink|CertProv|phpmyadmin|admin|cfg|wp|wordpress|cms|blog|old|new|test|dev|tmp|temp|remote|mgmt|properties|authenticate|tmui|ddem|a2billing|vtigercrm|secure|rpc|recordings|dana-na)(/.*|)|.*(Login|login|logon|configuration|header|admin|index)\.(php|jsp|asp)|(api/v1/pods|Telerik.Web.UI.WebResource.axd))'
504505

505506
# GDP mode settings
506507
gdp_distinguished_field = "GDP"

0 commit comments

Comments
 (0)