-
Notifications
You must be signed in to change notification settings - Fork 82
build: update sqlite3 to 3.x and adapt encryption helper to build hooks #2397
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
Draft
td-famedly
wants to merge
3
commits into
main
Choose a base branch
from
agentic-td/update-dependencies-0428
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
092c4d7
build: update sqlite3 to 3.x and adapt encryption helper to build hooks
cursoragent 32c46bd
build: ignore unused-dep warning for sqlite3 in dependency validator
cursoragent 4583262
fix: fail loudly when migrating a database without SQLCipher available
cursoragent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ dependencies: | |
| sdp_transform: ^0.3.2 | ||
| slugify: ^2.0.0 | ||
| sqflite_common: ^2.4.5 | ||
| sqlite3: ^2.1.0 | ||
| sqlite3: ^3.3.4 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not |
||
| typed_data: ^1.3.2 | ||
| vodozemac: ^0.5.0 | ||
| web: ^1.1.1 | ||
|
|
@@ -45,5 +45,5 @@ dev_dependencies: | |
| url: https://github.com/famedly/frontend-ci-templates.git | ||
| path: lints/dart | ||
| lints: any | ||
| sqflite_common_ffi: ^2.3.4+4 # sqflite_common_ffi aggressively requires newer dart versions | ||
| sqflite_common_ffi: ^2.4.0+3 # sqflite_common_ffi aggressively requires newer dart versions | ||
| test: ^1.27.0 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| // SPDX-FileCopyrightText: 2019-Present Famedly GmbH | ||
| // | ||
| // SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
|
||
| @TestOn('vm') | ||
| library; | ||
|
|
||
| import 'dart:io'; | ||
|
|
||
| import 'package:matrix/matrix.dart'; | ||
| import 'package:sqflite_common_ffi/sqflite_ffi.dart'; | ||
| import 'package:test/test.dart'; | ||
|
|
||
| void main() { | ||
| group('SQfLiteEncryptionHelper', () { | ||
| late Directory tempDir; | ||
| late String dbPath; | ||
| late SQfLiteEncryptionHelper helper; | ||
|
|
||
| setUp(() async { | ||
| tempDir = await Directory.systemTemp.createTemp('encryption_helper'); | ||
| dbPath = '${tempDir.path}/test.sqlite'; | ||
| helper = SQfLiteEncryptionHelper( | ||
| factory: databaseFactoryFfi, | ||
| path: dbPath, | ||
| cipher: 'secret', | ||
| ); | ||
| }); | ||
|
|
||
| tearDown(() async { | ||
| await tempDir.delete(recursive: true); | ||
| }); | ||
|
|
||
| test('ffiInit is a no-op', () { | ||
| // ignore: deprecated_member_use_from_same_package | ||
| expect(SQfLiteEncryptionHelper.ffiInit, returnsNormally); | ||
| }); | ||
|
|
||
| test( | ||
| 'ensureDatabaseFileEncrypted does nothing without a database file', | ||
| () async { | ||
| await helper.ensureDatabaseFileEncrypted(); | ||
| expect(await File(dbPath).exists(), false); | ||
| }, | ||
| ); | ||
|
|
||
| test( | ||
| 'ensureDatabaseFileEncrypted skips already encrypted databases', | ||
| () async { | ||
| // an encrypted database does not start with the plain text SQLite header | ||
| final bytes = List<int>.generate(32, (i) => 255 - i); | ||
| await File(dbPath).writeAsBytes(bytes); | ||
|
|
||
| await helper.ensureDatabaseFileEncrypted(); | ||
|
|
||
| expect(await File(dbPath).readAsBytes(), bytes); | ||
| }, | ||
| ); | ||
|
|
||
| test( | ||
| 'ensureDatabaseFileEncrypted fails loudly when SQLCipher is not available', | ||
| () async { | ||
| // create a plain text SQLite database | ||
| final db = await databaseFactoryFfi.openDatabase(dbPath); | ||
| await db.execute('CREATE TABLE cats (name TEXT)'); | ||
| await db.close(); | ||
|
|
||
| // the bundled sqlite3 is not SQLCipher, so the migration must not | ||
| // silently do the wrong thing | ||
| await expectLater( | ||
| helper.ensureDatabaseFileEncrypted(), | ||
| throwsStateError, | ||
| ); | ||
|
|
||
| // the plain database file is left untouched | ||
| expect(await File(dbPath).exists(), true); | ||
| }, | ||
| ); | ||
|
|
||
| test( | ||
| 'applyPragmaKey fails loudly when SQLCipher is not available', | ||
| () async { | ||
| final db = await databaseFactoryFfi.openDatabase(dbPath); | ||
|
|
||
| await expectLater(helper.applyPragmaKey(db), throwsStateError); | ||
|
|
||
| await db.close(); | ||
| }, | ||
| ); | ||
| }); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Migration lacks SQLCipher availability check
Medium Severity
This commit makes
ffiInita deprecated no-op, so SQLCipher is no longer loaded before database use.applyPragmaKeystill validatesPRAGMA cipher_version, butensureDatabaseFileEncryptedrunsATTACH/sqlcipher_exporton the opened database without that check, so apps that still rely onffiInitor omit build hooks hit unclear migration failures instead of the same explicit error.Reviewed by Cursor Bugbot for commit 32c46bd. Configure here.