Skip to content

Commit 4f25359

Browse files
committed
Fix method name in LocalDatabaseOpenMethodAccess
1 parent 652a1d2 commit 4f25359

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

java/ql/lib/semmle/code/java/security/CleartextStorageAndroidDatabaseQuery.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class LocalDatabaseOpenMethodAccess extends Storable, Call {
3333
m.hasName("getWritableDatabase")
3434
or
3535
m.getDeclaringType() instanceof TypeSQLiteDatabase and
36-
m.hasName(["create", "open%Database", "compileStatement"])
36+
m.hasName(["create", "openDatabase", "openOrCreateDatabase", "compileStatement"])
3737
or
3838
m.getDeclaringType().getASupertype*() instanceof TypeContext and
3939
m.hasName("openOrCreateDatabase")

java/ql/test/query-tests/security/CWE-312/CleartextStorageAndroidDatabaseTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,20 @@ public void testCleartextStorageAndroiDatabaseSafe2(Context ctx, String name, St
1919
db.execSQL("DROP TABLE passwords;"); // Safe - no sensitive value being stored
2020
}
2121

22-
public void testCleartextStorageAndroiDatabase1(Context ctx, String name, String password) {
22+
public void testCleartextStorageAndroiDatabase0(Context ctx, String name, String password) {
2323
SQLiteDatabase db = ctx.openOrCreateDatabase("test", Context.MODE_PRIVATE, null);
2424
String query = "INSERT INTO users VALUES ('" + name + "', '" + password + "');";
2525
db.execSQL(query); // $ hasCleartextStorageAndroidDatabase
2626
}
2727

28+
public void testCleartextStorageAndroiDatabase1(Context ctx, String name, String password) {
29+
SQLiteDatabase db = SQLiteDatabase.openDatabase("", null, 0);
30+
String query = "INSERT INTO users VALUES ('" + name + "', '" + password + "');";
31+
db.execSQL(query); // $ hasCleartextStorageAndroidDatabase
32+
}
33+
2834
public void testCleartextStorageAndroiDatabase2(String name, String password) {
29-
SQLiteDatabase db = SQLiteDatabase.create(null);
35+
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase("", null);
3036
String query = "INSERT INTO users VALUES (?, ?)";
3137
db.execSQL(query, new String[] {name, password}); // $ hasCleartextStorageAndroidDatabase
3238
}

0 commit comments

Comments
 (0)