From 71183592ef0751b7a63b0d22fe37c9cce88f2dac Mon Sep 17 00:00:00 2001 From: kenbak wan Date: Sat, 14 Nov 2026 20:39:23 -0300 Subject: [PATCH 1/2] Upgrade sqlx to 0.9.0 and audit dynamic SQL sqlx 0.9 requires SqlSafeStr for query strings. Static migration arrays now iterate by value (&'static str); webhook SQL is literal; the pragma_table_info column check is fully bound. The remaining dynamic sites interpolate only compile-time column lists, '?' placeholders, fixed identifiers, or DDL read from this database's sqlite_master, and are marked AssertSqlSafe with that justification. Features are pinned to sqlite-bundled + sqlite-unlock-notify, matching the 0.8 libsqlite3-sys feature set (0.9's 'sqlite' would add deserialize and load-extension). sqlx 0.9.0 still caps libsqlite3-sys < 0.38, so RUSTSEC-2026-0459 is not fixed by this commit. --- Cargo.lock | 394 +++++++++++------------------------- Cargo.toml | 2 +- src/api/admin.rs | 5 +- src/api/auth.rs | 19 +- src/api/payment_links.rs | 4 +- src/db.rs | 8 +- src/db/bootstrap.rs | 35 ++-- src/db/schema_tracking.rs | 5 +- src/merchants/mod.rs | 22 +- src/payment_links/mod.rs | 6 +- src/prices/mod.rs | 6 +- src/referrals/guardrails.rs | 3 +- src/subscriptions/mod.rs | 12 +- 13 files changed, 182 insertions(+), 339 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2cf2251..7b3471c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,7 +60,7 @@ dependencies = [ "bytestring", "derive_more", "encoding_rs", - "foldhash 0.2.0", + "foldhash", "futures-core", "http 0.2.12", "httparse", @@ -170,7 +170,7 @@ dependencies = [ "cookie", "derive_more", "encoding_rs", - "foldhash 0.2.0", + "foldhash", "futures-core", "futures-util", "impl-more 0.3.10", @@ -530,7 +530,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" dependencies = [ - "sha2", + "sha2 0.10.9", "tinyvec", ] @@ -607,6 +607,7 @@ dependencies = [ "cfg-if", "cipher 0.5.2", "cpufeatures 0.3.1", + "rand_core 0.10.1", "zeroize", ] @@ -678,7 +679,7 @@ dependencies = [ "ed25519-dalek", "futures", "hex", - "hmac", + "hmac 0.12.1", "image", "qrcode", "rand 0.8.8", @@ -686,7 +687,7 @@ dependencies = [ "serde", "serde_json", "serde_json_canonicalizer", - "sha2", + "sha2 0.10.9", "sha3", "sqlx", "subtle", @@ -918,7 +919,7 @@ dependencies = [ "cfg-if", "cpufeatures 0.2.17", "curve25519-dalek-derive", - "digest", + "digest 0.10.7", "fiat-crypto", "rustc_version", "subtle", @@ -963,7 +964,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" dependencies = [ "const-oid", - "pem-rfc7468", "zeroize", ] @@ -1017,11 +1017,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", - "const-oid", "crypto-common 0.1.7", "subtle", ] +[[package]] +name = "digest" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" +dependencies = [ + "block-buffer 0.12.1", + "crypto-common 0.2.2", + "ctutils", +] + [[package]] name = "displaydoc" version = "0.2.7" @@ -1058,7 +1068,7 @@ dependencies = [ "curve25519-dalek", "ed25519", "serde", - "sha2", + "sha2 0.10.9", "subtle", "zeroize", ] @@ -1100,18 +1110,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] name = "etcetera" -version = "0.8.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +checksum = "de48cc4d1c1d97a20fd819def54b890cadde72ed3ad0c614822a0a433361be96" dependencies = [ "cfg-if", - "home", - "windows-sys 0.48.0", + "windows-sys 0.61.2", ] [[package]] @@ -1174,9 +1183,9 @@ dependencies = [ [[package]] name = "flume" -version = "0.11.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" +checksum = "5e139bc46ca777eb5efaf62df0ab8cc5fd400866427e56c68b22e414e53bd3be" dependencies = [ "futures-core", "futures-sink", @@ -1189,12 +1198,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - [[package]] name = "foldhash" version = "0.2.0" @@ -1386,6 +1389,7 @@ dependencies = [ "cfg-if", "libc", "r-efi 6.0.0", + "rand_core 0.10.1", ] [[package]] @@ -1479,13 +1483,13 @@ checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "hashbrown" -version = "0.15.5" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ "allocator-api2", "equivalent", - "foldhash 0.1.5", + "foldhash", ] [[package]] @@ -1496,11 +1500,11 @@ checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" [[package]] name = "hashlink" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" +checksum = "824e001ac4f3012dd16a264bec811403a67ca9deb6c102fc5049b32c4574b35f" dependencies = [ - "hashbrown 0.15.5", + "hashbrown 0.16.1", ] [[package]] @@ -1517,11 +1521,11 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hkdf" -version = "0.12.4" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +checksum = "4aaa26c720c68b866f2c96ef5c1264b3e6f473fe5d4ce61cd44bbe913e553018" dependencies = [ - "hmac", + "hmac 0.13.0", ] [[package]] @@ -1530,16 +1534,16 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest", + "digest 0.10.7", ] [[package]] -name = "home" -version = "0.5.12" +name = "hmac" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d" +checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f" dependencies = [ - "windows-sys 0.61.2", + "digest 0.11.3", ] [[package]] @@ -1927,9 +1931,6 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] [[package]] name = "libc" @@ -1943,18 +1944,6 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" -[[package]] -name = "libredox" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d8f1ea3f21fd3405dcaf6c9b5c1630af9afc422d9073ea39c5f6d6c772e08ed" -dependencies = [ - "bitflags", - "libc", - "plain", - "redox_syscall 0.9.4", -] - [[package]] name = "libsqlite3-sys" version = "0.30.1" @@ -2021,12 +2010,12 @@ dependencies = [ [[package]] name = "md-5" -version = "0.10.6" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +checksum = "69b6441f590336821bb897fb28fc622898ccceb1d6cea3fde5ea86b090c4de98" dependencies = [ "cfg-if", - "digest", + "digest 0.11.3", ] [[package]] @@ -2197,22 +2186,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-bigint-dig" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e661dda6640fad38e827a6d4a310ff4763082116fe217f279885c97f511bb0b7" -dependencies = [ - "lazy_static", - "libm", - "num-integer", - "num-iter", - "num-traits", - "rand 0.8.8", - "smallvec", - "zeroize", -] - [[package]] name = "num-conv" version = "0.2.2" @@ -2228,16 +2201,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-iter" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c92800bd69a1eac91786bcfe9da64a897eb72911b8dc3095decbd07429e8048b" -dependencies = [ - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -2245,7 +2208,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", - "libm", ] [[package]] @@ -2336,7 +2298,7 @@ checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.18", + "redox_syscall", "smallvec", "windows-link", ] @@ -2347,15 +2309,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35fb2e5f958ec131621fdd531e9fc186ed768cbe395337403ae56c17a74c68ec" -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - [[package]] name = "percent-encoding" version = "2.3.2" @@ -2368,17 +2321,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" -[[package]] -name = "pkcs1" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" -dependencies = [ - "der", - "pkcs8", - "spki", -] - [[package]] name = "pkcs8" version = "0.10.2" @@ -2395,12 +2337,6 @@ version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" -[[package]] -name = "plain" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" - [[package]] name = "png" version = "0.18.1" @@ -2562,6 +2498,8 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" dependencies = [ + "chacha20", + "getrandom 0.4.3", "rand_core 0.10.1", ] @@ -2627,15 +2565,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "redox_syscall" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "737970939a87c6fa31e7acad13307bccbb017a073b695b6089a2c484f929e20e" -dependencies = [ - "bitflags", -] - [[package]] name = "regex" version = "1.13.1" @@ -2731,27 +2660,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" dependencies = [ - "digest", -] - -[[package]] -name = "rsa" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8573f03f5883dcaebdfcf4725caa1ecb9c15b2ef50c43a07b816e06799bb12d" -dependencies = [ - "const-oid", - "digest", - "num-bigint-dig", - "num-integer", - "num-traits", - "pkcs1", - "pkcs8", - "rand_core 0.6.4", - "signature", - "spki", - "subtle", - "zeroize", + "digest 0.10.7", ] [[package]] @@ -2782,7 +2691,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -2988,7 +2897,18 @@ checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8" dependencies = [ "cfg-if", "cpufeatures 0.2.17", - "digest", + "digest 0.10.7", +] + +[[package]] +name = "sha1" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aacc4cc499359472b4abe1bf11d0b12e688af9a805fa5e3016f9a386dc2d0214" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.1", + "digest 0.11.3", ] [[package]] @@ -2999,7 +2919,18 @@ checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ "cfg-if", "cpufeatures 0.2.17", - "digest", + "digest 0.10.7", +] + +[[package]] +name = "sha2" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.1", + "digest 0.11.3", ] [[package]] @@ -3008,7 +2939,7 @@ version = "0.10.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77fd7028345d415a4034cf8777cd4f8ab1851274233b45f84e3d955502d93874" dependencies = [ - "digest", + "digest 0.10.7", "keccak", ] @@ -3043,7 +2974,6 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "digest", "rand_core 0.6.4", ] @@ -3114,9 +3044,9 @@ dependencies = [ [[package]] name = "sqlx" -version = "0.8.6" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fefb893899429669dcdd979aff487bd78f4064e5e7907e4269081e0ef7d97dc" +checksum = "378620ccc25c62c89d8be1c819e76a88d59bdcc3304733330788948e619bfd71" dependencies = [ "sqlx-core", "sqlx-macros", @@ -3127,12 +3057,13 @@ dependencies = [ [[package]] name = "sqlx-core" -version = "0.8.6" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee6798b1838b6a0f69c007c133b8df5866302197e404e8b6ee8ed3e3a5e68dc6" +checksum = "05b44e85bf579a8eeb4ceaa77a3a523baf2bf0e9bac7e40f405d537b5d2d5ccb" dependencies = [ "base64 0.22.1", "bytes", + "cfg-if", "chrono", "crc", "crossbeam-queue", @@ -3142,16 +3073,15 @@ dependencies = [ "futures-intrusive", "futures-io", "futures-util", - "hashbrown 0.15.5", + "hashbrown 0.16.1", "hashlink", "indexmap", "log", "memchr", - "once_cell", "percent-encoding", "serde", "serde_json", - "sha2", + "sha2 0.10.9", "smallvec", "thiserror 2.0.20", "tokio", @@ -3163,9 +3093,9 @@ dependencies = [ [[package]] name = "sqlx-macros" -version = "0.8.6" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2d452988ccaacfbf5e0bdbc348fb91d7c8af5bee192173ac3636b5fb6e6715d" +checksum = "bd2b84f2bc39a5705ef27ec785a11c934a41bbd4a24941e257927cddc26b60bf" dependencies = [ "proc-macro2", "quote", @@ -3176,20 +3106,20 @@ dependencies = [ [[package]] name = "sqlx-macros-core" -version = "0.8.6" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19a9c1841124ac5a61741f96e1d9e2ec77424bf323962dd894bdb93f37d5219b" +checksum = "fb8d96de5fdc85a5c4ec813432b523ec637e80ba98f046555f75f7908ddac7c3" dependencies = [ + "cfg-if", "dotenvy", "either", "heck", "hex", - "once_cell", "proc-macro2", "quote", "serde", "serde_json", - "sha2", + "sha2 0.10.9", "sqlx-core", "sqlx-mysql", "sqlx-postgres", @@ -3201,53 +3131,37 @@ dependencies = [ [[package]] name = "sqlx-mysql" -version = "0.8.6" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa003f0038df784eb8fecbbac13affe3da23b45194bd57dba231c8f48199c526" +checksum = "90b8020fe17c5f2c245bfa2505d7ef59c5604839527c740266ad2214acebea27" dependencies = [ - "atoi", - "base64 0.22.1", "bitflags", "byteorder", "bytes", "chrono", "crc", - "digest", + "digest 0.11.3", "dotenvy", "either", - "futures-channel", "futures-core", - "futures-io", "futures-util", "generic-array", - "hex", - "hkdf", - "hmac", - "itoa", "log", - "md-5", - "memchr", - "once_cell", "percent-encoding", - "rand 0.8.8", - "rsa", "serde", - "sha1", - "sha2", - "smallvec", + "sha1 0.11.0", + "sha2 0.11.1", "sqlx-core", - "stringprep", "thiserror 2.0.20", "tracing", "uuid", - "whoami", ] [[package]] name = "sqlx-postgres" -version = "0.8.6" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db58fcd5a53cf07c184b154801ff91347e4c30d17a3562a635ff028ad5deda46" +checksum = "87a2bdd6e83f6b3ea525ca9fee568030508b58355a43d0b2c1674d5f79dcd65e" dependencies = [ "atoi", "base64 0.22.1", @@ -3262,17 +3176,15 @@ dependencies = [ "futures-util", "hex", "hkdf", - "hmac", - "home", + "hmac 0.13.0", "itoa", "log", "md-5", "memchr", - "once_cell", - "rand 0.8.8", + "rand 0.10.2", "serde", "serde_json", - "sha2", + "sha2 0.11.1", "smallvec", "sqlx-core", "stringprep", @@ -3284,13 +3196,14 @@ dependencies = [ [[package]] name = "sqlx-sqlite" -version = "0.8.6" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2d12fe70b2c1b4401038055f90f151b78208de1f9f89a7dbfd41587a10c3eea" +checksum = "488e99c397a62007e4229aec669a179816339afc6d2620ca6fa420dbee2e982c" dependencies = [ "atoi", "chrono", "flume", + "form_urlencoded", "futures-channel", "futures-core", "futures-executor", @@ -3300,7 +3213,6 @@ dependencies = [ "log", "percent-encoding", "serde", - "serde_urlencoded", "sqlx-core", "thiserror 2.0.20", "tracing", @@ -3416,7 +3328,7 @@ dependencies = [ "getrandom 0.4.3", "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -3766,7 +3678,7 @@ dependencies = [ "log", "native-tls", "rand 0.9.5", - "sha1", + "sha1 0.10.7", "thiserror 2.0.20", "utf-8", ] @@ -3921,12 +3833,6 @@ dependencies = [ "wit-bindgen", ] -[[package]] -name = "wasite" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" - [[package]] name = "wasm-bindgen" version = "0.2.128" @@ -4062,13 +3968,9 @@ dependencies = [ [[package]] name = "whoami" -version = "1.6.1" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d4a4db5077702ca3015d3d02d74974948aba2ad9e12ab7df718ee64ccd7e97d" -dependencies = [ - "libredox", - "wasite", -] +checksum = "626c4bac6755d76ffc12cb01b2eac751db1996b9e0041de9aa02c8c211ddc82c" [[package]] name = "winapi" @@ -4162,22 +4064,13 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.6", + "windows-targets", ] [[package]] @@ -4189,67 +4082,34 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - [[package]] name = "windows-targets" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -4262,48 +4122,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -4531,7 +4367,7 @@ dependencies = [ "incrementalmerkletree", "nonempty", "rand_core 0.10.1", - "sha2", + "sha2 0.10.9", "zakura-jubjub", "zakura-note-encryption", "zakura-orchard", @@ -4667,7 +4503,7 @@ dependencies = [ "hex", "nonempty", "ripemd", - "sha2", + "sha2 0.10.9", "subtle", "zakura-address", "zakura-protocol", @@ -4695,8 +4531,8 @@ dependencies = [ "bitflags", "bounded-vec", "ripemd", - "sha1", - "sha2", + "sha1 0.10.7", + "sha2 0.10.9", "thiserror 2.0.20", ] diff --git a/Cargo.toml b/Cargo.toml index 6d99f47..f8ceca4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ actix-governor = "0.7" tokio = { version = "1", features = ["full"] } # Database (SQLite for local dev, Postgres for production) -sqlx = { version = "0.8", default-features = false, features = ["runtime-tokio", "sqlite", "derive", "uuid", "chrono", "json"] } +sqlx = { version = "0.9", default-features = false, features = ["runtime-tokio", "sqlite-bundled", "sqlite-unlock-notify", "derive", "uuid", "chrono", "json"] } # Serialization serde = { version = "1", features = ["derive"] } diff --git a/src/api/admin.rs b/src/api/admin.rs index 53fb1b8..217667c 100644 --- a/src/api/admin.rs +++ b/src/api/admin.rs @@ -484,7 +484,8 @@ pub async fn webhooks( where_sql ); - let mut count_q = sqlx::query_scalar::<_, i64>(&count_sql); + // where_sql joins only fixed "column = ?" fragments; every value is bound. + let mut count_q = sqlx::query_scalar::<_, i64>(sqlx::AssertSqlSafe(count_sql)); for v in &bind_values { count_q = count_q.bind(v); } @@ -505,7 +506,7 @@ pub async fn webhooks( String, Option, ), - >(&list_sql); + >(sqlx::AssertSqlSafe(list_sql)); for v in &bind_values { list_q = list_q.bind(v); } diff --git a/src/api/auth.rs b/src/api/auth.rs index ff33208..509b09d 100644 --- a/src/api/auth.rs +++ b/src/api/auth.rs @@ -269,7 +269,8 @@ pub async fn my_invoices(req: HttpRequest, pool: web::Data) -> HttpR "SELECT id, label FROM prices WHERE id IN ({}) AND label IS NOT NULL", placeholders ); - let mut q = sqlx::query(&query_str); + // Only "?" placeholders are interpolated; every price id is bound. + let mut q = sqlx::query(sqlx::AssertSqlSafe(query_str)); for pid in &price_ids { q = q.bind(pid); } @@ -343,27 +344,27 @@ pub async fn my_webhooks( let (count_sql, list_sql) = if let Some(ref _status) = query.status { ( - "SELECT COUNT(*) FROM webhook_deliveries WHERE merchant_id = ? AND status = ?".to_string(), + "SELECT COUNT(*) FROM webhook_deliveries WHERE merchant_id = ? AND status = ?", "SELECT id, invoice_id, event_type, status, response_status, response_error, attempts, created_at, last_attempt_at - FROM webhook_deliveries WHERE merchant_id = ? AND status = ? ORDER BY created_at DESC LIMIT ? OFFSET ?".to_string(), + FROM webhook_deliveries WHERE merchant_id = ? AND status = ? ORDER BY created_at DESC LIMIT ? OFFSET ?", ) } else { ( - "SELECT COUNT(*) FROM webhook_deliveries WHERE merchant_id = ?".to_string(), + "SELECT COUNT(*) FROM webhook_deliveries WHERE merchant_id = ?", "SELECT id, invoice_id, event_type, status, response_status, response_error, attempts, created_at, last_attempt_at - FROM webhook_deliveries WHERE merchant_id = ? ORDER BY created_at DESC LIMIT ? OFFSET ?".to_string(), + FROM webhook_deliveries WHERE merchant_id = ? ORDER BY created_at DESC LIMIT ? OFFSET ?", ) }; let total: i64 = if let Some(ref status) = query.status { - sqlx::query_scalar::<_, i64>(&count_sql) + sqlx::query_scalar::<_, i64>(count_sql) .bind(&merchant.id) .bind(status) .fetch_one(pool.get_ref()) .await .unwrap_or(0) } else { - sqlx::query_scalar::<_, i64>(&count_sql) + sqlx::query_scalar::<_, i64>(count_sql) .bind(&merchant.id) .fetch_one(pool.get_ref()) .await @@ -381,7 +382,7 @@ pub async fn my_webhooks( String, Option, )> = if let Some(ref status) = query.status { - sqlx::query_as(&list_sql) + sqlx::query_as(list_sql) .bind(&merchant.id) .bind(status) .bind(limit) @@ -390,7 +391,7 @@ pub async fn my_webhooks( .await .unwrap_or_default() } else { - sqlx::query_as(&list_sql) + sqlx::query_as(list_sql) .bind(&merchant.id) .bind(limit) .bind(offset) diff --git a/src/api/payment_links.rs b/src/api/payment_links.rs index feae950..b084db2 100644 --- a/src/api/payment_links.rs +++ b/src/api/payment_links.rs @@ -599,10 +599,10 @@ pub async fn campaigns( config: web::Data, ) -> HttpResponse { let rows = match sqlx::query_as::<_, payment_links::PaymentLink>( - &format!( + sqlx::AssertSqlSafe(format!( "SELECT {} FROM payment_links WHERE mode = 'donation' AND active = 1 AND listed = 1 ORDER BY total_raised_zatoshis DESC, created_at DESC", payment_links::PL_COLUMNS_PUB - ), + )), ) .fetch_all(pool.get_ref()) .await diff --git a/src/db.rs b/src/db.rs index 1876110..e48333f 100644 --- a/src/db.rs +++ b/src/db.rs @@ -38,7 +38,7 @@ pub async fn create_pool(database_url: &str) -> anyhow::Result { // Billing email infrastructure: per-merchant fee rate, discount expiry, email idempotency run_tracked_migration(&pool, "billing_emails_v2026_04_10", || async { - for sql in &[ + for sql in [ "ALTER TABLE merchants ADD COLUMN fee_rate REAL", "ALTER TABLE merchants ADD COLUMN fee_discount_until TEXT", "ALTER TABLE fee_ledger ADD COLUMN fee_rate_applied REAL", @@ -106,7 +106,7 @@ pub async fn create_pool(database_url: &str) -> anyhow::Result { .await .ok(); - for sql in &[ + for sql in [ "ALTER TABLE sessions ADD COLUMN reauth_at TEXT", "ALTER TABLE merchants ADD COLUMN last_token_login_at TEXT", ] { @@ -233,7 +233,7 @@ pub async fn create_pool(database_url: &str) -> anyhow::Result { .await?; run_tracked_migration(&pool, "accounting_v2026_06_21", || async { - for sql in &[ + for sql in [ "ALTER TABLE invoices ADD COLUMN confirmed_rate REAL", "ALTER TABLE invoices ADD COLUMN confirmed_fiat_amount REAL", ] { @@ -266,7 +266,7 @@ pub async fn create_pool(database_url: &str) -> anyhow::Result { .await?; run_tracked_migration(&pool, "campaign_catchall_addresses_v2026_06_30", || async { - for sql in &[ + for sql in [ "ALTER TABLE payment_links ADD COLUMN campaign_address_hex TEXT", "ALTER TABLE payment_links ADD COLUMN campaign_diversifier_index INTEGER", "ALTER TABLE payment_links ADD COLUMN campaign_address_ua TEXT", diff --git a/src/db/bootstrap.rs b/src/db/bootstrap.rs index 6becb09..1c493be 100644 --- a/src/db/bootstrap.rs +++ b/src/db/bootstrap.rs @@ -17,7 +17,7 @@ pub(crate) async fn apply_inline_schema_migration(pool: SqlitePool) -> anyhow::R "ALTER TABLE merchants ADD COLUMN recovery_email TEXT", "ALTER TABLE merchants ADD COLUMN name TEXT NOT NULL DEFAULT ''", ]; - for sql in &upgrades { + for sql in upgrades { sqlx::query(sql).execute(&mut *conn).await.ok(); } @@ -38,7 +38,7 @@ pub(crate) async fn apply_inline_schema_migration(pool: SqlitePool) -> anyhow::R "ALTER TABLE invoices ADD COLUMN payment_address TEXT NOT NULL DEFAULT ''", "ALTER TABLE invoices ADD COLUMN zcash_uri TEXT NOT NULL DEFAULT ''", ]; - for sql in &invoice_upgrades { + for sql in invoice_upgrades { sqlx::query(sql).execute(&mut *conn).await.ok(); } @@ -454,7 +454,8 @@ pub(crate) async fn apply_inline_schema_migration(pool: SqlitePool) -> anyhow::R .execute(&mut *conn) .await .ok(); - sqlx::query(&inv_sql).execute(&mut *conn).await.ok(); + // DDL comes from this database's own sqlite_master, not from a request. + sqlx::query(sqlx::AssertSqlSafe(inv_sql)).execute(&mut *conn).await.ok(); sqlx::query("INSERT OR IGNORE INTO invoices SELECT * FROM _inv_repair") .execute(&mut *conn) .await @@ -635,7 +636,7 @@ pub(crate) async fn apply_inline_schema_migration(pool: SqlitePool) -> anyhow::R "ALTER TABLE merchants ADD COLUMN fee_rate REAL", "ALTER TABLE merchants ADD COLUMN fee_discount_until TEXT", ]; - for sql in &billing_upgrades { + for sql in billing_upgrades { sqlx::query(sql).execute(&mut *conn).await.ok(); } @@ -718,7 +719,7 @@ pub(crate) async fn apply_inline_schema_migration(pool: SqlitePool) -> anyhow::R .execute(&mut *conn) .await .ok(); - for sql in &[ + for sql in [ "ALTER TABLE billing_cycles ADD COLUMN total_fees_zatoshis INTEGER NOT NULL DEFAULT 0", "ALTER TABLE billing_cycles ADD COLUMN auto_collected_zatoshis INTEGER NOT NULL DEFAULT 0", "ALTER TABLE billing_cycles ADD COLUMN outstanding_zatoshis INTEGER NOT NULL DEFAULT 0", @@ -845,7 +846,7 @@ pub(crate) async fn apply_inline_schema_migration(pool: SqlitePool) -> anyhow::R .ok(); // Optional ticketing metadata on prices (safe additive columns) - for sql in &[ + for sql in [ "ALTER TABLE prices ADD COLUMN label TEXT", "ALTER TABLE prices ADD COLUMN max_quantity INTEGER", ] { @@ -1047,7 +1048,7 @@ pub(crate) async fn apply_inline_schema_migration(pool: SqlitePool) -> anyhow::R .ok(); // Price type columns (one_time vs recurring) - for sql in &[ + for sql in [ "ALTER TABLE prices ADD COLUMN price_type TEXT NOT NULL DEFAULT 'one_time'", "ALTER TABLE prices ADD COLUMN billing_interval TEXT", "ALTER TABLE prices ADD COLUMN interval_count INTEGER", @@ -1104,7 +1105,7 @@ pub(crate) async fn apply_inline_schema_migration(pool: SqlitePool) -> anyhow::R .await .ok(); - for sql in &[ + for sql in [ "CREATE INDEX IF NOT EXISTS idx_tickets_invoice ON tickets(invoice_id)", "CREATE INDEX IF NOT EXISTS idx_tickets_product_status ON tickets(product_id, status)", "CREATE INDEX IF NOT EXISTS idx_tickets_merchant_created ON tickets(merchant_id, created_at)", @@ -1265,17 +1266,19 @@ pub(crate) async fn apply_inline_schema_migration(pool: SqlitePool) -> anyhow::R ("subscriptions", "current_invoice_id"), ("subscriptions", "label"), ] { - let exists: bool = sqlx::query_scalar::<_, i32>(&format!( - "SELECT COUNT(*) FROM pragma_table_info('{}') WHERE name = '{}'", - table, col - )) + let exists: bool = sqlx::query_scalar::<_, i32>( + "SELECT COUNT(*) FROM pragma_table_info(?) WHERE name = ?", + ) + .bind(*table) + .bind(*col) .fetch_one(&mut *conn) .await .unwrap_or(0) > 0; if !exists { tracing::info!("Adding missing column {}.{}", table, col); - sqlx::query(&format!("ALTER TABLE {} ADD COLUMN {} TEXT", table, col)) + // table and col come from the fixed list above; DDL identifiers cannot be bound. + sqlx::query(sqlx::AssertSqlSafe(format!("ALTER TABLE {} ADD COLUMN {} TEXT", table, col))) .execute(&mut *conn) .await .ok(); @@ -1294,7 +1297,7 @@ pub(crate) async fn apply_inline_schema_migration(pool: SqlitePool) -> anyhow::R .ok(); // Webhook delivery enrichment: queryable event_type, merchant_id, response tracking - for sql in &[ + for sql in [ "ALTER TABLE webhook_deliveries ADD COLUMN event_type TEXT", "ALTER TABLE webhook_deliveries ADD COLUMN merchant_id TEXT", "ALTER TABLE webhook_deliveries ADD COLUMN response_status INTEGER", @@ -1384,7 +1387,7 @@ pub(crate) async fn apply_inline_schema_migration(pool: SqlitePool) -> anyhow::R .ok(); // Luma integration: merchant API key, event/price linking, invoice PII + registration state - for sql in &[ + for sql in [ "ALTER TABLE merchants ADD COLUMN luma_api_key TEXT", "ALTER TABLE events ADD COLUMN luma_event_id TEXT", "ALTER TABLE events ADD COLUMN luma_event_url TEXT", @@ -1404,7 +1407,7 @@ pub(crate) async fn apply_inline_schema_migration(pool: SqlitePool) -> anyhow::R .ok(); // Donation infrastructure: extend payment_links and invoices - for sql in &[ + for sql in [ "ALTER TABLE payment_links ADD COLUMN mode TEXT NOT NULL DEFAULT 'payment'", "ALTER TABLE payment_links ADD COLUMN donation_config TEXT", "ALTER TABLE payment_links ADD COLUMN total_raised INTEGER NOT NULL DEFAULT 0", diff --git a/src/db/schema_tracking.rs b/src/db/schema_tracking.rs index 7961692..4dfceba 100644 --- a/src/db/schema_tracking.rs +++ b/src/db/schema_tracking.rs @@ -203,10 +203,11 @@ async fn ensure_table_exists(pool: &SqlitePool, table: &str) -> anyhow::Result<( Ok(()) } -async fn ensure_columns(pool: &SqlitePool, table: &str, required: &[&str]) -> anyhow::Result<()> { +async fn ensure_columns(pool: &SqlitePool, table: &'static str, required: &[&str]) -> anyhow::Result<()> { let pragma = format!("PRAGMA table_info({})", table); let rows: Vec<(i64, String, String, i64, Option, i64)> = - sqlx::query_as(&pragma).fetch_all(pool).await?; + // Callers pass fixed table names; PRAGMA arguments cannot be bound. + sqlx::query_as(sqlx::AssertSqlSafe(pragma)).fetch_all(pool).await?; let existing: std::collections::HashSet = rows.into_iter().map(|row| row.1).collect(); for column in required { diff --git a/src/merchants/mod.rs b/src/merchants/mod.rs index 1eefc26..65eff28 100644 --- a/src/merchants/mod.rs +++ b/src/merchants/mod.rs @@ -242,7 +242,7 @@ pub async fn get_all_merchants( pool: &SqlitePool, encryption_key: &str, ) -> anyhow::Result> { - let rows = sqlx::query_as::<_, MerchantRow>(&format!("SELECT {MERCHANT_COLS} FROM merchants")) + let rows = sqlx::query_as::<_, MerchantRow>(sqlx::AssertSqlSafe(format!("SELECT {MERCHANT_COLS} FROM merchants"))) .fetch_all(pool) .await?; @@ -257,9 +257,9 @@ pub async fn get_merchant_by_id( id: &str, encryption_key: &str, ) -> anyhow::Result> { - let row = sqlx::query_as::<_, MerchantRow>(&format!( + let row = sqlx::query_as::<_, MerchantRow>(sqlx::AssertSqlSafe(format!( "SELECT {MERCHANT_COLS} FROM merchants WHERE id = ?" - )) + ))) .bind(id) .fetch_optional(pool) .await?; @@ -328,9 +328,9 @@ pub async fn authenticate_with_kind( // 2. Legacy primary key column. Same access semantics as a `Full` key in the // new table — kept so existing integrations don't have to migrate. - let row = sqlx::query_as::<_, MerchantRow>(&format!( + let row = sqlx::query_as::<_, MerchantRow>(sqlx::AssertSqlSafe(format!( "SELECT {MERCHANT_COLS} FROM merchants WHERE api_key_hash = ?" - )) + ))) .bind(&key_hash) .fetch_optional(pool) .await?; @@ -345,9 +345,9 @@ pub async fn authenticate_dashboard( ) -> anyhow::Result> { let token_hash = hash_key(token); - let row = sqlx::query_as::<_, MerchantRow>(&format!( + let row = sqlx::query_as::<_, MerchantRow>(sqlx::AssertSqlSafe(format!( "SELECT {MERCHANT_COLS} FROM merchants WHERE dashboard_token_hash = ?" - )) + ))) .bind(&token_hash) .fetch_optional(pool) .await?; @@ -383,11 +383,11 @@ pub async fn get_by_session_with_scope( .replace("id,", "m.id,") .replace(", ", ", m.") .replacen("m.id", "m.id", 1); - let row = sqlx::query_as::<_, MerchantRow>(&format!( + let row = sqlx::query_as::<_, MerchantRow>(sqlx::AssertSqlSafe(format!( "SELECT {} FROM merchants m JOIN sessions s ON s.merchant_id = m.id WHERE s.id = ? AND s.expires_at > strftime('%Y-%m-%dT%H:%M:%SZ', 'now')", cols - )) + ))) .bind(session_id) .fetch_optional(pool) .await?; @@ -475,9 +475,9 @@ pub async fn find_by_email( encryption_key: &str, ) -> anyhow::Result> { let email_hash = crate::crypto::blind_index(email, encryption_key); - let row = sqlx::query_as::<_, MerchantRow>(&format!( + let row = sqlx::query_as::<_, MerchantRow>(sqlx::AssertSqlSafe(format!( "SELECT {MERCHANT_COLS} FROM merchants WHERE recovery_email_hash = ?" - )) + ))) .bind(&email_hash) .fetch_optional(pool) .await?; diff --git a/src/payment_links/mod.rs b/src/payment_links/mod.rs index c4ad076..010ad65 100644 --- a/src/payment_links/mod.rs +++ b/src/payment_links/mod.rs @@ -333,7 +333,7 @@ pub async fn create_donation_link( pub async fn get_payment_link(pool: &SqlitePool, id: &str) -> anyhow::Result> { let query = format!("SELECT {} FROM payment_links WHERE id = ?", PL_COLUMNS); - let row = sqlx::query_as::<_, PaymentLink>(&query) + let row = sqlx::query_as::<_, PaymentLink>(sqlx::AssertSqlSafe(query)) .bind(id) .fetch_optional(pool) .await?; @@ -343,7 +343,7 @@ pub async fn get_payment_link(pool: &SqlitePool, id: &str) -> anyhow::Result anyhow::Result> { let query = format!("SELECT {} FROM payment_links WHERE slug = ?", PL_COLUMNS); - let row = sqlx::query_as::<_, PaymentLink>(&query) + let row = sqlx::query_as::<_, PaymentLink>(sqlx::AssertSqlSafe(query)) .bind(slug) .fetch_optional(pool) .await?; @@ -359,7 +359,7 @@ pub async fn list_payment_links( "SELECT {} FROM payment_links WHERE merchant_id = ? ORDER BY created_at DESC", PL_COLUMNS ); - let rows = sqlx::query_as::<_, PaymentLink>(&query) + let rows = sqlx::query_as::<_, PaymentLink>(sqlx::AssertSqlSafe(query)) .bind(merchant_id) .fetch_all(pool) .await?; diff --git a/src/prices/mod.rs b/src/prices/mod.rs index 19de12f..6ead89f 100644 --- a/src/prices/mod.rs +++ b/src/prices/mod.rs @@ -174,7 +174,7 @@ pub async fn list_prices_for_product( "SELECT {} FROM prices WHERE product_id = ? ORDER BY currency ASC", PRICE_COLS ); - let rows = sqlx::query_as::<_, Price>(&q) + let rows = sqlx::query_as::<_, Price>(sqlx::AssertSqlSafe(q)) .bind(product_id) .fetch_all(pool) .await?; @@ -183,7 +183,7 @@ pub async fn list_prices_for_product( pub async fn get_price(pool: &SqlitePool, id: &str) -> anyhow::Result> { let q = format!("SELECT {} FROM prices WHERE id = ?", PRICE_COLS); - let row = sqlx::query_as::<_, Price>(&q) + let row = sqlx::query_as::<_, Price>(sqlx::AssertSqlSafe(q)) .bind(id) .fetch_optional(pool) .await?; @@ -199,7 +199,7 @@ pub async fn get_price_by_product_currency( "SELECT {} FROM prices WHERE product_id = ? AND currency = ? AND active = 1", PRICE_COLS ); - let row = sqlx::query_as::<_, Price>(&q) + let row = sqlx::query_as::<_, Price>(sqlx::AssertSqlSafe(q)) .bind(product_id) .bind(currency) .fetch_optional(pool) diff --git a/src/referrals/guardrails.rs b/src/referrals/guardrails.rs index cd6279c..9c030e9 100644 --- a/src/referrals/guardrails.rs +++ b/src/referrals/guardrails.rs @@ -80,7 +80,8 @@ pub async fn migrate(pool: &SqlitePool) -> anyhow::Result<()> { ) .execute(&mut *tx) .await?; - sqlx::query(&trigger).execute(&mut *tx).await?; + // Recreates the trigger DDL read from this database's sqlite_master above. + sqlx::query(sqlx::AssertSqlSafe(trigger)).execute(&mut *tx).await?; let existing: Vec = sqlx::query_scalar("SELECT merchant_id FROM merchant_referrals") .fetch_all(&mut *tx) .await?; diff --git a/src/subscriptions/mod.rs b/src/subscriptions/mod.rs index f149d7f..2daeede 100644 --- a/src/subscriptions/mod.rs +++ b/src/subscriptions/mod.rs @@ -105,7 +105,7 @@ pub async fn create_subscription( pub async fn get_subscription(pool: &SqlitePool, id: &str) -> anyhow::Result> { let q = format!("SELECT {} FROM subscriptions WHERE id = ?", SUB_COLS); - let row = sqlx::query_as::<_, Subscription>(&q) + let row = sqlx::query_as::<_, Subscription>(sqlx::AssertSqlSafe(q)) .bind(id) .fetch_optional(pool) .await?; @@ -120,7 +120,7 @@ pub async fn list_subscriptions( "SELECT {} FROM subscriptions WHERE merchant_id = ? ORDER BY created_at DESC", SUB_COLS ); - let rows = sqlx::query_as::<_, Subscription>(&q) + let rows = sqlx::query_as::<_, Subscription>(sqlx::AssertSqlSafe(q)) .bind(merchant_id) .fetch_all(pool) .await?; @@ -334,7 +334,7 @@ pub async fn process_renewals( "SELECT {} FROM subscriptions WHERE pause_at_period_end = 1 AND current_period_end <= ? AND status = 'active' LIMIT 500", SUB_COLS ); - let to_pause: Vec = sqlx::query_as::<_, Subscription>(&q) + let to_pause: Vec = sqlx::query_as::<_, Subscription>(sqlx::AssertSqlSafe(q)) .bind(&now_str) .fetch_all(pool) .await?; @@ -374,7 +374,7 @@ pub async fn process_renewals( "SELECT {} FROM subscriptions WHERE cancel_at_period_end = 1 AND current_period_end <= ? AND status = 'active' LIMIT 500", SUB_COLS ); - let to_cancel: Vec = sqlx::query_as::<_, Subscription>(&q) + let to_cancel: Vec = sqlx::query_as::<_, Subscription>(sqlx::AssertSqlSafe(q)) .bind(&now_str) .fetch_all(pool) .await?; @@ -422,7 +422,7 @@ pub async fn process_renewals( "SELECT {} FROM subscriptions WHERE status = 'active' AND current_period_end <= ? AND cancel_at_period_end = 0 AND pause_at_period_end = 0 LIMIT 500", SUB_COLS ); - let due_subs: Vec = sqlx::query_as::<_, Subscription>(&q) + let due_subs: Vec = sqlx::query_as::<_, Subscription>(sqlx::AssertSqlSafe(q)) .bind(¬ice_threshold) .fetch_all(pool) .await?; @@ -534,7 +534,7 @@ pub async fn process_renewals( ))) AND current_period_end <= ? AND cancel_at_period_end = 0 AND pause_at_period_end = 0 LIMIT 500", SUB_COLS ); - let past_due_candidates: Vec = sqlx::query_as::<_, Subscription>(&q) + let past_due_candidates: Vec = sqlx::query_as::<_, Subscription>(sqlx::AssertSqlSafe(q)) .bind(&now_str) .fetch_all(pool) .await?; From 5854da27baa15836f3b16750be202f4449b97d04 Mon Sep 17 00:00:00 2001 From: kenbak wan Date: Sat, 14 Nov 2026 20:43:35 -0300 Subject: [PATCH 2/2] CI: keep RUSTSEC-2026-0459 ignore until sqlx 0.9.1 --- .github/workflows/audit.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 5a2a23b..cc15ede 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -19,6 +19,7 @@ jobs: # RUSTSEC-2026-0459 (bundled SQLite < 3.54 WAL page-size disclosure) is # local-only: it needs a less-trusted party to write the DB/-wal pair the # process opens. The API opens only its own database under its service - # user. Owner-approved 2026-11-14. The fix needs sqlx 0.9 - # (libsqlite3-sys 0.39); remove this ignore with that upgrade. + # user. Owner-approved 2026-11-14. sqlx 0.9.0 still caps libsqlite3-sys + # below 0.38; remove this ignore with sqlx 0.9.1, which allows + # libsqlite3-sys 0.39 (https://github.com/launchbadge/sqlx/pull/4517). - run: cargo audit --deny unmaintained --deny unsound --ignore RUSTSEC-2023-0071 --ignore RUSTSEC-2023-0089 --ignore RUSTSEC-2026-0459