This function calls a class that parses the input HTML page to fingerprint the back-end database management system >>> from lib.core.enums import DBMS >>> htmlParser("Warning: mysql_fetch_array() expects parameter 1 to be resource") == DBMS.MYSQL True >>> threadData = getCu
(page)
| 59 | kb.forkNote = kb.forkNote or attrs.get("fork") |
| 60 | |
| 61 | def htmlParser(page): |
| 62 | """ |
| 63 | This function calls a class that parses the input HTML page to |
| 64 | fingerprint the back-end database management system |
| 65 | |
| 66 | >>> from lib.core.enums import DBMS |
| 67 | >>> htmlParser("Warning: mysql_fetch_array() expects parameter 1 to be resource") == DBMS.MYSQL |
| 68 | True |
| 69 | >>> threadData = getCurrentThreadData() |
| 70 | >>> threadData.lastErrorPage = None |
| 71 | """ |
| 72 | |
| 73 | page = page[:HEURISTIC_PAGE_SIZE_THRESHOLD] |
| 74 | |
| 75 | xmlfile = paths.ERRORS_XML |
| 76 | handler = HTMLHandler(page) |
| 77 | key = hash(page) |
| 78 | |
| 79 | # generic SQL warning/error messages |
| 80 | if re.search(r"SQL (warning|error|syntax)", page, re.I): |
| 81 | handler._markAsErrorPage() |
| 82 | |
| 83 | if key in kb.cache.parsedDbms: |
| 84 | retVal = kb.cache.parsedDbms[key] |
| 85 | if retVal: |
| 86 | handler._markAsErrorPage() |
| 87 | return retVal |
| 88 | |
| 89 | parseXmlFile(xmlfile, handler) |
| 90 | |
| 91 | if handler.dbms and handler.dbms not in kb.htmlFp: |
| 92 | kb.lastParserStatus = handler.dbms |
| 93 | kb.htmlFp.append(handler.dbms) |
| 94 | else: |
| 95 | kb.lastParserStatus = None |
| 96 | |
| 97 | kb.cache.parsedDbms[key] = handler.dbms |
| 98 | |
| 99 | return handler.dbms |
no test coverage detected
searching dependent graphs…