GUI editor to tame mod_security rules

⌈⌋ ⎇ branch:  modseccfg


Check-in [81e5866c7a]

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

Overview
Comment:Use dateutil.parser fuzzy=True
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 81e5866c7a55fbcee2eb140b9bb63c1e7460272f81c3f4072cc4b4ceeee923c2
User & Date: mario 2021-02-02 12:32:12
Context
2021-02-02
16:07
Move to safer Unicode glyphs. Tk doesn't like current system setup: <blockquote> X Error of failed request: BadLength (poly request too large or internal Xlib length error) Major opcode of failed request: 139 (RENDER) Minor opcode of failed request: 20 (RenderAddGlyphs) Serial number of failed request: 28016 Current serial number in output stream: 28018 </blockquote> check-in: acaec56692 user: mario tags: trunk
12:32
Use dateutil.parser fuzzy=True check-in: 81e5866c7a user: mario tags: trunk
2021-01-12
22:51
Man pages (in data_files=) are now handled by pluginconf.setup check-in: d9a54476b3 user: mario tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to logfmt1/logex.py.

127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143

    if not row:
        row = {}
    if iso8601:
        for key in ["date", "request_time", "datetime"]:
            if key in row:
                # the […] wrapping should already be gone at this point
                row[key] = dateutil.parser.parse(row[key].strip("[]"))
    if as_json:
        print(
            json.dumps(row)
        )
    else:
        print(
            re.sub("([@+*#%]?)([\w\-]+)", lambda m: get_field(m, row), output_fields)
        )








|









127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143

    if not row:
        row = {}
    if iso8601:
        for key in ["date", "request_time", "datetime"]:
            if key in row:
                # the […] wrapping should already be gone at this point
                row[key] = dateutil.parser.parse(row[key].strip("[]"), fuzzy=True).isoformat()
    if as_json:
        print(
            json.dumps(row)
        )
    else:
        print(
            re.sub("([@+*#%]?)([\w\-]+)", lambda m: get_field(m, row), output_fields)
        )

Changes to modseccfg/scripts/fix_dateformat.py.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#

import sys, os, re, dateutil.parser

# extract and conversion
rx_dt = re.compile("\[([^\]]*\d\d+[^\]]*\d:\d\d[^\]]*)\]")
def cnv(m):
    d = dateutil.parser.parse(m.group(1))
    return "[{}]".format(d.isoformat())

# filename
fn = "/dev/stdin"
if len(sys.argv) > 1 and sys.argv[1] != "-":
    fn = sys.argv[1]

# iterate over lines
with open(fn, "r", encoding="utf-8") as f:
    for line in f:
        print(re.sub(rx_dt, cnv, line, 1), end="")








|












10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#

import sys, os, re, dateutil.parser

# extract and conversion
rx_dt = re.compile("\[([^\]]*\d\d+[^\]]*\d:\d\d[^\]]*)\]")
def cnv(m):
    d = dateutil.parser.parse(m.group(1), fuzzy=True)
    return "[{}]".format(d.isoformat())

# filename
fn = "/dev/stdin"
if len(sys.argv) > 1 and sys.argv[1] != "-":
    fn = sys.argv[1]

# iterate over lines
with open(fn, "r", encoding="utf-8") as f:
    for line in f:
        print(re.sub(rx_dt, cnv, line, 1), end="")