|
29 | 29 | from lib.core.threads import getCurrentThreadData |
30 | 30 |
|
31 | 31 | def comparison(page, headers, code=None, getRatioValue=False, pageLength=None): |
| 32 | + #return _checkNegativeLogic(_comparison(page, headers, code, getRatioValue, pageLength), getRatioValue) |
| 33 | + return _comparison(page, headers, code, getRatioValue, pageLength) |
| 34 | + |
| 35 | +def _checkNegativeLogic(condition, getRatioValue): |
| 36 | + condition = not (condition or False) if kb.negativeLogic else condition |
| 37 | + return condition if not getRatioValue else (MAX_RATIO if condition else MIN_RATIO) |
| 38 | + |
| 39 | +def _comparison(page, headers, code, getRatioValue, pageLength): |
32 | 40 | if page is None and pageLength is None: |
33 | 41 | return None |
34 | 42 |
|
35 | 43 | seqMatcher = getCurrentThreadData().seqMatcher |
36 | 44 | seqMatcher.set_seq1(kb.pageTemplate) |
37 | 45 |
|
38 | | - def checkNegativeLogic(condition): |
39 | | - condition = not condition if kb.negativeLogic else condition |
40 | | - return condition if not getRatioValue else (MAX_RATIO if condition else MIN_RATIO) |
41 | | - |
42 | 46 | if any([conf.string, conf.regexp]): |
43 | 47 | rawResponse = "%s%s" % (listToStrValue(headers.headers if headers else ""), page) |
44 | 48 |
|
45 | 49 | # String to match in page when the query is valid |
46 | 50 | if conf.string: |
47 | | - return checkNegativeLogic(conf.string in rawResponse) |
| 51 | + return conf.string in rawResponse |
48 | 52 |
|
49 | 53 | # Regular expression to match in page when the query is valid |
50 | 54 | if conf.regexp: |
51 | | - return checkNegativeLogic(re.search(conf.regexp, rawResponse, re.I | re.M) is not None) |
| 55 | + return re.search(conf.regexp, rawResponse, re.I | re.M) is not None |
52 | 56 |
|
53 | 57 | # HTTP code to match when the query is valid |
54 | 58 | if isinstance(code, int) and conf.code: |
55 | | - return checkNegativeLogic(conf.code == code) |
| 59 | + return conf.code == code |
56 | 60 |
|
57 | 61 | if page: |
58 | 62 | # In case of an DBMS error page return None |
|
0 commit comments