diff --git a/secrules/rules01.py b/secrules/rules01.py index c44aa6c462d21d3095133ef05c6c6697367670d6_c2VjcnVsZXMvcnVsZXMwMS5weQ==..806096d776f712e17c17a3c3f0994c0ea855fe6d_c2VjcnVsZXMvcnVsZXMwMS5weQ== 100644 --- a/secrules/rules01.py +++ b/secrules/rules01.py @@ -2,5 +2,5 @@ __version__ = '1.0' # __all__ = ['rule1201', 'rule1202', 'rule1203'] -from .common import level_rule +from ovms import dvidef, prvdef, syidef, uaidef, user from ovms.rtl import lib @@ -6,9 +6,6 @@ from ovms.rtl import lib -from ovms import syidef, uaidef, prvdef, dvidef, ossdef -from ovms import user -from ovms import starlet -from ovms import itemList -from ovms import crtl + +from .common import level_rule @level_rule(1) @@ -209,7 +206,7 @@ for u in list(all_users.values()): try: lib.getdvi(dvidef.DVI__DEVNAM, None, u.defdev) - except: + except OSError: if ftm: print('0106"3"', u.username.decode(), file=fo) else: @@ -232,7 +229,7 @@ for u in list(all_users.values()): try: lib.getdvi(dvidef.DVI__AVL, None, u.defdev) - except: + except OSError: if ftm: print('0107"3"', u.username.decode(), file=fo) else: diff --git a/secrules/rules02.py b/secrules/rules02.py index c44aa6c462d21d3095133ef05c6c6697367670d6_c2VjcnVsZXMvcnVsZXMwMi5weQ==..806096d776f712e17c17a3c3f0994c0ea855fe6d_c2VjcnVsZXMvcnVsZXMwMi5weQ== 100644 --- a/secrules/rules02.py +++ b/secrules/rules02.py @@ -1,6 +1,5 @@ # -*- coding: iso-8859-1 -*- __version__ = '1.0' -from .common import level_rule -import os, os.path +from ovms import itemList, ossdef, ssdef, starlet from ovms.rtl import lib @@ -6,8 +5,3 @@ from ovms.rtl import lib -from ovms import syidef, uaidef, prvdef, dvidef, ossdef, ssdef -from ovms import user -from ovms import starlet -from ovms import itemList -from ovms import crtl from ovms.rtl.lib.FindFile import FindFile @@ -12,5 +6,7 @@ from ovms.rtl.lib.FindFile import FindFile +from .common import level_rule + VMSError = OSError diff --git a/secrules/rules03.py b/secrules/rules03.py index c44aa6c462d21d3095133ef05c6c6697367670d6_c2VjcnVsZXMvcnVsZXMwMy5weQ==..806096d776f712e17c17a3c3f0994c0ea855fe6d_c2VjcnVsZXMvcnVsZXMwMy5weQ== 100644 --- a/secrules/rules03.py +++ b/secrules/rules03.py @@ -1,4 +1,6 @@ # -*- coding: iso-8859-1 -*- __version__ = '1.0' +from ovms.rtl.lib.FindFile import FindFile + from .common import level_rule @@ -4,5 +6,4 @@ from .common import level_rule -from ovms.rtl.lib.FindFile import FindFile from .get_security import get_security diff --git a/secrules/rules04.py b/secrules/rules04.py index c44aa6c462d21d3095133ef05c6c6697367670d6_c2VjcnVsZXMvcnVsZXMwNC5weQ==..806096d776f712e17c17a3c3f0994c0ea855fe6d_c2VjcnVsZXMvcnVsZXMwNC5weQ== 100644 --- a/secrules/rules04.py +++ b/secrules/rules04.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- __version__ = '1.0' -from .common import level_rule +from ovms import dcdef, dvidef, dvsdef, itemList, ossdef, rms, rmsdef, ssdef, starlet from ovms.rtl import lib @@ -5,4 +5,2 @@ from ovms.rtl import lib -from ovms import starlet -from ovms import ossdef, ssdef, rmsdef, dvsdef, dcdef, dvidef, itemList from ovms.rtl.lib.FindFile import FindFile @@ -8,3 +6,4 @@ from ovms.rtl.lib.FindFile import FindFile -from ovms import rms +from ovms.starlet.DeviceScan import DeviceScan + from secrules import get_security @@ -10,5 +9,6 @@ from secrules import get_security -from ovms.starlet.DeviceScan import DeviceScan + +from .common import level_rule VMSError = OSError @@ -104,7 +104,7 @@ while True: try: sts, device, devCtx, d = starlet.device_scan(b'*', devItm, devCtx) - except: + except OSError: break if not lib.getdvi(dvidef.DVI__MNT, device_name=device)[1]: continue @@ -145,7 +145,7 @@ while True: try: sts, device, devCtx, d = starlet.device_scan(b'*', devItm, devCtx) - except: + except OSError: break if not lib.getdvi(dvidef.DVI__MNT, device_name=device)[1]: continue @@ -308,7 +308,7 @@ while True: try: sts, device, devCtx, d = starlet.device_scan(b'*', devItm, devCtx) - except: + except OSError: break if not lib.getdvi(dvidef.DVI__MNT, device_name=device)[1]: continue diff --git a/secrules/rules05.py b/secrules/rules05.py index c44aa6c462d21d3095133ef05c6c6697367670d6_c2VjcnVsZXMvcnVsZXMwNS5weQ==..806096d776f712e17c17a3c3f0994c0ea855fe6d_c2VjcnVsZXMvcnVsZXMwNS5weQ== 100644 --- a/secrules/rules05.py +++ b/secrules/rules05.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- __version__ = '1.0' -from .common import level_rule +from ovms import starlet, syidef, uaidef, user from ovms.rtl import lib @@ -5,7 +5,6 @@ from ovms.rtl import lib -from ovms import syidef, uaidef -from ovms import user -from ovms import starlet + +from .common import level_rule maxsysgroup = lib.getsyi(syidef.SYI__MAXSYSGROUP)[1] all_users = None diff --git a/secrules/rules06.py b/secrules/rules06.py index c44aa6c462d21d3095133ef05c6c6697367670d6_c2VjcnVsZXMvcnVsZXMwNi5weQ==..806096d776f712e17c17a3c3f0994c0ea855fe6d_c2VjcnVsZXMvcnVsZXMwNi5weQ== 100644 --- a/secrules/rules06.py +++ b/secrules/rules06.py @@ -1,4 +1,10 @@ # -*- coding: iso-8859-1 -*- __version__ = '1.0' +import os + +from ovms import syidef +from ovms.rtl import lib +from ovms.rtl.lib.FindFile import file_exists + from .common import level_rule @@ -4,7 +10,3 @@ from .common import level_rule -import os -from ovms import starlet -from ovms.rtl import lib -from ovms import syidef from .DisplayProxy import DisplayProxy from .user_exists import user_exists @@ -9,6 +11,5 @@ from .DisplayProxy import DisplayProxy from .user_exists import user_exists -from ovms.rtl.lib.FindFile import FindFile, file_exists maxsysgroup = lib.getsyi(syidef.SYI__MAXSYSGROUP)[1] @@ -71,9 +72,9 @@ local_users_str, file=fo, ) - for l in local_users: - if (l != b'*') and (l != b''): - if user_exists(l)[0] is None: + for usr in local_users: + if (usr != b'*') and (usr != b''): + if user_exists(usr)[0] is None: if fmt: print( '0602', @@ -86,7 +87,7 @@ '2', proxy_node.decode(), proxy_user.decode(), - l.decode(), + usr.decode(), file=fo, ) print( @@ -128,8 +129,8 @@ default_user.decode(), file=fo, ) - for l in local_users: - if (l != b'*') and (l != b''): + for usr in local_users: + if (usr != b'*') and (usr != b''): g, m = user_exists(local_users) if (g is not None) and (g <= maxsysgroup): if fmt: @@ -140,7 +141,7 @@ print( proxy_node.decode(), proxy_user.decode(), - l.decode(), + usr.decode(), file=fo, ) diff --git a/secrules/rules07.py b/secrules/rules07.py index c44aa6c462d21d3095133ef05c6c6697367670d6_c2VjcnVsZXMvcnVsZXMwNy5weQ==..806096d776f712e17c17a3c3f0994c0ea855fe6d_c2VjcnVsZXMvcnVsZXMwNy5weQ== 100644 --- a/secrules/rules07.py +++ b/secrules/rules07.py @@ -1,6 +1,5 @@ # -*- coding: iso-8859-1 -*- __version__ = '1.0' -from .common import level_rule -from ovms import starlet +from ovms import dcdef, dvidef, itemList, ossdef, ssdef, starlet from ovms.rtl import lib @@ -6,7 +5,3 @@ from ovms.rtl import lib -from ovms import ssdef, kgbdef, ossdef, dcdef, dvidef -from ovms import itemList -from secrules import get_security -from secrules import user_exists from ovms.starlet.DeviceScan import DeviceScan @@ -11,5 +6,9 @@ from ovms.starlet.DeviceScan import DeviceScan +from secrules import get_security, user_exists + +from .common import level_rule + VMSError = OSError ids = ( diff --git a/secrules/rules08.py b/secrules/rules08.py index c44aa6c462d21d3095133ef05c6c6697367670d6_c2VjcnVsZXMvcnVsZXMwOC5weQ==..806096d776f712e17c17a3c3f0994c0ea855fe6d_c2VjcnVsZXMvcnVsZXMwOC5weQ== 100644 --- a/secrules/rules08.py +++ b/secrules/rules08.py @@ -1,4 +1,6 @@ # -*- coding: iso-8859-1 -*- __version__ = '1.0' +from ovms import uaidef, user + from .common import level_rule @@ -4,7 +6,4 @@ from .common import level_rule -from ovms import starlet -from ovms import user -from ovms import uaidef @level_rule(1) diff --git a/secrules/rules09.py b/secrules/rules09.py index c44aa6c462d21d3095133ef05c6c6697367670d6_c2VjcnVsZXMvcnVsZXMwOS5weQ==..806096d776f712e17c17a3c3f0994c0ea855fe6d_c2VjcnVsZXMvcnVsZXMwOS5weQ== 100644 --- a/secrules/rules09.py +++ b/secrules/rules09.py @@ -1,5 +1,4 @@ # -*- coding: iso-8859-1 -*- __version__ = '1.0' -from .common import level_rule import os @@ -5,3 +4,4 @@ import os -from ovms import starlet + +from ovms import itemList, ossdef, starlet from ovms.rtl import lib @@ -7,5 +7,3 @@ from ovms.rtl import lib -from ovms import itemList -from ovms import ossdef from ovms.rtl.lib.FindFile import FindFile, file_exists @@ -10,5 +8,7 @@ from ovms.rtl.lib.FindFile import FindFile, file_exists +from .common import level_rule + @level_rule(2) def rule0901(fo, fmt): @@ -19,6 +19,6 @@ can allow unauthorized users to modify their own or another user's execution environment.""" - ebit = 0x4 + # ebit = 0x4 wbit = 0x2 dbit = 0x8 @@ -23,6 +23,6 @@ wbit = 0x2 dbit = 0x8 - rbit = 0x1 + # rbit = 0x1 if not fmt: print(file=fo) diff --git a/secrules/rules10.py b/secrules/rules10.py index c44aa6c462d21d3095133ef05c6c6697367670d6_c2VjcnVsZXMvcnVsZXMxMC5weQ==..806096d776f712e17c17a3c3f0994c0ea855fe6d_c2VjcnVsZXMvcnVsZXMxMC5weQ== 100644 --- a/secrules/rules10.py +++ b/secrules/rules10.py @@ -1,4 +1,6 @@ # -*- coding: iso-8859-1 -*- __version__ = '1.0' +import os + from .common import level_rule @@ -4,5 +6,4 @@ from .common import level_rule -import os @level_rule(2) diff --git a/secrules/rules11.py b/secrules/rules11.py index c44aa6c462d21d3095133ef05c6c6697367670d6_c2VjcnVsZXMvcnVsZXMxMS5weQ==..806096d776f712e17c17a3c3f0994c0ea855fe6d_c2VjcnVsZXMvcnVsZXMxMS5weQ== 100644 --- a/secrules/rules11.py +++ b/secrules/rules11.py @@ -1,5 +1,4 @@ # -*- coding: iso-8859-1 -*- __version__ = '1.0' -from .common import level_rule import os @@ -5,3 +4,4 @@ import os -from ovms import starlet + +from ovms import itemList, ossdef, prvdef, starlet, syidef, uaidef, user from ovms.rtl import lib @@ -7,6 +7,2 @@ from ovms.rtl import lib -from ovms import user -from ovms import ossdef, uaidef, syidef, prvdef -from ovms import itemList -from ovms.rtl.lib.FindFile import FindFile from ovms.rtl.lib.FindFile import file_exists @@ -12,4 +8,6 @@ from ovms.rtl.lib.FindFile import file_exists + +from .common import level_rule from .getMailObjectInfo import getMailObjectInfo diff --git a/secrules/rules12.py b/secrules/rules12.py index c44aa6c462d21d3095133ef05c6c6697367670d6_c2VjcnVsZXMvcnVsZXMxMi5weQ==..806096d776f712e17c17a3c3f0994c0ea855fe6d_c2VjcnVsZXMvcnVsZXMxMi5weQ== 100644 --- a/secrules/rules12.py +++ b/secrules/rules12.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- __version__ = '1.0' -from .common import level_rule +from ovms import queues, quidef from ovms.rtl import lib @@ -5,5 +5,6 @@ from ovms.rtl import lib -from ovms import queues, quidef + +from .common import level_rule accname = lib.get_accnam('QUEUE')[1] diff --git a/secrules/rules13.py b/secrules/rules13.py index c44aa6c462d21d3095133ef05c6c6697367670d6_c2VjcnVsZXMvcnVsZXMxMy5weQ==..806096d776f712e17c17a3c3f0994c0ea855fe6d_c2VjcnVsZXMvcnVsZXMxMy5weQ== 100644 --- a/secrules/rules13.py +++ b/secrules/rules13.py @@ -1,6 +1,5 @@ # -*- coding: iso-8859-1 -*- __version__ = '1.0' -from .common import level_rule -from ovms import starlet +from ovms import itemList, ossdef, rmsdef, ssdef, starlet, uaidef, user from ovms.rtl import lib @@ -6,6 +5,3 @@ from ovms.rtl import lib -from ovms import user -from ovms import rmsdef, ossdef, ssdef, uaidef -from ovms import itemList from ovms.rtl.lib.FindFile import FindFile, file_exists @@ -10,5 +6,7 @@ from ovms.rtl.lib.FindFile import FindFile, file_exists +from .common import level_rule + VMSError = OSError diff --git a/secrules/rules14.py b/secrules/rules14.py index c44aa6c462d21d3095133ef05c6c6697367670d6_c2VjcnVsZXMvcnVsZXMxNC5weQ==..806096d776f712e17c17a3c3f0994c0ea855fe6d_c2VjcnVsZXMvcnVsZXMxNC5weQ== 100644 --- a/secrules/rules14.py +++ b/secrules/rules14.py @@ -1,3 +1,4 @@ # -*- coding: iso-8859-1 -*- +import os from typing import Tuple @@ -3,2 +4,6 @@ from typing import Tuple + +from ovms import rms, rmsdef +from ovms.rtl.lib import FindFile + from .common import level_rule @@ -4,8 +9,5 @@ from .common import level_rule -import os -from ovms.rtl.lib import FindFile -from ovms import rms -from ovms import rmsdef + __version__ = '1.0' @@ -87,7 +89,6 @@ auth = None hasPriv = False instr = False - state = 0 - for l in r: - if l == '': + for ln in r: + if ln == '': continue @@ -93,4 +94,4 @@ continue - if l[0] != ' ': - dspec = l.replace('.000000', '') + if ln[0] != ' ': + dspec = ln.replace('.000000', '') fspec = '' @@ -96,4 +97,4 @@ fspec = '' - elif ';' in l: + elif ';' in ln: priv = auth = None hasPriv = False @@ -98,6 +99,6 @@ priv = auth = None hasPriv = False - l = l.split() - fspec = l[0] - instr = len(l) > 1 + ln = ln.split() + fspec = ln[0] + instr = len(ln) > 1 if instr: @@ -103,5 +104,5 @@ if instr: - l = l[1:] - if 'Prv' in l: + ln = ln[1:] + if 'Prv' in ln: hasPriv = True elif not instr: @@ -106,5 +107,5 @@ hasPriv = True elif not instr: - l = l.split() - if 'Prv' in l: + ln = ln.split() + if 'Prv' in ln: hasPriv = True @@ -110,8 +111,8 @@ hasPriv = True - elif 'Privileges = ' in l: - priv = l - elif 'Authorized = ' in l: - auth = l + elif 'Privileges = ' in ln: + priv = ln + elif 'Authorized = ' in ln: + auth = ln with FindFile.FindFile( fspec.encode(), dspec.encode() ) as fi: # type: ignore diff --git a/secrules/rules15.py b/secrules/rules15.py index c44aa6c462d21d3095133ef05c6c6697367670d6_c2VjcnVsZXMvcnVsZXMxNS5weQ==..806096d776f712e17c17a3c3f0994c0ea855fe6d_c2VjcnVsZXMvcnVsZXMxNS5weQ== 100644 --- a/secrules/rules15.py +++ b/secrules/rules15.py @@ -1,3 +1,5 @@ # -*- coding: iso-8859-1 -*- +import os + from .common import level_rule @@ -3,6 +5,4 @@ from .common import level_rule -import os -from ovms.rtl.lib import FindFile __version__ = '1.0' @@ -16,6 +16,6 @@ with os.popen('TCPIP SHOW SERVICES') as p: r = [x[:-1].rstrip() for x in p] - for l in r: - if l == '': + for ln in r: + if ln == '': continue @@ -21,3 +21,3 @@ continue - if l[:7] == 'Service': + if ln[:7] == 'Service': continue @@ -23,5 +23,5 @@ continue - s = l.split() + s = ln.split() if s[0] in 'FINGER,FTP,RLOGIN,SNMP,TELNET,REXEC,RSH': if s[5] == '0.0.0.0': v = '%s %s' % (s[0], s[6])