File: generate_lua_fingerprints.py

package info (click to toggle)
modsecurity 3.0.4-2
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 37,876 kB
  • sloc: cpp: 26,238; ansic: 15,058; sh: 5,346; python: 2,934; yacc: 2,872; makefile: 1,409; lex: 1,344; php: 42; perl: 36
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))