Fix QLDocs and the qhelp example

This commit is contained in:
Tony Torralba
2021-09-03 14:10:15 +02:00
parent f0604e2e84
commit 16b61f78e6
3 changed files with 19 additions and 0 deletions

View File

@@ -1,3 +1,5 @@
/** Provides classes and predicates for working with SQLite databases. */
import java
import Android
import semmle.code.java.dataflow.FlowSteps
@@ -24,10 +26,16 @@ class TypeDatabaseUtils extends Class {
TypeDatabaseUtils() { hasQualifiedName("android.database", "DatabaseUtils") }
}
/**
* The class `android.database.sqlite.SQLiteOpenHelper`.
*/
class TypeSQLiteOpenHelper extends Class {
TypeSQLiteOpenHelper() { this.hasQualifiedName("android.database.sqlite", "SQLiteOpenHelper") }
}
/**
* The class `android.database.sqlite.SQLiteStatement`.
*/
class TypeSQLiteStatement extends Class {
TypeSQLiteStatement() { this.hasQualifiedName("android.database.sqlite", "SQLiteStatement") }
}

View File

@@ -1,3 +1,5 @@
/** Provides classes and predicates for working with Android widgets. */
import java
import semmle.code.java.dataflow.ExternalFlow
import semmle.code.java.dataflow.FlowSources

View File

@@ -16,3 +16,12 @@ public void sqlCipherStorageSafe(String name, String password, String databasePa
net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase("test", databasePassword, null);
db.execSQL("INSERT INTO users VALUES (?, ?)", new String[] {name, password});
}
private static String encrypt(String cleartext) {
// Use an encryption or strong hashing algorithm in the real world.
// The example below just returns a SHA-256 hash.
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(cleartext.getBytes(StandardCharsets.UTF_8));
String encoded = Base64.getEncoder().encodeToString(hash);
return encoded;
}