Skip to content

Commit 16b61f7

Browse files
committed
Fix QLDocs and the qhelp example
1 parent f0604e2 commit 16b61f7

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

java/ql/lib/semmle/code/java/frameworks/android/SQLite.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** Provides classes and predicates for working with SQLite databases. */
2+
13
import java
24
import Android
35
import semmle.code.java.dataflow.FlowSteps
@@ -24,10 +26,16 @@ class TypeDatabaseUtils extends Class {
2426
TypeDatabaseUtils() { hasQualifiedName("android.database", "DatabaseUtils") }
2527
}
2628

29+
/**
30+
* The class `android.database.sqlite.SQLiteOpenHelper`.
31+
*/
2732
class TypeSQLiteOpenHelper extends Class {
2833
TypeSQLiteOpenHelper() { this.hasQualifiedName("android.database.sqlite", "SQLiteOpenHelper") }
2934
}
3035

36+
/**
37+
* The class `android.database.sqlite.SQLiteStatement`.
38+
*/
3139
class TypeSQLiteStatement extends Class {
3240
TypeSQLiteStatement() { this.hasQualifiedName("android.database.sqlite", "SQLiteStatement") }
3341
}

java/ql/lib/semmle/code/java/frameworks/android/Widget.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** Provides classes and predicates for working with Android widgets. */
2+
13
import java
24
import semmle.code.java.dataflow.ExternalFlow
35
import semmle.code.java.dataflow.FlowSources

java/ql/src/Security/CWE/CWE-312/CleartextStorageAndroidDatabase.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,12 @@ public void sqlCipherStorageSafe(String name, String password, String databasePa
1616
net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase("test", databasePassword, null);
1717
db.execSQL("INSERT INTO users VALUES (?, ?)", new String[] {name, password});
1818
}
19+
20+
private static String encrypt(String cleartext) {
21+
// Use an encryption or strong hashing algorithm in the real world.
22+
// The example below just returns a SHA-256 hash.
23+
MessageDigest digest = MessageDigest.getInstance("SHA-256");
24+
byte[] hash = digest.digest(cleartext.getBytes(StandardCharsets.UTF_8));
25+
String encoded = Base64.getEncoder().encodeToString(hash);
26+
return encoded;
27+
}

0 commit comments

Comments
 (0)