mirror of
https://github.com/github/codeql.git
synced 2025-12-23 04:06:37 +01:00
Decouple from #10177
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
import java
|
||||
private import semmle.code.java.dataflow.TaintTracking
|
||||
private import semmle.code.java.frameworks.android.Android
|
||||
private import semmle.code.java.security.PathSanitizer
|
||||
|
||||
/** A URI that gets resolved by a `ContentResolver`. */
|
||||
abstract class ContentUriResolutionSink extends DataFlow::Node { }
|
||||
@@ -50,9 +49,6 @@ private class UninterestingTypeSanitizer extends ContentUriResolutionSanitizer {
|
||||
}
|
||||
}
|
||||
|
||||
private class PathSanitizer extends ContentUriResolutionSanitizer instanceof PathInjectionSanitizer {
|
||||
}
|
||||
|
||||
private class FilenameOnlySanitizer extends ContentUriResolutionSanitizer {
|
||||
FilenameOnlySanitizer() {
|
||||
exists(Method m | this.asExpr().(MethodAccess).getMethod() = m |
|
||||
|
||||
@@ -53,13 +53,13 @@ public class Test extends Activity {
|
||||
Uri uri = (Uri) getIntent().getParcelableExtra("URI_EXTRA");
|
||||
if (!uri.equals(Uri.parse("content://safe/uri")))
|
||||
throw new SecurityException();
|
||||
contentResolver.openInputStream(uri); // Safe
|
||||
contentResolver.openInputStream(uri); // $ SPURIOUS: hasTaintFlow
|
||||
}
|
||||
{
|
||||
ContentResolver contentResolver = getContentResolver();
|
||||
Uri uri = (Uri) getIntent().getParcelableExtra("URI_EXTRA");
|
||||
validateWithEquals(uri);
|
||||
contentResolver.openInputStream(uri); // Safe
|
||||
contentResolver.openInputStream(uri); // $ SPURIOUS: hasTaintFlow
|
||||
}
|
||||
// Allow list checks
|
||||
{
|
||||
@@ -78,13 +78,13 @@ public class Test extends Activity {
|
||||
java.nio.file.FileSystems.getDefault().getPath(path).normalize();
|
||||
if (!normalized.startsWith("/safe/path"))
|
||||
throw new SecurityException();
|
||||
contentResolver.openInputStream(uri); // Safe
|
||||
contentResolver.openInputStream(uri); // $ SPURIOUS: hasTaintFlow
|
||||
}
|
||||
{
|
||||
ContentResolver contentResolver = getContentResolver();
|
||||
Uri uri = (Uri) getIntent().getParcelableExtra("URI_EXTRA");
|
||||
validateWithAllowList(uri);
|
||||
contentResolver.openInputStream(uri); // Safe
|
||||
contentResolver.openInputStream(uri);// $ SPURIOUS: hasTaintFlow
|
||||
}
|
||||
// Block list checks
|
||||
{
|
||||
@@ -103,13 +103,13 @@ public class Test extends Activity {
|
||||
java.nio.file.FileSystems.getDefault().getPath(path).normalize();
|
||||
if (normalized.startsWith("/data"))
|
||||
throw new SecurityException();
|
||||
contentResolver.openInputStream(uri); // Safe
|
||||
contentResolver.openInputStream(uri); // $ SPURIOUS: hasTaintFlow
|
||||
}
|
||||
{
|
||||
ContentResolver contentResolver = getContentResolver();
|
||||
Uri uri = (Uri) getIntent().getParcelableExtra("URI_EXTRA");
|
||||
validateWithBlockList(uri);
|
||||
contentResolver.openInputStream(uri); // Safe
|
||||
contentResolver.openInputStream(uri); // $ SPURIOUS: hasTaintFlow
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user