MCPcopy Create free account
hub / github.com/SourceCode-AI/aura / test_matching_triggers

Function test_matching_triggers

tests/test_ast_pattern_matching.py:174–203  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

172
173
174def 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
206def test_any_of():

Callers

nothing calls this directly

Calls 4

traverseMethod · 0.95
ASTPatternClass · 0.90
_compile_srcMethod · 0.80

Tested by

no test coverage detected