-
Notifications
You must be signed in to change notification settings - Fork 0
Feature implementation from commits d493d77..1cb6137 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature-base-branch-2
Are you sure you want to change the base?
Conversation
Reduce library size
…opment Fix query & class not found error
| private HashMap<String, SupportSQLiteDatabase> mRoomInMemoryDatabases = new HashMap<>(); | ||
|
|
||
| public RequestHandler(Context context) { | ||
| public RequestHandler(Context context, DBFactory dbFactory) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 Correctness Issue
Breaking API Change: Constructor Parameter Added.
The RequestHandler constructor now requires a DBFactory parameter, which will break all existing code that instantiates this class.
Current Code (Diff):
- public RequestHandler(Context context) {
+ public RequestHandler(Context context, DBFactory dbFactory) {|
|
||
| @Override | ||
| public SQLiteDB create(Context context, String path, String password) { | ||
| return new DebugSQLiteDB(SQLiteDatabase.openOrCreateDatabase(path, null)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security Issue
Security: Ignored Password Parameter.
The password parameter is accepted but ignored when opening the database, which could lead to unencrypted database access in production if encryption is expected.
Current Code (Diff):
- return new DebugSQLiteDB(SQLiteDatabase.openOrCreateDatabase(path, null));
+ return new DebugSQLiteDB(SQLiteDatabase.openOrCreateDatabase(path, password, null));📝 Committable suggestion
‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀
| return new DebugSQLiteDB(SQLiteDatabase.openOrCreateDatabase(path, null)); | |
| return new DebugSQLiteDB(SQLiteDatabase.openOrCreateDatabase(path, password, null)); |
| public SQLiteDB create(Context context, String path, String password) { | ||
| return new DebugSQLiteDB(SQLiteDatabase.openOrCreateDatabase(path, null)); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 Correctness Issue
Correctness: No Error Handling.
SQLiteDatabase.openOrCreateDatabase can throw exceptions for invalid paths or permission issues with no error handling, causing application crashes.
Current Code (Diff):
- public SQLiteDB create(Context context, String path, String password) {
- return new DebugSQLiteDB(SQLiteDatabase.openOrCreateDatabase(path, null));
- }
+ public SQLiteDB create(Context context, String path, String password) {
+ try {
+ return new DebugSQLiteDB(SQLiteDatabase.openOrCreateDatabase(path, password, null));
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to open database at " + path, e);
+ }
+ }📝 Committable suggestion
‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀
| public SQLiteDB create(Context context, String path, String password) { | |
| return new DebugSQLiteDB(SQLiteDatabase.openOrCreateDatabase(path, null)); | |
| } | |
| public SQLiteDB create(Context context, String path, String password) { | |
| try { | |
| return new DebugSQLiteDB(SQLiteDatabase.openOrCreateDatabase(path, password, null)); | |
| } catch (Exception e) { | |
| throw new RuntimeException("Failed to open database at " + path, e); | |
| } | |
| } |
| import android.content.ContentValues; | ||
| import android.database.Cursor; | ||
| import android.database.SQLException; | ||
| import android.database.sqlite.SQLiteDatabase; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security Issue
Security: Database Encryption Removed.
Switching from SQLCipher to standard SQLite removes encryption, potentially exposing sensitive data if this debug implementation is used with real user data.
Current Code (Diff):
- import android.database.sqlite.SQLiteDatabase;
+ import net.sqlcipher.database.SQLiteDatabase;
+
+ /**
+ * Created by anandgaurav on 12/02/18.
+ */🔄 Dependencies Affected
debug-db/src/main/java/com/amitshekhar/debug/sqlite/DebugDBFactory.java
Function: DebugDBFactory.openOrCreateDatabase
Issue: Database factory creates unencrypted database instances
Suggestion: Either ensure this implementation is only used for debugging or restore encryption capability
PR Summary
Implement Factory Pattern for SQLite Database Access with Encryption Support
Overview
This PR refactors the database access layer to use a factory pattern, enabling support for both encrypted and unencrypted SQLite databases. The implementation adds new factory classes and modifies existing components to work with this abstraction.
Change Types
Affected Modules
src/main/java/com/amitshekhar/DebugDB.javasrc/main/java/com/amitshekhar/server/ClientServer.javasrc/main/java/com/amitshekhar/server/RequestHandler.javasrc/main/java/com/amitshekhar/debug/encrypt/sqlite/DebugDBEncryptFactory.javasrc/main/java/com/amitshekhar/debug/sqlite/DebugDBFactory.javasrc/main/java/com/amitshekhar/debug/sqlite/DebugSQLiteDB.javasrc/main/java/com/sample/encrypt/database/PersonDBHelper.javasrc/test/java/com/sample/encrypt/ExampleUnitTest.javasrc/main/java/com/sample/MainActivity.javaNotes for Reviewers