python: rule out test code for CSRF

This commit is contained in:
Rasmus Lerchedahl Petersen
2022-03-22 14:57:05 +01:00
parent 0f2c21c8bd
commit 53de8287f5

View File

@@ -17,5 +17,7 @@ import semmle.python.Concepts
from CSRFProtectionSetting s
where
s.getVerificationSetting() = false and
not exists(CSRFProtection p)
not exists(CSRFProtection p) and
// rule out test code as this is a common place to turn off CSRF protection
not s.getLocation().getFile().getAbsolutePath().matches("%test%")
select s, "Potential CSRF vulnerability due to forgery protection being disabled or weakened."