Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
build(sqlite): trim unused bundled extensions
ldm053ec9ba9d63c
diff --git a/.cargo/config.toml b/.cargo/config.tomlindex 5083f18bc..151a8f68f 100644--- a/.cargo/config.toml+++ b/.cargo/config.toml@@ -22,3 +22,21 @@ https_proxy = { value = "", force = true }ALL_PROXY = { value = "", force = true }HTTP_PROXY = { value = "", force = true }HTTPS_PROXY = { value = "", force = true }++# Browser imports only query ordinary SQLite tables. libsqlite3-sys enables+# these extensions in its bundled C build regardless of rusqlite features.+# Its LIBSQLITE3_FLAGS are appended after the defaults: use -U, since defining+# an SQLITE_ENABLE_* macro as 0 still enables code guarded by #ifdef.+# Extension loading requires SQLITE_OMIT_LOAD_EXTENSION to remove the loader.+# Keep normal SQL/schema parsing, PRAGMAs, thread safety, and WAL support for+# browser database compatibility. These defaults apply to local and CI builds.+LIBSQLITE3_FLAGS = """+ -USQLITE_ENABLE_FTS3+ -USQLITE_ENABLE_FTS3_PARENTHESIS+ -USQLITE_ENABLE_FTS5+ -USQLITE_ENABLE_RTREE+ -USQLITE_ENABLE_DBSTAT_VTAB+ -USQLITE_ENABLE_STAT4+ -USQLITE_ENABLE_LOAD_EXTENSION+ -DSQLITE_OMIT_LOAD_EXTENSION+"""diff --git a/moli-cookie-import/Cargo.toml b/moli-cookie-import/Cargo.tomlindex 0f34a919f..4c2f52933 100644--- a/moli-cookie-import/Cargo.toml+++ b/moli-cookie-import/Cargo.toml@@ -11,6 +11,7 @@ moli-browser-profile = { path = "../moli-browser-profile" }moli-cookie-cache = { path = "../moli-cookie-cache" }moli-cookie-jar = { path = "../moli-cookie-jar" }moli-crypto = { path = "../moli-crypto" }+# Keep imports self-contained; .cargo/config.toml trims unused SQLite C extensions.rusqlite = { version = "0.37.0", features = ["bundled"] }rusty-leveldb = "4.0.1"serde_json = "1.0.145"diff --git a/moli-cookie-import/src/chrome.rs b/moli-cookie-import/src/chrome.rsindex ab18588f4..a91a2bd16 100644--- a/moli-cookie-import/src/chrome.rs+++ b/moli-cookie-import/src/chrome.rs@@ -372,7 +372,63 @@ fn copy_dir(source: &Path, destination: &Path) -> Result<()> {#[cfg(test)]mod tests {- use super::{chrome_expiry, decode_chrome_string, decode_local_storage_key};+ use super::*;++ #[test]+ fn imports_chrome_cookies_with_and_without_partition_columns() -> Result<()> {+ for partitioned in [false, true] {+ let profile = tempfile::tempdir()?;+ let network = profile.path().join("Network");+ fs::create_dir(&network)?;+ let connection = Connection::open(network.join("Cookies"))?;+ connection.execute_batch(+ "CREATE TABLE meta (key TEXT PRIMARY KEY, value TEXT);+ INSERT INTO meta VALUES ('version', '24');+ CREATE TABLE cookies (+ host_key TEXT, name TEXT, value TEXT, encrypted_value BLOB,+ path TEXT, expires_utc INTEGER, is_secure INTEGER,+ is_httponly INTEGER, samesite INTEGER, priority INTEGER,+ source_scheme INTEGER, source_port INTEGER+ );+ INSERT INTO cookies VALUES (+ '.example.com', 'session', 'stored-value', X'', '/',+ 0, 1, 1, 1, 2, 2, 443+ );",+ )?;+ if partitioned {+ connection.execute_batch(+ "ALTER TABLE cookies ADD COLUMN top_frame_site_key TEXT;+ ALTER TABLE cookies ADD COLUMN has_cross_site_ancestor INTEGER;+ UPDATE cookies SET top_frame_site_key = 'https://example.org',+ has_cross_site_ancestor = 1;",+ )?;+ }+ drop(connection);++ let cookies = import_cookies(profile.path(), &ChromeCryptoKey::System)?;+ assert_eq!(cookies.len(), 1);+ let cookie = &cookies[0];+ assert_eq!(cookie.name, "session");+ assert_eq!(cookie.value, "stored-value");+ assert_eq!(cookie.domain, ".example.com");+ assert!(!cookie.host_only);+ assert!(cookie.secure);+ assert!(cookie.http_only);+ assert_eq!(cookie.expires, None);+ assert_eq!(cookie.same_site, StoredCookieSameSite::Lax);+ assert_eq!(cookie.priority, Some(CookiePriority::High));+ assert_eq!(cookie.source_scheme, StoredCookieSourceScheme::Secure);+ assert_eq!(cookie.source_port, 443);+ assert_eq!(+ cookie.partition_key,+ partitioned.then(|| StoredCookiePartitionKey::site(+ "https://example.org".to_owned(),+ true,+ )),+ );+ }+ Ok(())+ }#[test]fn decodes_chrome_local_storage_latin1_key() {diff --git a/moli-cookie-import/src/firefox.rs b/moli-cookie-import/src/firefox.rsindex 9ec0f83a7..a0a9f844c 100644--- a/moli-cookie-import/src/firefox.rs+++ b/moli-cookie-import/src/firefox.rs@@ -269,10 +269,21 @@ mod tests {#[test]fn imports_firefox_cookies_and_local_storage_databases() -> Result<()> {+ check_firefox_database_imports("DELETE")+ }++ #[test]+ fn imports_firefox_cookies_and_local_storage_from_wal() -> Result<()> {+ check_firefox_database_imports("WAL")+ }++ fn check_firefox_database_imports(journal_mode: &str) -> Result<()> {let temp = tempfile::tempdir()?;let profile = temp.path().join("firefox");fs::create_dir_all(&profile)?;let cookies_db = Connection::open(profile.join("cookies.sqlite"))?;+ cookies_db.pragma_update(None, "journal_mode", journal_mode)?;+ cookies_db.pragma_update(None, "wal_autocheckpoint", 0)?;cookies_db.execute_batch("CREATE TABLE moz_cookies (name TEXT, value TEXT, host TEXT, path TEXT, expiry INTEGER,@@ -295,11 +306,11 @@ mod tests {""],)?;- drop(cookies_db);-let storage_dir = profile.join("storage/default/https+++example.com/ls");fs::create_dir_all(&storage_dir)?;let storage_db = Connection::open(storage_dir.join("data.sqlite"))?;+ storage_db.pragma_update(None, "journal_mode", journal_mode)?;+ storage_db.pragma_update(None, "wal_autocheckpoint", 0)?;storage_db.execute_batch("CREATE TABLE database (origin TEXT NOT NULL);CREATE TABLE data (@@ -314,10 +325,17 @@ mod tests {"INSERT INTO data VALUES (?1,?2,?3,?4,0,?5)",params!["stored-key", 12, 1, 1, compressed],)?;- drop(storage_db);++ // Keep both connections open so WAL data is not checkpointed on close.+ if journal_mode == "WAL" {+ assert!(profile.join("cookies.sqlite-wal").is_file());+ assert!(storage_dir.join("data.sqlite-wal").is_file());+ }let cookies = import_cookies(&profile)?;assert_eq!(cookies.len(), 1);+ assert_eq!(cookies[0].name, "session");+ assert_eq!(cookies[0].value, "value");assert_eq!(cookies[0].same_site, StoredCookieSameSite::Lax);let destination = temp.path().join("localstorage.json");assert_eq!(import_local_storage(&profile, &destination)?, 1);diff --git a/moli-cookie-import/src/lib.rs b/moli-cookie-import/src/lib.rsindex 02a738597..301f4b4fc 100644--- a/moli-cookie-import/src/lib.rs+++ b/moli-cookie-import/src/lib.rs@@ -177,6 +177,36 @@ mod tests {use super::*;+ #[test]+ fn bundled_sqlite_omits_unused_extensions() -> Result<()> {+ // Inspect the linked engine so dependency upgrades cannot silently+ // reintroduce extensions excluded by .cargo/config.toml.+ let connection = rusqlite::Connection::open_in_memory()?;+ for option in [+ "ENABLE_FTS3",+ "ENABLE_FTS3_PARENTHESIS",+ "ENABLE_FTS4",+ "ENABLE_FTS5",+ "ENABLE_RTREE",+ "ENABLE_DBSTAT_VTAB",+ "ENABLE_STAT4",+ "ENABLE_LOAD_EXTENSION",+ ] {+ let enabled: bool =+ connection.query_row("SELECT sqlite_compileoption_used(?1)", [option], |row| {+ row.get(0)+ })?;+ assert!(!enabled, "bundled SQLite unexpectedly enables {option}");+ }+ let omits_extension_loading: bool = connection.query_row(+ "SELECT sqlite_compileoption_used('OMIT_LOAD_EXTENSION')",+ [],+ |row| row.get(0),+ )?;+ assert!(omits_extension_loading);+ Ok(())+ }+#[test]fn imports_a_netscape_cookie_jar() -> Result<()> {let temp = tempfile::tempdir()?;