Skip to content

Commit cd19a91

Browse files
Add unit test
1 parent 3aa2714 commit cd19a91

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import android.app.Activity;
2+
import androidx.core.app.NotificationCompat;
3+
import androidx.core.app.NotificationManagerCompat;
4+
5+
class Test extends Activity {
6+
void test(String password) {
7+
NotificationManagerCompat manager = NotificationManagerCompat.from(this);
8+
9+
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "");
10+
builder.setContentText(password);
11+
manager.notify(0, builder.build()); // sensitive-notification
12+
}
13+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../../../../stubs/google-android-9.0.0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
testFailures
2+
failures
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import java
2+
import TestUtilities.InlineExpectationsTest
3+
import semmle.code.java.dataflow.DataFlow
4+
import semmle.code.java.security.SensitiveUiQuery
5+
6+
module SensitiveNotifTest implements TestSig {
7+
string getARelevantTag() { result = "sensitive-notification" }
8+
9+
predicate hasActualResult(Location location, string element, string tag, string value) {
10+
tag = "sensitive-notification" and
11+
exists(DataFlow::Node sink | NotificationTracking::flowTo(sink) |
12+
sink.getLocation() = location and
13+
element = sink.toString() and
14+
value = ""
15+
)
16+
}
17+
}
18+
19+
import MakeTest<SensitiveNotifTest>

0 commit comments

Comments
 (0)