Skip to content

Commit 450e1bb

Browse files
committed
refactor: sanitize database encryption and connection logs
- Remove sensitive information, including JDBC URLs containing encoded passwords and password lengths, from JVM debug logs. - Redact `sqlite3_key` details, internal database pointers, and file paths from iOS debug logs. - Simplify log messages in `JvmCipherUtils` to avoid logging encrypted connection strings during the decryption process.
1 parent a31ebaf commit 450e1bb

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

core/data/db-sqldelight/src/iosMain/kotlin/com/softartdev/notedelight/db/IosCipherUtils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ object IosCipherUtils {
101101
var rc: Int = sqlite3_open(dbPath, db.ptr)
102102
checkError(rc, db, "Error opening database")
103103
val key: CValues<ByteVar>? = password?.cstr
104-
logger.d { "sqlite3_key key: ${key?.ptr?.toKString()}, rc: $rc, db: $db, dbPath: ${db.value}" }
104+
logger.d { "Applying sqlite3_key during password check" }
105105
rc = sqlite3_key(db.value, key?.ptr, key?.size ?: 0)
106106
checkError(rc, db, "Error key database")
107107
rc = sqlite3_exec(db.value, "SELECT count(*) FROM sqlite_master;", null, null, null)

core/data/db-sqldelight/src/jvmMain/kotlin/com/softartdev/notedelight/db/JdbcDatabaseHolder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class JdbcDatabaseHolder(props: Properties = Properties()) : SqlDelightDbHolder
8787
} else {
8888
val encodedPassword = URLEncoder.encode(password, StandardCharsets.UTF_8)
8989
val encryptedUrl = "$JDBC_PREFIX_ENCRYPTED$dbPath?cipher=$SQLCIPHER_CIPHER&legacy=$SQLCIPHER_LEGACY&key=$encodedPassword"
90-
logger.d { "Creating encrypted driver with URL: $encryptedUrl (password length: ${password.length})" }
90+
logger.d { "Creating encrypted SQLCipher driver" }
9191
encryptedUrl
9292
}
9393
}

core/data/db-sqldelight/src/jvmMain/kotlin/com/softartdev/notedelight/db/JvmCipherUtils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ object JvmCipherUtils {
103103
try {
104104
// Open encrypted database using sqlite-jdbc-crypt URL format
105105
val encryptedUrl = buildEncryptedUrl(originalFile.absolutePath, password)
106-
logger.d { "Opening encrypted database: $encryptedUrl" }
106+
logger.d { "Opening encrypted database for decrypt" }
107107
var connection = getConnection(encryptedUrl, isEncrypted = true)
108108

109109
// Get version from encrypted database
@@ -391,4 +391,4 @@ object JvmCipherUtils {
391391
throw FileNotFoundException(originalFile.absolutePath + " not found")
392392
}
393393
}
394-
}
394+
}

0 commit comments

Comments
 (0)