From efc57b4afa4bc85dde067d832b820af7b9dbf457 Mon Sep 17 00:00:00 2001 From: theMackabu <theMackabu@gmail.com> Date: Sun, 28 Jan 2024 00:21:00 -0800 Subject: [PATCH] migrate to rustls-tls --- Cargo.lock | 223 +++++++++++---------------- Cargo.toml | 2 +- crates/maid/client/Cargo.toml | 4 +- crates/maid/server/Cargo.toml | 2 +- crates/maid/server/src/docker/run.rs | 12 +- 5 files changed, 103 insertions(+), 140 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 13f876b..9cfacfb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -710,21 +710,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.2.0" @@ -1029,16 +1014,17 @@ dependencies = [ ] [[package]] -name = "hyper-tls" -version = "0.5.0" +name = "hyper-rustls" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ - "bytes", + "futures-util", + "http", "hyper", - "native-tls", + "rustls", "tokio", - "tokio-native-tls", + "tokio-rustls", ] [[package]] @@ -1287,9 +1273,9 @@ dependencies = [ [[package]] name = "macros-rs" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "973fff3a34801ae9c15ba9ef09e82b1e37e2fdcb554d3e5f05d38ab2896dd383" +checksum = "d2c6d3c8d7adb9850f41a7797b7a9718784aefeee3d1fe5a84c09243703a49d0" [[package]] name = "maid" @@ -1463,24 +1449,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "newline-converter" version = "0.2.2" @@ -1579,50 +1547,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "openssl" -version = "0.10.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" -dependencies = [ - "bitflags 2.4.1", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.93" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "overload" version = "0.1.1" @@ -1764,12 +1688,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "pkg-config" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" - [[package]] name = "portable-atomic" version = "1.5.1" @@ -1980,29 +1898,45 @@ dependencies = [ "http", "http-body", "hyper", - "hyper-tls", + "hyper-rustls", "ipnet", "js-sys", "log", "mime", - "native-tls", "once_cell", "percent-encoding", "pin-project-lite", + "rustls", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", "system-configuration", "tokio", - "tokio-native-tls", + "tokio-rustls", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "webpki-roots 0.25.3", "winreg", ] +[[package]] +name = "ring" +version = "0.17.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" +dependencies = [ + "cc", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.48.0", +] + [[package]] name = "rmp" version = "0.8.12" @@ -2137,6 +2071,37 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "rustls" +version = "0.21.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.14" @@ -2158,15 +2123,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "schannel" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" -dependencies = [ - "windows-sys 0.48.0", -] - [[package]] name = "scoped-tls" version = "1.0.1" @@ -2180,26 +2136,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] -name = "security-framework" -version = "2.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.9.1" +name = "sct" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "core-foundation-sys", - "libc", + "ring", + "untrusted", ] [[package]] @@ -2608,12 +2551,12 @@ dependencies = [ ] [[package]] -name = "tokio-native-tls" -version = "0.3.1" +name = "tokio-rustls" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "native-tls", + "rustls", "tokio", ] @@ -2773,12 +2716,13 @@ dependencies = [ "http", "httparse", "log", - "native-tls", "rand", + "rustls", "sha1", "thiserror", "url", "utf-8", + "webpki-roots 0.24.0", ] [[package]] @@ -2857,6 +2801,12 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f28467d3e1d3c6586d8f25fa243f544f5800fec42d97032474e17222c2b75cfa" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.4.1" @@ -2896,12 +2846,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version_check" version = "0.9.4" @@ -3029,6 +2973,21 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b291546d5d9d1eab74f069c77749f2cb8504a12caa20f0f2de93ddbf6f411888" +dependencies = [ + "rustls-webpki", +] + +[[package]] +name = "webpki-roots" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index 9c6cd3c..3393ff9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,4 +30,4 @@ env_logger = "0.10.0" clap-verbosity-flag = "2.1.0" clap = { version = "4.4.7", features = ["derive"] } uuid = { version = "1.5.0", features = ["v4", "fast-rng"] } -reqwest = { version = "0.11.22", features = ["json", "blocking"] } +reqwest = { version = "0.11.22", default-features = false, features = ["json", "blocking", "rustls-tls"] } diff --git a/crates/maid/client/Cargo.toml b/crates/maid/client/Cargo.toml index 7fa46f5..c67727c 100644 --- a/crates/maid/client/Cargo.toml +++ b/crates/maid/client/Cargo.toml @@ -27,7 +27,7 @@ inquire = "0.6.2" anyhow = "1.0.75" fs_extra = "1.3.0" termcolor = "1.3.0" -macros-rs = "0.4.0" +macros-rs = "0.5.0" indicatif = "0.17.7" serde_json = "1.0.108" serde_yaml = "0.9.27" @@ -40,7 +40,7 @@ clap-verbosity-flag = "2.1.0" notify-debouncer-mini = "0.4.1" serde = { version = "1.0.192", features = ["derive"] } human_bytes = { version = "0.4.3", default-features = false } -tungstenite = { version = "0.20.1", features = ["native-tls"] } +tungstenite = { version = "0.20.1", features = ["rustls-tls-webpki-roots"] } lazy_static = "1.4.0" [build-dependencies] diff --git a/crates/maid/server/Cargo.toml b/crates/maid/server/Cargo.toml index a35bb47..07924ec 100644 --- a/crates/maid/server/Cargo.toml +++ b/crates/maid/server/Cargo.toml @@ -27,7 +27,7 @@ chrono = "0.4.31" futures = "0.3.29" bollard = "0.15.0" termcolor = "1.3.0" -macros-rs = "0.4.0" +macros-rs = "0.5.0" indicatif = "0.17.7" tokio-util = "0.7.10" tungstenite = "0.20.1" diff --git a/crates/maid/server/src/docker/run.rs b/crates/maid/server/src/docker/run.rs index b024118..ec689c6 100644 --- a/crates/maid/server/src/docker/run.rs +++ b/crates/maid/server/src/docker/run.rs @@ -14,7 +14,7 @@ use bytes::Bytes; use flate2::{write::GzEncoder, Compression}; use futures_core::Stream; use futures_util::{stream::TryStreamExt, SinkExt, StreamExt}; -use macros_rs::{fmtstr, str, string}; +use macros_rs::{fmtstr, str, string, then}; use rocket_ws::{stream::DuplexStream, Message}; use std::{default::Default, io::Write, path::PathBuf}; use text_placeholder::Template; @@ -78,8 +78,8 @@ pub async fn exec(mut stream: DuplexStream, docker: &Result<Docker, anyhow::Erro let docker_message = Response { level: Level::Docker, - message: Some(formatted), kind: Kind::Message, + message: Some(formatted), }; stream.send(docker_message.into()).await?; @@ -165,8 +165,10 @@ pub async fn exec(mut stream: DuplexStream, docker: &Result<Docker, anyhow::Erro Handle!(id, socket, stream.send(build_start_message.into()).await); - while let Some(Ok(msg)) = output.next().await { - if !parsed.info.remote.silent { + while let Some(msg) = output.next().await { + if let Ok(msg) = msg { + then!(parsed.info.remote.silent, continue); + let output_message = Response { level: Level::None, kind: Kind::Message, @@ -174,6 +176,8 @@ pub async fn exec(mut stream: DuplexStream, docker: &Result<Docker, anyhow::Erro }; Handle!(id, socket, stream.send(output_message.into()).await); + } else if let Err(err) = msg { + log::error!("{err}"); } } } -- GitLab