GUI editor to tame mod_security rules

⌈⌋ ⎇ branch:  modseccfg


Check-in [90de09b9b2]

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

Overview
Comment:Enable fn_preconf() usage only in recipe and crsoptions for now (shouldn't come up for other writer calls anyway)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 90de09b9b2b14cbe4bd50e5a175639cb1db9e111ce0cb3dbb7780f0892cbe95b
User & Date: mario 2020-12-07 22:07:39
Context
2020-12-07
22:09
Update ./ in wrapper scripts/, omit non-_*.py from */* plugin scanning check-in: 1a3bf55fce user: mario tags: trunk
22:07
Enable fn_preconf() usage only in recipe and crsoptions for now (shouldn't come up for other writer calls anyway) check-in: 90de09b9b2 user: mario tags: trunk
22:06
Add support for import/include scripts in install/ check-in: 13ba5d6761 user: mario tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to modseccfg/crsoptions.py.

546
547
548
549
550
551
552


553
554
555
556
557
558
559
    print(secrule)
    
    # prepare update
    replace_rx = re.compile(f"""     # just ↓ in case user picks a different secrule id
        ^[\ \t]*   SecAction   \s+   \"id:({id}|5999|900999),[^"]+\"   .*\\n
    """, re.X|re.M)



    writer.update_or_add(confn, {replace_rx:secrule})


# rescan a *.conf file just for setvar:
def read_setvars(fn):
    src = srvroot.read(fn)
    r = {}







>
>







546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
    print(secrule)
    
    # prepare update
    replace_rx = re.compile(f"""     # just ↓ in case user picks a different secrule id
        ^[\ \t]*   SecAction   \s+   \"id:({id}|5999|900999),[^"]+\"   .*\\n
    """, re.X|re.M)

    # redirect to *.preconf if ctl:ruleRemove mentioned
    confn = writer.fn_preconf(fn=confn, addsrc=str(secrule))
    writer.update_or_add(confn, {replace_rx:secrule})


# rescan a *.conf file just for setvar:
def read_setvars(fn):
    src = srvroot.read(fn)
    r = {}

Changes to modseccfg/recipe.py.

317
318
319
320
321
322
323


324
325
326
327
328
329
330
331
        print(name)

    # write …
    def event(self, event, data):
        #print(data)
        if event == "save":
            text = data["src"]


            writer.append(fn=self.fn, directive=text, value="", comment="")
            # postconfig hooks
            if hasattr(self, self.name):
                getattr(self, self.name)()
        self.w.close()

    # hooks after saving
    def crs_preconfig_includes(self):







>
>
|







317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
        print(name)

    # write …
    def event(self, event, data):
        #print(data)
        if event == "save":
            text = data["src"]
            # possibly redirect to *.preconf
            fn = writer.fn_preconf(self.fn, addsrc=text)
            writer.append(fn=fn, directive=text, value="", comment="")
            # postconfig hooks
            if hasattr(self, self.name):
                getattr(self, self.name)()
        self.w.close()

    # hooks after saving
    def crs_preconfig_includes(self):