GUI editor to tame mod_security rules

βŒˆβŒ‹ βŽ‡ branch:  modseccfg


Check-in [f73ccce5e0]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:change print() to log()
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f73ccce5e049e6e964c18f963477f8f1e7d15477386ce4751cf61df1fe1c4f2e
User & Date: mario 2020-12-22 22:02:36
Context
2020-12-22
22:03
camelcase Vhost and SecRule classes, fix _secruleupdate to recgnize int id and int:offset (β†’float) syntax check-in: 42a623b5ab user: mario tags: trunk
22:02
change print() to log() check-in: f73ccce5e0 user: mario tags: trunk
2020-12-20
20:26
Fix catastrophic backtracking for secrule.help() lookup by splitting regex into cleanup + extraction. Move vhost() lookup into secrule as well. check-in: 88d331b02d user: mario tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to modseccfg/logs.py.

235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
    if id in log_count:
        log_count[id] += 1
    else:
        log_count[id] = 1

# search [id …] from only [file …] and [line …] - using vhosts.linemap{}
def search_id(file, line):
    print("linemap:", file, line)
    if file and line:
        vh = vhosts.vhosts.get(file)
        if vh:
            return vh.line_to_id(int(line))
    return 0









|







235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
    if id in log_count:
        log_count[id] += 1
    else:
        log_count[id] = 1

# search [id …] from only [file …] and [line …] - using vhosts.linemap{}
def search_id(file, line):
    utils.log.debug("linemap:", file, line)
    if file and line:
        vh = vhosts.vhosts.get(file)
        if vh:
            return vh.line_to_id(int(line))
    return 0


Changes to modseccfg/mainwindow.py.

38
39
40
41
42
43
44

45
46
47
48
49
50
51
#-- prepare vhost/rules/logs for UI structures
class ui:

    @inject(sg.PySimpleGUI)
    def print(s):
        if not s.startswith("***"):
            __builtins__["print"](s)


    # make tk widget methods more accessible
    @inject(sg.Element, sg.Window)
    def __getattr__(self, name):
        if "Widget" in self.__dict__ and hasattr(self.Widget, name):
            return getattr(self.Widget, name)
        elif "TKroot" in self.__dict__ and hasattr(self.TKroot, name):







>







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#-- prepare vhost/rules/logs for UI structures
class ui:

    @inject(sg.PySimpleGUI)
    def print(s):
        if not s.startswith("***"):
            __builtins__["print"](s)
    #warnings.simplefilter("ignore") would have been simpler, but PSG uses print() for some

    # make tk widget methods more accessible
    @inject(sg.Element, sg.Window)
    def __getattr__(self, name):
        if "Widget" in self.__dict__ and hasattr(self.Widget, name):
            return getattr(self.Widget, name)
        elif "TKroot" in self.__dict__ and hasattr(self.TKroot, name):

Changes to modseccfg/utils.py.

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
        regex = re.sub(r'\\h(?![^\[]*\])', r'[\ \t\f]', regex)
        #print("re_compile: " + regex)
    return re_compile_orig(regex, *kargs, **kwargs)
@inject(re)
def grep(regex, list, flags=0):
    return [s for s in list if re.search(regex, s, flags)]
    





#-- remote/sshfs bindings
#
# This wraps any modseccfg file operations on config or log files.
# If modseccfg is started with a ssh:/ parameter, then we'll connect
# the remote file system. All file IO uses the mount prefix henceforth;







<
<
<







108
109
110
111
112
113
114



115
116
117
118
119
120
121
        regex = re.sub(r'\\h(?![^\[]*\])', r'[\ \t\f]', regex)
        #print("re_compile: " + regex)
    return re_compile_orig(regex, *kargs, **kwargs)
@inject(re)
def grep(regex, list, flags=0):
    return [s for s in list if re.search(regex, s, flags)]
    





#-- remote/sshfs bindings
#
# This wraps any modseccfg file operations on config or log files.
# If modseccfg is started with a ssh:/ parameter, then we'll connect
# the remote file system. All file IO uses the mount prefix henceforth;