()
| 335 | setattr(options, key, DEFAULTS[key]) |
| 336 | |
| 337 | def load_data(): |
| 338 | global WAF_RECOGNITION_REGEX |
| 339 | |
| 340 | if os.path.isfile(DATA_JSON_FILE): |
| 341 | with open(DATA_JSON_FILE, "r") as f: |
| 342 | DATA_JSON.update(json.load(f)) |
| 343 | |
| 344 | WAF_RECOGNITION_REGEX = "" |
| 345 | for waf in DATA_JSON["wafs"]: |
| 346 | if DATA_JSON["wafs"][waf]["regex"]: |
| 347 | WAF_RECOGNITION_REGEX += "%s|" % ("(?P<waf_%s>%s)" % (waf, DATA_JSON["wafs"][waf]["regex"])) |
| 348 | for signature in DATA_JSON["wafs"][waf]["signatures"]: |
| 349 | SIGNATURES[signature] = waf |
| 350 | WAF_RECOGNITION_REGEX = WAF_RECOGNITION_REGEX.strip('|') |
| 351 | |
| 352 | flags = "".join(set(_ for _ in "".join(re.findall(r"\(\?(\w+)\)", WAF_RECOGNITION_REGEX)))) |
| 353 | WAF_RECOGNITION_REGEX = "(?%s)%s" % (flags, re.sub(r"\(\?\w+\)", "", WAF_RECOGNITION_REGEX)) # patch for "DeprecationWarning: Flags not at the start of the expression" in Python3.7 |
| 354 | else: |
| 355 | exit(colorize("[x] file '%s' is missing" % DATA_JSON_FILE)) |
| 356 | |
| 357 | def init(): |
| 358 | os.chdir(os.path.abspath(os.path.dirname(__file__))) |
no test coverage detected
searching dependent graphs…