Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ SQLite3MC is MIT licensed. The amalgamation also carries public-domain code (SQL

A daily workflow in the [repository](https://github.com/LucaCappelletti94/sqlite3mc-src) opens a pull request for each new SQLite3MC release, taking the archive's checksum only from the release's Sigstore-signed `SHA256SUMS`. CI re-runs `upgrade.sh`, which checks that signature again before trusting the pinned checksum, to prove the vendored bytes match the pinned release. It also compiles the packaged sources natively and through `sqlite-wasm-rs`, and checks that each build opens the other's files in every cipher, under Node and in headless Chrome and Firefox, on OPFS too.

CI also runs SQLite3MC's own tests, a rekey of every cipher and SQLite's TCL suite through the shipped amalgamation, once plainly and once under the address and undefined-behaviour sanitizers, with every expected failure named and explained. Six fuzz targets in `fuzz/` run on every pull request and daily through `ClusterFuzzLite`: a self-consistency check across the six native cipher schemes, and dedicated targets for rekeying, `journal_mode=WAL`, `ATTACH DATABASE`, the `sqlite3_backup_*` API, and shared-cache mode.
CI also runs SQLite3MC's own tests, a rekey of every cipher and SQLite's TCL suite through the shipped amalgamation, once plainly and once under the address and undefined-behaviour sanitizers, with every expected failure named and explained. Five fuzz targets in `fuzz/` run on every pull request and daily through `ClusterFuzzLite`: a self-consistency check across the six native cipher schemes, and dedicated targets for rekeying, `journal_mode=WAL`, `ATTACH DATABASE` and the `sqlite3_backup_*` API. Shared-cache mode is left out, since SQLite discourages it and SQLite3MC supports it only as legacy ([#290](https://github.com/utelle/SQLite3MultipleCiphers/issues/290)).
9 changes: 1 addition & 8 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "sqlite3mc-src-fuzz"
version = "0.0.0"
edition = "2021"
publish = false
description = "Fuzzing SQLite3MC's own cipher schemes for self-consistency, its rekey support, its WAL journal mode, its ATTACH DATABASE support, its backup API, and its shared-cache mode"
description = "Fuzzing SQLite3MC's own cipher schemes for self-consistency, its rekey support, its WAL journal mode, its ATTACH DATABASE support, and its backup API"

[package.metadata]
cargo-fuzz = true
Expand Down Expand Up @@ -51,13 +51,6 @@ test = false
doc = false
bench = false

[[bin]]
name = "shared_cache"
path = "fuzz_targets/shared_cache.rs"
test = false
doc = false
bench = false

# The crate's table, minus unsafe_code (FFI) and missing_docs and cargo (never published).
[lints.rust]
rust_2018_idioms = { level = "warn", priority = -1 }
Expand Down
Binary file removed fuzz/corpus/shared_cache/all-siblings-correct-key
Binary file not shown.
Binary file removed fuzz/corpus/shared_cache/many-siblings
Binary file not shown.
Binary file removed fuzz/corpus/shared_cache/mixed-correct-and-wrong
Binary file not shown.
2 changes: 0 additions & 2 deletions fuzz/corpus/shared_cache/no-siblings

This file was deleted.

Binary file removed fuzz/corpus/shared_cache/one-sibling-correct-key
Binary file not shown.
Binary file removed fuzz/corpus/shared_cache/one-sibling-wrong-key
Binary file not shown.
Binary file removed fuzz/corpus/shared_cache/sibling-has-ops
Binary file not shown.
81 changes: 0 additions & 81 deletions fuzz/examples/gen_shared_cache_seeds.rs

This file was deleted.

5 changes: 0 additions & 5 deletions fuzz/fuzz_targets/shared_cache.rs

This file was deleted.

7 changes: 0 additions & 7 deletions fuzz/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ pub(crate) enum Param<'a> {
Blob(&'a [u8]),
}

/// `sqlite3_enable_shared_cache`: process-wide, so every connection opened after the call
/// defaults to shared-cache mode.
pub(crate) fn enable_shared_cache(enable: bool) -> Result<(), Code> {
// SAFETY: takes a plain `c_int`, touches no pointers, safe to call at any time.
check(unsafe { ffi::sqlite3_enable_shared_cache(c_int::from(enable)) })
}

/// An open connection, closed on drop.
pub(crate) struct Connection {
db: NonNull<ffi::Sqlite3>,
Expand Down
1 change: 0 additions & 1 deletion fuzz/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ unsafe extern "C" {
) -> *mut Backup;
pub(crate) fn sqlite3_backup_step(p: *mut Backup, n_page: c_int) -> c_int;
pub(crate) fn sqlite3_backup_finish(p: *mut Backup) -> c_int;
pub(crate) fn sqlite3_enable_shared_cache(enable: c_int) -> c_int;
/// SQLite3MC's own entry points, absent from upstream SQLite.
pub(crate) fn sqlite3mc_config(db: *mut Sqlite3, param: *const c_char, value: c_int) -> c_int;
pub(crate) fn sqlite3mc_config_cipher(
Expand Down
45 changes: 0 additions & 45 deletions fuzz/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,48 +590,3 @@ pub struct BackupCase {
/// steps of it.
pub dest_ops: Vec<Op>,
}

/// Connections beyond this, opened to the same file under shared-cache mode, are ignored.
pub(crate) const MAX_SIBLINGS: usize = 3;

/// The cipher and key a [`SharedConnection`] stages and keys with.
#[derive(Debug, Clone, PartialEq, Eq, Arbitrary)]
pub enum SiblingKey {
/// [`SharedCacheCase::written`], the one key shared-cache mode supports per file.
Shared,
/// A configuration of its own, almost certainly not [`SharedCacheCase::written`].
Own(NativeConfig),
}

/// One sibling connection, opened to the same file `main` already created and populated under
/// [`SharedCacheCase::written`]'s key, under shared-cache mode.
#[derive(Debug, Clone, PartialEq, Arbitrary)]
pub struct SharedConnection {
/// The cipher and key this connection stages and keys with.
pub key: SiblingKey,
/// Workload attempted on this connection after opening, at most [`MAX_OPS`] steps of it,
/// tolerated to fail when this connection's own key turned out wrong.
pub ops: Vec<Op>,
}

/// One shared-cache execution: a main connection creates and populates a database, then up to
/// [`MAX_SIBLINGS`] further connections open the *same* file under shared-cache mode.
///
/// Shared-cache connections to one file share one pager and one codec, so SQLite3MC supports a
/// single key and cipher configuration per file, and a sibling keying it differently replaces
/// the codec under `main` (`utelle/SQLite3MultipleCiphers` issue #281).
///
/// Oracle: when every sibling keys with [`SiblingKey::Shared`], `main`'s own reads must keep
/// succeeding throughout. Unless a sibling ran a workload after one keyed the file differently,
/// and so wrote through the replaced codec, the file itself must still read back cleanly under
/// `written` once every connection closes, the same way the other harnesses' own "nothing
/// corrupts the file at rest" oracle does.
#[derive(Debug, Clone, PartialEq, Arbitrary)]
pub struct SharedCacheCase {
/// `main`'s own cipher and key, the file's one true key.
pub written: NativeConfig,
/// Workload `main` runs before any sibling connects, at most [`MAX_OPS`] steps of it.
pub main_ops: Vec<Op>,
/// Sibling connections to the same file, at most [`MAX_SIBLINGS`] of them.
pub siblings: Vec<SharedConnection>,
}
7 changes: 3 additions & 4 deletions fuzz/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Fuzzing SQLite3MC's own cipher schemes for self-consistency, its rekey support, its WAL
//! journal mode, its `ATTACH DATABASE` support, its `sqlite3_backup_*` API, and its shared-cache
//! mode.
//! journal mode, its `ATTACH DATABASE` support, and its `sqlite3_backup_*` API.

#![expect(
clippy::redundant_pub_crate,
Expand All @@ -15,6 +14,6 @@ pub mod seedgen;

pub use input::{
Algorithm, AttachCase, BackupCase, Checkpoint, Cipher, NativeCase, NativeKey, Op, RekeyAction,
RekeyCase, SharedCacheCase, SiblingKey, Table, WalCase,
RekeyCase, Table, WalCase,
};
pub use run::{run_attach, run_backup, run_native, run_rekey, run_shared_cache, run_wal};
pub use run::{run_attach, run_backup, run_native, run_rekey, run_wal};
Loading
Loading