|
@@ -28,6 +28,7 @@ class EventAttributeConditionTest(RuleTestCase):
|
|
|
"filename": "example.php",
|
|
|
"module": "example",
|
|
|
"context_line": 'echo "hello";',
|
|
|
+ "abs_path": "path/to/example.php",
|
|
|
}
|
|
|
]
|
|
|
},
|
|
@@ -412,3 +413,53 @@ class EventAttributeConditionTest(RuleTestCase):
|
|
|
|
|
|
rule = self.get_rule(data={"match": MatchType.EQUAL, "attribute": "type", "value": "csp"})
|
|
|
self.assertDoesNotPass(rule, event)
|
|
|
+
|
|
|
+ def test_stacktrace_abs_path(self):
|
|
|
+ """Stacktrace.abs_path should match frames anywhere in the stack."""
|
|
|
+
|
|
|
+ event = self.get_event(
|
|
|
+ exception={
|
|
|
+ "values": [
|
|
|
+ {
|
|
|
+ "type": "SyntaxError",
|
|
|
+ "value": "hello world",
|
|
|
+ "stacktrace": {
|
|
|
+ "frames": [
|
|
|
+ {
|
|
|
+ "filename": "example.php",
|
|
|
+ "module": "example",
|
|
|
+ "abs_path": "path/to/example.php",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "filename": "somecode.php",
|
|
|
+ "module": "somecode",
|
|
|
+ "abs_path": "path/to/somecode.php",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "filename": "othercode.php",
|
|
|
+ "module": "othercode",
|
|
|
+ "abs_path": "path/to/othercode.php",
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ )
|
|
|
+
|
|
|
+ # correctly matching filenames, at various locations in the stacktrace
|
|
|
+ for value in ["path/to/example.php", "path/to/somecode.php", "path/to/othercode.php"]:
|
|
|
+ rule = self.get_rule(
|
|
|
+ data={"match": MatchType.EQUAL, "attribute": "stacktrace.abs_path", "value": value}
|
|
|
+ )
|
|
|
+ self.assertPasses(rule, event)
|
|
|
+
|
|
|
+ # non-matching filename
|
|
|
+ rule = self.get_rule(
|
|
|
+ data={
|
|
|
+ "match": MatchType.EQUAL,
|
|
|
+ "attribute": "stacktrace.abs_path",
|
|
|
+ "value": "path/to/foo.php",
|
|
|
+ }
|
|
|
+ )
|
|
|
+ self.assertDoesNotPass(rule, event)
|