Skip to content

Commit f0b90b3

Browse files
committed
Add Kotlin test for CleartextStorageSharedPrefs
1 parent 85fab20 commit f0b90b3

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import android.app.Activity
2+
import android.content.Context
3+
import android.content.SharedPreferences
4+
5+
class CleartextStorageSharedPrefsTestKt : Activity() {
6+
fun testSetSharedPrefs1(context: Context, name: String, password: String) {
7+
val sharedPrefs = context.getSharedPreferences("user_prefs", Context.MODE_PRIVATE);
8+
sharedPrefs.edit().putString("name", name).apply(); // Safe
9+
sharedPrefs.edit().putString("password", password).apply(); // $ hasCleartextStorageSharedPrefs
10+
}
11+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
// semmle-extractor-options: --javac-args -cp ${testdir}/../../../stubs/google-android-9.0.0
2+
// codeql-extractor-kotlin-options: ${testdir}/../../../stubs/google-android-9.0.0

0 commit comments

Comments
 (0)