From bc552348d61992d40c6a9bf5fa49a8afe7d36fd6 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Fri, 20 Nov 2026 18:22:58 +0100 Subject: [PATCH] fix: replace chrono and update rustix for RustSec --- Cargo.lock | 194 ++++++++++++---------------------- Cargo.toml | 6 +- Jenkinsfile | 2 +- README.md | 2 +- docs/architecture.md | 2 +- docs/library.md | 2 +- docs/security-and-ci.md | 23 ++-- examples/validate-hardware.rs | 2 +- src/export.rs | 27 ++++- 9 files changed, 116 insertions(+), 144 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28e89fb..be5563f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,15 +32,6 @@ version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" -[[package]] -name = "android_system_properties" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" -dependencies = [ - "libc", -] - [[package]] name = "anyhow" version = "1.0.104" @@ -155,16 +146,6 @@ dependencies = [ "rustversion", ] -[[package]] -name = "cc" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f74872d07caf508b30a21f6836e7d7016a2eaf7d9ff4f48deaa58cd8a0407630" -dependencies = [ - "find-msvc-tools", - "shlex", -] - [[package]] name = "cfg-if" version = "1.0.5" @@ -177,19 +158,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" -[[package]] -name = "chrono" -version = "0.4.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" -dependencies = [ - "iana-time-zone", - "js-sys", - "num-traits", - "wasm-bindgen", - "windows-link", -] - [[package]] name = "color-eyre" version = "0.6.5" @@ -468,12 +436,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "find-msvc-tools" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484" - [[package]] name = "finl_unicode" version = "1.5.0" @@ -488,11 +450,11 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flexi_logger" -version = "0.29.8" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88a5a6882b2e137c4f2664562995865084eb5a00611fba30c582ef10354c4ad8" +checksum = "5e87b74024da93123949cca26cb6e366744234fdd4d7914eb3dfeab0baa82d51" dependencies = [ - "chrono", + "jiff", "log", "nu-ansi-term", "regex", @@ -608,30 +570,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "iana-time-zone" -version = "0.1.65" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "log", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - [[package]] name = "ident_case" version = "1.0.1" @@ -701,6 +639,58 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" +[[package]] +name = "jiff" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5d126d72eb017f10b302e73bdeca446bea405ee449af4d9e7866d6b082d83e" +dependencies = [ + "jiff-core", + "jiff-static", + "jiff-tzdb-platform", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", + "windows-link", +] + +[[package]] +name = "jiff-core" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6b46a105a9874634dd96231021526bf24ca04955a5998c59a9c7666e634b7b8" +dependencies = [ + "log", +] + +[[package]] +name = "jiff-static" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0127e9bde3c6130d6169e7d8d68676e4be69c4bf7573c308b6f960a5089c428" +dependencies = [ + "jiff-core", + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "jiff-tzdb" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12e71a1b68a875a44a33bb7a1dd84392cb77145a3367a552a3cfe6a4f5cf3afc" + +[[package]] +name = "jiff-tzdb-platform" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc65b284afcfa8f6cf189c7274c805505314a7ab975c60e1f548bff56525420e" +dependencies = [ + "jiff-tzdb", +] + [[package]] name = "js-sys" version = "0.3.106" @@ -1167,6 +1157,15 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" +[[package]] +name = "portable-atomic-util" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715" +dependencies = [ + "portable-atomic", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -1374,9 +1373,9 @@ dependencies = [ [[package]] name = "rustix" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" dependencies = [ "bitflags 2.13.2", "errno", @@ -1487,12 +1486,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "shlex" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" - [[package]] name = "signal-hook" version = "0.3.18" @@ -1758,9 +1751,9 @@ checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" name = "tiny-wb" version = "0.1.5" dependencies = [ - "chrono", "color-eyre", "flexi_logger", + "jiff", "log", "ratatui", "serde", @@ -2121,65 +2114,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-core" -version = "0.62.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" -dependencies = [ - "windows-implement", - "windows-interface", - "windows-link", - "windows-result", - "windows-strings", -] - -[[package]] -name = "windows-implement" -version = "0.60.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "windows-interface" -version = "0.59.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - [[package]] name = "windows-link" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" -[[package]] -name = "windows-result" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" -dependencies = [ - "windows-link", -] - -[[package]] -name = "windows-strings" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" -dependencies = [ - "windows-link", -] - [[package]] name = "windows-sys" version = "0.52.0" diff --git a/Cargo.toml b/Cargo.toml index 64566a1..ae0f7a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "tiny-wb" version = "0.1.5" edition = "2021" -rust-version = "1.88.0" +rust-version = "1.91.0" license = "MIT" repository = "https://proxy.dandaedre.com/gitea/idle-org/tiny-wb" @@ -49,9 +49,9 @@ path = "tests/mock_device.rs" required-features = ["mock"] [dependencies] -chrono = "0.4.38" color-eyre = { version = "0.6.3", optional = true } -flexi_logger = { version = "0.29.0", optional = true } +flexi_logger = { version = "0.32.0", optional = true } +jiff = "1.0.1" log = "0.4.22" ratatui = { version = "=0.30.2", optional = true } serde = { version = "1.0.210", features = ["derive"] } diff --git a/Jenkinsfile b/Jenkinsfile index 26ccfca..8c12fa9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { RUST_BACKTRACE = '1' // LTS-like compatibility floor verified by the dedicated MSRV stage. - MSRV = '1.88.0' + MSRV = '1.91.0' // Supply-chain tools are pinned for reproducible policy behavior. CARGO_AUDIT_VERSION = '0.22.2' diff --git a/README.md b/README.md index 3006e33..916fb32 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ cable**, and access to its serial port. Close other software using the tinySA. For a first communications check, leave external RF sources disconnected. Before connecting a signal, read the [safe-operation guide](docs/tinysa-field-guide.md#safe-operation-read-before-connecting-a-signal). -To build from source, install Rust **1.88 or newer**, then run: +To build from source, install Rust **1.91 or newer**, then run: ```console git clone https://proxy.dandaedre.com/gitea/idle-org/tiny-wb.git diff --git a/docs/architecture.md b/docs/architecture.md index 074654b..7a78458 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -167,7 +167,7 @@ See [configuration](configuration.md) for settings, paths and exact behavior. The core uses standard-library byte decoding instead of `packed_struct`, and buffered framing instead of a separate direct `memchr` dependency. Transitive `memchr` use elsewhere in the graph is unrelated. Serde/TOML handle settings; -serialport, Ratatui, chrono, log/flexi_logger, color-eyre and thiserror retain +serialport, Ratatui, jiff, log/flexi_logger, color-eyre and thiserror retain their device, presentation, timestamp and error-reporting roles. Library consumers can omit terminal and serial dependencies; see [feature selection](library.md). diff --git a/docs/library.md b/docs/library.md index 20e28fb..c7c88f8 100644 --- a/docs/library.md +++ b/docs/library.md @@ -1,7 +1,7 @@ # Rust library integration The package builds both `tiny_wb` (Rust library) and `tiny-wb` (terminal app). -Rust 1.88 or newer is required. To integrate a checkout without terminal, serial, +Rust 1.91 or newer is required. To integrate a checkout without terminal, serial, libudev or Windows resource dependencies: ```toml diff --git a/docs/security-and-ci.md b/docs/security-and-ci.md index 60c0d49..54b2aab 100644 --- a/docs/security-and-ci.md +++ b/docs/security-and-ci.md @@ -7,7 +7,7 @@ runs `cargo-audit` plus `cargo-deny`. No other hardening tools are in scope. ## Rust compatibility floor The declared and CI-tested minimum supported Rust version (MSRV) is -**Rust 1.88.0**. This is an LTS-like project policy rather than an upstream Rust +**Rust 1.91.0**. This is an LTS-like project policy rather than an upstream Rust LTS designation: Rust itself does not publish LTS toolchains. The application code and the former Ratatui 0.28 dependency could be made to @@ -15,14 +15,23 @@ compile with older compilers, but that graph contained the unmaintained `paste` crate and `lru` releases covered by RustSec soundness advisories. Ratatui 0.30.0 still locked an affected optional `lru` and a vulnerable `time`. Ratatui 0.30.2 is the first tested upstream line that clears those findings, and it declares -Rust 1.88.0. The project therefore treats 1.88.0 as the lowest supported clean -graph rather than adding advisory exceptions or local dependency patches. +Rust 1.88.0. That established the previous compatibility floor. -`Cargo.toml` declares `rust-version = "1.88.0"`. CI installs that exact +On 2026-11-20, [RUSTSEC-2026-0543](https://rustsec.org/advisories/RUSTSEC-2026-0543) +required removing chrono (all versions are unmaintained). CSV export and the +hardware-validation example now use jiff, preserving local-time filenames and +six fractional digits. flexi_logger 0.32 removes its transitive chrono dependency +and requires Rust 1.91.0, which is the new build and CI floor. Existing logging +settings remain compatible; source builders must upgrade their Rust toolchain. +The locked rustix is also updated to at least 1.1.6 for +[RUSTSEC-2026-0486](https://rustsec.org/advisories/RUSTSEC-2026-0486). +Neither advisory is ignored. + +`Cargo.toml` declares `rust-version = "1.91.0"`. CI installs that exact toolchain and runs: ```console -cargo +1.88.0 check --locked --all-targets --all-features +cargo +1.91.0 check --locked --all-targets --all-features ``` The normal CI jobs use current stable Rust, while the MSRV job prevents source @@ -118,7 +127,7 @@ Run from the repository root, in this order: cargo audit --deny warnings cargo deny check cargo fmt --all -- --check -cargo +1.88.0 check --locked --all-targets --all-features +cargo +1.91.0 check --locked --all-targets --all-features cargo check --locked --all-targets --all-features cargo test --locked --all-targets --all-features cargo test --locked --no-default-features --lib @@ -202,7 +211,7 @@ unchanged. This corrects report scope, not test coverage. The subsequent supplie FreeBSD Jenkins build #7 confirmed `Final line coverage: 90.87%` and passed the coverage stage. That build then stopped at Clippy's `chunks_exact_to_as_chunks` lint; the decoder now iterates fixed-size records with `as_chunks::<3>()`, -compatible with the declared Rust 1.88 MSRV. Its exact frame-length validation +compatible with the then-declared Rust 1.88 MSRV. Its exact frame-length validation still rejects incomplete records before iteration. At checkout, CI recreates ignored `coverage/` to remove stale workspace state. diff --git a/examples/validate-hardware.rs b/examples/validate-hardware.rs index dbc44de..994fccb 100644 --- a/examples/validate-hardware.rs +++ b/examples/validate-hardware.rs @@ -226,7 +226,7 @@ fn run() -> Result<(), Box> { let session = arguments.output.join(format!( "{}-{}", arguments.model.name().to_ascii_lowercase(), - chrono::Local::now().format("%Y%m%d-%H%M%S-%6f") + jiff::ZonedDateTime::now().strftime("%Y%m%d-%H%M%S-%6f") )); fs::create_dir_all(&session)?; diff --git a/src/export.rs b/src/export.rs index eb38181..fffe02b 100644 --- a/src/export.rs +++ b/src/export.rs @@ -1,7 +1,7 @@ //! CSV serialization and collision-safe file creation, separate from decoding. use crate::{config::OutputConfig, protocol::Sample}; -use chrono::Local; +use jiff::ZonedDateTime; use std::{ fs::{self, OpenOptions}, io::{self, BufRead, BufWriter, Write}, @@ -108,7 +108,7 @@ pub fn write_csv( /// Readers may see the in-progress file, so only the returned path means complete. pub fn save_csv(samples: &[Sample], settings: &OutputConfig) -> io::Result { fs::create_dir_all(&settings.directory)?; - let stamp = Local::now().format("%Y%m%d %H_%M_%S_%6f").to_string(); + let stamp = filename_stamp(&ZonedDateTime::now()); for suffix in 0..100 { let path = settings .directory @@ -135,10 +135,33 @@ pub fn save_csv(samples: &[Sample], settings: &OutputConfig) -> io::Result String { + now.strftime("%Y%m%d %H_%M_%S_%6f").to_string() +} + #[cfg(test)] mod tests { use super::*; + #[test] + fn filename_timestamp_preserves_local_time_and_microseconds() { + for (input, expected) in [ + ( + "2024-02-29T23:59:58.123456789+05:30[+05:30]", + "20240229 23_59_58_123456", + ), + ( + "2026-01-01T00:00:00.000001-04:00[-04:00]", + "20260101 00_00_00_000001", + ), + ("2026-01-01T00:00:00Z[UTC]", "20260101 00_00_00_000000"), + ] { + let now: ZonedDateTime = input.parse().unwrap(); + assert_eq!(filename_stamp(&now), expected); + } + } + #[test] fn csv_has_explicit_units_only_when_requested() { let samples = [Sample {