mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Add RequestForgerySanitizer
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
|
||||
import java
|
||||
import semmle.code.java.dataflow.FlowSources
|
||||
import semmle.code.java.security.RequestForgeryConfig
|
||||
import semmle.code.java.security.UnsafeAndroidAccess
|
||||
import DataFlow::PathGraph
|
||||
|
||||
@@ -25,6 +26,10 @@ class FetchUntrustedResourceConfiguration extends TaintTracking::Configuration {
|
||||
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) { sink instanceof UrlResourceSink }
|
||||
|
||||
override predicate isSanitizer(DataFlow::Node sanitizer) {
|
||||
sanitizer instanceof RequestForgerySanitizer
|
||||
}
|
||||
}
|
||||
|
||||
from DataFlow::PathNode source, DataFlow::PathNode sink, FetchUntrustedResourceConfiguration conf
|
||||
|
||||
@@ -147,6 +147,6 @@ public class UnsafeAndroidAccess extends Activity {
|
||||
|
||||
String thisUrl = getIntent().getStringExtra("url");
|
||||
// This should be considered safe - the query lacks a proper sanitizer for partial URLs.
|
||||
wv.loadUrl("https://www.mycorp.com/" + thisUrl); // $ SPURIOUS: hasUnsafeAndroidAccess
|
||||
wv.loadUrl("https://www.mycorp.com/" + thisUrl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import java
|
||||
import semmle.code.java.dataflow.DataFlow
|
||||
import semmle.code.java.dataflow.FlowSources
|
||||
import TestUtilities.InlineExpectationsTest
|
||||
import semmle.code.java.security.RequestForgeryConfig
|
||||
import semmle.code.java.security.UnsafeAndroidAccess
|
||||
import TestUtilities.InlineExpectationsTest
|
||||
|
||||
class Conf extends TaintTracking::Configuration {
|
||||
Conf() { this = "qltest:cwe:unsafe-android-access" }
|
||||
@@ -10,6 +11,10 @@ class Conf extends TaintTracking::Configuration {
|
||||
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) { sink instanceof UrlResourceSink }
|
||||
|
||||
override predicate isSanitizer(DataFlow::Node sanitizer) {
|
||||
sanitizer instanceof RequestForgerySanitizer
|
||||
}
|
||||
}
|
||||
|
||||
class UnsafeAndroidAccessTest extends InlineExpectationsTest {
|
||||
|
||||
Reference in New Issue
Block a user