(self, input_file, matches, excludes=None, **kwargs)
| 144 | return visitor.tree["ast_tree"] |
| 145 | |
| 146 | def scan_and_match(self, input_file, matches, excludes=None, **kwargs): |
| 147 | output = self.scan_test_file(input_file, **kwargs) |
| 148 | |
| 149 | for x in matches: |
| 150 | try: |
| 151 | assert any(match_rule(h, x) for h in output["detections"]), (x, output["detections"]) |
| 152 | except AssertionError: |
| 153 | for h in output["detections"]: |
| 154 | pprint.pprint(h) |
| 155 | raise |
| 156 | |
| 157 | if excludes: |
| 158 | for x in excludes: |
| 159 | for hit in output["detections"]: |
| 160 | assert not match_rule(hit, x), hit |
| 161 | |
| 162 | for hit in output["detections"]: |
| 163 | assert hit["type"] != "ASTParseError" |
| 164 | |
| 165 | |
| 166 | def match_rule(source, target) -> bool: |
no test coverage detected