mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Add test and fix a bug
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import android.os.Bundle;
|
||||
import android.os.ResultReceiver;
|
||||
|
||||
class SensitiveResultReceiver {
|
||||
<T> T source() { return null; }
|
||||
|
||||
void test1(String password) {
|
||||
ResultReceiver rec = source();
|
||||
Bundle b = new Bundle();
|
||||
b.putCharSequence("pass", password);
|
||||
rec.send(0, b); // $hasSensitiveResultReceiver
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import java
|
||||
import TestUtilities.InlineExpectationsTest
|
||||
import semmle.code.java.security.SensitiveResultReceiverQuery
|
||||
|
||||
class TestSource extends RemoteFlowSource {
|
||||
TestSource() { this.asExpr().(MethodAccess).getMethod().hasName("source") }
|
||||
|
||||
override string getSourceType() { result = "test" }
|
||||
}
|
||||
|
||||
class ResultReceiverTest extends InlineExpectationsTest {
|
||||
ResultReceiverTest() { this = "ResultReceiverTest" }
|
||||
|
||||
override string getARelevantTag() { result = "hasSensitiveResultReceiver" }
|
||||
|
||||
override predicate hasActualResult(Location loc, string element, string tag, string value) {
|
||||
exists(DataFlow::PathNode src, DataFlow::PathNode sink, DataFlow::Node recSrc |
|
||||
sensitiveResultReceiver(src, sink, recSrc) and
|
||||
element = sink.toString() and
|
||||
loc = sink.getNode().getLocation() and
|
||||
tag = "hasSensitiveResultReceiver" and
|
||||
value = ""
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user