From f1a907425571585620a678d3fa3224488ddfac1b Mon Sep 17 00:00:00 2001 From: Eugene Date: Fri, 15 Nov 2024 22:32:17 +0100 Subject: [PATCH 1/2] bumped russh --- Cargo.lock | 257 ++++++++++++++++++++++-------- warpgate-admin/Cargo.toml | 2 +- warpgate-protocol-ssh/Cargo.toml | 2 +- warpgate-protocol-ssh/src/keys.rs | 4 +- 4 files changed, 198 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3fb7d76ef..a5837c56c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,6 +70,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", + "const-random", "getrandom", "once_cell", "version_check", @@ -398,7 +399,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6aeac2e1fe888769f34f05ac343bbef98b14d1ffb292ab69d4608b3abc86f2a2" dependencies = [ "blowfish", - "pbkdf2 0.12.2", + "pbkdf2", "sha2", ] @@ -802,6 +803,26 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "const-random" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom", + "once_cell", + "tiny-keccak", +] + [[package]] name = "constant_time_eq" version = "0.2.6" @@ -918,6 +939,12 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "crypto-bigint" version = "0.5.5" @@ -1029,6 +1056,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "delegate" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e018fccbeeb50ff26562ece792ed06659b9c2dae79ece77c4456bb10d9bf79b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "der" version = "0.7.9" @@ -1093,6 +1131,15 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "des" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdd80ce8ce993de27e9f063a444a4d53ce8e8db4c1f00cc03af5ad5a9867a1e" +dependencies = [ + "cipher", +] + [[package]] name = "dialoguer" version = "0.10.4" @@ -1117,27 +1164,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "dirs" -version = "5.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" -dependencies = [ - "libc", - "option-ext", - "redox_users", - "windows-sys 0.48.0", -] - [[package]] name = "dotenvy" version = "0.15.7" @@ -1334,6 +1360,18 @@ dependencies = [ "spin 0.9.8", ] +[[package]] +name = "flurry" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037030493fadfabb7b5638c2d665c0d2d2e393d8fc7aff27926524cf98efd8c0" +dependencies = [ + "ahash 0.8.11", + "num_cpus", + "parking_lot", + "seize", +] + [[package]] name = "fnv" version = "1.0.7" @@ -1912,7 +1950,7 @@ dependencies = [ "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows-core", + "windows-core 0.52.0", ] [[package]] @@ -2527,6 +2565,16 @@ dependencies = [ "libm", ] +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi 0.3.9", + "libc", +] + [[package]] name = "num_threads" version = "0.1.7" @@ -2615,12 +2663,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" -[[package]] -name = "option-ext" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" - [[package]] name = "ordered-float" version = "2.10.1" @@ -2719,6 +2761,21 @@ dependencies = [ "thiserror", ] +[[package]] +name = "pageant" +version = "0.0.1-beta.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c8ca7f786256e4d89f369656546b1f504cfd2d5ec796f0b99600919dd993723" +dependencies = [ + "bytes", + "delegate 0.12.0", + "futures", + "rand", + "thiserror", + "tokio", + "windows", +] + [[package]] name = "parking_lot" version = "0.12.3" @@ -2776,18 +2833,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" -[[package]] -name = "pbkdf2" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" -dependencies = [ - "digest", - "hmac", - "password-hash 0.4.2", - "sha2", -] - [[package]] name = "pbkdf2" version = "0.12.2" @@ -2922,7 +2967,7 @@ dependencies = [ "aes", "cbc", "der", - "pbkdf2 0.12.2", + "pbkdf2", "scrypt", "sha2", "spki", @@ -3382,17 +3427,6 @@ dependencies = [ "bitflags 2.6.0", ] -[[package]] -name = "redox_users" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" -dependencies = [ - "getrandom", - "libredox", - "thiserror", -] - [[package]] name = "regex" version = "1.10.6" @@ -3646,7 +3680,7 @@ dependencies = [ "core2", "digest", "hmac", - "pbkdf2 0.12.2", + "pbkdf2", "rand", "serde_json", "sha2", @@ -3656,9 +3690,9 @@ dependencies = [ [[package]] name = "russh" -version = "0.44.1" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6500eedfaf8cd81597899d896908a4b9cd5cb566db875e843c04ccf92add2c16" +checksum = "c536b90d8e2468d8dedc8de2369383c101325e23fffa3a30de713032862a11d4" dependencies = [ "aes", "aes-gcm", @@ -3669,6 +3703,7 @@ dependencies = [ "chacha20", "ctr", "curve25519-dalek", + "des", "digest", "elliptic-curve", "flate2", @@ -3687,6 +3722,8 @@ dependencies = [ "rand_core", "russh-cryptovec", "russh-keys", + "russh-sftp", + "russh-util", "sha1", "sha2", "ssh-encoding", @@ -3708,9 +3745,9 @@ dependencies = [ [[package]] name = "russh-keys" -version = "0.44.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb8c0bfe024d4edd242f65a2ac6c8bf38a892930050b9eb90909d8fc2c413c8d" +checksum = "6e3db166c8678c824627c2c46f619ed5ce4ae33f38a35403c62f6ab8f3985867" dependencies = [ "aes", "async-trait", @@ -3722,12 +3759,13 @@ dependencies = [ "data-encoding", "der", "digest", - "dirs", "ecdsa", "ed25519-dalek", "elliptic-curve", "futures", + "getrandom", "hmac", + "home", "inout", "log", "md5", @@ -3735,7 +3773,8 @@ dependencies = [ "p256", "p384", "p521", - "pbkdf2 0.11.0", + "pageant", + "pbkdf2", "pkcs1", "pkcs5", "pkcs8", @@ -3743,6 +3782,7 @@ dependencies = [ "rand_core", "rsa", "russh-cryptovec", + "russh-util", "sec1", "serde", "sha1", @@ -3758,6 +3798,36 @@ dependencies = [ "zeroize", ] +[[package]] +name = "russh-sftp" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a01c4a01f72b31d3a7d5fb039cbfe4c5cc72da2b0182aa31d38c573444e1ae9" +dependencies = [ + "async-trait", + "bitflags 2.6.0", + "bytes", + "chrono", + "flurry", + "log", + "serde", + "thiserror", + "tokio", + "tokio-util", +] + +[[package]] +name = "russh-util" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63aeb9d2b74f8f38befdc0c5172d5ffcf58f3d2ffcb423f3b6cdfe2c2d747b80" +dependencies = [ + "chrono", + "tokio", + "wasm-bindgen", + "wasm-bindgen-futures", +] + [[package]] name = "rust-embed" version = "8.5.0" @@ -4033,7 +4103,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0516a385866c09368f0b5bcd1caff3366aace790fcd46e2bb032697bb172fd1f" dependencies = [ - "pbkdf2 0.12.2", + "pbkdf2", "salsa20", "sha2", ] @@ -4248,6 +4318,12 @@ dependencies = [ "libc", ] +[[package]] +name = "seize" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "689224d06523904ebcc9b482c6a3f4f7fb396096645c4cd10c0d2ff7371a34d3" + [[package]] name = "semver" version = "1.0.23" @@ -4969,6 +5045,15 @@ dependencies = [ "time-core", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinyvec" version = "1.8.0" @@ -5064,6 +5149,7 @@ dependencies = [ "futures-core", "pin-project-lite", "tokio", + "tokio-util", ] [[package]] @@ -5574,7 +5660,7 @@ dependencies = [ "bytes", "chrono", "data-encoding", - "delegate", + "delegate 0.6.2", "futures", "humantime-serde", "once_cell", @@ -5689,7 +5775,7 @@ dependencies = [ "chrono", "cookie 0.17.0", "data-encoding", - "delegate", + "delegate 0.6.2", "futures", "http 1.1.0", "once_cell", @@ -5990,6 +6076,16 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" +dependencies = [ + "windows-core 0.58.0", + "windows-targets 0.52.6", +] + [[package]] name = "windows-core" version = "0.52.0" @@ -5999,6 +6095,41 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-core" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-implement" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + +[[package]] +name = "windows-interface" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "windows-registry" version = "0.2.0" diff --git a/warpgate-admin/Cargo.toml b/warpgate-admin/Cargo.toml index abf7e4ce2..c16e95961 100644 --- a/warpgate-admin/Cargo.toml +++ b/warpgate-admin/Cargo.toml @@ -24,7 +24,7 @@ poem-openapi = { version = "5.1", features = [ "uuid", "static-files", ] } -russh = { version = "0.44.1", features = ["legacy-ed25519-pkcs8-parser"] } +russh = { version = "0.46.0", features = ["legacy-ed25519-pkcs8-parser"] } rust-embed = "8.3" sea-orm = { version = "0.12", features = [ "runtime-tokio-rustls", diff --git a/warpgate-protocol-ssh/Cargo.toml b/warpgate-protocol-ssh/Cargo.toml index c9ee6319b..5d457ec64 100644 --- a/warpgate-protocol-ssh/Cargo.toml +++ b/warpgate-protocol-ssh/Cargo.toml @@ -14,7 +14,7 @@ dialoguer = "0.10" curve25519-dalek = "4.0.0" # pin due to build fail on x86 ed25519-dalek = "2.0.0" # pin due to build fail on x86 in 2.1 futures = "0.3" -russh = { version = "0.44.1", features = ["legacy-ed25519-pkcs8-parser"] } +russh = { version = "0.46.0", features = ["legacy-ed25519-pkcs8-parser"] } # russh = { version = "0.35.0-beta.6", path = "../../russh/russh"} sea-orm = { version = "0.12", features = [ "runtime-tokio-rustls", diff --git a/warpgate-protocol-ssh/src/keys.rs b/warpgate-protocol-ssh/src/keys.rs index 6f20de453..b9e7b0ad5 100644 --- a/warpgate-protocol-ssh/src/keys.rs +++ b/warpgate-protocol-ssh/src/keys.rs @@ -22,7 +22,7 @@ pub fn generate_host_keys(config: &WarpgateConfig) -> Result<()> { let key_path = path.join("host-ed25519"); if !key_path.exists() { info!("Generating Ed25519 host key"); - let key = KeyPair::generate_ed25519().context("Failed to generate Ed25519 host key")?; + let key = KeyPair::generate_ed25519(); let f = File::create(&key_path)?; encode_pkcs8_pem(&key, f)?; } @@ -71,7 +71,7 @@ pub fn generate_client_keys(config: &WarpgateConfig) -> Result<()> { let key_path = path.join("client-ed25519"); if !key_path.exists() { info!("Generating Ed25519 client key"); - let key = KeyPair::generate_ed25519().context("Failed to generate Ed25519 client key")?; + let key = KeyPair::generate_ed25519(); let f = File::create(&key_path)?; encode_pkcs8_pem(&key, f)?; } From a648b7a006230c3d4bb9858ad2dc82422923d7bd Mon Sep 17 00:00:00 2001 From: Eugene Date: Sun, 17 Nov 2024 19:16:33 +0100 Subject: [PATCH 2/2] fixed http test-target --- warpgate-protocol-http/src/lib.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/warpgate-protocol-http/src/lib.rs b/warpgate-protocol-http/src/lib.rs index 7c8fe3ba4..2172b2efd 100644 --- a/warpgate-protocol-http/src/lib.rs +++ b/warpgate-protocol-http/src/lib.rs @@ -23,7 +23,7 @@ use logging::{get_client_ip, log_request_error, log_request_result, span_for_req use poem::endpoint::{EmbeddedFileEndpoint, EmbeddedFilesEndpoint}; use poem::listener::{Listener, RustlsConfig, TcpListener}; use poem::middleware::SetHeader; -use poem::session::{CookieConfig, MemoryStorage, ServerSession}; +use poem::session::{CookieConfig, MemoryStorage, ServerSession, Session}; use poem::web::Data; use poem::{Endpoint, EndpointExt, FromRequest, IntoEndpoint, IntoResponse, Route, Server}; use poem_openapi::OpenApiService; @@ -53,6 +53,10 @@ impl HTTPProtocolServer { } } +fn make_session_storage() -> SharedSessionStorage { + SharedSessionStorage(Arc::new(Mutex::new(Box::::default()))) +} + #[async_trait] impl ProtocolServer for HTTPProtocolServer { async fn run(self, address: SocketAddr) -> Result<()> { @@ -66,8 +70,7 @@ impl ProtocolServer for HTTPProtocolServer { let ui = api_service.swagger_ui(); let spec = api_service.spec_endpoint(); - let session_storage = - SharedSessionStorage(Arc::new(Mutex::new(Box::::default()))); + let session_storage =make_session_storage(); let session_store = SessionStore::new(); let cache_bust = || { @@ -215,7 +218,9 @@ impl ProtocolServer for HTTPProtocolServer { "Not an HTTP target".to_owned(), )); }; - let request = poem::Request::builder().uri_str("http://host/").finish(); + + let mut request = poem::Request::builder().uri_str("http://host/").finish(); + request.extensions_mut().insert(Session::default()); crate::proxy::proxy_normal_request(&request, poem::Body::empty(), &options) .await .map_err(|e| TargetTestError::ConnectionError(format!("{e}")))?;