()
| 172 | |
| 173 | |
| 174 | def test_matching_triggers(): |
| 175 | src = """ |
| 176 | import flask |
| 177 | app = flask.Flask() |
| 178 | app.run(debug=True) |
| 179 | """ |
| 180 | sig = { |
| 181 | "pattern": "flask.Flask.run(..., debug=True)", |
| 182 | "detection": { |
| 183 | "type": "CustomDetection", |
| 184 | "message": "detection_message", |
| 185 | "score": 666 |
| 186 | }, |
| 187 | "tags": ["detection_tag"], |
| 188 | "taint": "tainted" |
| 189 | } |
| 190 | |
| 191 | compiled_src = ASTPattern._compile_src(src) |
| 192 | p = ASTPattern(signature=sig) |
| 193 | v = PatternMatchingVisitor(pattern=p) |
| 194 | |
| 195 | result = v.traverse(compiled_src) |
| 196 | assert result is not None |
| 197 | assert len(v.hits) == 1, v.hits |
| 198 | |
| 199 | hit: Detection = v.hits[0] |
| 200 | assert hit.detection_type == "CustomDetection" |
| 201 | assert hit.score == 666 |
| 202 | assert "detection_tag" in hit.tags, hit.tags |
| 203 | assert result._taint_class == Taints.TAINTED |
| 204 | |
| 205 | |
| 206 | def test_any_of(): |
nothing calls this directly
no test coverage detected