diff --git a/Cargo.lock b/Cargo.lock index 0d69f8a7d..681e3ee3f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -258,15 +258,15 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "console" -version = "0.15.10" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea3c6ecd8059b57859df5c69830340ed3c41d30e3da0c1cbed90a96ac853041b" +checksum = "b430743a6eb14e9764d4260d4c0d8123087d504eeb9c48f2b2a5e810dd369df4" dependencies = [ "encode_unicode", "libc", "once_cell", - "unicode-width 0.2.0", - "windows-sys 0.59.0", + "unicode-width", + "windows-sys 0.61.2", ] [[package]] @@ -692,14 +692,14 @@ dependencies = [ [[package]] name = "indicatif" -version = "0.17.11" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "183b3088984b400f4cfac3620d5e076c84da5364016b4f49473de574b2586235" +checksum = "9375e112e4b463ec1b1c6c011953545c65a30164fbab5b581df32b3abf0dcb88" dependencies = [ "console", - "number_prefix", "portable-atomic", - "unicode-width 0.2.0", + "unicode-width", + "unit-prefix", "vt100", "web-time", ] @@ -745,9 +745,9 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itoa" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jobserver" @@ -900,12 +900,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" -[[package]] -name = "number_prefix" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" - [[package]] name = "object" version = "0.36.7" @@ -1541,9 +1535,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.33" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" dependencies = [ "once_cell", "valuable", @@ -1551,9 +1545,9 @@ dependencies = [ [[package]] name = "tracing-indicatif" -version = "0.3.9" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8201ca430e0cd893ef978226fd3516c06d9c494181c8bf4e5b32e30ed4b40aa1" +checksum = "04d4e11e0e27acef25a47f27e9435355fecdc488867fa2bc90e75b0700d2823d" dependencies = [ "indicatif", "tracing", @@ -1598,15 +1592,9 @@ checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" [[package]] name = "unicode-width" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" - -[[package]] -name = "unicode-width" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" [[package]] name = "unicode-xid" @@ -1614,6 +1602,12 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "unit-prefix" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81e544489bf3d8ef66c953931f56617f423cd4b5494be343d9b9d3dda037b9a3" + [[package]] name = "url" version = "2.5.4" @@ -1658,35 +1652,23 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vt100" -version = "0.15.2" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84cd863bf0db7e392ba3bd04994be3473491b31e66340672af5d11943c6274de" +checksum = "054ff75fb8fa83e609e685106df4faeffdf3a735d3c74ebce97ec557d5d36fd9" dependencies = [ "itoa", - "log", - "unicode-width 0.1.14", + "unicode-width", "vte", ] [[package]] name = "vte" -version = "0.11.1" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5022b5fbf9407086c180e9557be968742d839e68346af7792b8592489732197" +checksum = "a5924018406ce0063cd67f8e008104968b74b563ee1b85dde3ed1f7cb87d3dbd" dependencies = [ "arrayvec", - "utf8parse", - "vte_generate_state_changes", -] - -[[package]] -name = "vte_generate_state_changes" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e369bee1b05d510a7b4ed645f5faa90619e05437111783ea5848f28d97d3c2e" -dependencies = [ - "proc-macro2", - "quote", + "memchr", ] [[package]] @@ -1771,6 +1753,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + [[package]] name = "windows-sys" version = "0.52.0" @@ -1789,6 +1777,15 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + [[package]] name = "windows-targets" version = "0.52.6" diff --git a/Cargo.toml b/Cargo.toml index bd77acaec..fb6bc3bd5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,11 @@ time = { version = "0.3.41", features = ["parsing", "formatting"] } tokio = { version = "1.46.1", features = ["rt", "macros", "process"] } toml = "0.9.2" tracing = "0.1.41" -tracing-indicatif = "0.3.9" +tracing-indicatif = "0.3.13" tracing-subscriber = { version = "0.3.19", features = ["env-filter"] } url = { version = "2.5.4", features = ["serde"] } + +[workspace.lints.clippy] +unwrap_in_result = "deny" +unwrap_used = "deny" +panic = "deny" diff --git a/rust/boil/Cargo.toml b/rust/boil/Cargo.toml index 0bea38bbc..b1107d952 100644 --- a/rust/boil/Cargo.toml +++ b/rust/boil/Cargo.toml @@ -27,3 +27,6 @@ url.workspace = true [dev-dependencies] rstest.workspace = true + +[lints] +workspace = true diff --git a/rust/boil/src/build/bakefile.rs b/rust/boil/src/build/bakefile.rs index 505746df1..547052649 100644 --- a/rust/boil/src/build/bakefile.rs +++ b/rust/boil/src/build/bakefile.rs @@ -59,6 +59,12 @@ pub enum Error { #[snafu(display("failed to locate containerfile relative to the {path:?} directory"))] NoSuchContainerfileExists { path: String }, + + #[snafu(display("failed to open scoped directory as {path}"))] + OpenScopedDirectory { + source: std::io::Error, + path: String, + }, } #[derive(Debug, Snafu)] @@ -68,6 +74,9 @@ pub enum TargetsError { #[snafu(display("failed to read image config"))] ReadImageConfig { source: ImageConfigError }, + + #[snafu(display("failed to resolve parent directory of image config at {path}", path = path.display()))] + ResolveParentDirectory { path: PathBuf }, } #[derive(Debug, Default)] @@ -111,9 +120,21 @@ impl Targets { /// Returns a map of all targets by globbing for (nested) image config files. /// /// The search behaviour can be customized using the provided [`TargetsOptions`]. + // + // SAFETY: We purposefully allow the `clippy::unwrap_in_result` lint below in this function. + // We can use expect here, because the glob pattern is defined as a constant and the glob + // function only returns an error if the pattern is invalid. We must ensure the pattern is + // valid at compile time, because there is no need to allow an invalid pattern which would + // render this tool inoperable. + // + // FIXME (@Techassi): This attribute can be used on individual unwrap and expect calls since + // Rust 1.91.0. We should move this attribute to not contaminate an unnecessarily large scope + // once we bump the toolchain to 1.91.0. + // See https://github.com/rust-lang/rust-clippy/pull/15445 + #[allow(clippy::unwrap_in_result)] pub fn all(options: TargetsOptions) -> Result { let image_config_paths = glob(ImageConfig::ALL_CONFIGS_GLOB_PATTERN) - .expect("glob pattern must be valid") + .expect("constant glob pattern must be valid") .filter_map(Result::ok); let mut targets = Self::default(); @@ -124,7 +145,9 @@ impl Targets { let image_name = image_config_path .parent() - .expect("there must be a parent") + .with_context(|| ResolveParentDirectorySnafu { + path: image_config_path.clone(), + })? .to_string_lossy() .into_owned(); @@ -336,7 +359,10 @@ impl Bakefile { // By using a cap-std Dir, we can ensure that the paths provided must be relative to // the appropriate image folder and wont escape it by providing absolute or relative // paths with traversals (..). - let image_dir = Dir::open_ambient_dir(&image_name, ambient_authority()).unwrap(); + let image_dir = Dir::open_ambient_dir(&image_name, ambient_authority()) + .with_context(|_| OpenScopedDirectorySnafu { + path: image_name.clone(), + })?; let dockerfile_path = if let Some(custom_path) = &image_options.dockerfile { ensure!( diff --git a/rust/patchable/Cargo.toml b/rust/patchable/Cargo.toml index 9b8653ee6..498d7134e 100644 --- a/rust/patchable/Cargo.toml +++ b/rust/patchable/Cargo.toml @@ -18,3 +18,6 @@ toml.workspace = true tracing.workspace = true tracing-indicatif.workspace = true tracing-subscriber.workspace = true + +[lints] +workspace = true