Skip to content

Commit 3416f07

Browse files
yoffRasmusWL
andauthored
Update python/ql/src/Security/CWE-352/CSRFProtectionDisabled.ql
Explain why `TestScope` is not used. Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
1 parent d39410a commit 3416f07

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

python/ql/src/Security/CWE-352/CSRFProtectionDisabled.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ from HTTP::Server::CsrfProtectionSetting s
1818
where
1919
s.getVerificationSetting() = false and
2020
not exists(HTTP::Server::CsrfLocalProtectionSetting p | p.csrfEnabled()) and
21-
// rule out test code as this is a common place to turn off CSRF protection
21+
// rule out test code as this is a common place to turn off CSRF protection.
22+
// We don't use normal `TestScope` to find test files, since we also want to match
23+
// a settings file such as `.../integration-tests/settings.py`
2224
not s.getLocation().getFile().getAbsolutePath().matches("%test%")
2325
select s, "Potential CSRF vulnerability due to forgery protection being disabled or weakened."

0 commit comments

Comments
 (0)