python: broaden local protection concept

This commit is contained in:
Rasmus Lerchedahl Petersen
2022-03-25 12:28:33 +01:00
parent 179f77b123
commit 1e9840d779
5 changed files with 34 additions and 24 deletions

View File

@@ -520,18 +520,20 @@ class CsrfProtectionSettingTest extends InlineExpectationsTest {
}
}
class CsrfLocalProtectionTest extends InlineExpectationsTest {
CsrfLocalProtectionTest() { this = "CsrfLocalProtectionTest" }
class CsrfLocalProtectionSettingTest extends InlineExpectationsTest {
CsrfLocalProtectionSettingTest() { this = "CsrfLocalProtectionSettingTest" }
override string getARelevantTag() { result = "CsrfLocalProtection" }
override string getARelevantTag() { result = "CsrfLocalProtection" + ["Enabled", "Disabled"] }
override predicate hasActualResult(Location location, string element, string tag, string value) {
exists(location.getFile().getRelativePath()) and
exists(CsrfLocalProtection p |
exists(CsrfLocalProtectionSetting p |
location = p.getLocation() and
element = p.toString() and
value = p.getProtected().getName().toString() and
tag = "CsrfLocalProtection"
value = p.getRequestHandler().getName().toString() and
if p.csrfEnabled()
then tag = "CsrfLocalProtectionEnabled"
else tag = "CsrfLocalProtectionDisabled"
)
}
}