File: generate_lua_fingerprints.py

package info (click to toggle)
modsecurity 3.0.14-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 88,920 kB
  • sloc: ansic: 174,512; sh: 43,569; cpp: 26,214; python: 15,734; makefile: 3,864; yacc: 2,947; lex: 1,359; perl: 1,243; php: 42; tcl: 4
file content (26 lines) | stat: -rwxr-xr-x 634 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python

"""
Generates a Lua table of fingerprints.
One can then add, turn off or delete fingerprints from lua.
"""

def make_lua_table(obj):
    """
    Generates table.  Fingerprints don't contain any special chars
    so they don't need to be escaped.  The output may be
    sorted but it is not required.
    """
    fp = obj[u'fingerprints']
    print("sqlifingerprints = {")
    for f in fp:
        print('  ["{0}"]=true,'.format(f))
    print("}")
    return 0

if __name__ == '__main__':
    import sys
    import json
    with open('../c/sqlparse_data.json', 'r') as fd:
        make_lua_table(json.load(fd))