mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
Java: Improve java/spring-disabled-csrf-protection
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
testFailures
|
||||
failures
|
||||
@@ -0,0 +1,10 @@
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
||||
|
||||
public class SpringCsrfProtectionTest {
|
||||
protected void test(HttpSecurity http) throws Exception {
|
||||
http.csrf(csrf -> csrf.disable()); // $ hasSpringCsrfProtectionDisabled
|
||||
http.csrf().disable(); // $ hasSpringCsrfProtectionDisabled
|
||||
http.csrf(AbstractHttpConfigurer::disable); // $ hasSpringCsrfProtectionDisabled
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import java
|
||||
import semmle.code.java.security.SpringCsrfProtection
|
||||
import TestUtilities.InlineExpectationsTest
|
||||
|
||||
module SpringCsrfProtectionTest implements TestSig {
|
||||
string getARelevantTag() { result = "hasSpringCsrfProtectionDisabled" }
|
||||
|
||||
predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
tag = "hasSpringCsrfProtectionDisabled" and
|
||||
exists(MethodAccess call | disablesSpringCsrfProtection(call) |
|
||||
call.getLocation() = location and
|
||||
element = call.toString() and
|
||||
value = ""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
import MakeTest<SpringCsrfProtectionTest>
|
||||
1
java/ql/test/query-tests/security/CWE-352/options
Normal file
1
java/ql/test/query-tests/security/CWE-352/options
Normal file
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: --javac-args -cp ${testdir}/../../../stubs/springframework-5.3.8
|
||||
Reference in New Issue
Block a user