diff options
author | Papoteur <papoteur@mageia.org> | 2022-04-14 20:06:30 +0200 |
---|---|---|
committer | Papoteur <papoteur@mageia.org> | 2022-04-14 20:06:30 +0200 |
commit | d7928e782dfc0edc4262389af4bbf6f602be22ed (patch) | |
tree | 91e472ae7c15ae799e03209a959ec9bfd4cc9154 /src | |
parent | 426ab9ba160fc0e16c7166a8087d686d90503b8f (diff) | |
download | msec-d7928e782dfc0edc4262389af4bbf6f602be22ed.tar msec-d7928e782dfc0edc4262389af4bbf6f602be22ed.tar.gz msec-d7928e782dfc0edc4262389af4bbf6f602be22ed.tar.bz2 msec-d7928e782dfc0edc4262389af4bbf6f602be22ed.tar.xz msec-d7928e782dfc0edc4262389af4bbf6f602be22ed.zip |
Suppress warning of DeprecationWarning: invalid escape sequence in regexp
- set strings as raw strings with r prefix
Diffstat (limited to 'src')
-rwxr-xr-x | src/msec/config.py | 2 | ||||
-rwxr-xr-x | src/msec/libmsec.py | 2 | ||||
-rwxr-xr-x | src/msec/plugins/msec.py | 12 | ||||
-rwxr-xr-x | src/msec/plugins/network.py | 10 | ||||
-rwxr-xr-x | src/msec/plugins/pam.py | 12 | ||||
-rwxr-xr-x | src/msec/plugins/sudo.py | 2 |
6 files changed, 20 insertions, 20 deletions
diff --git a/src/msec/config.py b/src/msec/config.py index ff08b88..ef2946c 100755 --- a/src/msec/config.py +++ b/src/msec/config.py @@ -406,7 +406,7 @@ class PermConfig(MsecConfig): self.options_order = [] self.comments = [] self.log = log - self.regexp = re.compile("^([^\s]*)\s*([a-z]*)\.([a-z]*)\s*([\d]?\d\d\d|current)\s*(force)?\s?([^\s]*)$") + self.regexp = re.compile(r"^([^\s]*)\s*([a-z]*)\.([a-z]*)\s*([\d]?\d\d\d|current)\s*(force)?\s?([^\s]*)$") def merge(self, newconfig, overwrite=False): """Merges parameters from newconfig to current config""" diff --git a/src/msec/libmsec.py b/src/msec/libmsec.py index 00eda9c..fa5a121 100755 --- a/src/msec/libmsec.py +++ b/src/msec/libmsec.py @@ -68,7 +68,7 @@ INSIDE=1 AFTER=2 # regexps -space = re.compile('\s') +space = re.compile(r'\s') # {{{ helper functions def move(old, new): diff --git a/src/msec/plugins/msec.py b/src/msec/plugins/msec.py index 52eb8d7..5b18f62 100755 --- a/src/msec/plugins/msec.py +++ b/src/msec/plugins/msec.py @@ -70,10 +70,10 @@ SYSTEMCTL = '../bin/systemctl' # regexps # X server SECURETTY = '/etc/securetty' -STARTX_REGEXP = '(\s*serverargs=".*) -nolisten tcp(.*")' -XSERVERS_REGEXP = '(\s*[^#]+/usr/bin/X .*) -nolisten tcp(.*)' -GDMCONF_REGEXP = '(\s*command=.*/X.*?) -nolisten tcp(.*)$' -SDDMCONF_REGEXP = re.compile('(.*?)-listen tcp(.*)$') +STARTX_REGEXP = r'(\s*serverargs=".*) -nolisten tcp(.*")' +XSERVERS_REGEXP = r'(\s*[^#]+/usr/bin/X .*) -nolisten tcp(.*)' +GDMCONF_REGEXP = r'(\s*command=.*/X.*?) -nolisten tcp(.*)$' +SDDMCONF_REGEXP = re.compile(r'(.*?)-listen tcp(.*)$') # ctrl-alt-del CTRALTDEL_REGEXP = '^ca::ctrlaltdel:/sbin/shutdown.*' # ssh PermitRootLogin @@ -99,12 +99,12 @@ class msec: # associate helper commands with files self.configfiles.add_config_assoc(INITTAB, '/sbin/telinit q') - self.configfiles.add_config_assoc('/etc(?:/rc.d)?/init.d/(.+)', '[ -f /var/lock/subsys/@1 ] && @0 reload') + self.configfiles.add_config_assoc(r'/etc(?:/rc.d)?/init.d/(.+)', '[ -f /var/lock/subsys/@1 ] && @0 reload') self.configfiles.add_config_assoc(SYSCTLCONF, '/sbin/sysctl -e -p /etc/sysctl.d/51-drakx.conf') self.configfiles.add_config_assoc(SSHDCONFIG, '[ -f /var/lock/subsys/sshd ] && /etc/rc.d/init.d/sshd restart') self.configfiles.add_config_assoc(LILOCONF, '[ `/usr/sbin/detectloader` = LILO ] && /sbin/lilo') self.configfiles.add_config_assoc(JOURNALDCONF, '[ -f /var/lock/subsys/journald ] && systemctl restart journald') - self.configfiles.add_config_assoc('^/etc/issue$', '/usr/bin/killall mingetty') + self.configfiles.add_config_assoc(r'^/etc/issue$', '/usr/bin/killall mingetty') # security options config.SETTINGS['USER_UMASK'] = ("msec.set_user_umask", ['*']) diff --git a/src/msec/plugins/network.py b/src/msec/plugins/network.py index 37959f5..67c72c7 100755 --- a/src/msec/plugins/network.py +++ b/src/msec/plugins/network.py @@ -65,9 +65,9 @@ EXPORT = '/root/.xauth/export' # regexps # X server SECURETTY = '/etc/securetty' -STARTX_REGEXP = '(\s*serverargs=".*) -nolisten tcp(.*")' -XSERVERS_REGEXP = '(\s*[^#]+/usr/bin/X .*) -nolisten tcp(.*)' -GDMCONF_REGEXP = '(\s*command=.*/X.*?) -nolisten tcp(.*)$' +STARTX_REGEXP = r'(\s*serverargs=".*) -nolisten tcp(.*")' +XSERVERS_REGEXP = r'(\s*[^#]+/usr/bin/X .*) -nolisten tcp(.*)' +GDMCONF_REGEXP = r'(\s*command=.*/X.*?) -nolisten tcp(.*)$' # ctrl-alt-del CTRALTDEL_REGEXP = '^ca::ctrlaltdel:/sbin/shutdown.*' # consolehelper @@ -95,12 +95,12 @@ class network: # associate helper commands with files self.configfiles.add_config_assoc(INITTAB, '/sbin/telinit q') - self.configfiles.add_config_assoc('/etc(?:/rc.d)?/init.d/(.+)', '[ -f /var/lock/subsys/@1 ] && @0 reload') + self.configfiles.add_config_assoc(r'/etc(?:/rc.d)?/init.d/(.+)', '[ -f /var/lock/subsys/@1 ] && @0 reload') self.configfiles.add_config_assoc(SYSCTLCONF, '/sbin/sysctl -e -p /etc/sysctl.d/51-drakx.conf') self.configfiles.add_config_assoc(SSHDCONFIG, '[ -f /var/lock/subsys/sshd ] && /etc/rc.d/init.d/sshd restart') self.configfiles.add_config_assoc(LILOCONF, '[ `/usr/sbin/detectloader` = LILO ] && /sbin/lilo') self.configfiles.add_config_assoc(SYSLOGCONF, '[ -f /var/lock/subsys/syslog ] && service syslog reload') - self.configfiles.add_config_assoc('^/etc/issue$', '/usr/bin/killall mingetty') + self.configfiles.add_config_assoc(r'^/etc/issue$', '/usr/bin/killall mingetty') # security options config.SETTINGS['ACCEPT_BOGUS_ERROR_RESPONSES'] = ("network.accept_bogus_error_responses", ['yes', 'no']) diff --git a/src/msec/plugins/pam.py b/src/msec/plugins/pam.py index e02b6d9..72ab688 100755 --- a/src/msec/plugins/pam.py +++ b/src/msec/plugins/pam.py @@ -28,12 +28,12 @@ class pam: SUCCEED_MATCH = '^auth\s+sufficient\s+pam_succeed_if.so\s+use_uid\s+user\s+ingroup\s+wheel\s*$' SUCCEED_LINE = 'auth sufficient pam_succeed_if.so use_uid user ingroup wheel' # password stuff - LENGTH_REGEXP = re.compile('^(password\s+required\s+(?:/lib/security/)?pam_cracklib.so.*?)\sminlen=([0-9]+)\s(.*)') - NDIGITS_REGEXP = re.compile('^(password\s+required\s+(?:/lib/security/)?pam_cracklib.so.*?)\sdcredit=([0-9]+)\s(.*)') - UCREDIT_REGEXP = re.compile('^(password\s+required\s+(?:/lib/security/)?pam_cracklib.so.*?)\sucredit=([0-9]+)\s(.*)') - PASSWORD_REGEXP = '^\s*auth\s+sufficient\s+(?:/lib/security/)?pam_permit.so' - UNIX_REGEXP = re.compile('(^\s*password\s+sufficient\s+(?:/lib/security/)?pam_unix.so.*)\sremember=([0-9]+)(.*)') - PAM_TCB_REGEXP = re.compile('(^\s*password\s+sufficient\s+(?:/lib/security/)?pam_tcb.so.*)') + LENGTH_REGEXP = re.compile(r'^(password\s+required\s+(?:/lib/security/)?pam_cracklib.so.*?)\sminlen=([0-9]+)\s(.*)') + NDIGITS_REGEXP = re.compile(r'^(password\s+required\s+(?:/lib/security/)?pam_cracklib.so.*?)\sdcredit=([0-9]+)\s(.*)') + UCREDIT_REGEXP = re.compile(r'^(password\s+required\s+(?:/lib/security/)?pam_cracklib.so.*?)\sucredit=([0-9]+)\s(.*)') + PASSWORD_REGEXP = r'^\s*auth\s+sufficient\s+(?:/lib/security/)?pam_permit.so' + UNIX_REGEXP = re.compile(r'(^\s*password\s+sufficient\s+(?:/lib/security/)?pam_unix.so.*)\sremember=([0-9]+)(.*)') + PAM_TCB_REGEXP = re.compile(r'(^\s*password\s+sufficient\s+(?:/lib/security/)?pam_tcb.so.*)') def __init__(self, log=None, configfiles=None, root=None): # initializing plugin diff --git a/src/msec/plugins/sudo.py b/src/msec/plugins/sudo.py index 1f9eddd..1dde667 100755 --- a/src/msec/plugins/sudo.py +++ b/src/msec/plugins/sudo.py @@ -20,7 +20,7 @@ except IOError: class sudo: SUDOERS="/etc/sudoers" - SUDO_WHEEL_MATCH = re.compile("^\s*%wheel\s+ALL\s*=\s*\(ALL\)\s+(NOPASSWD:)?\s*ALL") + SUDO_WHEEL_MATCH = re.compile(r"^\s*%wheel\s+ALL\s*=\s*\(ALL\)\s+(NOPASSWD:)?\s*ALL") SUDO_WHEEL = "%wheel\tALL=(ALL)\tALL" SUDO_WHEEL_NO_PASSWORD="%wheel\tALL=(ALL)\tNOPASSWD: ALL" def __init__(self, log=None, configfiles=None, root=None): |