GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — sqlmap/tests/test_settings_regex.py at master · sqlmapproject/sqlmap Expand file tree/ Copy pathtest_settings_regex.pyMore file actions 66 lines (52 loc) · 2.66 KB / Copy pathtest_settings_regex.pyFile metadata and controls66 lines (52 loc) · 2.66 KB 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 #!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission Compiled-regex battery for lib/core/settings.py. settings.py defines ~40 module-level *_REGEX patterns that drive WAF/error/ charset/IP/title detection. A bad edit to any one of them is a silent failure (detection just stops firing). This compiles them all and pins the behavior of the high-traffic detection patterns with positive + negative cases. """ import os import re import sys import unittest sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from _testutils import bootstrap bootstrap() import lib.core.settings as S from lib.core.common import extractRegexResult class TestAllRegexesCompile(unittest.TestCase): def test_every_regex_constant_compiles(self): names = [n for n in dir(S) if n.endswith("_REGEX")] self.assertGreater(len(names), 20, msg="expected many *_REGEX constants") failures = [] for name in names: value = getattr(S, name) if isinstance(value, str): # some carry a single %s placeholder (e.g. SENSITIVE_DATA_REGEX) - fill it before compiling candidate = value.replace("%s", "X") if "%s" in value else value try: re.compile(candidate) except re.error as ex: failures.append("%s: %s" % (name, ex)) self.assertEqual(failures, [], msg="non-compiling regexes: %s" % failures) class TestDetectionPatterns(unittest.TestCase): def test_ip_address(self): self.assertTrue(re.search(S.IP_ADDRESS_REGEX, "connect to 192.168.0.1 now")) self.assertFalse(re.search(S.IP_ADDRESS_REGEX, "999.999.999.999")) def test_permission_denied(self): self.assertEqual(extractRegexResult(S.PERMISSION_DENIED_REGEX, "access denied for user 'x'"), "access denied") def test_parameter_splitting(self): self.assertEqual(re.split(S.PARAMETER_SPLITTING_REGEX, "a,b;c|d"), ["a", "b", "c", "d"]) def test_html_title(self): self.assertEqual(extractRegexResult(S.HTML_TITLE_REGEX, "<title>Hello</title>"), "Hello") # case-insensitive tag, first-of-two wins, empty/absent -> None (probed) self.assertEqual(extractRegexResult(S.HTML_TITLE_REGEX, "<TITLE>x</TITLE>"), "x") self.assertEqual(extractRegexResult(S.HTML_TITLE_REGEX, "<title>A</title><title>B</title>"), "A") self.assertIsNone(extractRegexResult(S.HTML_TITLE_REGEX, "<title></title>")) self.assertIsNone(extractRegexResult(S.HTML_TITLE_REGEX, "no title here")) if __name__ == "__main__": unittest.main(verbosity=2) |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |