diff --git a/Cargo.lock b/Cargo.lock index b3126f0..3e70c15 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,15 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "addr2line" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" -dependencies = [ - "gimli", -] - [[package]] name = "adler2" version = "2.0.1" @@ -19,11 +10,11 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "aes" -version = "0.8.4" +version = "0.9.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +checksum = "7e713c57c2a2b19159e7be83b9194600d7e8eb3b7c2cd67e671adf47ce189a05" dependencies = [ - "cfg-if 1.0.1", + "cfg-if 1.0.4", "cipher", "cpufeatures", ] @@ -39,9 +30,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.20" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" dependencies = [ "anstyle", "anstyle-parse", @@ -54,9 +45,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" [[package]] name = "anstyle-parse" @@ -165,9 +156,9 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "aws-lc-rs" -version = "1.13.3" +version = "1.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c953fe1ba023e6b7730c0d4b031d06f267f23a46167dcbd40316644b10a17ba" +checksum = "879b6c89592deb404ba4dc0ae6b58ffd1795c78991cbb5b8bc441c48a070440d" dependencies = [ "aws-lc-sys", "zeroize", @@ -175,9 +166,9 @@ dependencies = [ [[package]] name = "aws-lc-sys" -version = "0.30.0" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbfd150b5dbdb988bcc8fb1fe787eb6b7ee6180ca24da683b61ea5405f3d43ff" +checksum = "107a4e9d9cab9963e04e84bb8dee0e25f2a987f9a8bad5ed054abd439caa8f8c" dependencies = [ "bindgen", "cc", @@ -186,26 +177,11 @@ dependencies = [ "fs_extra", ] -[[package]] -name = "backtrace" -version = "0.3.75" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" -dependencies = [ - "addr2line", - "cfg-if 1.0.1", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", - "windows-targets 0.52.6", -] - [[package]] name = "base16ct" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" +checksum = "d8b59d472eab27ade8d770dcb11da7201c11234bef9f82ce7aa517be028d462b" [[package]] name = "base64" @@ -221,25 +197,22 @@ checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" [[package]] name = "bindgen" -version = "0.69.5" +version = "0.72.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" +checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.4", "cexpr", "clang-sys", "itertools", - "lazy_static", - "lazycell", "log", "prettyplease", "proc-macro2", "quote", "regex", - "rustc-hash 1.1.0", + "rustc-hash", "shlex", "syn", - "which", ] [[package]] @@ -250,9 +223,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.9.1" +version = "2.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" +checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" [[package]] name = "block-buffer" @@ -263,13 +236,22 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-buffer" +version = "0.11.0-rc.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9ef36a6fcdb072aa548f3da057640ec10859eb4e91ddf526ee648d50c76a949" +dependencies = [ + "hybrid-array", +] + [[package]] name = "block-padding" -version = "0.3.3" +version = "0.4.0-rc.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93" +checksum = "7e59c1aab3e6c5e56afe1b7e8650be9b5a791cb997bdea449194ae62e4bf8c73" dependencies = [ - "generic-array", + "hybrid-array", ] [[package]] @@ -292,19 +274,20 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "cbc" -version = "0.1.2" +version = "0.2.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6" +checksum = "5dbf9e5b071e9de872e32b73f485e8f644ff47c7011d95476733e7482ee3e5c3" dependencies = [ "cipher", ] [[package]] name = "cc" -version = "1.2.30" +version = "1.2.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deec109607ca693028562ed836a5f1c4b8bd77755c4e132fc5ce11b0b6211ae7" +checksum = "ac9fe6cdbb24b6ade63616c0a0688e45bb56732262c158df3c0c4bea4ca47cb7" dependencies = [ + "find-msvc-tools", "jobserver", "libc", "shlex", @@ -327,9 +310,9 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cfg-if" -version = "1.0.1" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "cfg_aliases" @@ -339,11 +322,11 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "cipher" -version = "0.4.4" +version = "0.5.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +checksum = "1e12a13eb01ded5d32ee9658d94f553a19e804204f2dc811df69ab4d9e0cb8c7" dependencies = [ - "crypto-common", + "crypto-common 0.2.0-rc.4", "inout", ] @@ -360,9 +343,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.45" +version = "4.5.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc0e74a703892159f5ae7d3aac52c8e6c392f5ae5f359c70b5881d60aaac318" +checksum = "f4512b90fa68d3a9932cea5184017c5d200f5921df706d45e853537dea51508f" dependencies = [ "clap_builder", "clap_derive", @@ -370,9 +353,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.44" +version = "4.5.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e7f4214277f3c7aa526a59dd3fbe306a370daee1f8b7b8c987069cd8e888a8" +checksum = "0025e98baa12e766c67ba13ff4695a887a1eba19569aad00a472546795bd6730" dependencies = [ "anstream", "anstyle", @@ -382,9 +365,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.45" +version = "4.5.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14cb31bb0a7d536caef2639baa7fad459e15c3144efefa6dbd1c84562c4739f6" +checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" dependencies = [ "heck", "proc-macro2", @@ -394,9 +377,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" +checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cmake" @@ -419,15 +402,15 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" dependencies = [ - "cfg-if 1.0.1", + "cfg-if 1.0.4", "wasm-bindgen", ] [[package]] name = "const-oid" -version = "0.9.6" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +checksum = "0dabb6555f92fb9ee4140454eb5dcd14c7960e1225c6d1a6cc361f032947713e" [[package]] name = "convert_case" @@ -479,7 +462,7 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" dependencies = [ - "cfg-if 1.0.1", + "cfg-if 1.0.4", ] [[package]] @@ -563,7 +546,7 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.4", "crossterm_winapi", "mio", "parking_lot", @@ -579,14 +562,14 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.4", "crossterm_winapi", "derive_more", "document-features", "futures-core", "mio", "parking_lot", - "rustix 1.0.8", + "rustix 1.1.2", "signal-hook", "signal-hook-mio", "winapi", @@ -601,23 +584,16 @@ dependencies = [ "winapi", ] -[[package]] -name = "crypto" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf1e6e5492f8f0830c37f301f6349e0dac8b2466e4fe89eef90e9eef906cd046" -dependencies = [ - "crypto-common", -] - [[package]] name = "crypto-bigint" -version = "0.5.5" +version = "0.7.0-rc.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +checksum = "4113edbc9f68c0a64d5b911f803eb245d04bb812680fd56776411f69c670f3e0" dependencies = [ - "generic-array", - "rand_core 0.6.4", + "hybrid-array", + "num-traits", + "rand_core 0.9.3", + "serdect", "subtle", "zeroize", ] @@ -632,6 +608,15 @@ dependencies = [ "typenum", ] +[[package]] +name = "crypto-common" +version = "0.2.0-rc.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8235645834fbc6832939736ce2f2d08192652269e11010a6240f61b908a1c6" +dependencies = [ + "hybrid-array", +] + [[package]] name = "crypto-mac" version = "0.11.0" @@ -642,16 +627,27 @@ dependencies = [ "subtle", ] +[[package]] +name = "crypto-primes" +version = "0.7.0-pre.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25f2523fbb68811c8710829417ad488086720a6349e337c38d12fa81e09e50bf" +dependencies = [ + "crypto-bigint", + "libm", + "rand_core 0.9.3", +] + [[package]] name = "curve25519-dalek" -version = "4.1.3" +version = "5.0.0-pre.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +checksum = "6f9200d1d13637f15a6acb71e758f64624048d85b31a5fdbfd8eca1e2687d0b7" dependencies = [ - "cfg-if 1.0.1", + "cfg-if 1.0.4", "cpufeatures", "curve25519-dalek-derive", - "digest", + "digest 0.11.0-rc.3", "fiat-crypto", "rustc_version", "subtle", @@ -671,9 +667,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.10" +version = "0.8.0-rc.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +checksum = "e9d8dd2f26c86b27a2a8ea2767ec7f9df7a89516e4794e54ac01ee618dda3aa4" dependencies = [ "const-oid", "pem-rfc7468", @@ -682,9 +678,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d630bccd429a5bb5a64b5e94f693bfc48c9f8566418fda4c494cc94f911f87cc" +checksum = "a41953f86f8a05768a6cda24def994fd2f424b04ec5c719cf89989779f199071" dependencies = [ "powerfmt", ] @@ -712,9 +708,9 @@ dependencies = [ [[package]] name = "des" -version = "0.8.1" +version = "0.9.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdd80ce8ce993de27e9f063a444a4d53ce8e8db4c1f00cc03af5ad5a9867a1e" +checksum = "3f51594a70805988feb1c85495ddec0c2052e4fbe59d9c0bb7f94bfc164f4f90" dependencies = [ "cipher", ] @@ -725,9 +721,19 @@ version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer", + "block-buffer 0.10.4", + "crypto-common 0.1.6", +] + +[[package]] +name = "digest" +version = "0.11.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dac89f8a64533a9b0eaa73a68e424db0fb1fd6271c74cc0125336a05f090568d" +dependencies = [ + "block-buffer 0.11.0-rc.5", "const-oid", - "crypto-common", + "crypto-common 0.2.0-rc.4", "subtle", ] @@ -759,23 +765,24 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "ecdsa" -version = "0.16.9" +version = "0.17.0-rc.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" +checksum = "b4ab355ec063f7a110eb627471058093aba00eb7f4e70afbd15e696b79d1077b" dependencies = [ "der", - "digest", + "digest 0.11.0-rc.3", "elliptic-curve", "rfc6979", "signature", "spki", + "zeroize", ] [[package]] name = "ed25519" -version = "2.2.3" +version = "3.0.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +checksum = "9ef49c0b20c0ad088893ad2a790a29c06a012b3f05bcfc66661fd22a94b32129" dependencies = [ "pkcs8", "signature", @@ -783,14 +790,13 @@ dependencies = [ [[package]] name = "ed25519-dalek" -version = "2.2.0" +version = "3.0.0-pre.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" +checksum = "ad207ed88a133091f83224265eac21109930db09bedcad05d5252f2af2de20a1" dependencies = [ "curve25519-dalek", "ed25519", - "rand_core 0.6.4", - "serde", + "rand_core 0.9.3", "sha2", "subtle", "zeroize", @@ -804,20 +810,21 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "elliptic-curve" -version = "0.13.8" +version = "0.14.0-rc.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +checksum = "2e3be87c458d756141f3b6ee188828132743bf90c7d14843e2835d6443e5fb03" dependencies = [ "base16ct", "crypto-bigint", - "digest", + "digest 0.11.0-rc.3", "ff", - "generic-array", "group", "hkdf", + "hybrid-array", + "once_cell", "pem-rfc7468", "pkcs8", - "rand_core 0.6.4", + "rand_core 0.9.3", "sec1", "subtle", "zeroize", @@ -829,7 +836,7 @@ version = "0.8.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" dependencies = [ - "cfg-if 1.0.1", + "cfg-if 1.0.4", ] [[package]] @@ -840,12 +847,12 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -865,25 +872,31 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "ff" -version = "0.13.1" +version = "0.14.0-pre.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" +checksum = "d42dd26f5790eda47c1a2158ea4120e32c35ddc9a7743c98a292accc01b54ef3" dependencies = [ - "rand_core 0.6.4", + "rand_core 0.9.3", "subtle", ] [[package]] name = "fiat-crypto" -version = "0.2.9" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +checksum = "64cd1e32ddd350061ae6edb1b082d7c54915b5c672c389143b9a63403a109f24" + +[[package]] +name = "find-msvc-tools" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" [[package]] name = "flate2" -version = "1.1.2" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" +checksum = "dc5a4e564e38c699f2880d3fda590bedc2e69f3f84cd48b457bd892ce61d0aa9" dependencies = [ "crc32fast", "miniz_oxide", @@ -1026,13 +1039,12 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.7" +version = "0.14.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -1041,33 +1053,27 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ - "cfg-if 1.0.1", + "cfg-if 1.0.4", "js-sys", "libc", - "wasi 0.11.1+wasi-snapshot-preview1", + "wasi", "wasm-bindgen", ] [[package]] name = "getrandom" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ - "cfg-if 1.0.1", + "cfg-if 1.0.4", "js-sys", "libc", "r-efi", - "wasi 0.14.2+wasi-0.2.4", + "wasip2", "wasm-bindgen", ] -[[package]] -name = "gimli" -version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" - [[package]] name = "glob" version = "0.3.3" @@ -1134,20 +1140,20 @@ dependencies = [ [[package]] name = "group" -version = "0.13.0" +version = "0.14.0-pre.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +checksum = "1ff6a0b2dd4b981b1ae9e3e6830ab146771f3660d31d57bafd9018805a91b0f1" dependencies = [ "ff", - "rand_core 0.6.4", + "rand_core 0.9.3", "subtle", ] [[package]] name = "h2" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17da50a276f1e01e0ba6c029e47b7100754904ee8a278f886546e98575380785" +checksum = "f3c0b69cfcb4e1b9f1bf2f53f95f766e4661169728ec61cd3fe5a0166f2d1386" dependencies = [ "atomic-waker", "bytes", @@ -1164,9 +1170,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.4" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" +checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" [[package]] name = "heck" @@ -1182,29 +1188,20 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hkdf" -version = "0.12.4" +version = "0.13.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +checksum = "d8ef30358b03ca095a5b910547f4f8d4b9f163e4057669c5233ef595b1ecf008" dependencies = [ "hmac", ] [[package]] name = "hmac" -version = "0.12.1" +version = "0.13.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +checksum = "a3fd4dc94c318c1ede8a2a48341c250d6ddecd3ba793da2820301a9f92417ad9" dependencies = [ - "digest", -] - -[[package]] -name = "home" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" -dependencies = [ - "windows-sys 0.59.0", + "digest 0.11.0-rc.3", ] [[package]] @@ -1247,21 +1244,34 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" +[[package]] +name = "hybrid-array" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f471e0a81b2f90ffc0cb2f951ae04da57de8baa46fa99112b062a5173a5088d0" +dependencies = [ + "subtle", + "typenum", + "zeroize", +] + [[package]] name = "hyper" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" +checksum = "eb3aa54a13a0dfe7fbe3a59e0c76093041720fdc77b110cc0fc260fafb4dc51e" dependencies = [ + "atomic-waker", "bytes", "futures-channel", - "futures-util", + "futures-core", "h2", "http", "http-body", "httparse", "itoa", "pin-project-lite", + "pin-utils", "smallvec", "tokio", "want", @@ -1302,9 +1312,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d9b05277c7e8da2c93a568989bb6207bef0112e8d17df7a6eda4a3cf143bc5e" +checksum = "3c6995591a8f1380fcb4ba966a252a4b29188d51d2b89e3a252f5305be65aea8" dependencies = [ "base64", "bytes", @@ -1435,9 +1445,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.10.0" +version = "2.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" +checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5" dependencies = [ "equivalent", "hashbrown", @@ -1445,23 +1455,12 @@ dependencies = [ [[package]] name = "inout" -version = "0.1.4" +version = "0.2.0-rc.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +checksum = "1603f76010ff924b616c8f44815a42eb10fb0b93d308b41deaa8da6d4251fd4b" dependencies = [ "block-padding", - "generic-array", -] - -[[package]] -name = "io-uring" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013" -dependencies = [ - "bitflags 2.9.1", - "cfg-if 1.0.1", - "libc", + "hybrid-array", ] [[package]] @@ -1507,7 +1506,7 @@ dependencies = [ "regex", "serde", "sspi", - "thiserror 2.0.16", + "thiserror 2.0.17", "tokio", "tracing", "tracing-subscriber", @@ -1579,7 +1578,7 @@ dependencies = [ "quick-xml", "regex", "serde", - "thiserror 2.0.16", + "thiserror 2.0.17", "tracing", "tracing-subscriber", "tracing-test", @@ -1615,7 +1614,7 @@ dependencies = [ "js-sys", "serde", "serde-wasm-bindgen", - "thiserror 2.0.16", + "thiserror 2.0.17", "tracing", "tracing-wasm", "tsify", @@ -1638,7 +1637,7 @@ dependencies = [ "ironposh-macros", "ironposh-xml", "paste", - "thiserror 2.0.16", + "thiserror 2.0.17", "tracing", "tracing-subscriber", "tracing-test", @@ -1651,7 +1650,7 @@ name = "ironposh-xml" version = "0.1.0" dependencies = [ "roxmltree", - "thiserror 2.0.16", + "thiserror 2.0.17", "tracing", ] @@ -1663,9 +1662,9 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itertools" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" dependencies = [ "either", ] @@ -1682,7 +1681,7 @@ version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" dependencies = [ - "getrandom 0.3.3", + "getrandom 0.3.4", "libc", ] @@ -1698,9 +1697,9 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.5" +version = "0.2.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +checksum = "3d546793a04a1d3049bd192856f804cfe96356e2cf36b54b4e575155babe9f41" dependencies = [ "cpufeatures", ] @@ -1714,26 +1713,20 @@ dependencies = [ "spin", ] -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - [[package]] name = "libc" -version = "0.2.174" +version = "0.2.177" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" +checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" [[package]] name = "libloading" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" +checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" dependencies = [ - "cfg-if 1.0.1", - "windows-targets 0.53.3", + "cfg-if 1.0.4", + "windows-link 0.2.1", ] [[package]] @@ -1744,11 +1737,11 @@ checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" [[package]] name = "libredox" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "391290121bad3d37fbddad76d8f5d1c1c314cfc646d143d7e07a3086ddff0ce3" +checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.4", "libc", "redox_syscall", ] @@ -1761,9 +1754,9 @@ checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "linux-raw-sys" -version = "0.9.4" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" +checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" [[package]] name = "litemap" @@ -1779,19 +1772,18 @@ checksum = "f5e54036fe321fd421e10d732f155734c4e4afd610dd556d9a82833ab3ee0bed" [[package]] name = "lock_api" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" dependencies = [ - "autocfg", "scopeguard", ] [[package]] name = "log" -version = "0.4.27" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" [[package]] name = "lru-slab" @@ -1801,21 +1793,21 @@ checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" [[package]] name = "matchers" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" dependencies = [ - "regex-automata 0.1.10", + "regex-automata", ] [[package]] name = "md-5" -version = "0.10.6" +version = "0.11.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +checksum = "f9ec86664728010f574d67ef01aec964e6f1299241a3402857c1a8a390a62478" dependencies = [ - "cfg-if 1.0.1", - "digest", + "cfg-if 1.0.4", + "digest 0.11.0-rc.3", ] [[package]] @@ -1824,14 +1816,14 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da5ac363534dce5fabf69949225e174fbf111a498bf0ff794c8ea1fba9f3dda" dependencies = [ - "digest", + "digest 0.10.7", ] [[package]] name = "memchr" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" [[package]] name = "memory_units" @@ -1868,6 +1860,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ "adler2", + "simd-adler32", ] [[package]] @@ -1878,7 +1871,7 @@ checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" dependencies = [ "libc", "log", - "wasi 0.11.1+wasi-snapshot-preview1", + "wasi", "windows-sys 0.59.0", ] @@ -1911,12 +1904,11 @@ dependencies = [ [[package]] name = "nu-ansi-term" -version = "0.46.0" +version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "overload", - "winapi", + "windows-sys 0.61.2", ] [[package]] @@ -1934,7 +1926,6 @@ dependencies = [ "rand 0.8.5", "serde", "smallvec", - "zeroize", ] [[package]] @@ -1981,16 +1972,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", - "libm", -] - -[[package]] -name = "object" -version = "0.36.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" -dependencies = [ - "memchr", ] [[package]] @@ -2016,12 +1997,12 @@ checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" [[package]] name = "openssl" -version = "0.10.73" +version = "0.10.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8" +checksum = "24ad14dd45412269e1a30f52ad8f0664f0f4f4a89ee8fe28c3b3527021ebb654" dependencies = [ - "bitflags 2.9.1", - "cfg-if 1.0.1", + "bitflags 2.9.4", + "cfg-if 1.0.4", "foreign-types", "libc", "once_cell", @@ -2048,9 +2029,9 @@ checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "openssl-sys" -version = "0.9.109" +version = "0.9.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571" +checksum = "0a9f0075ba3c21b09f8e8b2026584b1d18d49388648f2fbbf3c97ea8deced8e2" dependencies = [ "cc", "libc", @@ -2058,55 +2039,53 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - [[package]] name = "p256" -version = "0.13.2" +version = "0.14.0-pre.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +checksum = "81b374901df34ee468167a58e2a49e468cb059868479cafebeb804f6b855423d" dependencies = [ "ecdsa", "elliptic-curve", + "primefield", "primeorder", "sha2", ] [[package]] name = "p384" -version = "0.13.1" +version = "0.14.0-pre.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe42f1670a52a47d448f14b6a5c61dd78fce51856e68edaa38f7ae3a46b8d6b6" +checksum = "701032b3730df6b882496d6cee8221de0ce4bc11ddc64e6d89784aa5b8a6de30" dependencies = [ "ecdsa", "elliptic-curve", + "fiat-crypto", + "primefield", "primeorder", "sha2", ] [[package]] name = "p521" -version = "0.13.3" +version = "0.14.0-pre.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc9e2161f1f215afdfce23677034ae137bbd45016a880c2eb3ba8eb95f085b2" +checksum = "40ba29c2906eb5c89a8c411c4f11243ee4e5517ee7d71d9a13fedc877a6057b1" dependencies = [ "base16ct", "ecdsa", "elliptic-curve", + "primefield", "primeorder", - "rand_core 0.6.4", + "rand_core 0.9.3", "sha2", ] [[package]] name = "parking_lot" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" dependencies = [ "lock_api", "parking_lot_core", @@ -2114,15 +2093,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.11" +version = "0.9.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" dependencies = [ - "cfg-if 1.0.1", + "cfg-if 1.0.4", "libc", "redox_syscall", "smallvec", - "windows-targets 0.52.6", + "windows-link 0.2.1", ] [[package]] @@ -2133,20 +2112,20 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pbkdf2" -version = "0.12.2" +version = "0.13.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +checksum = "ca3fc18bb4460ac250ba6b75dfa7cf9d0b2273e3e623f660bd6ce2c3e902342e" dependencies = [ - "digest", + "digest 0.11.0-rc.3", "hmac", "sha1", ] [[package]] name = "pem-rfc7468" -version = "0.7.0" +version = "1.0.0-rc.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +checksum = "a8e58fab693c712c0d4e88f8eb3087b6521d060bcaf76aeb20cb192d809115ba" dependencies = [ "base64ct", ] @@ -2159,30 +2138,49 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "picky" -version = "7.0.0-rc.17" +version = "7.0.0-rc.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33807ce79d4b14a8918e968a8606e5142ddc6aec933acef79de0bd769cae5fb1" +checksum = "143fec6b7fa8ec91cbe1136f70ffa5de7e9627064da7bc3f7c0becc9b9493f8c" dependencies = [ "base64", - "digest", + "block-buffer 0.11.0-rc.5", + "block-padding", + "crypto-bigint", + "crypto-common 0.2.0-rc.4", + "der", + "digest 0.11.0-rc.3", + "ecdsa", + "ed25519", "ed25519-dalek", + "elliptic-curve", "hex", + "hkdf", + "inout", + "keccak", "md-5", - "num-bigint-dig", "p256", "p384", "p521", + "pem-rfc7468", "picky-asn1", "picky-asn1-der", "picky-asn1-x509", - "rand 0.8.5", - "rand_core 0.6.4", + "pkcs1", + "pkcs8", + "primefield", + "primeorder", + "rand 0.9.2", + "rand_core 0.9.3", + "rfc6979", "rsa", + "sec1", "serde", "sha1", "sha2", "sha3", - "thiserror 1.0.69", + "signature", + "spki", + "thiserror 2.0.17", "x25519-dalek", "zeroize", ] @@ -2202,9 +2200,9 @@ dependencies = [ [[package]] name = "picky-asn1-der" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dccb53c26f70c082e008818f524bd45d057069517b047bd0c0ee062d6d7d7f2" +checksum = "f1c9c33310628f2e1758bbde11b16713505e188a859ab7990f98eb015b943bf5" dependencies = [ "picky-asn1", "serde", @@ -2213,9 +2211,9 @@ dependencies = [ [[package]] name = "picky-asn1-x509" -version = "0.14.6" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d493f73cf052073ca1fe38666f74c2396987aa6ea660e77dd624cc6c8f60389e" +checksum = "1aabb518a46486587cd22928d3444925eb7559579db3aa9ef153315f53d09602" dependencies = [ "base64", "num-bigint-dig", @@ -2229,26 +2227,31 @@ dependencies = [ [[package]] name = "picky-krb" -version = "0.11.1" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e78a55491723b0a10bc2c02709a8d92d74ef674fe1b569cb4a08bac3d105487" +checksum = "14b13eb1a97b2293277b475f07d0c36c33579e2e71f852557015addcd95f8892" dependencies = [ "aes", + "block-buffer 0.11.0-rc.5", + "block-padding", "byteorder", "cbc", - "crypto", + "cipher", + "crypto-bigint", + "crypto-common 0.2.0-rc.4", "des", + "digest 0.11.0-rc.3", "hmac", - "num-bigint-dig", + "inout", "oid", "pbkdf2", "picky-asn1", "picky-asn1-der", "picky-asn1-x509", - "rand 0.8.5", + "rand 0.9.2", "serde", "sha1", - "thiserror 1.0.69", + "thiserror 2.0.17", "uuid", ] @@ -2286,20 +2289,19 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkcs1" -version = "0.7.5" +version = "0.8.0-rc.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +checksum = "986d2e952779af96ea048f160fd9194e1751b4faea78bcf3ceb456efe008088e" dependencies = [ "der", - "pkcs8", "spki", ] [[package]] name = "pkcs8" -version = "0.10.2" +version = "0.11.0-rc.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +checksum = "93eac55f10aceed84769df670ea4a32d2ffad7399400d41ee1c13b1cd8e1b478" dependencies = [ "der", "spki", @@ -2313,9 +2315,9 @@ checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "potential_utf" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5a7c30837279ca13e7c867e9e40053bc68740f988cb07f7ca6df43cc734b585" +checksum = "84df19adbe5b5a0782edcab45899906947ab039ccf4573713735ee7de1e6b08a" dependencies = [ "zerovec", ] @@ -2337,37 +2339,50 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.36" +version = "0.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff24dfcda44452b9816fff4cd4227e1bb73ff5a2f1bc1105aa92fb8565ce44d2" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", "syn", ] +[[package]] +name = "primefield" +version = "0.14.0-pre.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7fcd4a163053332fd93f39b81c133e96a98567660981654579c90a99062fbf5" +dependencies = [ + "crypto-bigint", + "ff", + "rand_core 0.9.3", + "subtle", + "zeroize", +] + [[package]] name = "primeorder" -version = "0.13.6" +version = "0.14.0-pre.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +checksum = "1c36e8766fcd270fa9c665b9dc364f570695f5a59240949441b077a397f15b74" dependencies = [ "elliptic-curve", ] [[package]] name = "proc-macro2" -version = "1.0.95" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" dependencies = [ "unicode-ident", ] [[package]] name = "quick-xml" -version = "0.38.0" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8927b0664f5c5a98265138b7e3f90aa19a6b21353182469ace36d4ac527b7b1b" +checksum = "42a232e7487fc2ef313d96dde7948e7a3c05101870d8985e4fd8d26aedd27b89" dependencies = [ "memchr", "serde", @@ -2384,10 +2399,10 @@ dependencies = [ "pin-project-lite", "quinn-proto", "quinn-udp", - "rustc-hash 2.1.1", + "rustc-hash", "rustls", "socket2", - "thiserror 2.0.16", + "thiserror 2.0.17", "tokio", "tracing", "web-time", @@ -2400,15 +2415,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1906b49b0c3bc04b5fe5d86a77925ae6524a19b816ae38ce1e426255f1d8a31" dependencies = [ "bytes", - "getrandom 0.3.3", + "getrandom 0.3.4", "lru-slab", "rand 0.9.2", "ring", - "rustc-hash 2.1.1", + "rustc-hash", "rustls", "rustls-pki-types", "slab", - "thiserror 2.0.16", + "thiserror 2.0.17", "tinyvec", "tracing", "web-time", @@ -2425,14 +2440,14 @@ dependencies = [ "once_cell", "socket2", "tracing", - "windows-sys 0.60.2", + "windows-sys 0.52.0", ] [[package]] name = "quote" -version = "1.0.40" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" dependencies = [ "proc-macro2", ] @@ -2499,67 +2514,52 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ - "getrandom 0.3.3", + "getrandom 0.3.4", ] [[package]] name = "redox_syscall" -version = "0.5.17" +version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.4", ] [[package]] name = "regex" -version = "1.11.2" +version = "1.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d7fd106d8c02486a8d64e778353d1cffe08ce79ac2e82f540c86d0facf6912" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.9", - "regex-syntax 0.8.5", + "regex-automata", + "regex-syntax", ] [[package]] name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", -] - -[[package]] -name = "regex-automata" -version = "0.4.9" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.5", + "regex-syntax", ] [[package]] name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - -[[package]] -name = "regex-syntax" -version = "0.8.5" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" [[package]] name = "reqwest" -version = "0.12.23" +version = "0.12.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d429f34c8092b2d42c7c93cec323bb4adeb7c67698f70839adec842ec10c7ceb" +checksum = "9d0946410b9f7b082a427e4ef5c8ff541a88b357bc6c637c40db3a68ac70a36f" dependencies = [ "base64", "bytes", @@ -2603,9 +2603,9 @@ dependencies = [ [[package]] name = "rfc6979" -version = "0.4.0" +version = "0.5.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +checksum = "d369f9c4f79388704648e7bcb92749c0d6cf4397039293a9b747694fa4fb4bae" dependencies = [ "hmac", "subtle", @@ -2618,7 +2618,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" dependencies = [ "cc", - "cfg-if 1.0.1", + "cfg-if 1.0.4", "getrandom 0.2.16", "libc", "untrusted", @@ -2633,18 +2633,17 @@ checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" [[package]] name = "rsa" -version = "0.9.8" +version = "0.10.0-rc.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78928ac1ed176a5ca1d17e578a1825f3d81ca54cf41053a592584b020cfd691b" +checksum = "bf8955ab399f6426998fde6b76ae27233cce950705e758a6c17afd2f6d0e5d52" dependencies = [ "const-oid", - "digest", - "num-bigint-dig", - "num-integer", - "num-traits", + "crypto-bigint", + "crypto-primes", + "digest 0.11.0-rc.3", "pkcs1", "pkcs8", - "rand_core 0.6.4", + "rand_core 0.9.3", "sha1", "signature", "spki", @@ -2652,18 +2651,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "rustc-demangle" -version = "0.1.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f" - -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - [[package]] name = "rustc-hash" version = "2.1.1" @@ -2685,7 +2672,7 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.4", "errno", "libc", "linux-raw-sys 0.4.15", @@ -2694,22 +2681,22 @@ dependencies = [ [[package]] name = "rustix" -version = "1.0.8" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8" +checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.4", "errno", "libc", - "linux-raw-sys 0.9.4", - "windows-sys 0.60.2", + "linux-raw-sys 0.11.0", + "windows-sys 0.61.2", ] [[package]] name = "rustls" -version = "0.23.29" +version = "0.23.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2491382039b29b9b11ff08b76ff6c97cf287671dbb74f0be44bda389fffe9bd1" +checksum = "cd3c25631629d034ce7cd9940adc9d45762d46de2b0f57193c4443b92c6d4d40" dependencies = [ "aws-lc-rs", "log", @@ -2723,14 +2710,14 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" +checksum = "9980d917ebb0c0536119ba501e90834767bffc3d60641457fd84a1f3fd337923" dependencies = [ "openssl-probe", "rustls-pki-types", "schannel", - "security-framework 3.3.0", + "security-framework 3.5.1", ] [[package]] @@ -2745,9 +2732,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.4" +version = "0.103.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a17884ae0c1b773f1ccd2bd4a8c72f16da897310a98b0e84bf349ad5ead92fc" +checksum = "e10b3f4191e8a80e6b43eebabfac91e5dcecebb27a71f04e820c47ec41d314bf" dependencies = [ "aws-lc-rs", "ring", @@ -2757,9 +2744,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.21" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "ryu" @@ -2778,11 +2765,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -2793,14 +2780,13 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sec1" -version = "0.7.3" +version = "0.8.0-rc.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +checksum = "1dff52f6118bc9f0ac974a54a639d499ac26a6cad7a6e39bc0990c19625e793b" dependencies = [ "base16ct", "der", - "generic-array", - "pkcs8", + "hybrid-array", "subtle", "zeroize", ] @@ -2811,7 +2797,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.4", "core-foundation 0.9.4", "core-foundation-sys", "libc", @@ -2820,11 +2806,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "3.3.0" +version = "3.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80fb1d92c5028aa318b4b8bd7302a5bfcf48be96a37fc6fc790f806b0004ee0c" +checksum = "b3297343eaf830f66ede390ea39da1d462b6b0c1b000f420d0a83f898bbbe6ef" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.4", "core-foundation 0.10.1", "core-foundation-sys", "libc", @@ -2833,9 +2819,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.14.0" +version = "2.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" +checksum = "cc1f0cbffaac4852523ce30d8bd3c5cdc873501d96ff467ca09b6767bb8cd5c0" dependencies = [ "core-foundation-sys", "libc", @@ -2843,9 +2829,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" [[package]] name = "send_wrapper" @@ -2876,11 +2862,12 @@ dependencies = [ [[package]] name = "serde_bytes" -version = "0.11.17" +version = "0.11.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8437fd221bde2d4ca316d61b90e337e9e702b3820b87d63caa9ba6c02bd06d96" +checksum = "a5d440709e79d88e51ac01c4b72fc6cb7314017bb7da9eeff678aa94c10e3ea8" dependencies = [ "serde", + "serde_core", ] [[package]] @@ -2939,35 +2926,45 @@ dependencies = [ "serde", ] +[[package]] +name = "serdect" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3ef0e35b322ddfaecbc60f34ab448e157e48531288ee49fafbb053696b8ffe2" +dependencies = [ + "base16ct", + "serde", +] + [[package]] name = "sha1" -version = "0.10.6" +version = "0.11.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +checksum = "c5e046edf639aa2e7afb285589e5405de2ef7e61d4b0ac1e30256e3eab911af9" dependencies = [ - "cfg-if 1.0.1", + "cfg-if 1.0.4", "cpufeatures", - "digest", + "digest 0.11.0-rc.3", ] [[package]] name = "sha2" -version = "0.10.9" +version = "0.11.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +checksum = "d1e3878ab0f98e35b2df35fe53201d088299b41a6bb63e3e34dada2ac4abd924" dependencies = [ - "cfg-if 1.0.1", + "cfg-if 1.0.4", "cpufeatures", - "digest", + "digest 0.11.0-rc.3", ] [[package]] name = "sha3" -version = "0.10.8" +version = "0.11.0-rc.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +checksum = "2103ca0e6f4e9505eae906de5e5883e06fc3b2232fb5d6914890c7bbcb62f478" dependencies = [ - "digest", + "digest 0.11.0-rc.3", "keccak", ] @@ -3009,28 +3006,34 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.5" +version = "1.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" +checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" dependencies = [ "libc", ] [[package]] name = "signature" -version = "2.2.0" +version = "3.0.0-rc.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +checksum = "fc280a6ff65c79fbd6622f64d7127f32b85563bca8c53cd2e9141d6744a9056d" dependencies = [ - "digest", - "rand_core 0.6.4", + "digest 0.11.0-rc.3", + "rand_core 0.9.3", ] +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + [[package]] name = "slab" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" +checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" [[package]] name = "smallvec" @@ -3040,12 +3043,12 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "socket2" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807" +checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -3056,9 +3059,9 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "spki" -version = "0.7.3" +version = "0.8.0-rc.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +checksum = "8baeff88f34ed0691978ec34440140e1572b68c7dd4a495fd14a3dc1944daa80" dependencies = [ "base64ct", "der", @@ -3066,20 +3069,23 @@ dependencies = [ [[package]] name = "sspi" -version = "0.16.1" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0dd26ac316dc68526e95332572236eb6d2f45728ef31bf770d1387d60d0bc9" dependencies = [ "async-dnssd", "async-recursion", - "bitflags 2.9.1", + "bitflags 2.9.4", "byteorder", - "cfg-if 1.0.1", + "cfg-if 1.0.4", + "crypto-bigint", "crypto-mac", "futures", + "getrandom 0.3.4", "hmac", "lazy_static", "md-5", "md4", - "num-bigint-dig", "num-derive", "num-traits", "oid", @@ -3088,7 +3094,7 @@ dependencies = [ "picky-asn1-der", "picky-asn1-x509", "picky-krb", - "rand 0.8.5", + "rand 0.9.2", "reqwest", "rsa", "rustls", @@ -3109,9 +3115,9 @@ dependencies = [ [[package]] name = "stable_deref_trait" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "strsim" @@ -3127,9 +3133,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.104" +version = "2.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" +checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" dependencies = [ "proc-macro2", "quote", @@ -3162,7 +3168,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.4", "core-foundation 0.9.4", "system-configuration-sys", ] @@ -3179,15 +3185,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.21.0" +version = "3.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15b61f8f20e3a6f7e0649d825294eaf317edce30f82cf6026e7e4cb9222a7d1e" +checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" dependencies = [ "fastrand", - "getrandom 0.3.3", + "getrandom 0.3.4", "once_cell", - "rustix 1.0.8", - "windows-sys 0.60.2", + "rustix 1.1.2", + "windows-sys 0.61.2", ] [[package]] @@ -3201,11 +3207,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.16" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" dependencies = [ - "thiserror-impl 2.0.16", + "thiserror-impl 2.0.17", ] [[package]] @@ -3221,9 +3227,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.16" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", @@ -3236,16 +3242,17 @@ version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" dependencies = [ - "cfg-if 1.0.1", + "cfg-if 1.0.4", ] [[package]] name = "time" -version = "0.3.43" +version = "0.3.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83bde6f1ec10e72d583d91623c939f623002284ef622b87de38cfd546cbf2031" +checksum = "91e7d9e3bb61134e77bde20dd4825b97c010155709965fedf0f49bb138e52a9d" dependencies = [ "deranged", + "itoa", "num-conv", "powerfmt", "serde", @@ -3296,29 +3303,26 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.47.1" +version = "1.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038" +checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" dependencies = [ - "backtrace", "bytes", - "io-uring", "libc", "mio", "parking_lot", "pin-project-lite", "signal-hook-registry", - "slab", "socket2", "tokio-macros", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] name = "tokio-macros" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" dependencies = [ "proc-macro2", "quote", @@ -3337,9 +3341,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.26.2" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" dependencies = [ "rustls", "tokio", @@ -3347,9 +3351,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.15" +version = "0.7.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" +checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5" dependencies = [ "bytes", "futures-core", @@ -3379,7 +3383,7 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.4", "bytes", "futures-util", "http", @@ -3460,14 +3464,14 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.19" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" +checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" dependencies = [ "matchers", "nu-ansi-term", "once_cell", - "regex", + "regex-automata", "sharded-slab", "smallvec", "thread_local", @@ -3516,9 +3520,9 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tsify" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ec91b85e6c6592ed28636cb1dd1fac377ecbbeb170ff1d79f97aac5e38926d" +checksum = "8ec5505497c87f1c050b4392d3f11b49a04537fcb9dc0da57bc0af168a6331f2" dependencies = [ "gloo-utils", "serde", @@ -3530,9 +3534,9 @@ dependencies = [ [[package]] name = "tsify-macros" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a324606929ad11628a19206d7853807481dcaecd6c08be70a235930b8241955" +checksum = "9fc2c44dc9fe4baf55b88e032621b7a11b215a1f0a7de8d0aa04367207d915bc" dependencies = [ "proc-macro2", "quote", @@ -3542,18 +3546,18 @@ dependencies = [ [[package]] name = "typed-builder" -version = "0.21.0" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce63bcaf7e9806c206f7d7b9c1f38e0dce8bb165a80af0898161058b19248534" +checksum = "fef81aec2ca29576f9f6ae8755108640d0a86dd3161b2e8bca6cfa554e98f77d" dependencies = [ "typed-builder-macro", ] [[package]] name = "typed-builder-macro" -version = "0.21.0" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60d8d828da2a3d759d3519cdf29a5bac49c77d039ad36d0782edadbf9cd5415b" +checksum = "1ecb9ecf7799210407c14a8cfdfe0173365780968dc57973ed082211958e0b18" dependencies = [ "proc-macro2", "quote", @@ -3562,15 +3566,15 @@ dependencies = [ [[package]] name = "typenum" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" [[package]] name = "unicode-segmentation" @@ -3580,9 +3584,9 @@ checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a1a07cc7db3810833284e8d372ccdc6da29741639ecc70c9ec107df0fa6154c" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" [[package]] name = "untrusted" @@ -3636,7 +3640,7 @@ version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2" dependencies = [ - "getrandom 0.3.3", + "getrandom 0.3.4", "js-sys", "serde", "wasm-bindgen", @@ -3707,12 +3711,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] -name = "wasi" -version = "0.14.2+wasi-0.2.4" +name = "wasip2" +version = "1.0.1+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" dependencies = [ - "wit-bindgen-rt", + "wit-bindgen", ] [[package]] @@ -3727,7 +3731,7 @@ version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1da10c01ae9f1ae40cbfac0bac3b1e724b320abfcf52229f80b547c0d250e2d" dependencies = [ - "cfg-if 1.0.1", + "cfg-if 1.0.4", "once_cell", "rustversion", "wasm-bindgen-macro", @@ -3754,7 +3758,7 @@ version = "0.4.54" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e038d41e478cc73bae0ff9b36c60cff1c98b8f38f8d7e8061e79ee63608ac5c" dependencies = [ - "cfg-if 1.0.1", + "cfg-if 1.0.4", "js-sys", "once_cell", "wasm-bindgen", @@ -3843,14 +3847,14 @@ version = "0.26.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" dependencies = [ - "webpki-roots 1.0.2", + "webpki-roots 1.0.3", ] [[package]] name = "webpki-roots" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8983c3ab33d6fb807cfcdad2491c4ea8cbc8ed839181c7dfd9c67c83e261b2" +checksum = "32b130c0d2d49f8b6889abc456e795e82525204f27c42cf767cf0d7734e089b8" dependencies = [ "rustls-pki-types", ] @@ -3867,18 +3871,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "which" -version = "4.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" -dependencies = [ - "either", - "home", - "once_cell", - "rustix 0.38.44", -] - [[package]] name = "whoami" version = "1.6.1" @@ -3892,9 +3884,9 @@ dependencies = [ [[package]] name = "widestring" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd7cf3379ca1aac9eea11fba24fd7e315d621f8dfe35c8d7d2be8b793726e07d" +checksum = "72069c3113ab32ab29e5584db3c6ec55d416895e60715417b5b883a357c3e471" [[package]] name = "winapi" @@ -3918,7 +3910,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -3936,7 +3928,7 @@ dependencies = [ "windows-collections", "windows-core", "windows-future", - "windows-link", + "windows-link 0.1.3", "windows-numerics", ] @@ -3957,7 +3949,7 @@ checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" dependencies = [ "windows-implement", "windows-interface", - "windows-link", + "windows-link 0.1.3", "windows-result", "windows-strings", ] @@ -3969,15 +3961,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" dependencies = [ "windows-core", - "windows-link", + "windows-link 0.1.3", "windows-threading", ] [[package]] name = "windows-implement" -version = "0.60.0" +version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", @@ -3986,9 +3978,9 @@ dependencies = [ [[package]] name = "windows-interface" -version = "0.59.1" +version = "0.59.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", @@ -4001,6 +3993,12 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + [[package]] name = "windows-numerics" version = "0.2.0" @@ -4008,7 +4006,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" dependencies = [ "windows-core", - "windows-link", + "windows-link 0.1.3", ] [[package]] @@ -4017,7 +4015,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b8a9ed28765efc97bbc954883f4e6796c33a06546ebafacbabee9696967499e" dependencies = [ - "windows-link", + "windows-link 0.1.3", "windows-result", "windows-strings", ] @@ -4028,7 +4026,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" dependencies = [ - "windows-link", + "windows-link 0.1.3", ] [[package]] @@ -4037,7 +4035,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" dependencies = [ - "windows-link", + "windows-link 0.1.3", ] [[package]] @@ -4064,7 +4062,16 @@ version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" dependencies = [ - "windows-targets 0.53.3", + "windows-targets 0.53.5", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link 0.2.1", ] [[package]] @@ -4085,19 +4092,19 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.53.3" +version = "0.53.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" dependencies = [ - "windows-link", - "windows_aarch64_gnullvm 0.53.0", - "windows_aarch64_msvc 0.53.0", - "windows_i686_gnu 0.53.0", - "windows_i686_gnullvm 0.53.0", - "windows_i686_msvc 0.53.0", - "windows_x86_64_gnu 0.53.0", - "windows_x86_64_gnullvm 0.53.0", - "windows_x86_64_msvc 0.53.0", + "windows-link 0.2.1", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", ] [[package]] @@ -4106,7 +4113,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6" dependencies = [ - "windows-link", + "windows-link 0.1.3", ] [[package]] @@ -4117,9 +4124,9 @@ checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" [[package]] name = "windows_aarch64_msvc" @@ -4129,9 +4136,9 @@ checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_aarch64_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" [[package]] name = "windows_i686_gnu" @@ -4141,9 +4148,9 @@ checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnu" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" [[package]] name = "windows_i686_gnullvm" @@ -4153,9 +4160,9 @@ checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" [[package]] name = "windows_i686_msvc" @@ -4165,9 +4172,9 @@ checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_i686_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" [[package]] name = "windows_x86_64_gnu" @@ -4177,9 +4184,9 @@ checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnu" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" [[package]] name = "windows_x86_64_gnullvm" @@ -4189,9 +4196,9 @@ checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" [[package]] name = "windows_x86_64_msvc" @@ -4201,18 +4208,15 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "windows_x86_64_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" [[package]] -name = "wit-bindgen-rt" -version = "0.39.0" +name = "wit-bindgen" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" -dependencies = [ - "bitflags 2.9.1", -] +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" [[package]] name = "writeable" @@ -4222,12 +4226,12 @@ checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" [[package]] name = "x25519-dalek" -version = "2.0.1" +version = "3.0.0-pre.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" +checksum = "3a45998121837fd8c92655d2334aa8f3e5ef0645cdfda5b321b13760c548fd55" dependencies = [ "curve25519-dalek", - "rand_core 0.6.4", + "rand_core 0.9.3", "serde", "zeroize", ] @@ -4258,18 +4262,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.26" +version = "0.8.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" +checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.26" +version = "0.8.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" +checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", @@ -4299,9 +4303,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.8.1" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" dependencies = [ "zeroize_derive", ] @@ -4330,9 +4334,9 @@ dependencies = [ [[package]] name = "zerovec" -version = "0.11.2" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428" +checksum = "e7aa2bd55086f1ab526693ecbe444205da57e25f4489879da80635a46d90e73b" dependencies = [ "yoke", "zerofrom", diff --git a/Cargo.toml b/Cargo.toml index 9b0b054..bacdaf4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,3 +2,30 @@ resolver = "3" # Define the members of the workspace. Currently, it includes the main crate. members = ["crates/*"] + +[workspace.lints.clippy] +all = { level = "deny", priority = -1 } +pedantic = { level = "deny", priority = -1 } +nursery = { level = "deny", priority = -1 } +suspicious = { level = "deny", priority = -1 } +#cargo = { level = "warn", priority = -1 } + + +# pedantic exceptions +doc_markdown = { level = "allow" } # false positives for the word `PowerShell` +missing_errors_doc = { level = "allow" } +missing_panics_doc = { level = "allow" } + +cast_lossless = { level = "allow" } +cast_possible_truncation = { level = "allow" } +cast_possible_wrap = { level = "allow" } +cast_sign_loss = { level = "allow" } + +must_use_candidate = { level = "allow" } +return_self_not_must_use = { level = "allow" } +unreadable_literal = { level = "allow" } +used_underscore_binding = { level = "allow" } +wildcard_imports = { level = "allow" } + +#nursery exceptions +missing_const_for_fn = { level = "allow" } \ No newline at end of file diff --git a/crates/ironposh-async/Cargo.toml b/crates/ironposh-async/Cargo.toml index 57b72cf..3b41e71 100644 --- a/crates/ironposh-async/Cargo.toml +++ b/crates/ironposh-async/Cargo.toml @@ -18,3 +18,6 @@ uuid = "1.0" [target.'cfg(target_arch = "wasm32")'.dependencies] futures-timer = { version = "3", features = ["wasm-bindgen"] } + +[lints] +workspace = true diff --git a/crates/ironposh-async/src/connection.rs b/crates/ironposh-async/src/connection.rs index 1775ceb..09302fc 100644 --- a/crates/ironposh-async/src/connection.rs +++ b/crates/ironposh-async/src/connection.rs @@ -17,7 +17,8 @@ use crate::{HostIo, HostSubmitter, HttpClient, session}; /// /// This function creates the connection channels and establishes a WinRM connection, /// then starts the active session loop in the background. -pub fn establish_connection( +#[expect(clippy::too_many_lines)] +pub fn establish_connection( config: WinRmConfig, client: C, ) -> ( @@ -27,7 +28,7 @@ pub fn establish_connection( impl std::future::Future>, ) where - C: 'static, + C: HttpClient + 'static, { let (mut user_input_tx, user_input_rx) = mpsc::channel(10); let (server_output_tx, mut server_output_rx) = mpsc::channel(10); @@ -113,7 +114,7 @@ where .await; match result { - Ok(_) => { + Ok(()) => { info!("Active session loop ended"); let _ = session_event_tx.unbounded_send(crate::SessionEvent::ActiveSessionEnded); Ok(()) diff --git a/crates/ironposh-async/src/lib.rs b/crates/ironposh-async/src/lib.rs index edcda8f..b28b584 100644 --- a/crates/ironposh-async/src/lib.rs +++ b/crates/ironposh-async/src/lib.rs @@ -58,7 +58,7 @@ pub struct HostResponse { impl HostSubmitter { /// Submit a host call response back to the session - pub async fn submit(&self, resp: HostResponse) -> anyhow::Result<()> { + pub fn submit(&self, resp: HostResponse) -> anyhow::Result<()> { self.0 .unbounded_send(resp) .map_err(|_| anyhow::anyhow!("Host response channel closed"))?; diff --git a/crates/ironposh-async/src/session.rs b/crates/ironposh-async/src/session.rs index c7c3212..251184e 100644 --- a/crates/ironposh-async/src/session.rs +++ b/crates/ironposh-async/src/session.rs @@ -20,6 +20,8 @@ fn launch( } /// Main active session loop that handles network responses and user operations +#[expect(clippy::too_many_arguments)] +#[expect(clippy::too_many_lines)] #[instrument(skip_all)] pub async fn start_active_session_loop( runspace_polling_request: TrySend, @@ -135,81 +137,78 @@ pub async fn start_active_session_loop( // 2) user operations user_op = user_input_rx.next() => { info!(target: "user", "processing user operation"); - match user_op { - Some(user_operation) => { - info!(target: "user", operation = ?user_operation, "processing user operation"); - - let step_result = active_session - .accept_client_operation(user_operation) - .map_err(|e| { - error!(target: "user", error = %e, "failed to accept user operation"); - e - }) - .context("Failed to accept user operation")?; - - match step_result { - ActiveSessionOutput::SendBack(reqs) => { - info!( - target: "network", - request_count = reqs.len(), - "launching HTTP requests from user operation" - ); - for r in reqs { - inflight.push(launch(&client, r)); - } - } - ActiveSessionOutput::UserEvent(event) => { - info!(target: "user", event = ?event, "sending user event from user operation"); - if user_output_tx.send(event).await.is_err() { - return Err(anyhow::anyhow!("User output channel disconnected")); - } - } - ActiveSessionOutput::HostCall(host_call) => { - debug!(host_call = ?host_call.method_name(), call_id = host_call.call_id(), scope = ?host_call.scope()); - - // Forward to consumer - if host_call_tx.unbounded_send(host_call).is_err() { - return Err(anyhow::anyhow!("Host-call channel closed")); - } - - // Await the consumer's reply - let HostResponse { call_id, scope, submission } = host_resp_rx.next().await - .ok_or_else(|| anyhow::anyhow!("Host-response channel closed"))?; - - let step_result = active_session - .accept_client_operation( - UserOperation::SubmitHostResponse { - call_id, - scope, - submission, - }, - ) - .map_err(|e| { - error!(target: "user", error = %e, "failed to submit host response"); - e - }) - .context("Failed to submit host response")?; - - process_session_outputs(vec![step_result], &mut user_output_tx, &mut user_input_tx, &host_call_tx, &mut host_resp_rx).await?; - } - ActiveSessionOutput::OperationSuccess => { - info!(target: "session", "operation completed successfully"); - } - ActiveSessionOutput::SendBackError(e) => { - error!(target: "session", error = %e, "session step failed"); - return Err(anyhow::anyhow!("Session step failed: {e}")); - }, - ActiveSessionOutput::Ignore => { - // Do nothing - } - } - - } - None => { - info!("User input channel disconnected"); - break; // UI side closed - } - } + if let Some(user_operation) = user_op { + info!(target: "user", operation = ?user_operation, "processing user operation"); + + let step_result = active_session + .accept_client_operation(user_operation) + .map_err(|e| { + error!(target: "user", error = %e, "failed to accept user operation"); + e + }) + .context("Failed to accept user operation")?; + + match step_result { + ActiveSessionOutput::SendBack(reqs) => { + info!( + target: "network", + request_count = reqs.len(), + "launching HTTP requests from user operation" + ); + for r in reqs { + inflight.push(launch(&client, r)); + } + } + ActiveSessionOutput::UserEvent(event) => { + info!(target: "user", event = ?event, "sending user event from user operation"); + if user_output_tx.send(event).await.is_err() { + return Err(anyhow::anyhow!("User output channel disconnected")); + } + } + ActiveSessionOutput::HostCall(host_call) => { + debug!(host_call = ?host_call.method_name(), call_id = host_call.call_id(), scope = ?host_call.scope()); + + // Forward to consumer + if host_call_tx.unbounded_send(host_call).is_err() { + return Err(anyhow::anyhow!("Host-call channel closed")); + } + + // Await the consumer's reply + let HostResponse { call_id, scope, submission } = host_resp_rx.next().await + .ok_or_else(|| anyhow::anyhow!("Host-response channel closed"))?; + + let step_result = active_session + .accept_client_operation( + UserOperation::SubmitHostResponse { + call_id, + scope, + submission, + }, + ) + .map_err(|e| { + error!(target: "user", error = %e, "failed to submit host response"); + e + }) + .context("Failed to submit host response")?; + + process_session_outputs(vec![step_result], &mut user_output_tx, &mut user_input_tx, &host_call_tx, &mut host_resp_rx).await?; + } + ActiveSessionOutput::OperationSuccess => { + info!(target: "session", "operation completed successfully"); + } + ActiveSessionOutput::SendBackError(e) => { + error!(target: "session", error = %e, "session step failed"); + return Err(anyhow::anyhow!("Session step failed: {e}")); + }, + ActiveSessionOutput::Ignore => { + // Do nothing + } + } + + } else { + info!("User input channel disconnected"); + break; // UI side closed + } } } } diff --git a/crates/ironposh-client-core/Cargo.toml b/crates/ironposh-client-core/Cargo.toml index 05051bd..7d0fa4d 100644 --- a/crates/ironposh-client-core/Cargo.toml +++ b/crates/ironposh-client-core/Cargo.toml @@ -13,12 +13,10 @@ ironposh-xml = { path = "../ironposh-xml" } typed-builder = "0.21.0" base64 = "0.22.1" tracing = "0.1.41" -sspi = { path = "C:\\dev\\sspi-rs", features = ["ring"] } url = "2.5.7" whoami = "1.6.1" serde = { version = "1.0.228", features = ["derive"] } -# sspi = { version = "0.16.1", features = ["ring"] } - +sspi = { version = "0.17", features = ["ring"] } [dev-dependencies] ureq = "2" @@ -26,3 +24,6 @@ tracing-subscriber = { version = "0.3.19", features = ["env-filter"] } tokio = { version = "1", features = ["full"] } anyhow = "1" regex = "1" + +[lints] +workspace = true diff --git a/crates/ironposh-client-core/src/connector/active_session.rs b/crates/ironposh-client-core/src/connector/active_session.rs index 739261f..fc6f5ac 100644 --- a/crates/ironposh-client-core/src/connector/active_session.rs +++ b/crates/ironposh-client-core/src/connector/active_session.rs @@ -11,6 +11,7 @@ use crate::{ use ironposh_psrp::{ErrorRecord, PipelineOutput, PsPrimitiveValue, PsValue}; use tracing::{error, info, instrument, warn}; +#[expect(clippy::large_enum_variant)] #[derive(Debug, PartialEq, Eq)] pub enum UserEvent { PipelineCreated { @@ -32,21 +33,22 @@ pub enum UserEvent { impl UserEvent { pub fn pipeline_id(&self) -> uuid::Uuid { match self { - UserEvent::PipelineCreated { + Self::PipelineCreated { pipeline: powershell, } - | UserEvent::PipelineFinished { + | Self::PipelineFinished { pipeline: powershell, } - | UserEvent::PipelineOutput { + | Self::PipelineOutput { pipeline: powershell, .. } => powershell.id(), - UserEvent::ErrorRecord { handle, .. } => handle.id(), + Self::ErrorRecord { handle, .. } => handle.id(), } } } +#[expect(clippy::large_enum_variant)] #[derive(Debug)] pub enum ActiveSessionOutput { SendBack(Vec), @@ -60,12 +62,12 @@ pub enum ActiveSessionOutput { impl ActiveSessionOutput { pub fn priority(&self) -> u8 { match self { - ActiveSessionOutput::HostCall { .. } => 1, - ActiveSessionOutput::SendBack(_) => 2, - ActiveSessionOutput::SendBackError(_) => 3, - ActiveSessionOutput::UserEvent(_) => 4, - ActiveSessionOutput::OperationSuccess => 5, - ActiveSessionOutput::Ignore => 6, + Self::HostCall { .. } => 1, + Self::SendBack(_) => 2, + Self::SendBackError(_) => 3, + Self::UserEvent(_) => 4, + Self::OperationSuccess => 5, + Self::Ignore => 6, } } } @@ -86,6 +88,7 @@ impl Ord for ActiveSessionOutput { } } +#[expect(clippy::large_enum_variant)] #[derive(Debug)] pub enum UserOperation { InvokeWithSpec { @@ -112,10 +115,10 @@ pub enum UserOperation { impl UserOperation { pub fn operation_type(&self) -> &str { match self { - UserOperation::InvokeWithSpec { .. } => "InvokeWithSpec", - UserOperation::KillPipeline { .. } => "KillPipeline", - UserOperation::SubmitHostResponse { .. } => "SubmitHostResponse", - UserOperation::CancelHostCall { .. } => "CancelHostCall", + Self::InvokeWithSpec { .. } => "InvokeWithSpec", + Self::KillPipeline { .. } => "KillPipeline", + Self::SubmitHostResponse { .. } => "SubmitHostResponse", + Self::CancelHostCall { .. } => "CancelHostCall", } } } @@ -163,7 +166,7 @@ impl ActiveSession { info!(pipeline_id = %pipeline.id(), "killing pipeline"); // 1) Build the Signal request - let kill_xml = self.runspace_pool.kill_pipeline(pipeline); + let kill_xml = self.runspace_pool.kill_pipeline(&pipeline); let kill_xml = match kill_xml { Ok(kill_xml) => kill_xml, Err(e) => { @@ -269,7 +272,7 @@ impl ActiveSession { } // 2) Feed PSRP - let results = self.runspace_pool.accept_response(xml_body).map_err(|e| { + let results = self.runspace_pool.accept_response(&xml_body).map_err(|e| { error!("RunspacePool.accept_response failed: {:#}", e); e })?; @@ -359,7 +362,7 @@ impl ActiveSession { // 1) Fragment to XML let send_xml = self .runspace_pool - .send_pipeline_host_response(command_id, host_resp)?; + .send_pipeline_host_response(command_id, &host_resp)?; info!(send_xml_length = send_xml.len(), "built host response XML"); info!(unencrypted_host_response_xml = %send_xml, "outgoing unencrypted pipeline host response SOAP"); @@ -408,7 +411,7 @@ impl ActiveSession { // 1) Fragment to XML let send_xml = self .runspace_pool - .send_runspace_pool_host_response(host_resp)?; + .send_runspace_pool_host_response(&host_resp)?; info!( send_xml_length = send_xml.len(), "built pool host response XML" diff --git a/crates/ironposh-client-core/src/connector/auth_sequence.rs b/crates/ironposh-client-core/src/connector/auth_sequence.rs index 359a91e..e5751dc 100644 --- a/crates/ironposh-client-core/src/connector/auth_sequence.rs +++ b/crates/ironposh-client-core/src/connector/auth_sequence.rs @@ -7,7 +7,7 @@ use crate::{ PwshCoreError, connector::{ authenticator::{ - SecContextMaybeInit, SecurityContextBuilder, SspiAuthenticator, SspiConext, SspiConfig, + SecContextMaybeInit, SecurityContextBuilder, SspiAuthenticator, SspiContext, SspiConfig, Token, }, config::{AuthenticatorConfig, SspiAuthConfig}, @@ -17,11 +17,12 @@ use crate::{ }, }; +#[expect(clippy::large_enum_variant)] #[derive(Debug)] pub enum SspiAuthContext { - Ntlm(SspiConext), - Kerberos(SspiConext), - Negotiate(SspiConext), + Ntlm(SspiContext), + Kerberos(SspiContext), + Negotiate(SspiContext), } pub struct SecurityContextBuilderHolder<'ctx> { @@ -68,14 +69,14 @@ impl SspiAuthContext { SspiAuthConfig::NTLM { identity, target: target_name, - } => SspiConext::new_ntlm(identity, SspiConfig::new(target_name)) + } => SspiContext::new_ntlm(identity, SspiConfig::new(target_name)) .map(SspiAuthContext::Ntlm), SspiAuthConfig::Kerberos { identity, kerberos_config, target: target_name, - } => SspiConext::new_kerberos( + } => SspiContext::new_kerberos( identity, kerberos_config.into(), SspiConfig::new(target_name), @@ -95,27 +96,24 @@ impl SspiAuthContext { )) })?; - let config = match kerberos_config { - Some(kerberos_config) => { - let kerberos_config: sspi::kerberos::config::KerberosConfig = - kerberos_config.into(); - - NegotiateConfig::from_protocol_config( - Box::new(kerberos_config), - client_computer_name, - ) - } - None => { - let ntlm_config = NtlmConfig::new(client_computer_name.clone()); - - NegotiateConfig::from_protocol_config( - Box::new(ntlm_config), - client_computer_name, - ) - } + let config = if let Some(kerberos_config) = kerberos_config { + let kerberos_config: sspi::kerberos::config::KerberosConfig = + kerberos_config.into(); + + NegotiateConfig::from_protocol_config( + Box::new(kerberos_config), + client_computer_name, + ) + } else { + let ntlm_config = NtlmConfig::new(client_computer_name.clone()); + + NegotiateConfig::from_protocol_config( + Box::new(ntlm_config), + client_computer_name, + ) }; - SspiConext::new_negotiate(identity, config, sspi_config) + SspiContext::new_negotiate(identity, config, sspi_config) .map(SspiAuthContext::Negotiate) } } @@ -130,7 +128,7 @@ pub struct AuthSequenceConfig { impl AuthSequenceConfig { pub fn new(config: AuthenticatorConfig) -> Self { // require_encryption is now embedded in the AuthenticatorConfig::Sspi variant - AuthSequenceConfig { + Self { authenticator_config: config, } } @@ -147,6 +145,7 @@ pub enum SecCtxInited { Done(Option), } +#[expect(clippy::missing_fields_in_debug)] impl Debug for SspiAuthSequence { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("AuthSequence") @@ -163,7 +162,7 @@ impl SspiAuthSequence { http_builder: HttpBuilder, ) -> Result { let context = SspiAuthContext::new(sspi_auth_config)?; - Ok(SspiAuthSequence { + Ok(Self { context, http_builder, require_encryption, @@ -201,16 +200,16 @@ impl SspiAuthSequence { }) } - pub fn resume<'a>( - generator_holder: crate::connector::authenticator::GeneratorHolder<'a>, + pub fn resume( + generator_holder: crate::connector::authenticator::GeneratorHolder<'_>, kdc_response: Vec, - ) -> Result, PwshCoreError> { + ) -> Result, PwshCoreError> { SspiAuthenticator::resume(generator_holder, kdc_response) } pub(crate) fn process_initialized_sec_context( &mut self, - sec_context: crate::connector::authenticator::SecContextInit, + sec_context: &crate::connector::authenticator::SecContextInit, ) -> Result { let res = match &mut self.context { SspiAuthContext::Ntlm(auth_context) => { @@ -236,7 +235,7 @@ impl SspiAuthSequence { } pub fn when_finish(self) -> Authenticated { - let SspiAuthSequence { + let Self { context, http_builder, require_encryption, @@ -278,6 +277,7 @@ pub struct PostConAuthSequence { } /// Drives auth for a newly created connection. +#[expect(clippy::large_enum_variant)] #[derive(Debug)] pub enum AuthSequence { Sspi(SspiAuthSequence), @@ -317,10 +317,10 @@ impl AuthSequence { require_encryption, } => { let sspi_auth = SspiAuthSequence::new(sspi.clone(), *require_encryption, http)?; - Ok(AuthSequence::Sspi(sspi_auth)) + Ok(Self::Sspi(sspi_auth)) } AuthenticatorConfig::Basic { username, password } => { - Ok(AuthSequence::Basic(BasicAuthSequence { + Ok(Self::Basic(BasicAuthSequence { username: username.clone(), password: password.clone(), http_builder: http, diff --git a/crates/ironposh-client-core/src/connector/authenticator.rs b/crates/ironposh-client-core/src/connector/authenticator.rs index 65619d9..421df94 100644 --- a/crates/ironposh-client-core/src/connector/authenticator.rs +++ b/crates/ironposh-client-core/src/connector/authenticator.rs @@ -33,30 +33,24 @@ pub struct SspiConfig { } impl SspiConfig { - pub fn new(target: String) -> Self { - if target.trim().starts_with("HTTP/") { - // OK - } else { - // Assume it's a bare hostname, prepend "HTTP/" - let target = format!("HTTP/{target}"); - return SspiConfig { - target_name: target, - }; - }; - - SspiConfig { + pub fn new(mut target: String) -> Self { + if !target.trim().starts_with("HTTP/") { + target = format!("HTTP/{target}"); + } + Self { target_name: target, } } } /// Caller-owned "Context" the generator borrows. +/// /// Holds provider, credential handle, in/out buffers, and the ISC builder for the current round. /// The reason we need to hold the builder is that, during the generator suspension, the generator holds /// a mutable borrow to the future that holds both the builder and the mut ref of provider, and we need to keep the /// context around during the suspension. #[derive(Debug)] -pub struct SspiConext { +pub struct SspiContext { pub(crate) provider: P, // Box provides a stable heap address; we keep borrows within the same `AuthFurniture`. cred: Box, @@ -66,13 +60,13 @@ pub struct SspiConext { sspi_auth_config: SspiConfig, } -impl SspiConext { +impl SspiContext { pub fn new_ntlm(id: ClientAuthIdentity, config: SspiConfig) -> Result { Self::new_with_identity(Ntlm::new(), id, config) } } -impl SspiConext { +impl SspiContext { pub fn new_negotiate( id: ClientAuthIdentity, config: NegotiateConfig, @@ -80,13 +74,13 @@ impl SspiConext { ) -> Result { Self::new_with_credential( Negotiate::new_client(config)?, - Credentials::AuthIdentity(id.into_inner()), + &Credentials::AuthIdentity(id.into_inner()), sspi_config, ) } } -impl SspiConext { +impl SspiContext { pub fn new_kerberos( id: ClientAuthIdentity, kerberos_config: KerberosConfig, @@ -94,25 +88,25 @@ impl SspiConext { ) -> Result { Self::new_with_credential( Kerberos::new_client_from_config(kerberos_config)?, - Credentials::AuthIdentity(id.into_inner()), + &Credentials::AuthIdentity(id.into_inner()), sspi_config, ) } } -impl

SspiConext

+impl

SspiContext

where P: Sspi + SspiImpl, { pub fn new_with_credential( mut provider: P, - id: Credentials, + id: &Credentials, config: SspiConfig, ) -> Result { let acq = provider .acquire_credentials_handle() .with_credential_use(CredentialUse::Outbound) - .with_auth_data(&id); + .with_auth_data(id); let cred = acq.execute(&mut provider)?.credentials_handle; Ok(Self { @@ -125,7 +119,7 @@ where } } -impl

SspiConext

+impl

SspiContext

where P: Sspi + SspiImpl, { @@ -151,7 +145,7 @@ where } } -impl

SspiConext

+impl

SspiContext

where P: Sspi, { @@ -212,7 +206,7 @@ impl SspiAuthenticator { #[instrument(skip(context, sec_ctx_holder))] pub fn try_init_sec_context<'ctx, 'builder, 'generator, P>( response: Option<&HttpResponse>, - context: &'ctx mut SspiConext

, + context: &'ctx mut SspiContext

, sec_ctx_holder: &'builder mut Option>, require_encryption: bool, ) -> Result, PwshCoreError> @@ -312,9 +306,9 @@ impl SspiAuthenticator { } #[instrument(skip_all)] - pub fn process_initialized_sec_context( - furniture: &mut SspiConext

, - sec_context: SecContextInit, + pub fn process_initialized_sec_context

( + furniture: &mut SspiContext

, + sec_context: &SecContextInit, ) -> Result where P: Sspi + SspiImpl, diff --git a/crates/ironposh-client-core/src/connector/config.rs b/crates/ironposh-client-core/src/connector/config.rs index 6a0eb98..b6f4074 100644 --- a/crates/ironposh-client-core/src/connector/config.rs +++ b/crates/ironposh-client-core/src/connector/config.rs @@ -11,7 +11,7 @@ pub struct KerberosConfig { impl From for sspi::KerberosConfig { fn from(val: KerberosConfig) -> Self { - sspi::KerberosConfig { + Self { kdc_url: val.kdc_url, client_computer_name: Some(val.client_computer_name), } diff --git a/crates/ironposh-client-core/src/connector/conntion_pool.rs b/crates/ironposh-client-core/src/connector/conntion_pool.rs index 97b7267..788b35e 100644 --- a/crates/ironposh-client-core/src/connector/conntion_pool.rs +++ b/crates/ironposh-client-core/src/connector/conntion_pool.rs @@ -43,6 +43,7 @@ pub enum ConnectionState { } // =============================== TrySend API =============================== +#[expect(clippy::large_enum_variant)] #[derive(Debug)] pub enum TrySend { /// We had an Idle socket: body was sealed inside the pool and the conn was @@ -62,8 +63,8 @@ pub enum TrySend { impl TrySend { pub fn get_connection_id(&self) -> ConnectionId { match self { - TrySend::JustSend { conn_id, .. } => *conn_id, - TrySend::AuthNeeded { auth_sequence } => auth_sequence.conn_id, + Self::JustSend { conn_id, .. } => *conn_id, + Self::AuthNeeded { auth_sequence } => auth_sequence.conn_id, } } } @@ -81,8 +82,8 @@ pub struct JustSendOut { impl TrySendExt for TrySend { fn expect_just_send(self) -> JustSendOut { match self { - TrySend::JustSend { request, conn_id } => JustSendOut { request, conn_id }, - other => panic!("expected JustSend, got {other:?}"), + Self::JustSend { request, conn_id } => JustSendOut { request, conn_id }, + other @ Self::AuthNeeded { .. } => panic!("expected JustSend, got {other:?}"), } } } @@ -229,6 +230,7 @@ impl ConnectionPool { Ok(try_send) } + #[expect(clippy::too_many_lines)] #[instrument(skip(self, response), fields( conn_id = response.connection_id.inner(), status_code = response.response.status_code, @@ -256,48 +258,45 @@ impl ConnectionPool { ConnectionState::PreAuth => { info!(conn_id = connection_id.inner(), "handling PreAuth response"); - match encryption { - Some(encryption_provider) => { - let AuthenticatedHttpChannel { - mut encryption_provider, - conn_id: _, - } = encryption_provider; - - let body = encryption_provider.decrypt(response.body)?; - if response.status_code >= 400 { - error!( - conn_id = connection_id.inner(), - status_code = response.status_code, - decrypted_error_body = %body, - "server returned error response with decrypted body" - ); - } else { - info!( - conn_id = connection_id.inner(), - decrypted_length = body.len(), - "decrypted PreAuth response, moving to Idle" - ); - } - - *state = ConnectionState::Idle { - enc: EncryptionOptions::Sspi { - encryption_provider, - }, - }; - - Ok(body) - } - None => { - // Unreachable + if let Some(encryption_provider) = encryption { + let AuthenticatedHttpChannel { + mut encryption_provider, + conn_id: _, + } = encryption_provider; + + let body = encryption_provider.decrypt(response.body)?; + if response.status_code >= 400 { error!( conn_id = connection_id.inner(), - "PreAuth response missing encryption provider" + status_code = response.status_code, + decrypted_error_body = %body, + "server returned error response with decrypted body" + ); + } else { + info!( + conn_id = connection_id.inner(), + decrypted_length = body.len(), + "decrypted PreAuth response, moving to Idle" ); - - Err(PwshCoreError::InvalidState( - "PreAuth response missing encryption provider", - )) } + + *state = ConnectionState::Idle { + enc: EncryptionOptions::Sspi { + encryption_provider, + }, + }; + + Ok(body) + } else { + // Unreachable + error!( + conn_id = connection_id.inner(), + "PreAuth response missing encryption provider" + ); + + Err(PwshCoreError::InvalidState( + "PreAuth response missing encryption provider", + )) } } ConnectionState::Pending { @@ -438,7 +437,7 @@ impl PostConAuthSequence { pub fn process_sec_ctx_init( mut self, - sec_context: crate::connector::authenticator::SecContextInit, + sec_context: &crate::connector::authenticator::SecContextInit, ) -> Result { match self .auth_sequence @@ -454,7 +453,7 @@ impl PostConAuthSequence { }) } super::auth_sequence::SecCtxInited::Done(mut token) => { - let PostConAuthSequence { + let Self { auth_sequence, queued_xml, conn_id, diff --git a/crates/ironposh-client-core/src/connector/encryption.rs b/crates/ironposh-client-core/src/connector/encryption.rs index 3b68edd..d939737 100644 --- a/crates/ironposh-client-core/src/connector/encryption.rs +++ b/crates/ironposh-client-core/src/connector/encryption.rs @@ -11,6 +11,7 @@ use crate::{ }, }; +#[expect(clippy::large_enum_variant)] #[derive(Debug, PartialEq, Eq)] pub enum EncryptionOptions { IncludeHeader { @@ -160,19 +161,14 @@ impl EncryptionProvider { body_type = ?data, "Decrypting HTTP body" ); - let encrypted_data = match data { - HttpBody::Encrypted(encrypted_data) => { - debug!( - encrypted_data_len = encrypted_data.len(), - "Processing encrypted HTTP body" - ); - encrypted_data - } - _ => { - debug!("Body is not encrypted, returning as-is"); - return Ok(data.as_str()?.to_owned()); - } + let HttpBody::Encrypted(encrypted_data) = data else { + debug!("Body is not encrypted, returning as-is"); + return Ok(data.as_str()?.to_owned()); }; + debug!( + encrypted_data_len = encrypted_data.len(), + "Processing encrypted HTTP body" + ); // Parse the multipart/encrypted body to extract the binary payload let binary_payload = extract_binary_payload(&encrypted_data)?; @@ -259,7 +255,6 @@ impl EncryptionProvider { } /// Extract the binary payload from a multipart/encrypted HTTP body - fn wrap( &mut self, data: &mut [u8], @@ -365,20 +360,24 @@ fn extract_binary_payload(data: &[u8]) -> Result, PwshCoreError> { ); // Look for either the next boundary or the closing boundary - let binary_end = if let Some(next_boundary_pos) = - find_subsequence(&data[binary_start..], boundary_bytes) - { - debug!(next_boundary_pos = next_boundary_pos, "Found next boundary"); - binary_start + next_boundary_pos - } else if let Some(closing_pos) = - find_subsequence(&data[binary_start..], closing_boundary_bytes) - { - debug!(closing_pos = closing_pos, "Found closing boundary"); - binary_start + closing_pos - } else { - debug!("No boundary found, using end of data"); - data.len() - }; + let binary_end = find_subsequence(&data[binary_start..], boundary_bytes).map_or_else( + || { + find_subsequence(&data[binary_start..], closing_boundary_bytes).map_or_else( + || { + debug!("No boundary found, using end of data"); + data.len() + }, + |closing_pos| { + debug!(closing_pos = closing_pos, "Found closing boundary"); + binary_start + closing_pos + }, + ) + }, + |next_boundary_pos| { + debug!(next_boundary_pos = next_boundary_pos, "Found next boundary"); + binary_start + next_boundary_pos + }, + ); if binary_end > binary_start { let payload_len = binary_end - binary_start; diff --git a/crates/ironposh-client-core/src/connector/http.rs b/crates/ironposh-client-core/src/connector/http.rs index eccd389..f1d6406 100644 --- a/crates/ironposh-client-core/src/connector/http.rs +++ b/crates/ironposh-client-core/src/connector/http.rs @@ -12,23 +12,26 @@ pub enum ServerAddress { impl ServerAddress { pub fn parse(value: &str) -> Result { - if let Ok(ip) = value.parse::() { - Ok(ServerAddress::Ip(ip)) - } else if !value.trim().is_empty() { - Ok(ServerAddress::Domain(value.to_string())) - } else { - Err(crate::PwshCoreError::InvalidServerAddress( - "server address cannot be empty", - )) - } + value.parse::().map_or_else( + |_| { + if value.trim().is_empty() { + Err(crate::PwshCoreError::InvalidServerAddress( + "server address cannot be empty", + )) + } else { + Ok(Self::Domain(value.to_string())) + } + }, + |ip| Ok(Self::Ip(ip)), + ) } } impl Display for ServerAddress { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - ServerAddress::Ip(ip) => write!(f, "{ip}"), - ServerAddress::Domain(domain) => write!(f, "{domain}"), + Self::Ip(ip) => write!(f, "{ip}"), + Self::Domain(domain) => write!(f, "{domain}"), } } } @@ -51,54 +54,50 @@ pub enum HttpBody { impl HttpBody { pub fn is_encrypted(&self) -> bool { - matches!(self, HttpBody::Encrypted(_)) + matches!(self, Self::Encrypted(_)) } - pub(crate) fn empty() -> HttpBody { - HttpBody::None + pub(crate) fn empty() -> Self { + Self::None } } impl HttpBody { pub fn content_type(&self) -> &'static str { match self { - HttpBody::Xml(_) => "application/soap+xml; charset=utf-8", - HttpBody::Encrypted(_) => { + Self::Xml(_) => "application/soap+xml; charset=utf-8", + Self::Encrypted(_) => { r#"multipart/encrypted;protocol="application/HTTP-SPNEGO-session-encrypted";boundary="Encrypted Boundary""# } - HttpBody::Text(_) => "text/plain; charset=utf-8", - HttpBody::None => "text/plain; charset=utf-8", + Self::Text(_) | Self::None => "text/plain; charset=utf-8", } } pub fn is_empty(&self) -> bool { match self { - HttpBody::Xml(content) => content.is_empty(), - HttpBody::Encrypted(content) => content.is_empty(), - HttpBody::Text(content) => content.is_empty(), - HttpBody::None => true, + Self::Xml(content) | Self::Text(content) => content.is_empty(), + Self::Encrypted(content) => content.is_empty(), + Self::None => true, } } /// Returns the length of the body content in bytes pub fn len(&self) -> usize { match self { - HttpBody::Xml(content) => content.len(), - HttpBody::Encrypted(content) => content.len(), - HttpBody::Text(content) => content.len(), - HttpBody::None => 0, + Self::Xml(content) | Self::Text(content) => content.len(), + Self::Encrypted(content) => content.len(), + Self::None => 0, } } /// Returns the body content as a string reference pub fn as_str(&self) -> Result<&str, crate::PwshCoreError> { match self { - HttpBody::Xml(content) => Ok(content), - HttpBody::Encrypted(_) => Err(crate::PwshCoreError::InternalError( + Self::Xml(content) | Self::Text(content) => Ok(content), + Self::Encrypted(_) => Err(crate::PwshCoreError::InternalError( "Cannot convert binary encrypted content to &str".to_owned(), )), - HttpBody::Text(content) => Ok(content), - HttpBody::None => Ok(""), + Self::None => Ok(""), } } } diff --git a/crates/ironposh-client-core/src/connector/mod.rs b/crates/ironposh-client-core/src/connector/mod.rs index fe4860d..2980c95 100644 --- a/crates/ironposh-client-core/src/connector/mod.rs +++ b/crates/ironposh-client-core/src/connector/mod.rs @@ -72,8 +72,8 @@ pub enum ConnectorStepResult { impl ConnectorStepResult { pub fn name(&self) -> &'static str { match self { - ConnectorStepResult::SendBack { .. } => "SendBack", - ConnectorStepResult::Connected { .. } => "Connected", + Self::SendBack { .. } => "SendBack", + Self::Connected { .. } => "Connected", } } } @@ -81,8 +81,8 @@ impl ConnectorStepResult { impl ConnectorStepResult { pub fn priority(&self) -> u8 { match self { - ConnectorStepResult::SendBack { .. } => 1, - ConnectorStepResult::Connected { .. } => 3, + Self::SendBack { .. } => 1, + Self::Connected { .. } => 3, } } } @@ -105,10 +105,10 @@ pub enum ConnectorState { impl ConnectorState { fn state_name(&self) -> &'static str { match self { - ConnectorState::Idle => "Idle", - ConnectorState::Connecting { .. } => "Connecting", - ConnectorState::ConnectReceiveCycle { .. } => "ConnectReceiveCycle", - ConnectorState::Connected => "Connected", + Self::Idle => "Idle", + Self::Connecting { .. } => "Connecting", + Self::ConnectReceiveCycle { .. } => "ConnectReceiveCycle", + Self::Connected => "Connected", } } } @@ -190,7 +190,7 @@ impl Connector { let xml = connection_pool.accept(targeted_response)?; // Advance runspace handshake - let mut runspace_pool = expect_shell_created.accept(xml)?; + let runspace_pool = expect_shell_created.accept(&xml)?; let receive_xml = runspace_pool.fire_receive(DesiredStream::runspace_pool_streams())?; info!(connecting_receive_xml = %receive_xml, "outgoing unencrypted connecting receive SOAP"); @@ -212,7 +212,7 @@ impl Connector { )?; let xml = connection_pool.accept(targeted_response)?; - let results = runspace_pool.accept_response(xml)?; + let results = runspace_pool.accept_response(&xml)?; let Some(AcceptResponsResult::ReceiveResponse { desired_streams }) = results .into_iter() .find(|r| matches!(r, AcceptResponsResult::ReceiveResponse { .. })) @@ -222,7 +222,7 @@ impl Connector { )); }; - if let RunspacePoolState::NegotiationSent = runspace_pool.state { + if runspace_pool.state == RunspacePoolState::NegotiationSent { let receive_xml = runspace_pool.fire_receive(desired_streams)?; let try_send = connection_pool.send(&receive_xml)?; let new_state = ConnectorState::ConnectReceiveCycle { @@ -230,7 +230,7 @@ impl Connector { connection_pool, }; (new_state, ConnectorStepResult::SendBack { try_send }) - } else if let RunspacePoolState::Opened = runspace_pool.state { + } else if runspace_pool.state == RunspacePoolState::Opened { // Hand off to ActiveSession: it should carry the pool forward let next_receive_xml = runspace_pool.fire_receive(desired_streams)?; let next_req = connection_pool.send(&next_receive_xml)?; diff --git a/crates/ironposh-client-core/src/host/error.rs b/crates/ironposh-client-core/src/host/error.rs index 3f8c1ea..ac1008b 100644 --- a/crates/ironposh-client-core/src/host/error.rs +++ b/crates/ironposh-client-core/src/host/error.rs @@ -1,5 +1,5 @@ /// Error type for host operations -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum HostError { NotImplemented, InvalidParameters, @@ -11,11 +11,11 @@ pub enum HostError { impl std::fmt::Display for HostError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - HostError::NotImplemented => write!(f, "Operation not implemented"), - HostError::InvalidParameters => write!(f, "Invalid parameters"), - HostError::RequestReturnMismatch => write!(f, "Request and return types do not match"), - HostError::Cancelled => write!(f, "Operation cancelled"), - HostError::Other(msg) => write!(f, "{msg}"), + Self::NotImplemented => write!(f, "Operation not implemented"), + Self::InvalidParameters => write!(f, "Invalid parameters"), + Self::RequestReturnMismatch => write!(f, "Request and return types do not match"), + Self::Cancelled => write!(f, "Operation cancelled"), + Self::Other(msg) => write!(f, "{msg}"), } } } diff --git a/crates/ironposh-client-core/src/host/methods.rs b/crates/ironposh-client-core/src/host/methods.rs index 2806903..64a8376 100644 --- a/crates/ironposh-client-core/src/host/methods.rs +++ b/crates/ironposh-client-core/src/host/methods.rs @@ -37,7 +37,7 @@ pub struct KeyInfo { pub key_down: bool, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct ProgressRecord { pub activity: String, pub status_description: String, @@ -49,7 +49,7 @@ pub struct ProgressRecord { pub record_type: i32, // ProgressRecordType } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct FieldDescription { pub name: String, pub label: String, @@ -59,13 +59,13 @@ pub struct FieldDescription { pub default_value: Option, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct ChoiceDescription { pub label: String, pub help_message: String, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct PSCredential { pub user_name: String, pub password: Vec, // SecureString as bytes diff --git a/crates/ironposh-client-core/src/host/params.rs b/crates/ironposh-client-core/src/host/params.rs index 7c63ccc..2a5c934 100644 --- a/crates/ironposh-client-core/src/host/params.rs +++ b/crates/ironposh-client-core/src/host/params.rs @@ -100,7 +100,7 @@ impl FromParams for (i64, methods::ProgressRecord) { ComplexObjectContent::PsEnums(enums) => Some(enums.value), _ => None, }, - _ => None, + PsValue::Primitive(_) => None, }) .unwrap_or(0); @@ -117,7 +117,7 @@ impl FromParams for (i64, methods::ProgressRecord) { Ok((source_id, progress_record)) } - _ => Err(HostError::InvalidParameters), + PsValue::Primitive(_) => Err(HostError::InvalidParameters), } } } @@ -215,9 +215,9 @@ impl FromParams for methods::Coordinates { .and_then(|prop| prop.value.as_i32()) .ok_or(HostError::InvalidParameters)?; - Ok(methods::Coordinates { x, y }) + Ok(Self { x, y }) } - _ => Err(HostError::InvalidParameters), + PsValue::Primitive(_) => Err(HostError::InvalidParameters), } } } @@ -276,14 +276,14 @@ impl FromParams for methods::Rectangle { .and_then(|prop| prop.value.as_i32()) .ok_or(HostError::InvalidParameters)?; - Ok(methods::Rectangle { + Ok(Self { left, top, right, bottom, }) } - _ => Err(HostError::InvalidParameters), + PsValue::Primitive(_) => Err(HostError::InvalidParameters), } } } @@ -374,14 +374,14 @@ impl FromParams for methods::BufferCell { .and_then(|prop| prop.value.as_i32()) .ok_or(HostError::InvalidParameters)?; - Ok(methods::BufferCell { + Ok(Self { character, foreground, background, flags, }) } - _ => Err(HostError::InvalidParameters), + PsValue::Primitive(_) => Err(HostError::InvalidParameters), } } } diff --git a/crates/ironposh-client-core/src/host/returns.rs b/crates/ironposh-client-core/src/host/returns.rs index c9ce78e..1d41230 100644 --- a/crates/ironposh-client-core/src/host/returns.rs +++ b/crates/ironposh-client-core/src/host/returns.rs @@ -1,44 +1,46 @@ +use std::collections::HashMap; + use super::{methods, traits::ToPs}; use ironposh_psrp::PsValue; -impl ToPs for std::collections::HashMap { - fn to_ps(_v: std::collections::HashMap) -> Option { +impl ToPs for HashMap { + fn to_ps(_v: Self) -> Option { todo!("Implement HashMap to PsValue conversion") } } impl ToPs for methods::PSCredential { - fn to_ps(_v: methods::PSCredential) -> Option { + fn to_ps(_v: Self) -> Option { todo!("Implement PSCredential to PsValue conversion") } } impl ToPs for Vec { - fn to_ps(_v: Vec) -> Option { + fn to_ps(_v: Self) -> Option { todo!("Implement Vec to PsValue conversion") } } impl ToPs for methods::KeyInfo { - fn to_ps(_v: methods::KeyInfo) -> Option { + fn to_ps(_v: Self) -> Option { todo!("Implement KeyInfo to PsValue conversion") } } impl ToPs for Vec> { - fn to_ps(_v: Vec>) -> Option { + fn to_ps(_v: Self) -> Option { todo!("Implement Vec> to PsValue conversion") } } impl ToPs for methods::Coordinates { - fn to_ps(_v: methods::Coordinates) -> Option { + fn to_ps(_v: Self) -> Option { todo!("Implement Coordinates to PsValue conversion") } } impl ToPs for methods::Size { - fn to_ps(_v: methods::Size) -> Option { + fn to_ps(_v: Self) -> Option { todo!("Implement Size to PsValue conversion") } } diff --git a/crates/ironposh-client-core/src/host/traits.rs b/crates/ironposh-client-core/src/host/traits.rs index 41f0a9a..fc8e9d8 100644 --- a/crates/ironposh-client-core/src/host/traits.rs +++ b/crates/ironposh-client-core/src/host/traits.rs @@ -11,7 +11,7 @@ pub trait Method: sealed::Sealed { fn should_send_response() -> bool; } -pub(crate) mod sealed { +pub mod sealed { pub trait Sealed {} } @@ -39,7 +39,7 @@ impl FromParams for () { impl FromParams for String { fn from_params(a: &[PsValue]) -> Result { a.first() - .and_then(|v| v.as_string()) + .and_then(PsValue::as_string) .ok_or(HostError::InvalidParameters) } } @@ -47,7 +47,7 @@ impl FromParams for String { impl FromParams for i32 { fn from_params(a: &[PsValue]) -> Result { a.first() - .and_then(|v| v.as_i32()) + .and_then(PsValue::as_i32) .ok_or(HostError::InvalidParameters) } } @@ -55,7 +55,7 @@ impl FromParams for i32 { impl FromParams for i64 { fn from_params(a: &[PsValue]) -> Result { a.first() - .and_then(|v| v.as_i64()) + .and_then(PsValue::as_i64) .ok_or(HostError::InvalidParameters) } } @@ -64,7 +64,7 @@ impl FromParams for (i32,) { fn from_params(a: &[PsValue]) -> Result { let param = a .first() - .and_then(|v| v.as_i32()) + .and_then(PsValue::as_i32) .ok_or(HostError::InvalidParameters)?; Ok((param,)) } @@ -74,7 +74,7 @@ impl FromParams for (String,) { fn from_params(a: &[PsValue]) -> Result { let param = a .first() - .and_then(|v| v.as_string()) + .and_then(PsValue::as_string) .ok_or(HostError::InvalidParameters)?; Ok((param,)) } @@ -82,43 +82,43 @@ impl FromParams for (String,) { // Basic return type conversions impl ToPs for String { - fn to_ps(v: String) -> Option { + fn to_ps(v: Self) -> Option { Some(PsValue::from(v)) } } impl ToPs for i32 { - fn to_ps(v: i32) -> Option { + fn to_ps(v: Self) -> Option { Some(PsValue::from(v)) } } impl ToPs for bool { - fn to_ps(v: bool) -> Option { + fn to_ps(v: Self) -> Option { Some(PsValue::from(v)) } } impl ToPs for uuid::Uuid { - fn to_ps(v: uuid::Uuid) -> Option { + fn to_ps(v: Self) -> Option { Some(PsValue::from(v.to_string())) } } impl ToPs for Vec { - fn to_ps(v: Vec) -> Option { + fn to_ps(v: Self) -> Option { Some(PsValue::from(v)) } } impl ToPs for PsValue { - fn to_ps(v: PsValue) -> Option { + fn to_ps(v: Self) -> Option { Some(v) } } impl ToPs for () { - fn to_ps(_: ()) -> Option { + fn to_ps(_value: ()) -> Option { None // Void methods don't return values } } diff --git a/crates/ironposh-client-core/src/host/transports.rs b/crates/ironposh-client-core/src/host/transports.rs index 2921c34..b772db2 100644 --- a/crates/ironposh-client-core/src/host/transports.rs +++ b/crates/ironposh-client-core/src/host/transports.rs @@ -45,6 +45,7 @@ pub struct ResultTransport { } /// What gets passed back to the session +#[expect(clippy::large_enum_variant)] #[derive(Debug)] pub enum Submission { Send(PipelineHostResponse), diff --git a/crates/ironposh-client-core/src/pipeline.rs b/crates/ironposh-client-core/src/pipeline.rs index 4b6a8aa..4cb4999 100644 --- a/crates/ironposh-client-core/src/pipeline.rs +++ b/crates/ironposh-client-core/src/pipeline.rs @@ -3,7 +3,7 @@ use ironposh_psrp::{CommandParameter, PsValue}; use crate::runspace_pool::PsInvocationState; /// Represents a single parameter for a command -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum Parameter { Named { name: String, value: PsValue }, Positional { value: PsValue }, @@ -11,7 +11,7 @@ pub enum Parameter { } /// Represents a single PowerShell command in business logic terms -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct PipelineCommand { pub command_text: String, pub is_script: bool, @@ -19,7 +19,7 @@ pub struct PipelineCommand { } /// Represents a pipeline specification at the API boundary -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct PipelineSpec { pub commands: Vec, } @@ -50,8 +50,8 @@ impl PipelineCommand { self } - pub fn new_output_stream() -> PipelineCommand { - PipelineCommand::new_command("Out-String".to_string()).with_parameter(Parameter::Switch { + pub fn new_output_stream() -> Self { + Self::new_command("Out-String".to_string()).with_parameter(Parameter::Switch { name: "-Stream".to_owned(), value: true, }) @@ -104,8 +104,7 @@ impl Pipeline { /// Convert the business-level pipeline to a protocol-level PowerShellPipeline pub(crate) fn to_protocol_pipeline( &self, - ) -> Result - { + ) -> ironposh_psrp::messages::create_pipeline::PowerShellPipeline { use ironposh_psrp::Command; // Convert all commands to protocol commands @@ -121,13 +120,13 @@ impl Pipeline { .iter() .map(|param| match param { Parameter::Named { name, value } => { - CommandParameter::named(name.to_string(), value.clone()) + CommandParameter::named(name.clone(), value.clone()) } Parameter::Positional { value } => { CommandParameter::positional(value.clone()) } Parameter::Switch { name, value } => { - CommandParameter::named(name.to_string(), *value) + CommandParameter::named(name.clone(), *value) } }) .collect(), @@ -136,12 +135,10 @@ impl Pipeline { }) .collect(); - Ok( - ironposh_psrp::messages::create_pipeline::PowerShellPipeline::builder() - .is_nested(false) - .redirect_shell_error_output_pipe(true) - .cmds(protocol_commands) - .build(), - ) + ironposh_psrp::messages::create_pipeline::PowerShellPipeline::builder() + .is_nested(false) + .redirect_shell_error_output_pipe(true) + .cmds(protocol_commands) + .build() } } diff --git a/crates/ironposh-client-core/src/runspace/win_rs.rs b/crates/ironposh-client-core/src/runspace/win_rs.rs index ff010b4..21f0a15 100644 --- a/crates/ironposh-client-core/src/runspace/win_rs.rs +++ b/crates/ironposh-client-core/src/runspace/win_rs.rs @@ -7,7 +7,7 @@ use ironposh_winrm::{ shell_value::ShellValue, }, soap::{SoapEnvelope, body::SoapBody}, - ws_management::{self, OptionSetValue, SelectorSetValue, WsMan}, + ws_management::{OptionSetValue, SelectorSetValue, WsAction, WsMan}, }; use ironposh_xml::builder::Element; use tracing::{debug, instrument}; @@ -99,7 +99,7 @@ impl WinRunspace { } ws_man.invoke( - ws_management::WsAction::Create, + &WsAction::Create, None, SoapBody::builder().shell(shell).build(), Some(option_set), @@ -157,7 +157,7 @@ impl WinRunspace { .map(|shell_id| SelectorSetValue::new().add_selector("ShellId", shell_id)); ws_man.invoke( - ws_management::WsAction::ShellReceive, + &WsAction::ShellReceive, Some(&self.resource_uri), SoapBody::builder().receive(receive_tag).build(), Some(option_set), @@ -166,18 +166,17 @@ impl WinRunspace { } #[instrument(skip_all)] - pub(crate) fn accept_receive_response<'a>( - &mut self, - soap_envelope: &SoapEnvelope<'a>, + pub(crate) fn accept_receive_response( + soap_envelope: &SoapEnvelope<'_>, ) -> Result<(Vec, Option), crate::PwshCoreError> { let receive_response = &soap_envelope .body .as_ref() .receive_response .as_ref() - .ok_or(crate::PwshCoreError::InvalidResponse( - "No ReceiveResponse found in response".into(), - ))?; + .ok_or_else(|| { + crate::PwshCoreError::InvalidResponse("No ReceiveResponse found in response".into()) + })?; let streams = receive_response .value @@ -202,14 +201,14 @@ impl WinRunspace { } #[instrument(skip_all)] - pub(crate) fn accept_create_response<'a>( + pub(crate) fn accept_create_response( &mut self, - soap_envelop: &SoapEnvelope<'a>, + soap_envelop: &SoapEnvelope<'_>, ) -> Result<(), crate::PwshCoreError> { - let shell = &soap_envelop.body.as_ref().shell.as_ref().ok_or( - crate::PwshCoreError::InvalidResponse("No shell found in response".into()), - )?; - let shell_id = shell.as_ref().shell_id.as_ref().map(|id| id.clone_value()); + let shell = &soap_envelop.body.as_ref().shell.as_ref().ok_or_else(|| { + crate::PwshCoreError::InvalidResponse("No shell found in response".into()) + })?; + let shell_id = shell.as_ref().shell_id.as_ref().map(Tag::clone_value); let resource_uri = &shell.as_ref().resource_uri; let owner = &shell.as_ref().owner; let client_ip = &shell.as_ref().client_ip; @@ -224,13 +223,12 @@ impl WinRunspace { self.idle_time_out = idle_time_out.as_ref().map(|t| t.value.0); self.output_streams = output_stream .as_ref() - .map(|o| o.value.as_ref().to_string()) - .unwrap_or_else(|| "stdout".to_string()); + .map_or_else(|| "stdout".to_string(), |o| o.value.as_ref().to_string()); - self.resource_uri = resource_uri - .as_ref() - .map(|r| r.value.as_ref().to_string()) - .unwrap_or_else(|| self.resource_uri.clone()); + self.resource_uri = resource_uri.as_ref().map_or_else( + || self.resource_uri.clone(), + |r| r.value.as_ref().to_string(), + ); self.shell_run_time = shell_run_time .as_ref() @@ -240,9 +238,14 @@ impl WinRunspace { .as_ref() .map(|t| t.value.as_ref().to_string()); - let resource_created = soap_envelop.body.as_ref().resource_created.as_ref().ok_or( - crate::PwshCoreError::InvalidResponse("No ResourceCreated found in response".into()), - )?; + let resource_created = soap_envelop + .body + .as_ref() + .resource_created + .as_ref() + .ok_or_else(|| { + crate::PwshCoreError::InvalidResponse("No ResourceCreated found in response".into()) + })?; let reference_parameters = resource_created.as_ref().reference_parameters.as_ref(); @@ -257,9 +260,9 @@ impl WinRunspace { /// Accept a SignalResponse and match it's message ID to a previously sent Signal request /// If matched, return the associated CommandId - pub(crate) fn accept_signal_response<'a>( + pub(crate) fn accept_signal_response( &mut self, - soap_envelope: &SoapEnvelope<'a>, + soap_envelope: &SoapEnvelope<'_>, ) -> Result, crate::PwshCoreError> { let message_id = soap_envelope .header @@ -271,12 +274,13 @@ impl WinRunspace { .value .0; - if let Some(command_id) = self.signal_messages.remove(&message_id) { - Ok(Some(command_id)) - } else { - debug!(message_id = %message_id, "Received Signal response with unknown MessageId"); - Ok(None) - } + self.signal_messages.remove(&message_id).map_or_else( + || { + debug!(message_id = %message_id, "Received Signal response with unknown MessageId"); + Ok(None) + }, + |command_id| Ok(Some(command_id)), + ) } pub(crate) fn create_pipeline_request<'a>( @@ -286,14 +290,14 @@ impl WinRunspace { arguments: Vec, executable: Option, no_shell: Option, - ) -> Result>, crate::PwshCoreError> { + ) -> impl Into> { let command_line = CommandLineValue { command: executable, arguments, }; - let request = connection.invoke( - ws_management::WsAction::Command, + connection.invoke( + &WsAction::Command, Some(self.resource_uri.as_ref()), SoapBody::builder() .command_line( @@ -305,9 +309,7 @@ impl WinRunspace { no_shell.unwrap_or_default().to_string(), )), self.selector_set.clone().into(), - ); - - Ok(request) + ) } /// Send data to the shell stdin (for host responses) @@ -316,7 +318,7 @@ impl WinRunspace { &'a self, connection: &'a WsMan, command_id: Option, - data: Vec, + data: &[String], ) -> Result>, crate::PwshCoreError> { use ironposh_winrm::{ cores::{Tag, tag_name::Send}, @@ -324,18 +326,17 @@ impl WinRunspace { }; // Add send tag with data - let send_tag = if let Some(cmd_id) = command_id { - // For pipeline-scoped sends, include CommandId - Tag::from_name(Send) - .with_value(Text::from(data.join(""))) - .with_attribute(Attribute::CommandId(cmd_id)) - } else { - // For runspace-scoped sends, no CommandId - Tag::from_name(Send).with_value(Text::from(data.join(""))) - }; + let send_tag = command_id.map_or_else( + || Tag::from_name(Send).with_value(Text::from(data.join(""))), + |cmd_id| { + Tag::from_name(Send) + .with_value(Text::from(data.join(""))) + .with_attribute(Attribute::CommandId(cmd_id)) + }, + ); let request = connection.invoke( - ws_management::WsAction::Send, + &WsAction::Send, Some(self.resource_uri.as_ref()), SoapBody::builder().send(send_tag).build(), Some( @@ -348,18 +349,18 @@ impl WinRunspace { Ok(request) } - pub fn accept_commannd_response<'a>( + pub fn accept_commannd_response( &mut self, - soap_envelope: &SoapEnvelope<'a>, + soap_envelope: &SoapEnvelope<'_>, ) -> Result { let command_id = soap_envelope .body .as_ref() .command_response .as_ref() - .ok_or(crate::PwshCoreError::InvalidResponse( - "No CommandResponse found in response".into(), - ))? + .ok_or_else(|| { + crate::PwshCoreError::InvalidResponse("No CommandResponse found in response".into()) + })? .as_ref() .as_ref(); @@ -395,7 +396,7 @@ impl WinRunspace { let selector_set = self.selector_set.clone().into(); let body = connection.invoke( - ws_management::WsAction::Signal, + &WsAction::Signal, Some(self.resource_uri.as_ref()), SoapBody::builder().signal(signal).build(), Some(option_set), @@ -451,9 +452,9 @@ impl<'a> TryFrom<&Tag<'a, Text<'a>, tag_name::Stream>> for Stream { Attribute::Name(name) => Some(name.to_string()), _ => None, }) - .ok_or(crate::PwshCoreError::InvalidResponse( - "Stream tag missing name attribute".into(), - ))?; + .ok_or_else(|| { + crate::PwshCoreError::InvalidResponse("Stream tag missing name attribute".into()) + })?; let command_id = attributes.iter().find_map(|attr| match attr { Attribute::CommandId(id) => Some(id.to_owned()), @@ -467,7 +468,7 @@ impl<'a> TryFrom<&Tag<'a, Text<'a>, tag_name::Stream>> for Stream { crate::PwshCoreError::InvalidResponse("Failed to decode stream value".into()) })?; - Ok(Stream { + Ok(Self { name, command_id, value, @@ -495,9 +496,11 @@ impl<'a> TryFrom<&Tag<'a, CommandStateValue<'a>, tag_name::CommandState>> for Co Attribute::CommandId(id) => Some(id), _ => None, }) - .ok_or(crate::PwshCoreError::InvalidResponse( - "CommandState tag missing command_id attribute".into(), - ))?; + .ok_or_else(|| { + crate::PwshCoreError::InvalidResponse( + "CommandState tag missing command_id attribute".into(), + ) + })?; let state = value .attributes @@ -506,9 +509,11 @@ impl<'a> TryFrom<&Tag<'a, CommandStateValue<'a>, tag_name::CommandState>> for Co Attribute::State(state) => Some(state.to_string()), _ => None, }) - .ok_or(crate::PwshCoreError::InvalidResponse( - "CommandState tag missing state attribute".into(), - ))?; + .ok_or_else(|| { + crate::PwshCoreError::InvalidResponse( + "CommandState tag missing state attribute".into(), + ) + })?; let exit_code = value .value @@ -516,9 +521,9 @@ impl<'a> TryFrom<&Tag<'a, CommandStateValue<'a>, tag_name::CommandState>> for Co .as_ref() .map(|exit_code| exit_code.value.0); - Ok(CommandState { + Ok(Self { command_id: *command_id, - state: state.to_string(), + state, exit_code, }) } diff --git a/crates/ironposh-client-core/src/runspace_pool/creator.rs b/crates/ironposh-client-core/src/runspace_pool/creator.rs index 39bc657..b680644 100644 --- a/crates/ironposh-client-core/src/runspace_pool/creator.rs +++ b/crates/ironposh-client-core/src/runspace_pool/creator.rs @@ -66,7 +66,7 @@ impl RunspacePoolCreator { application_private_data: self.application_private_data, session_capability: self.session_capability, pipelines: self.pipelines, - runspace_pool_desired_stream_is_pooling: false, + desired_stream_is_pooling: false, } } } diff --git a/crates/ironposh-client-core/src/runspace_pool/enums.rs b/crates/ironposh-client-core/src/runspace_pool/enums.rs index 6d1a5d1..6984ed7 100644 --- a/crates/ironposh-client-core/src/runspace_pool/enums.rs +++ b/crates/ironposh-client-core/src/runspace_pool/enums.rs @@ -1,4 +1,4 @@ -use ironposh_psrp::RunspacePoolStateValue; +use ironposh_psrp::{PSInvocationState, RunspacePoolStateValue}; #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub enum PowerShellState { @@ -17,16 +17,16 @@ pub enum PsInvocationState { Disconnected = 6, } -impl From for PsInvocationState { - fn from(value: ironposh_psrp::PSInvocationState) -> Self { +impl From for PsInvocationState { + fn from(value: PSInvocationState) -> Self { match value { - ironposh_psrp::PSInvocationState::NotStarted => PsInvocationState::NotStarted, - ironposh_psrp::PSInvocationState::Running => PsInvocationState::Running, - ironposh_psrp::PSInvocationState::Stopping => PsInvocationState::Stopping, - ironposh_psrp::PSInvocationState::Stopped => PsInvocationState::Stopped, - ironposh_psrp::PSInvocationState::Completed => PsInvocationState::Completed, - ironposh_psrp::PSInvocationState::Failed => PsInvocationState::Failed, - ironposh_psrp::PSInvocationState::Disconnected => PsInvocationState::Disconnected, + PSInvocationState::NotStarted => Self::NotStarted, + PSInvocationState::Running => Self::Running, + PSInvocationState::Stopping => Self::Stopping, + PSInvocationState::Stopped => Self::Stopped, + PSInvocationState::Completed => Self::Completed, + PSInvocationState::Failed => Self::Failed, + PSInvocationState::Disconnected => Self::Disconnected, } } } @@ -50,16 +50,16 @@ pub enum RunspacePoolState { impl From<&RunspacePoolStateValue> for RunspacePoolState { fn from(value: &RunspacePoolStateValue) -> Self { match value { - RunspacePoolStateValue::BeforeOpen => RunspacePoolState::BeforeOpen, - RunspacePoolStateValue::Opening => RunspacePoolState::Opening, - RunspacePoolStateValue::Opened => RunspacePoolState::Opened, - RunspacePoolStateValue::Closed => RunspacePoolState::Closed, - RunspacePoolStateValue::Closing => RunspacePoolState::Closing, - RunspacePoolStateValue::Broken => RunspacePoolState::Broken, - RunspacePoolStateValue::NegotiationSent => RunspacePoolState::NegotiationSent, - RunspacePoolStateValue::NegotiationSucceeded => RunspacePoolState::NegotiationSucceeded, - RunspacePoolStateValue::Connecting => RunspacePoolState::Connecting, - RunspacePoolStateValue::Disconnected => RunspacePoolState::Disconnected, + RunspacePoolStateValue::BeforeOpen => Self::BeforeOpen, + RunspacePoolStateValue::Opening => Self::Opening, + RunspacePoolStateValue::Opened => Self::Opened, + RunspacePoolStateValue::Closed => Self::Closed, + RunspacePoolStateValue::Closing => Self::Closing, + RunspacePoolStateValue::Broken => Self::Broken, + RunspacePoolStateValue::NegotiationSent => Self::NegotiationSent, + RunspacePoolStateValue::NegotiationSucceeded => Self::NegotiationSucceeded, + RunspacePoolStateValue::Connecting => Self::Connecting, + RunspacePoolStateValue::Disconnected => Self::Disconnected, } } } diff --git a/crates/ironposh-client-core/src/runspace_pool/expect_shell_created.rs b/crates/ironposh-client-core/src/runspace_pool/expect_shell_created.rs index 2c354a7..9f6668f 100644 --- a/crates/ironposh-client-core/src/runspace_pool/expect_shell_created.rs +++ b/crates/ironposh-client-core/src/runspace_pool/expect_shell_created.rs @@ -9,10 +9,10 @@ pub struct ExpectShellCreated { } impl ExpectShellCreated { - pub fn accept(self, response: String) -> Result { - let ExpectShellCreated { mut runspace_pool } = self; + pub fn accept(self, response: &str) -> Result { + let Self { mut runspace_pool } = self; - let parsed = ironposh_xml::parser::parse(response.as_str())?; + let parsed = ironposh_xml::parser::parse(response)?; let soap_response = SoapEnvelope::from_node(parsed.root_element()) .map_err(crate::PwshCoreError::XmlParsingError)?; diff --git a/crates/ironposh-client-core/src/runspace_pool/pool.rs b/crates/ironposh-client-core/src/runspace_pool/pool.rs index 7232322..f3a46ee 100644 --- a/crates/ironposh-client-core/src/runspace_pool/pool.rs +++ b/crates/ironposh-client-core/src/runspace_pool/pool.rs @@ -54,7 +54,7 @@ impl DesiredStream { } pub(crate) fn runspace_pool_streams() -> Vec { - vec![DesiredStream { + vec![Self { name: "stdout".to_string(), command_id: None, }] @@ -62,11 +62,11 @@ impl DesiredStream { pub(crate) fn pipeline_streams(command_id: Uuid) -> Vec { vec![ - DesiredStream { + Self { name: "stdout".to_string(), command_id: Some(command_id), }, - DesiredStream { + Self { name: "stderr".to_string(), command_id: Some(command_id), }, @@ -74,13 +74,14 @@ impl DesiredStream { } pub(crate) fn stdout_for_command(command_id: Uuid) -> Self { - DesiredStream { + Self { name: "stdout".to_string(), command_id: Some(command_id), } } } +#[expect(clippy::large_enum_variant)] #[derive(Debug)] pub enum AcceptResponsResult { ReceiveResponse { @@ -99,6 +100,7 @@ pub enum AcceptResponsResult { }, } +#[expect(clippy::large_enum_variant)] #[derive(Debug)] pub enum PwshMessageResponse { HostCall(HostCall), @@ -115,9 +117,9 @@ pub enum PwshMessageResponse { impl PwshMessageResponse { pub fn name(&self) -> &str { match self { - PwshMessageResponse::HostCall(_) => "HostCall", - PwshMessageResponse::PipelineOutput { .. } => "PipelineOutput", - PwshMessageResponse::ErrorRecord { .. } => "ErrorRecord", + Self::HostCall(_) => "HostCall", + Self::PipelineOutput { .. } => "PipelineOutput", + Self::ErrorRecord { .. } => "ErrorRecord", } } } @@ -125,14 +127,14 @@ impl PwshMessageResponse { impl From for AcceptResponsResult { fn from(response: PwshMessageResponse) -> Self { match response { - PwshMessageResponse::HostCall(host_call) => AcceptResponsResult::HostCall(host_call), + PwshMessageResponse::HostCall(host_call) => Self::HostCall(host_call), PwshMessageResponse::PipelineOutput { output, handle } => { - AcceptResponsResult::PipelineOutput { output, handle } + Self::PipelineOutput { output, handle } } PwshMessageResponse::ErrorRecord { error_record, handle, - } => AcceptResponsResult::ErrorRecord { + } => Self::ErrorRecord { error_record, handle, }, @@ -157,7 +159,7 @@ pub struct RunspacePool { pub(super) session_capability: Option, pub(super) pipelines: HashMap, pub(super) fragmenter: fragmentation::Fragmenter, - pub(super) runspace_pool_desired_stream_is_pooling: bool, + pub(super) desired_stream_is_pooling: bool, } impl RunspacePool { @@ -240,7 +242,7 @@ impl RunspacePool { // We should accept the pipeline id here, but for now let's ignore it pub(crate) fn fire_receive( - &mut self, + &self, desired_streams: Vec, ) -> Result { debug_assert!(!desired_streams.is_empty(), "At least one desired stream"); @@ -251,14 +253,15 @@ impl RunspacePool { .to_xml_string()?) } + #[expect(clippy::too_many_lines)] #[instrument(skip(self, soap_envelope), fields(envelope_length = soap_envelope.len()))] pub(crate) fn accept_response( &mut self, - soap_envelope: String, + soap_envelope: &str, ) -> Result, crate::PwshCoreError> { debug!(target: "soap", "parsing SOAP envelope"); - let parsed = ironposh_xml::parser::parse(soap_envelope.as_str()).map_err(|e| { + let parsed = ironposh_xml::parser::parse(soap_envelope).map_err(|e| { error!(target: "xml", error = %e, xml = soap_envelope, "failed to parse XML"); e })?; @@ -273,9 +276,7 @@ impl RunspacePool { if soap_envelope.body.as_ref().receive_response.is_some() { debug!(target: "receive", "processing receive response"); - let (streams, command_state) = self - .shell - .accept_receive_response(&soap_envelope) + let (streams, command_state) = WinRunspace::accept_receive_response(&soap_envelope) .map_err(|e| { error!(target: "receive", error = %e, "failed to accept receive response"); e @@ -283,7 +284,7 @@ impl RunspacePool { let streams_ids = streams .iter() - .filter_map(|stream| stream.command_id().cloned()) + .filter_map(|stream| stream.command_id().copied()) .collect::>(); let is_there_a_stream_has_no_command_id = @@ -294,7 +295,7 @@ impl RunspacePool { target: "receive", "stream without command_id found, should be runspace pool stream" ); - self.runspace_pool_desired_stream_is_pooling = false + self.desired_stream_is_pooling = false; } debug!( @@ -311,12 +312,12 @@ impl RunspacePool { debug!( target: "pwsh", - response_names = ?handle_pwsh_response.iter().map(|r| r.name()).collect::>(), + response_names = ?handle_pwsh_response.iter().map(PwshMessageResponse::name).collect::>(), response_count = handle_pwsh_response.len(), "handled PowerShell responses" ); - result.extend(handle_pwsh_response.into_iter().map(|resp| resp.into())); + result.extend(handle_pwsh_response.into_iter().map(Into::into)); if let Some(command_state) = command_state && command_state.is_done() @@ -352,10 +353,10 @@ impl RunspacePool { stream_set .into_iter() - .map(|stream| DesiredStream::new("stdout", stream.to_owned().into())) + .map(|stream| DesiredStream::new("stdout", stream.into())) .collect::>() - } else if !self.runspace_pool_desired_stream_is_pooling { - self.runspace_pool_desired_stream_is_pooling = true; + } else if !self.desired_stream_is_pooling { + self.desired_stream_is_pooling = true; DesiredStream::runspace_pool_streams() } else { vec![] @@ -371,9 +372,11 @@ impl RunspacePool { self.pipelines .get_mut(&pipeline_id) - .ok_or(crate::PwshCoreError::InvalidResponse( - "Pipeline not found for command response".into(), - ))? + .ok_or_else(|| { + crate::PwshCoreError::InvalidResponse( + "Pipeline not found for command response".into(), + ) + })? .state = PsInvocationState::Running; result.push(AcceptResponsResult::ReceiveResponse { @@ -431,6 +434,7 @@ impl RunspacePool { } /// Fire create pipeline for a specific pipeline handle (used by service API) + #[expect(clippy::too_many_lines)] #[instrument(skip(self, responses))] fn handle_pwsh_responses( &mut self, @@ -583,11 +587,11 @@ impl RunspacePool { result.push(PwshMessageResponse::PipelineOutput { output, handle: PipelineHandle { - id: *stream.command_id().ok_or( + id: *stream.command_id().ok_or_else(|| { crate::PwshCoreError::InvalidResponse( "PipelineOutput message must have a command_id".into(), - ), - )?, + ) + })?, }, }); } @@ -614,11 +618,11 @@ impl RunspacePool { result.push(PwshMessageResponse::ErrorRecord { error_record, handle: PipelineHandle { - id: *stream.command_id().ok_or( + id: *stream.command_id().ok_or_else(|| { crate::PwshCoreError::InvalidResponse( "ErrorRecord message must have a command_id".into(), - ), - )?, + ) + })?, }, }); } @@ -736,12 +740,9 @@ impl RunspacePool { ); // Find the pipeline by command_id - let pipeline = self - .pipelines - .get_mut(command_id) - .ok_or(PwshCoreError::InvalidResponse( - "Pipeline not found for command_id".into(), - ))?; + let pipeline = self.pipelines.get_mut(command_id).ok_or_else(|| { + PwshCoreError::InvalidResponse("Pipeline not found for command_id".into()) + })?; pipeline.add_progress_record(progress_record); @@ -777,12 +778,9 @@ impl RunspacePool { }; // Find the pipeline by command_id - let pipeline = self - .pipelines - .get_mut(command_id) - .ok_or(PwshCoreError::InvalidResponse( - "Pipeline not found for command_id".into(), - ))?; + let pipeline = self.pipelines.get_mut(command_id).ok_or_else(|| { + PwshCoreError::InvalidResponse("Pipeline not found for command_id".into()) + })?; pipeline.add_information_record(info_record); @@ -817,12 +815,9 @@ impl RunspacePool { }; // Find the pipeline by command_id - let pipeline = self - .pipelines - .get_mut(command_id) - .ok_or(PwshCoreError::InvalidResponse( - "Pipeline not found for command_id".into(), - ))?; + let pipeline = self.pipelines.get_mut(command_id).ok_or_else(|| { + PwshCoreError::InvalidResponse("Pipeline not found for command_id".into()) + })?; // Update the pipeline state pipeline.state = PsInvocationState::from(pipeline_state.pipeline_state); @@ -832,7 +827,7 @@ impl RunspacePool { #[instrument(skip_all)] pub fn invoke_pipeline_request( &mut self, - handle: PipelineHandle, + handle: &PipelineHandle, ) -> Result { let pipeline = self .pipelines @@ -844,7 +839,7 @@ impl RunspacePool { info!(pipeline_id = %handle.id(), "Invoking pipeline"); // Convert business pipeline to protocol pipeline and build CreatePipeline message - let protocol_pipeline = pipeline.to_protocol_pipeline()?; + let protocol_pipeline = pipeline.to_protocol_pipeline(); let create_pipeline = CreatePipeline::builder() .pipeline(protocol_pipeline) .host_info(self.host_info.clone()) @@ -868,12 +863,12 @@ impl RunspacePool { arguments, None, None, - )?; + ); Ok(request.into().to_xml_string()?) } - pub fn kill_pipeline(&mut self, handle: PipelineHandle) -> Result { + pub fn kill_pipeline(&mut self, handle: &PipelineHandle) -> Result { let pipeline = self .pipelines .get_mut(&handle.id()) @@ -949,12 +944,12 @@ impl RunspacePool { pub fn send_pipeline_host_response( &mut self, command_id: uuid::Uuid, - host_response: ironposh_psrp::PipelineHostResponse, + host_response: &ironposh_psrp::PipelineHostResponse, ) -> Result { // Fragment the host response message let fragmented = self.fragmenter - .fragment(&host_response, self.id, Some(command_id), None)?; + .fragment(host_response, self.id, Some(command_id), None)?; // Encode fragments as base64 let arguments = fragmented @@ -965,7 +960,7 @@ impl RunspacePool { // Create WS-Man Send request (send data to stdin) let request = self.shell - .send_data_request(&self.connection, Some(command_id), arguments)?; + .send_data_request(&self.connection, Some(command_id), &arguments)?; Ok(request.into().to_xml_string()?) } @@ -973,11 +968,11 @@ impl RunspacePool { /// Send a runspace pool host response to the server pub fn send_runspace_pool_host_response( &mut self, - host_response: ironposh_psrp::RunspacePoolHostResponse, + host_response: &ironposh_psrp::RunspacePoolHostResponse, ) -> Result { // Fragment the host response message let fragmented = self.fragmenter.fragment( - &host_response, + host_response, self.id, None, // No command ID for runspace pool messages None, @@ -993,7 +988,7 @@ impl RunspacePool { let request = self.shell.send_data_request( &self.connection, None, // No command ID for runspace pool - arguments, + &arguments, )?; Ok(request.into().to_xml_string()?) @@ -1043,6 +1038,6 @@ impl RunspacePool { } // 3) Invoke the pipeline using existing logic - self.invoke_pipeline_request(handle) + self.invoke_pipeline_request(&handle) } } diff --git a/crates/ironposh-client-core/src/runspace_pool/types.rs b/crates/ironposh-client-core/src/runspace_pool/types.rs index d9721a9..ff4b570 100644 --- a/crates/ironposh-client-core/src/runspace_pool/types.rs +++ b/crates/ironposh-client-core/src/runspace_pool/types.rs @@ -10,7 +10,7 @@ pub struct PipelineRepresentation { impl PipelineRepresentation { pub fn new(id: uuid::Uuid) -> Self { - PipelineRepresentation { + Self { id, state: PsInvocationState::NotStarted, } diff --git a/crates/ironposh-client-sync/Cargo.toml b/crates/ironposh-client-sync/Cargo.toml index e69d92f..b62e00f 100644 --- a/crates/ironposh-client-sync/Cargo.toml +++ b/crates/ironposh-client-sync/Cargo.toml @@ -25,3 +25,6 @@ tracing-log = "0.2" byteorder = "1.5.0" whoami = "1.6.1" crossterm = "0.29.0" + +[lints] +workspace = true diff --git a/crates/ironposh-client-sync/src/config.rs b/crates/ironposh-client-sync/src/config.rs index d2cb390..8ad60d8 100644 --- a/crates/ironposh-client-sync/src/config.rs +++ b/crates/ironposh-client-sync/src/config.rs @@ -99,10 +99,10 @@ pub enum AuthMethod { impl std::fmt::Display for AuthMethod { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - AuthMethod::Basic => write!(f, "basic"), - AuthMethod::Ntlm => write!(f, "ntlm"), - AuthMethod::Kerberos => write!(f, "kerberos"), - AuthMethod::Negotiate => write!(f, "negotiate"), + Self::Basic => write!(f, "basic"), + Self::Ntlm => write!(f, "ntlm"), + Self::Kerberos => write!(f, "kerberos"), + Self::Negotiate => write!(f, "negotiate"), } } } @@ -154,6 +154,7 @@ pub fn init_logging(verbose_level: u8) -> anyhow::Result<()> { } /// Create connector configuration from command line arguments +#[expect(clippy::too_many_lines)] pub fn create_connector_config( args: &Args, cols: u16, @@ -197,7 +198,7 @@ pub fn create_connector_config( ironposh_client_core::credentials::ClientUserName::new(&args.username, domain)?; let identity = ironposh_client_core::credentials::ClientAuthIdentity::new( - client_username.clone(), + client_username, args.password.clone(), ); diff --git a/crates/ironposh-client-sync/src/connection.rs b/crates/ironposh-client-sync/src/connection.rs index 770207d..08763c8 100644 --- a/crates/ironposh-client-sync/src/connection.rs +++ b/crates/ironposh-client-sync/src/connection.rs @@ -13,7 +13,7 @@ pub struct RemotePowershell { impl RemotePowershell { /// Establish connection to the PowerShell remote server - pub fn open(config: WinRmConfig, client: &mut dyn HttpClient) -> Result { + pub fn open(config: WinRmConfig, client: &dyn HttpClient) -> Result { let mut connector = Connector::new(config); let mut response = None; diff --git a/crates/ironposh-client-sync/src/http_client.rs b/crates/ironposh-client-sync/src/http_client.rs index 120e71e..051fffe 100644 --- a/crates/ironposh-client-sync/src/http_client.rs +++ b/crates/ironposh-client-sync/src/http_client.rs @@ -260,7 +260,7 @@ impl HttpClient for UreqHttpClient { }; // 2) Process initialized context → either Continue (send another token) or Done - match auth_sequence.process_sec_ctx_init(init)? { + match auth_sequence.process_sec_ctx_init(&init)? { SecContextInited::Continue { request, sequence } => { info!("continuing authentication sequence"); // send challenge-response step on the same conn_id diff --git a/crates/ironposh-client-sync/src/main.rs b/crates/ironposh-client-sync/src/main.rs index 1943de2..3b35e70 100644 --- a/crates/ironposh-client-sync/src/main.rs +++ b/crates/ironposh-client-sync/src/main.rs @@ -32,8 +32,8 @@ fn establish_connection( TrySend, UreqHttpClient, )> { - let mut client = UreqHttpClient::new(); - let remote_ps = RemotePowershell::open(config, &mut client)?; + let client = UreqHttpClient::new(); + let remote_ps = RemotePowershell::open(config, &client)?; let (active_session, next_request) = remote_ps.into_components(); Ok((active_session, next_request, client)) } @@ -92,14 +92,13 @@ fn run_app(args: &Args) -> anyhow::Result<()> { let (ui_tx, ui_rx) = mpsc::channel::(); // Spawn network handler - let mut network_handler = - NetworkHandler::new(network_request_rx, network_response_tx, http_client); + let network_handler = NetworkHandler::new(network_request_rx, network_response_tx, http_client); let network_handle = thread::spawn(move || { network_handler.run(); }); // Spawn user input/UI handler (now takes unified_rx) - let mut user_input_handler = UIHanlder::new(user_request_tx.clone(), ui_rx); + let user_input_handler = UIHanlder::new(user_request_tx, ui_rx); let user_handle = thread::spawn(move || { let _ = user_input_handler .run(terminal) @@ -114,10 +113,10 @@ fn run_app(args: &Args) -> anyhow::Result<()> { // Run the main event loop run_event_loop( active_session, - network_response_rx, - user_request_rx, - network_request_tx, - ui_tx, + &network_response_rx, + &user_request_rx, + &network_request_tx, + &ui_tx, ) .inspect_err(|e| error!("Error in main event loop: {}", e))?; @@ -128,17 +127,18 @@ fn run_app(args: &Args) -> anyhow::Result<()> { } /// Main event loop that processes network responses and user requests +#[expect(clippy::too_many_lines)] #[instrument(level = "info", skip_all)] fn run_event_loop( mut active_session: ironposh_client_core::connector::active_session::ActiveSession, - network_response_rx: mpsc::Receiver, - user_request_rx: mpsc::Receiver, - network_request_tx: mpsc::Sender, - ui_tx: mpsc::Sender, + network_response_rx: &mpsc::Receiver, + user_request_rx: &mpsc::Receiver, + network_request_tx: &mpsc::Sender, + ui_tx: &mpsc::Sender, ) -> anyhow::Result<()> { 'main: loop { // Use select! equivalent for synchronous channels - let next_step = select_sync(&network_response_rx, &user_request_rx)?; + let next_step = select_sync(network_response_rx, user_request_rx)?; info!(next_step = %next_step, "processing step"); @@ -262,7 +262,7 @@ fn run_event_loop( result_transport.accept_result(()) } HostCall::WriteProgress { transport } => { - let (params, result_transport) = transport.into_parts(); + let (_params, result_transport) = transport.into_parts(); result_transport.accept_result(()) } @@ -308,7 +308,6 @@ fn select_sync( Err(TryRecvError::Empty) => { // Both channels empty, wait a bit and try again thread::sleep(std::time::Duration::from_millis(10)); - continue; } Err(TryRecvError::Disconnected) => { return Err(anyhow::anyhow!("User request channel disconnected")); diff --git a/crates/ironposh-client-sync/src/network.rs b/crates/ironposh-client-sync/src/network.rs index 7f62b42..dbd9fe9 100644 --- a/crates/ironposh-client-sync/src/network.rs +++ b/crates/ironposh-client-sync/src/network.rs @@ -35,7 +35,7 @@ impl NetworkHandler { skip(self), fields(processed_requests = 0u64, active_requests = 0u64) )] - pub fn run(&mut self) { + pub fn run(&self) { info!("network handler started, waiting for requests"); let mut active_request_count = 0u64; @@ -63,9 +63,9 @@ impl NetworkHandler { thread::spawn(move || { Self::handle_request_in_thread( request, - http_client, - response_tx, - request_type_for_thread, + &http_client, + &response_tx, + &request_type_for_thread, ); }); @@ -89,9 +89,9 @@ impl NetworkHandler { )] fn handle_request_in_thread( request: TrySend, - http_client: Arc, - response_tx: mpsc::Sender, - request_type: String, + http_client: &Arc, + response_tx: &mpsc::Sender, + request_type: &str, ) { info!("worker thread started for request"); diff --git a/crates/ironposh-client-sync/src/types.rs b/crates/ironposh-client-sync/src/types.rs index 50dce4e..1d0de26 100644 --- a/crates/ironposh-client-sync/src/types.rs +++ b/crates/ironposh-client-sync/src/types.rs @@ -5,6 +5,7 @@ use ironposh_client_core::connector::UserOperation; use ironposh_terminal::TerminalOp; /// Represents the next step in the event loop +#[expect(clippy::large_enum_variant)] #[derive(Debug)] pub enum NextStep { NetworkResponse(HttpResponseTargeted), @@ -14,8 +15,8 @@ pub enum NextStep { impl fmt::Display for NextStep { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - NextStep::NetworkResponse(_) => write!(f, "NetworkResponse"), - NextStep::UserRequest(_) => write!(f, "UserRequest"), + Self::NetworkResponse(_) => write!(f, "NetworkResponse"), + Self::UserRequest(_) => write!(f, "UserRequest"), } } } @@ -24,9 +25,11 @@ impl fmt::Display for NextStep { #[derive(Debug)] pub enum UiOp { Apply(Vec), // render ops (cursor move, clear, fill, bytes…) - Print(String), // for plain text lines if you want + #[expect(dead_code)] + Print(String), // for plain text lines if you want } /// Unified input event for the main loop - combines UI operations and user events +#[expect(clippy::large_enum_variant)] #[derive(Debug)] pub enum UIInputEvent { /// UI operation (rendering, printing) diff --git a/crates/ironposh-client-sync/src/ui_handler.rs b/crates/ironposh-client-sync/src/ui_handler.rs index 0bf0257..0e75ed9 100644 --- a/crates/ironposh-client-sync/src/ui_handler.rs +++ b/crates/ironposh-client-sync/src/ui_handler.rs @@ -27,7 +27,8 @@ impl UIHanlder { } } - pub fn run(&mut self, mut terminal: Terminal) -> anyhow::Result<()> { + #[expect(clippy::too_many_lines)] + pub fn run(&self, mut terminal: Terminal) -> anyhow::Result<()> { let mut io = terminal.stdio(); // stdio-like wrapper let mut current_pipeline: Option = None; @@ -77,7 +78,7 @@ impl UIHanlder { 'receive: while let Ok(event) = self.unified_rx.recv() { debug!("Received UI event"); let read_outcome = io.try_read_line()?; - if let Some(ReadOutcome::Interrupt) = read_outcome { + if matches!(read_outcome, Some(ReadOutcome::Interrupt)) { debug!("Interrupt detected during event processing"); let Some(pipeline) = current_pipeline.take() else { debug!("No active pipeline to interrupt, continuing"); @@ -105,13 +106,11 @@ impl UIHanlder { } UiOp::Print(s) => { debug!(text = %s, "Printing text to terminal"); - use std::io::Write; writeln!(io, "{s}")?; } } io.render()?; debug!("UI operation processed and rendered"); - continue 'receive; } UIInputEvent::UserEvent(user_event) => { debug!("Processing user event"); @@ -119,7 +118,6 @@ impl UIHanlder { active_session::UserEvent::PipelineCreated { pipeline } => { info!(pipeline_id = %pipeline.id(), "Pipeline created, setting as current"); current_pipeline = Some(pipeline); - continue 'receive; } active_session::UserEvent::PipelineFinished { pipeline: _ } => { info!("Pipeline finished, clearing current pipeline"); @@ -144,9 +142,8 @@ impl UIHanlder { debug!(error = %e, "Failed to format pipeline output"); let _ = writeln!(io, "Error formatting output: {e}"); } - }; + } let _ = io.render(); // best-effort - continue 'receive; } active_session::UserEvent::ErrorRecord { error_record, @@ -155,7 +152,6 @@ impl UIHanlder { info!(pipeline_id = %handle.id(), error_record = ?error_record, "Received ErrorRecord from pipeline"); let _ = writeln!(io, "{}", error_record.render_concise()); let _ = io.render(); // best-effort - continue 'receive; } } } diff --git a/crates/ironposh-client-tokio/Cargo.toml b/crates/ironposh-client-tokio/Cargo.toml index 68ca907..2c8bf21 100644 --- a/crates/ironposh-client-tokio/Cargo.toml +++ b/crates/ironposh-client-tokio/Cargo.toml @@ -18,3 +18,6 @@ uuid = { version = "1.18.0", features = ["v4"] } futures = "0.3" crossbeam-channel = "0.5" whoami = "1.5" + +[lints] +workspace = true \ No newline at end of file diff --git a/crates/ironposh-client-tokio/src/config.rs b/crates/ironposh-client-tokio/src/config.rs index 5f7e8a6..31ea0bb 100644 --- a/crates/ironposh-client-tokio/src/config.rs +++ b/crates/ironposh-client-tokio/src/config.rs @@ -84,10 +84,10 @@ pub enum AuthMethod { impl std::fmt::Display for AuthMethod { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - AuthMethod::Basic => write!(f, "basic"), - AuthMethod::Ntlm => write!(f, "ntlm"), - AuthMethod::Kerberos => write!(f, "kerberos"), - AuthMethod::Negotiate => write!(f, "negotiate"), + Self::Basic => write!(f, "basic"), + Self::Ntlm => write!(f, "ntlm"), + Self::Kerberos => write!(f, "kerberos"), + Self::Negotiate => write!(f, "negotiate"), } } } diff --git a/crates/ironposh-client-tokio/src/hostcall.rs b/crates/ironposh-client-tokio/src/hostcall.rs index f800fb6..cd3bfdf 100644 --- a/crates/ironposh-client-tokio/src/hostcall.rs +++ b/crates/ironposh-client-tokio/src/hostcall.rs @@ -74,19 +74,19 @@ async fn process_host_call( // For Get methods, try to return a default string match host_call { HostCall::GetVersion { transport } => { - let (_, rt) = transport.into_parts(); + let ((), rt) = transport.into_parts(); rt.accept_result("1.0".to_string()) } HostCall::GetInstanceId { transport } => { - let (_, rt) = transport.into_parts(); + let ((), rt) = transport.into_parts(); rt.accept_result(uuid::Uuid::new_v4()) } HostCall::GetCurrentCulture { transport } => { - let (_, rt) = transport.into_parts(); + let ((), rt) = transport.into_parts(); rt.accept_result("en-US".to_string()) } HostCall::GetCurrentUICulture { transport } => { - let (_, rt) = transport.into_parts(); + let ((), rt) = transport.into_parts(); rt.accept_result("en-US".to_string()) } _ => { @@ -122,14 +122,11 @@ pub async fn handle_host_calls( match process_host_call(host_call, &ui_tx).await { Ok(submission) => { // Submit the response back - if let Err(e) = submitter - .submit(HostResponse { - call_id, - scope, - submission, - }) - .await - { + if let Err(e) = submitter.submit(HostResponse { + call_id, + scope, + submission, + }) { error!(error = %e, "failed to submit host call response"); break; } diff --git a/crates/ironposh-client-tokio/src/http_client.rs b/crates/ironposh-client-tokio/src/http_client.rs index 02a4671..5f12a6b 100644 --- a/crates/ironposh-client-tokio/src/http_client.rs +++ b/crates/ironposh-client-tokio/src/http_client.rs @@ -35,7 +35,7 @@ impl ReqwestHttpClient { method = ?request.method, url = %request.url, headers_count = request.headers.len(), - body_length = request.body.as_ref().map(|b| b.len()).unwrap_or(0), + body_length = request.body.as_ref().map_or(0, HttpBody::len), "Starting HTTP request" ); @@ -125,7 +125,7 @@ impl HttpClient for ReqwestHttpClient { }; // 2) Process initialized context → either Continue (send another token) or Done - match auth_sequence.process_sec_ctx_init(init)? { + match auth_sequence.process_sec_ctx_init(&init)? { SecContextInited::Continue { request, sequence } => { info!("continuing authentication sequence"); let HttpRequestAction { diff --git a/crates/ironposh-client-tokio/src/main.rs b/crates/ironposh-client-tokio/src/main.rs index 0419f97..91d2fac 100644 --- a/crates/ironposh-client-tokio/src/main.rs +++ b/crates/ironposh-client-tokio/src/main.rs @@ -66,6 +66,7 @@ async fn main() -> anyhow::Result<()> { // Execute command let mut stream = client.send_script(command).await?; + #[expect(clippy::never_loop)] while let Some(event) = stream.next().await { unimplemented!("{event:?}"); } diff --git a/crates/ironposh-macros/Cargo.toml b/crates/ironposh-macros/Cargo.toml index 88439bd..6ae3b1d 100644 --- a/crates/ironposh-macros/Cargo.toml +++ b/crates/ironposh-macros/Cargo.toml @@ -10,3 +10,6 @@ proc-macro = true proc-macro2 = "1.0" quote = "1.0" syn = { version = "2.0", features = ["full", "extra-traits"] } + +[lints] +workspace = true \ No newline at end of file diff --git a/crates/ironposh-macros/src/lib.rs b/crates/ironposh-macros/src/lib.rs index a3746ae..bd6e691 100644 --- a/crates/ironposh-macros/src/lib.rs +++ b/crates/ironposh-macros/src/lib.rs @@ -195,16 +195,14 @@ fn generate_simple_xml_visitor_impl( let match_arms: Vec = field_entries .iter() .filter_map(|entry| { - if let Some(tag_name_type) = &entry.tag_name_type { - let field_name = &entry.field_name; - Some(quote! { - crate::cores::#tag_name_type::TAG_NAME => { - self.#field_name = Some(ironposh_xml::parser::XmlDeserialize::from_node(child)?); - } - }) - } else { - None + entry.tag_name_type.as_ref().map(|tag_name_type| { + let field_name = &entry.field_name; + quote! { + crate::cores::#tag_name_type::TAG_NAME => { + self.#field_name = Some(ironposh_xml::parser::XmlDeserialize::from_node(child)?); } + } + }) }) .collect(); diff --git a/crates/ironposh-psrp/Cargo.toml b/crates/ironposh-psrp/Cargo.toml index db11aad..d1fdd10 100644 --- a/crates/ironposh-psrp/Cargo.toml +++ b/crates/ironposh-psrp/Cargo.toml @@ -29,3 +29,6 @@ crossterm = { version = "0.28.1", optional = true } [dev-dependencies] tracing-test = { version = "0.2.4", features = ["no-env-filter"] } tracing-subscriber = { version = "0.3.17", features = ["fmt", "env-filter"] } + +[lints] +workspace = true \ No newline at end of file diff --git a/crates/ironposh-psrp/src/cores.rs b/crates/ironposh-psrp/src/cores.rs index 3446f74..979a11b 100644 --- a/crates/ironposh-psrp/src/cores.rs +++ b/crates/ironposh-psrp/src/cores.rs @@ -17,8 +17,8 @@ impl TryFrom for Destination { fn try_from(value: u32) -> Result { match value { - 0x0000_0001 => Ok(Destination::Client), - 0x0000_0002 => Ok(Destination::Server), + 0x0000_0001 => Ok(Self::Client), + 0x0000_0002 => Ok(Self::Server), _ => Err(crate::PowerShellRemotingError::InvalidMessage(format!( "Unknown Destination value: 0x{value:08x}" ))), @@ -26,7 +26,7 @@ impl TryFrom for Destination { } } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum MessageType { SessionCapability, InitRunspacepool, @@ -64,37 +64,37 @@ pub enum MessageType { impl MessageType { pub fn value(&self) -> u32 { match self { - MessageType::SessionCapability => 0x00010002, - MessageType::InitRunspacepool => 0x00010004, - MessageType::PublicKey => 0x00010005, - MessageType::EncryptedSessionKey => 0x00010006, - MessageType::PublicKeyRequest => 0x00010007, - MessageType::ConnectRunspacepool => 0x00010008, - MessageType::RunspacepoolInitData => 0x0002100B, - MessageType::ResetRunspaceState => 0x0002100C, - MessageType::SetMaxRunspaces => 0x00021002, - MessageType::SetMinRunspaces => 0x00021003, - MessageType::RunspaceAvailability => 0x00021004, - MessageType::RunspacepoolState => 0x00021005, - MessageType::CreatePipeline => 0x00021006, - MessageType::GetAvailableRunspaces => 0x00021007, - MessageType::UserEvent => 0x00021008, - MessageType::ApplicationPrivateData => 0x00021009, - MessageType::GetCommandMetadata => 0x0002100A, - MessageType::RunspacepoolHostCall => 0x00021100, - MessageType::RunspacepoolHostResponse => 0x00021101, - MessageType::PipelineInput => 0x00041002, - MessageType::EndOfPipelineInput => 0x00041003, - MessageType::PipelineOutput => 0x00041004, - MessageType::ErrorRecord => 0x00041005, - MessageType::PipelineState => 0x00041006, - MessageType::DebugRecord => 0x00041007, - MessageType::VerboseRecord => 0x00041008, - MessageType::WarningRecord => 0x00041009, - MessageType::ProgressRecord => 0x00041010, - MessageType::InformationRecord => 0x00041011, - MessageType::PipelineHostCall => 0x00041100, - MessageType::PipelineHostResponse => 0x00041101, + Self::SessionCapability => 0x00010002, + Self::InitRunspacepool => 0x00010004, + Self::PublicKey => 0x00010005, + Self::EncryptedSessionKey => 0x00010006, + Self::PublicKeyRequest => 0x00010007, + Self::ConnectRunspacepool => 0x00010008, + Self::RunspacepoolInitData => 0x0002100B, + Self::ResetRunspaceState => 0x0002100C, + Self::SetMaxRunspaces => 0x00021002, + Self::SetMinRunspaces => 0x00021003, + Self::RunspaceAvailability => 0x00021004, + Self::RunspacepoolState => 0x00021005, + Self::CreatePipeline => 0x00021006, + Self::GetAvailableRunspaces => 0x00021007, + Self::UserEvent => 0x00021008, + Self::ApplicationPrivateData => 0x00021009, + Self::GetCommandMetadata => 0x0002100A, + Self::RunspacepoolHostCall => 0x00021100, + Self::RunspacepoolHostResponse => 0x00021101, + Self::PipelineInput => 0x00041002, + Self::EndOfPipelineInput => 0x00041003, + Self::PipelineOutput => 0x00041004, + Self::ErrorRecord => 0x00041005, + Self::PipelineState => 0x00041006, + Self::DebugRecord => 0x00041007, + Self::VerboseRecord => 0x00041008, + Self::WarningRecord => 0x00041009, + Self::ProgressRecord => 0x00041010, + Self::InformationRecord => 0x00041011, + Self::PipelineHostCall => 0x00041100, + Self::PipelineHostResponse => 0x00041101, } } } @@ -104,37 +104,37 @@ impl TryFrom for MessageType { fn try_from(value: u32) -> Result { match value { - 0x00010002 => Ok(MessageType::SessionCapability), - 0x00010004 => Ok(MessageType::InitRunspacepool), - 0x00010005 => Ok(MessageType::PublicKey), - 0x00010006 => Ok(MessageType::EncryptedSessionKey), - 0x00010007 => Ok(MessageType::PublicKeyRequest), - 0x00010008 => Ok(MessageType::ConnectRunspacepool), - 0x0002100B => Ok(MessageType::RunspacepoolInitData), - 0x0002100C => Ok(MessageType::ResetRunspaceState), - 0x00021002 => Ok(MessageType::SetMaxRunspaces), - 0x00021003 => Ok(MessageType::SetMinRunspaces), - 0x00021004 => Ok(MessageType::RunspaceAvailability), - 0x00021005 => Ok(MessageType::RunspacepoolState), - 0x00021006 => Ok(MessageType::CreatePipeline), - 0x00021007 => Ok(MessageType::GetAvailableRunspaces), - 0x00021008 => Ok(MessageType::UserEvent), - 0x00021009 => Ok(MessageType::ApplicationPrivateData), - 0x0002100A => Ok(MessageType::GetCommandMetadata), - 0x00021100 => Ok(MessageType::RunspacepoolHostCall), - 0x00021101 => Ok(MessageType::RunspacepoolHostResponse), - 0x00041002 => Ok(MessageType::PipelineInput), - 0x00041003 => Ok(MessageType::EndOfPipelineInput), - 0x00041004 => Ok(MessageType::PipelineOutput), - 0x00041005 => Ok(MessageType::ErrorRecord), - 0x00041006 => Ok(MessageType::PipelineState), - 0x00041007 => Ok(MessageType::DebugRecord), - 0x00041008 => Ok(MessageType::VerboseRecord), - 0x00041009 => Ok(MessageType::WarningRecord), - 0x00041010 => Ok(MessageType::ProgressRecord), - 0x00041011 => Ok(MessageType::InformationRecord), - 0x00041100 => Ok(MessageType::PipelineHostCall), - 0x00041101 => Ok(MessageType::PipelineHostResponse), + 0x00010002 => Ok(Self::SessionCapability), + 0x00010004 => Ok(Self::InitRunspacepool), + 0x00010005 => Ok(Self::PublicKey), + 0x00010006 => Ok(Self::EncryptedSessionKey), + 0x00010007 => Ok(Self::PublicKeyRequest), + 0x00010008 => Ok(Self::ConnectRunspacepool), + 0x0002100B => Ok(Self::RunspacepoolInitData), + 0x0002100C => Ok(Self::ResetRunspaceState), + 0x00021002 => Ok(Self::SetMaxRunspaces), + 0x00021003 => Ok(Self::SetMinRunspaces), + 0x00021004 => Ok(Self::RunspaceAvailability), + 0x00021005 => Ok(Self::RunspacepoolState), + 0x00021006 => Ok(Self::CreatePipeline), + 0x00021007 => Ok(Self::GetAvailableRunspaces), + 0x00021008 => Ok(Self::UserEvent), + 0x00021009 => Ok(Self::ApplicationPrivateData), + 0x0002100A => Ok(Self::GetCommandMetadata), + 0x00021100 => Ok(Self::RunspacepoolHostCall), + 0x00021101 => Ok(Self::RunspacepoolHostResponse), + 0x00041002 => Ok(Self::PipelineInput), + 0x00041003 => Ok(Self::EndOfPipelineInput), + 0x00041004 => Ok(Self::PipelineOutput), + 0x00041005 => Ok(Self::ErrorRecord), + 0x00041006 => Ok(Self::PipelineState), + 0x00041007 => Ok(Self::DebugRecord), + 0x00041008 => Ok(Self::VerboseRecord), + 0x00041009 => Ok(Self::WarningRecord), + 0x00041010 => Ok(Self::ProgressRecord), + 0x00041011 => Ok(Self::InformationRecord), + 0x00041100 => Ok(Self::PipelineHostCall), + 0x00041101 => Ok(Self::PipelineHostResponse), _ => Err(crate::PowerShellRemotingError::InvalidMessage(format!( "Unknown MessageType value: 0x{value:08x}" ))), @@ -203,7 +203,7 @@ impl PowerShellRemotingMessage { message: &dyn PsObjectWithType, rpid: Uuid, pid: Option, - ) -> Result { + ) -> Result { let message_type = message.message_type(); let data = message.to_ps_object(); diff --git a/crates/ironposh-psrp/src/fragmentation/defragmenter.rs b/crates/ironposh-psrp/src/fragmentation/defragmenter.rs index 234352b..26c8873 100644 --- a/crates/ironposh-psrp/src/fragmentation/defragmenter.rs +++ b/crates/ironposh-psrp/src/fragmentation/defragmenter.rs @@ -20,14 +20,11 @@ impl FragmentBuffer { } /// Add a fragment to this buffer if it's the expected next fragment - fn add_fragment(&mut self, fragment: Fragment) -> Result<(), PowerShellRemotingError> { + fn add_fragment(&mut self, fragment: Fragment) { if fragment.end { self.is_complete = true; } - self.fragments.push(fragment); - - Ok(()) } /// Reassemble all fragments into complete message data @@ -46,7 +43,7 @@ impl FragmentBuffer { /// Defragmenter handles defragmentation of incoming PowerShell remoting message fragments /// with internal state management -#[derive(Debug)] +#[derive(Debug, Default)] pub struct Defragmenter { buffers: HashMap, } @@ -54,9 +51,7 @@ pub struct Defragmenter { impl Defragmenter { /// Create a new defragmenter pub fn new() -> Self { - Self { - buffers: HashMap::new(), - } + Self::default() } /// Process incoming packet data containing one or more fragments @@ -86,7 +81,7 @@ impl Defragmenter { // Handle complete single-fragment message if fragment.start && fragment.end { - let message = self.parse_message(fragment.data)?; + let message = Self::parse_message(fragment.data)?; completed_messages.push(message); continue; } @@ -103,12 +98,12 @@ impl Defragmenter { } // Add fragment to buffer - buffer.add_fragment(fragment)?; + buffer.add_fragment(fragment); // Check if message is complete if buffer.is_complete { let complete_data = buffer.reassemble(); - let message = self.parse_message(complete_data)?; + let message = Self::parse_message(complete_data)?; completed_messages.push(message); self.buffers.remove(&object_id); } @@ -132,17 +127,8 @@ impl Defragmenter { } /// Parse a complete message from reassembled data - fn parse_message( - &self, - data: Vec, - ) -> Result { + fn parse_message(data: Vec) -> Result { let mut cursor = std::io::Cursor::new(data); PowerShellRemotingMessage::parse(&mut cursor) } } - -impl Default for Defragmenter { - fn default() -> Self { - Self::new() - } -} diff --git a/crates/ironposh-psrp/src/fragmentation/fragment.rs b/crates/ironposh-psrp/src/fragmentation/fragment.rs index c6b5c76..d722b50 100644 --- a/crates/ironposh-psrp/src/fragmentation/fragment.rs +++ b/crates/ironposh-psrp/src/fragmentation/fragment.rs @@ -109,7 +109,7 @@ impl Fragment { let fragment_data = data[21..21 + length].to_vec(); let remaining = &data[21 + length..]; - let fragment = Fragment::new(object_id, fragment_id, fragment_data, start, end); + let fragment = Self::new(object_id, fragment_id, fragment_data, start, end); Ok((fragment, remaining)) } diff --git a/crates/ironposh-psrp/src/fragmentation/fragmenter.rs b/crates/ironposh-psrp/src/fragmentation/fragmenter.rs index f5a8657..a6888c7 100644 --- a/crates/ironposh-psrp/src/fragmentation/fragmenter.rs +++ b/crates/ironposh-psrp/src/fragmentation/fragmenter.rs @@ -47,7 +47,7 @@ impl Fragmenter { let mut fragments = Vec::new(); if let Some(remaining_size) = remaining_size { - let (fragment1, remaining) = safe_split_at(remaining_bytes, remaining_size); + let (frag1, remaining) = safe_split_at(remaining_bytes, remaining_size); let end = remaining.is_empty(); remaining_bytes = remaining; @@ -55,7 +55,7 @@ impl Fragmenter { let fragment = Fragment::new( self.outgoing_counter, fragment_id, - fragment1.to_vec(), + frag1.to_vec(), start, end, ); @@ -124,7 +124,7 @@ impl Fragmenter { fragements.extend(message_fragments); - remaing_size = self.max_fragment_size - fragements.last().map_or(0, |last| last.len()); + remaing_size = self.max_fragment_size - fragements.last().map_or(0, Vec::len); if remaing_size == 0 { remaing_size = self.max_fragment_size; // Reset for next message } diff --git a/crates/ironposh-psrp/src/lib.rs b/crates/ironposh-psrp/src/lib.rs index 1097f2d..ea2bfa8 100644 --- a/crates/ironposh-psrp/src/lib.rs +++ b/crates/ironposh-psrp/src/lib.rs @@ -39,6 +39,6 @@ pub enum PowerShellRemotingError { impl From for PowerShellRemotingError { fn from(err: std::io::Error) -> Self { - PowerShellRemotingError::IoError(err.to_string()) + Self::IoError(err.to_string()) } } diff --git a/crates/ironposh-psrp/src/messages/create_pipeline/command.rs b/crates/ironposh-psrp/src/messages/create_pipeline/command.rs index b4211ad..e3b1832 100644 --- a/crates/ironposh-psrp/src/messages/create_pipeline/command.rs +++ b/crates/ironposh-psrp/src/messages/create_pipeline/command.rs @@ -33,6 +33,7 @@ pub struct Command { } impl From for ComplexObject { + #[expect(clippy::too_many_lines)] fn from(command: Command) -> Self { let mut extended_properties = BTreeMap::new(); @@ -61,7 +62,7 @@ impl From for ComplexObject { .map(|param| PsValue::Object(param.into())) .collect(); - let args_obj = ComplexObject { + let args_obj = Self { type_def: Some(PsType::array_list()), to_string: cmd_str.clone().into(), content: ComplexObjectContent::Container(Container::List(args_values)), @@ -81,12 +82,10 @@ impl From for ComplexObject { "UseLocalScope".to_string(), PsProperty { name: "UseLocalScope".to_string(), - value: match command.use_local_scope { - Some(use_local_scope) => { - PsValue::Primitive(PsPrimitiveValue::Bool(use_local_scope)) - } - None => PsValue::Primitive(PsPrimitiveValue::Nil), - }, + value: command.use_local_scope.map_or( + PsValue::Primitive(PsPrimitiveValue::Nil), + |use_local_scope| PsValue::Primitive(PsPrimitiveValue::Bool(use_local_scope)), + ), }, ); @@ -154,7 +153,7 @@ impl From for ComplexObject { }, ); - ComplexObject { + Self { type_def: None, to_string: Some(cmd_str), content: ComplexObjectContent::Standard, @@ -198,39 +197,37 @@ impl TryFrom for Command { ComplexObjectContent::Container(Container::List(list)) => { let mut command_params = Vec::new(); for item in list { - if let PsValue::Object(param_obj) = item { - match CommandParameter::try_from(param_obj.clone()) { - Ok(param) => command_params.push(param), - Err(_) => continue, - } + if let PsValue::Object(param_obj) = item + && let Ok(param) = CommandParameter::try_from(param_obj.clone()) + { + command_params.push(param); } } command_params } _ => vec![], }, - _ => vec![], + PsValue::Primitive(_) => vec![], }; - let use_local_scope = match value.extended_properties.get("UseLocalScope") { - Some(prop) => match &prop.value { - PsValue::Primitive(PsPrimitiveValue::Bool(b)) => Some(*b), - PsValue::Primitive(PsPrimitiveValue::Nil) => None, - _ => None, - }, - None => None, + let use_local_scope = if let Some(prop) = value.extended_properties.get("UseLocalScope") + && let PsValue::Primitive(PsPrimitiveValue::Bool(b)) = &prop.value + { + Some(*b) + } else { + None }; let get_merge_property = |name: &str| -> PipelineResultTypes { - match value.extended_properties.get(name) { - Some(prop) => match &prop.value { + value + .extended_properties + .get(name) + .map_or_else(PipelineResultTypes::default, |prop| match &prop.value { PsValue::Object(obj) => { PipelineResultTypes::try_from(obj.clone()).unwrap_or_default() } - _ => PipelineResultTypes::default(), - }, - None => PipelineResultTypes::default(), - } + PsValue::Primitive(_) => PipelineResultTypes::default(), + }) }; let merge_my_result = get_merge_property("MergeMyResult"); @@ -242,7 +239,7 @@ impl TryFrom for Command { let merge_verbose = get_merge_property("MergeVerbose"); let merge_warning = get_merge_property("MergeWarning"); - Ok(Command { + Ok(Self { cmd, is_script, args, diff --git a/crates/ironposh-psrp/src/messages/create_pipeline/command_parameter.rs b/crates/ironposh-psrp/src/messages/create_pipeline/command_parameter.rs index 6cc9688..7f477bf 100644 --- a/crates/ironposh-psrp/src/messages/create_pipeline/command_parameter.rs +++ b/crates/ironposh-psrp/src/messages/create_pipeline/command_parameter.rs @@ -31,10 +31,11 @@ impl From for ComplexObject { "N".to_string(), PsProperty { name: "N".to_string(), - value: match param.name { - Some(name) => PsValue::Primitive(PsPrimitiveValue::Str(name)), - None => PsValue::Primitive(PsPrimitiveValue::Nil), - }, + value: param + .name + .map_or(PsValue::Primitive(PsPrimitiveValue::Nil), |name| { + PsValue::Primitive(PsPrimitiveValue::Str(name)) + }), }, ); @@ -46,7 +47,7 @@ impl From for ComplexObject { }, ); - ComplexObject { + Self { type_def: None, to_string: None, content: ComplexObjectContent::Standard, @@ -67,14 +68,14 @@ impl TryFrom for CommandParameter { .ok_or_else(|| Self::Error::InvalidMessage(format!("Missing property: {name}"))) }; - let name = match &get_property("N")?.value { - PsValue::Primitive(PsPrimitiveValue::Str(s)) => Some(s.clone()), - PsValue::Primitive(PsPrimitiveValue::Nil) => None, - _ => None, + let name = if let PsValue::Primitive(PsPrimitiveValue::Str(s)) = &get_property("N")?.value { + Some(s.clone()) + } else { + None }; let value = get_property("V")?.value.clone(); - Ok(CommandParameter { name, value }) + Ok(Self { name, value }) } } diff --git a/crates/ironposh-psrp/src/messages/create_pipeline/mod.rs b/crates/ironposh-psrp/src/messages/create_pipeline/mod.rs index 8e7c818..af74927 100644 --- a/crates/ironposh-psrp/src/messages/create_pipeline/mod.rs +++ b/crates/ironposh-psrp/src/messages/create_pipeline/mod.rs @@ -63,7 +63,7 @@ impl From for ComplexObject { "ApartmentState".to_string(), PsProperty { name: "ApartmentState".to_string(), - value: PsValue::Object(ComplexObject::from(create_pipeline.apartment_state)), + value: PsValue::Object(Self::from(create_pipeline.apartment_state)), }, ); @@ -71,7 +71,7 @@ impl From for ComplexObject { "RemoteStreamOptions".to_string(), PsProperty { name: "RemoteStreamOptions".to_string(), - value: PsValue::Object(ComplexObject::from(create_pipeline.remote_stream_options)), + value: PsValue::Object(Self::from(create_pipeline.remote_stream_options)), }, ); @@ -87,7 +87,7 @@ impl From for ComplexObject { "HostInfo".to_string(), PsProperty { name: "HostInfo".to_string(), - value: PsValue::Object(ComplexObject::from(create_pipeline.host_info)), + value: PsValue::Object(Self::from(create_pipeline.host_info)), }, ); @@ -95,7 +95,7 @@ impl From for ComplexObject { "PowerShell".to_string(), PsProperty { name: "PowerShell".to_string(), - value: PsValue::Object(ComplexObject::from(create_pipeline.pipeline)), + value: PsValue::Object(Self::from(create_pipeline.pipeline)), }, ); @@ -107,7 +107,7 @@ impl From for ComplexObject { }, ); - ComplexObject { + Self { type_def: Some(PsType { type_names: vec![Cow::Borrowed("System.Object")], }), @@ -140,17 +140,16 @@ impl TryFrom for CreatePipeline { ComplexObjectContent::PsEnums(PsEnums { value }) => match *value { 0 => ApartmentState::STA, 1 => ApartmentState::MTA, - 2 => ApartmentState::Unknown, - _ => ApartmentState::Unknown, + _ => ApartmentState::Unknown, // 2 is also Unknown }, _ => ApartmentState::Unknown, }, - _ => ApartmentState::Unknown, + PsValue::Primitive(_) => ApartmentState::Unknown, }; let remote_stream_options = match &get_property("RemoteStreamOptions")?.value { PsValue::Object(obj) => RemoteStreamOptions::try_from(obj.clone())?, - _ => RemoteStreamOptions::None, + PsValue::Primitive(_) => RemoteStreamOptions::None, }; let add_to_history = match &get_property("AddToHistory")?.value { @@ -161,7 +160,7 @@ impl TryFrom for CreatePipeline { let host_info = match &get_property("HostInfo")?.value { PsValue::Object(obj) => HostInfo::try_from(obj.clone()) .map_err(|_| Self::Error::InvalidMessage("Failed to parse HostInfo".to_string()))?, - _ => { + PsValue::Primitive(_) => { return Err(Self::Error::InvalidMessage( "HostInfo must be an object".to_string(), )); @@ -170,7 +169,7 @@ impl TryFrom for CreatePipeline { let power_shell = match &get_property("PowerShell")?.value { PsValue::Object(obj) => PowerShellPipeline::try_from(obj.clone())?, - _ => { + PsValue::Primitive(_) => { return Err(Self::Error::InvalidMessage( "PowerShell must be an object".to_string(), )); @@ -182,7 +181,7 @@ impl TryFrom for CreatePipeline { _ => false, }; - Ok(CreatePipeline { + Ok(Self { no_input, apartment_state, remote_stream_options, diff --git a/crates/ironposh-psrp/src/messages/create_pipeline/pipeline_result_types.rs b/crates/ironposh-psrp/src/messages/create_pipeline/pipeline_result_types.rs index 13400cb..89629fc 100644 --- a/crates/ironposh-psrp/src/messages/create_pipeline/pipeline_result_types.rs +++ b/crates/ironposh-psrp/src/messages/create_pipeline/pipeline_result_types.rs @@ -23,15 +23,14 @@ impl PipelineResultTypes { impl From for PipelineResultTypes { fn from(value: i32) -> Self { match value { - 0x00 => PipelineResultTypes::None, - 0x01 => PipelineResultTypes::Output, - 0x02 => PipelineResultTypes::Error, - 0x04 => PipelineResultTypes::Warning, - 0x08 => PipelineResultTypes::Verbose, - 0x10 => PipelineResultTypes::Debug, - 0x20 => PipelineResultTypes::All, - 0x40 => PipelineResultTypes::Null, - _ => PipelineResultTypes::None, + 0x01 => Self::Output, + 0x02 => Self::Error, + 0x04 => Self::Warning, + 0x08 => Self::Verbose, + 0x10 => Self::Debug, + 0x20 => Self::All, + 0x40 => Self::Null, + _ => Self::None, // 0x00 is also None } } } @@ -49,7 +48,7 @@ impl From for ComplexObject { PipelineResultTypes::Null => Some("Null".to_string()), }; - ComplexObject { + Self { type_def: Some(PsType::pipeline_result_types()), to_string: to_string_value, content: ComplexObjectContent::PsEnums(PsEnums { @@ -67,7 +66,7 @@ impl TryFrom for PipelineResultTypes { fn try_from(value: ComplexObject) -> Result { match value.content { ComplexObjectContent::PsEnums(PsEnums { value: val }) => { - Ok(PipelineResultTypes::from(val)) + Ok(Self::from(val)) } _ => Err(crate::PowerShellRemotingError::InvalidMessage( "PipelineResultTypes must be an enum".to_string(), diff --git a/crates/ironposh-psrp/src/messages/create_pipeline/powershell_pipeline.rs b/crates/ironposh-psrp/src/messages/create_pipeline/powershell_pipeline.rs index df97e4f..c499656 100644 --- a/crates/ironposh-psrp/src/messages/create_pipeline/powershell_pipeline.rs +++ b/crates/ironposh-psrp/src/messages/create_pipeline/powershell_pipeline.rs @@ -32,10 +32,10 @@ impl From for ComplexObject { let cmds: Vec = pipeline .cmds .into_iter() - .map(|cmd| PsValue::Object(ComplexObject::from(cmd))) + .map(|cmd| PsValue::Object(Self::from(cmd))) .collect(); - let cmds_obj = ComplexObject { + let cmds_obj = Self { type_def: Some(PsType::array_list()), to_string: None, content: ComplexObjectContent::Container(Container::List(cmds)), @@ -73,7 +73,7 @@ impl From for ComplexObject { }, ); - ComplexObject { + Self { type_def: None, to_string: None, content: ComplexObjectContent::Standard, @@ -120,21 +120,20 @@ impl TryFrom for PowerShellPipeline { )); } }, - _ => { + PsValue::Primitive(_) => { return Err(Self::Error::InvalidMessage( "Cmds must be an object".to_string(), )); } }; - let history = match value.extended_properties.get("History") { - Some(prop) => match &prop.value { + let history = value + .extended_properties + .get("History") + .map_or_else(String::new, |prop| match &prop.value { PsValue::Primitive(PsPrimitiveValue::Str(s)) => s.clone(), - PsValue::Primitive(PsPrimitiveValue::Nil) => String::new(), _ => String::new(), - }, - None => String::new(), - }; + }); let redirect_shell_error_output_pipe = match &get_property("RedirectShellErrorOutputPipe")?.value { @@ -142,7 +141,7 @@ impl TryFrom for PowerShellPipeline { _ => false, }; - Ok(PowerShellPipeline { + Ok(Self { is_nested, cmds, history, diff --git a/crates/ironposh-psrp/src/messages/create_pipeline/remote_stream_options.rs b/crates/ironposh-psrp/src/messages/create_pipeline/remote_stream_options.rs index b12ddca..7a3964d 100644 --- a/crates/ironposh-psrp/src/messages/create_pipeline/remote_stream_options.rs +++ b/crates/ironposh-psrp/src/messages/create_pipeline/remote_stream_options.rs @@ -23,7 +23,7 @@ impl From for ComplexObject { RemoteStreamOptions::AddInvocationInfo => "AddInvocationInfo".to_string(), }; - ComplexObject { + Self { type_def: Some(type_def), to_string: Some(to_string), content: ComplexObjectContent::PsEnums(PsEnums { @@ -41,8 +41,8 @@ impl TryFrom for RemoteStreamOptions { fn try_from(value: ComplexObject) -> Result { match value.content { ComplexObjectContent::PsEnums(PsEnums { value }) => match value { - 0 => Ok(RemoteStreamOptions::None), - 1 => Ok(RemoteStreamOptions::AddInvocationInfo), + 0 => Ok(Self::None), + 1 => Ok(Self::AddInvocationInfo), _ => Err(Self::Error::InvalidMessage(format!( "Invalid RemoteStreamOptions value: {value}" ))), diff --git a/crates/ironposh-psrp/src/messages/error_record.rs b/crates/ironposh-psrp/src/messages/error_record.rs index ccf7d55..e7cfe59 100644 --- a/crates/ironposh-psrp/src/messages/error_record.rs +++ b/crates/ironposh-psrp/src/messages/error_record.rs @@ -1,9 +1,11 @@ +use std::{borrow::Cow, collections::BTreeMap, fmt::Write}; + use crate::MessageType; use crate::ps_value::{ ComplexObject, ComplexObjectContent, PsObjectWithType, PsPrimitiveValue, PsProperty, PsType, PsValue, }; -use std::{borrow::Cow, collections::BTreeMap}; + use tracing::{debug, error}; #[derive(Debug, Clone, PartialEq, Eq, typed_builder::TypedBuilder)] @@ -87,7 +89,7 @@ impl ErrorRecord { let mut out = String::new(); // 1) Primary message - push_line(&mut out, normalize(&self.message), opts.trim); + push_line(&mut out, &normalize(&self.message), opts.trim); // 2) Category line (short diagnostic summary) if opts.include_category @@ -98,14 +100,14 @@ impl ErrorRecord { .map(|s| normalize(s)) && !cat.is_empty() { - push_line(&mut out, cat, opts.trim); + push_line(&mut out, &cat, opts.trim); } // 3) Position block (from InvocationInfo if present) if opts.include_position - && let Some(pos) = extract_position_block(&self.invocation_info) + && let Some(pos) = extract_position_block(self.invocation_info.as_ref()) { - push_line(&mut out, pos, opts.trim); + push_line(&mut out, &pos, opts.trim); } out @@ -123,6 +125,7 @@ impl PsObjectWithType for ErrorRecord { } impl From for ComplexObject { + #[expect(clippy::too_many_lines)] fn from(record: ErrorRecord) -> Self { let mut extended_properties = BTreeMap::new(); @@ -272,7 +275,7 @@ impl From for ComplexObject { }, ); - ComplexObject { + Self { type_def: Some(PsType { type_names: vec![ Cow::Borrowed("System.Management.Automation.ErrorRecord"), @@ -293,7 +296,7 @@ impl TryFrom for ErrorRecord { fn try_from(value: PsValue) -> Result { match value { PsValue::Object(obj) => Self::try_from(obj), - _ => Err(Self::Error::InvalidMessage( + PsValue::Primitive(_) => Err(Self::Error::InvalidMessage( "Expected ComplexObject for ErrorRecord".to_string(), )), } @@ -303,6 +306,7 @@ impl TryFrom for ErrorRecord { impl TryFrom for ErrorRecord { type Error = crate::PowerShellRemotingError; + #[expect(clippy::too_many_lines)] fn try_from(value: ComplexObject) -> Result { // Debug logging to understand what properties are actually available debug!(?value.extended_properties, "ErrorRecord extended_properties"); @@ -334,7 +338,7 @@ impl TryFrom for ErrorRecord { _ => None, }) } - _ => None, + PsValue::Primitive(_) => None, }) }) .or_else(|| { @@ -372,18 +376,20 @@ impl TryFrom for ErrorRecord { PsValue::Primitive(PsPrimitiveValue::Str(s)) => Some(s.clone()), _ => None, }), - _ => None, + PsValue::Primitive(_) => None, }) }); let was_thrown_from_throw_statement = value .extended_properties .get("WasThrownFromThrowStatement") - .map(|prop| match &prop.value { - PsValue::Primitive(PsPrimitiveValue::Bool(b)) => *b, - _ => false, - }) - .unwrap_or(false); + .is_some_and(|prop| { + if let PsValue::Primitive(PsPrimitiveValue::Bool(b)) = prop.value { + b + } else { + false + } + }); let fully_qualified_error_id = value .extended_properties @@ -415,11 +421,13 @@ impl TryFrom for ErrorRecord { let serialize_extended_info = value .extended_properties .get("SerializeExtendedInfo") - .map(|prop| match &prop.value { - PsValue::Primitive(PsPrimitiveValue::Bool(b)) => *b, - _ => false, - }) - .unwrap_or(false); + .is_some_and(|prop| { + if let PsValue::Primitive(PsPrimitiveValue::Bool(b)) = prop.value { + b + } else { + false + } + }); // Parse error category let error_category = @@ -482,7 +490,7 @@ impl TryFrom for ErrorRecord { None }; - Ok(ErrorRecord::builder() + Ok(Self::builder() .message(message) .command_name(command_name) .was_thrown_from_throw_statement(was_thrown_from_throw_statement) @@ -503,7 +511,7 @@ fn normalize(s: &str) -> String { s.replace("_x000D__x000A_", "\r\n") } -fn push_line(buf: &mut String, s: String, trim: bool) { +fn push_line(buf: &mut String, s: &str, trim: bool) { if s.is_empty() { return; } @@ -517,7 +525,7 @@ fn push_line(buf: &mut String, s: String, trim: bool) { if !buf.is_empty() && !buf.ends_with('\n') { buf.push('\n'); } - buf.push_str(&s); + buf.push_str(s); if !s.ends_with('\n') { buf.push('\n'); } @@ -526,10 +534,9 @@ fn push_line(buf: &mut String, s: String, trim: bool) { /// Extract a ready-to-print "at path:line char:col\n+ code\n+ ~~" block /// from InvocationInfo when available. Falls back gracefully. -fn extract_position_block(invocation_info: &Option) -> Option { - let obj = match invocation_info { - Some(PsValue::Object(o)) => o, - _ => return None, +fn extract_position_block(invocation_info: Option<&PsValue>) -> Option { + let Some(PsValue::Object(obj)) = invocation_info else { + return None; }; // 1) If PowerShell already provided PositionMessage, use it. @@ -559,7 +566,8 @@ fn extract_position_block(invocation_info: &Option) -> Option { let mut block = String::new(); if !script.is_empty() || line > 0 || col > 0 { - block.push_str(&format!( + write!( + block, "at {}{}{}", if script.is_empty() { "" @@ -569,14 +577,15 @@ fn extract_position_block(invocation_info: &Option) -> Option { if line > 0 { format!(":{line}") } else { - "".into() + String::new() }, if col > 0 { format!(" char:{col}") } else { - "".into() + String::new() }, - )); + ) + .unwrap(); } if !line_text.is_empty() { @@ -617,7 +626,7 @@ fn get_str(map: &BTreeMap, key: &str) -> Option { PsValue::Primitive(PsPrimitiveValue::Char(c)) => Some(c.to_string()), // Or nest the value as an object ToString() PsValue::Object(o) => o.to_string.clone(), - _ => None, + PsValue::Primitive(_) => None, }) } diff --git a/crates/ironposh-psrp/src/messages/information_record.rs b/crates/ironposh-psrp/src/messages/information_record.rs index 475541a..034b50d 100644 --- a/crates/ironposh-psrp/src/messages/information_record.rs +++ b/crates/ironposh-psrp/src/messages/information_record.rs @@ -39,6 +39,7 @@ impl PsObjectWithType for InformationRecord { } impl From for ComplexObject { + #[expect(clippy::too_many_lines)] fn from(record: InformationRecord) -> Self { let mut extended_properties = BTreeMap::new(); @@ -81,13 +82,8 @@ impl From for ComplexObject { if let Some(tags) = record.tags && !tags.is_empty() { - let tag_values: Vec = tags - .into_iter() - .map(|tag| PsValue::Primitive(PsPrimitiveValue::Str(tag))) - .collect(); - // Create array-like structure for tags - let tags_obj = ComplexObject { + let tags_obj = Self { type_def: Some(PsType { type_names: vec![ Cow::Borrowed("System.String[]"), @@ -98,15 +94,16 @@ impl From for ComplexObject { to_string: None, content: ComplexObjectContent::Standard, adapted_properties: BTreeMap::new(), - extended_properties: tag_values + extended_properties: tags .into_iter() .enumerate() - .map(|(i, val)| { + .map(|(i, tag)| { + let value = PsValue::Primitive(PsPrimitiveValue::Str(tag)); ( i.to_string(), PsProperty { name: i.to_string(), - value: val, + value, }, ) }) @@ -172,7 +169,7 @@ impl From for ComplexObject { ); } - ComplexObject { + Self { type_def: Some(PsType { type_names: vec![ Cow::Borrowed("System.Management.Automation.InformationRecord"), @@ -191,6 +188,7 @@ impl From for ComplexObject { impl TryFrom for InformationRecord { type Error = crate::PowerShellRemotingError; + #[expect(clippy::too_many_lines)] fn try_from(value: ComplexObject) -> Result { let message_data = value .extended_properties @@ -212,11 +210,13 @@ impl TryFrom for InformationRecord { let serialize_invocation_info = value .extended_properties .get("InformationalRecord_SerializeInvocationInfo") - .map(|prop| match &prop.value { - PsValue::Primitive(PsPrimitiveValue::Bool(b)) => *b, - _ => false, - }) - .unwrap_or(false); + .is_some_and(|prop| { + if let PsValue::Primitive(PsPrimitiveValue::Bool(b)) = prop.value { + b + } else { + false + } + }); let source = value .extended_properties @@ -247,7 +247,7 @@ impl TryFrom for InformationRecord { } if tags.is_empty() { None } else { Some(tags) } } - _ => None, + PsValue::Primitive(_) => None, }); let user = value @@ -290,7 +290,7 @@ impl TryFrom for InformationRecord { _ => None, }); - Ok(InformationRecord::builder() + Ok(Self::builder() .message_data(message_data) .serialize_invocation_info(serialize_invocation_info) .source(source) diff --git a/crates/ironposh-psrp/src/messages/init_runspace_pool/apartment_state.rs b/crates/ironposh-psrp/src/messages/init_runspace_pool/apartment_state.rs index 328e62d..5614dcd 100644 --- a/crates/ironposh-psrp/src/messages/init_runspace_pool/apartment_state.rs +++ b/crates/ironposh-psrp/src/messages/init_runspace_pool/apartment_state.rs @@ -25,7 +25,7 @@ impl From for ComplexObject { ApartmentState::Unknown => "Unknown".to_string(), }; - ComplexObject { + Self { type_def: Some(type_def), to_string: Some(to_string), content: ComplexObjectContent::PsEnums(PsEnums { diff --git a/crates/ironposh-psrp/src/messages/init_runspace_pool/application_arguments.rs b/crates/ironposh-psrp/src/messages/init_runspace_pool/application_arguments.rs index 65f2e9c..c2a1cca 100644 --- a/crates/ironposh-psrp/src/messages/init_runspace_pool/application_arguments.rs +++ b/crates/ironposh-psrp/src/messages/init_runspace_pool/application_arguments.rs @@ -20,7 +20,7 @@ pub struct PSVersionTable { impl Default for PSVersionTable { fn default() -> Self { - PSVersionTable { + Self { ps_semantic_version: "7.4.11".to_string(), ps_remoting_protocol_version: "2.3".to_string(), ps_compatible_versions: vec![ @@ -71,7 +71,7 @@ impl From for ComplexObject { .map(|v| PsValue::Primitive(PsPrimitiveValue::Version(v))) .collect(); - let compatible_versions_obj = ComplexObject { + let compatible_versions_obj = Self { type_def: Some(PsType { type_names: vec![ Cow::Borrowed("System.Version[]"), @@ -134,7 +134,7 @@ impl From for ComplexObject { PsValue::Primitive(PsPrimitiveValue::Str(version_table.git_commit_id)), ); - ComplexObject { + Self { type_def: Some(PsType { type_names: vec![ Cow::Borrowed("System.Management.Automation.PSPrimitiveDictionary"), @@ -154,20 +154,18 @@ impl TryFrom for PSVersionTable { type Error = crate::PowerShellRemotingError; fn try_from(value: ComplexObject) -> Result { - let entries = match value.content { - ComplexObjectContent::Container(Container::Dictionary(dict)) => dict, - _ => { - return Err(Self::Error::InvalidMessage( - "Expected Dictionary for PSVersionTable".to_string(), - )); - } + let ComplexObjectContent::Container(Container::Dictionary(entries)) = value.content else { + return Err(Self::Error::InvalidMessage( + "Expected Dictionary for PSVersionTable".to_string(), + )); }; let get_string_value = |key: &str| -> Result { let key_value = PsValue::Primitive(PsPrimitiveValue::Str(key.to_string())); match entries.get(&key_value) { - Some(PsValue::Primitive(PsPrimitiveValue::Str(s))) => Ok(s.clone()), - Some(PsValue::Primitive(PsPrimitiveValue::Version(s))) => Ok(s.clone()), + Some(PsValue::Primitive( + PsPrimitiveValue::Str(s) | PsPrimitiveValue::Version(s), + )) => Ok(s.clone()), Some(_) => Err(Self::Error::InvalidMessage(format!( "Property '{key}' is not a String or Version" ))), @@ -197,10 +195,9 @@ impl TryFrom for PSVersionTable { let mut version_strings = Vec::new(); for version in versions { match version { - PsValue::Primitive(PsPrimitiveValue::Str(s)) => { - version_strings.push(s.clone()); - } - PsValue::Primitive(PsPrimitiveValue::Version(s)) => { + PsValue::Primitive( + PsPrimitiveValue::Str(s) | PsPrimitiveValue::Version(s), + ) => { version_strings.push(s.clone()); } _ => { @@ -232,7 +229,7 @@ impl TryFrom for PSVersionTable { } }; - Ok(PSVersionTable { + Ok(Self { ps_semantic_version, ps_remoting_protocol_version, ps_compatible_versions, @@ -248,35 +245,21 @@ impl TryFrom for PSVersionTable { } /// Represents the ApplicationArguments structure in PowerShell Remoting -#[derive(Debug, Clone, PartialEq, Eq, typed_builder::TypedBuilder)] +#[derive(Debug, Clone, Default, PartialEq, Eq, typed_builder::TypedBuilder)] pub struct ApplicationArguments { pub ps_version_table: Option, pub additional_arguments: BTreeMap, } -impl Default for ApplicationArguments { - fn default() -> Self { - ApplicationArguments { - ps_version_table: Some(PSVersionTable::default()), - additional_arguments: BTreeMap::new(), - } - } -} - impl ApplicationArguments { /// Create an empty ApplicationArguments (renders as Nil in XML) pub fn empty() -> Self { - ApplicationArguments { + Self { ps_version_table: None, additional_arguments: BTreeMap::new(), } } - /// Create ApplicationArguments with default PSVersionTable - pub fn with_default_version_table() -> Self { - ApplicationArguments::default() - } - /// Check if this ApplicationArguments is empty pub fn is_empty(&self) -> bool { self.ps_version_table.is_none() && self.additional_arguments.is_empty() @@ -300,7 +283,7 @@ impl From for ComplexObject { entries.insert(PsValue::Primitive(PsPrimitiveValue::Str(key)), value); } - ComplexObject { + Self { type_def: Some(PsType { type_names: vec![ Cow::Borrowed("System.Management.Automation.PSPrimitiveDictionary"), @@ -320,13 +303,10 @@ impl TryFrom for ApplicationArguments { type Error = crate::PowerShellRemotingError; fn try_from(value: ComplexObject) -> Result { - let entries = match value.content { - ComplexObjectContent::Container(Container::Dictionary(dict)) => dict, - _ => { - return Err(Self::Error::InvalidMessage( - "Expected Dictionary for ApplicationArguments".to_string(), - )); - } + let ComplexObjectContent::Container(Container::Dictionary(entries)) = value.content else { + return Err(Self::Error::InvalidMessage( + "Expected Dictionary for ApplicationArguments".to_string(), + )); }; let mut ps_version_table = None; @@ -339,7 +319,7 @@ impl TryFrom for ApplicationArguments { PsValue::Object(obj) => { ps_version_table = Some(PSVersionTable::try_from(obj)?); } - _ => { + PsValue::Primitive(_) => { return Err(Self::Error::InvalidMessage( "PSVersionTable is not an Object".to_string(), )); @@ -357,7 +337,7 @@ impl TryFrom for ApplicationArguments { } } - Ok(ApplicationArguments { + Ok(Self { ps_version_table, additional_arguments, }) @@ -386,14 +366,14 @@ mod tests { #[test] fn test_application_arguments_with_version_table() { - let args = ApplicationArguments::with_default_version_table(); + let args = ApplicationArguments::default(); assert!(!args.is_empty()); assert!(args.ps_version_table.is_some()); } #[test] fn test_application_arguments_serialization_deserialization() { - let original_args = ApplicationArguments::with_default_version_table(); + let original_args = ApplicationArguments::default(); let complex_object: ComplexObject = original_args.clone().into(); let deserialized_args = ApplicationArguments::try_from(complex_object).unwrap(); @@ -403,7 +383,7 @@ mod tests { #[test] fn test_application_arguments_with_additional_args() { - let mut args = ApplicationArguments::with_default_version_table(); + let mut args = ApplicationArguments::default(); args.additional_arguments.insert( "CustomKey".to_string(), PsValue::Primitive(PsPrimitiveValue::Str("CustomValue".to_string())), diff --git a/crates/ironposh-psrp/src/messages/init_runspace_pool/application_private_data.rs b/crates/ironposh-psrp/src/messages/init_runspace_pool/application_private_data.rs index 6cdb320..981368e 100644 --- a/crates/ironposh-psrp/src/messages/init_runspace_pool/application_private_data.rs +++ b/crates/ironposh-psrp/src/messages/init_runspace_pool/application_private_data.rs @@ -14,7 +14,7 @@ use std::collections::BTreeMap; /// /// The data contains an extended property named "ApplicationPrivateData" with a value that is /// either a Primitive Dictionary or a Null Value. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, Default, PartialEq, Eq)] pub struct ApplicationPrivateData { /// The application private data as a dictionary of string keys to primitive values pub data: Option>, @@ -23,13 +23,7 @@ pub struct ApplicationPrivateData { impl ApplicationPrivateData { /// Create a new ApplicationPrivateData with no data (null value) pub fn new() -> Self { - Self { data: None } - } -} - -impl Default for ApplicationPrivateData { - fn default() -> Self { - Self::new() + Self::default() } } @@ -47,24 +41,24 @@ impl From for ComplexObject { fn from(app_data: ApplicationPrivateData) -> Self { let mut extended_properties = BTreeMap::new(); - let application_private_data_value = match app_data.data { - Some(data) => { - // Convert BTreeMap to BTreeMap - let ps_dict: BTreeMap = data - .into_iter() - .map(|(k, v)| (PsValue::Primitive(PsPrimitiveValue::Str(k)), v)) - .collect(); - - PsValue::Object(ComplexObject { - type_def: Some(PsType::ps_primitive_dictionary()), - to_string: None, - content: ComplexObjectContent::Container(Container::Dictionary(ps_dict)), - adapted_properties: BTreeMap::new(), - extended_properties: BTreeMap::new(), - }) - } - None => PsValue::Primitive(PsPrimitiveValue::Nil), - }; + let application_private_data_value = + app_data + .data + .map_or(PsValue::Primitive(PsPrimitiveValue::Nil), |data| { + // Convert BTreeMap to BTreeMap + let ps_dict: BTreeMap = data + .into_iter() + .map(|(k, v)| (PsValue::Primitive(PsPrimitiveValue::Str(k)), v)) + .collect(); + + PsValue::Object(Self { + type_def: Some(PsType::ps_primitive_dictionary()), + to_string: None, + content: ComplexObjectContent::Container(Container::Dictionary(ps_dict)), + adapted_properties: BTreeMap::new(), + extended_properties: BTreeMap::new(), + }) + }); extended_properties.insert( "ApplicationPrivateData".to_string(), @@ -74,7 +68,7 @@ impl From for ComplexObject { }, ); - ComplexObject { + Self { type_def: None, to_string: None, content: ComplexObjectContent::Standard, @@ -95,7 +89,10 @@ impl TryFrom for ApplicationPrivateData { Self::Error::InvalidMessage("Missing ApplicationPrivateData property".to_string()) })?; - let data = if let PsValue::Primitive(PsPrimitiveValue::Nil) = &app_data_property.value { + let data = if matches!( + &app_data_property.value, + PsValue::Primitive(PsPrimitiveValue::Nil) + ) { None } else { let PsValue::Object(obj) = &app_data_property.value else { @@ -125,6 +122,6 @@ impl TryFrom for ApplicationPrivateData { Some(result) }; - Ok(ApplicationPrivateData { data }) + Ok(Self { data }) } } diff --git a/crates/ironposh-psrp/src/messages/init_runspace_pool/host_default_data.rs b/crates/ironposh-psrp/src/messages/init_runspace_pool/host_default_data.rs index 5fea486..2beba8b 100644 --- a/crates/ironposh-psrp/src/messages/init_runspace_pool/host_default_data.rs +++ b/crates/ironposh-psrp/src/messages/init_runspace_pool/host_default_data.rs @@ -65,7 +65,7 @@ impl From for ComplexObject { }, ); - ComplexObject { + Self { type_def: None, to_string: None, content: ComplexObjectContent::Standard, @@ -102,7 +102,7 @@ impl TryFrom<&ComplexObject> for ValueWrapper { ) })?; - Ok(ValueWrapper { type_name, value }) + Ok(Self { type_name, value }) } } @@ -131,7 +131,7 @@ impl From for ComplexObject { value: PsValue::Primitive(PsPrimitiveValue::I32(coords.y)), }, ); - ComplexObject { + Self { type_def: None, to_string: None, content: ComplexObjectContent::Standard, @@ -159,7 +159,7 @@ impl TryFrom<&ComplexObject> for Coordinates { }) }; - Ok(Coordinates { + Ok(Self { x: get_i32("x")?, y: get_i32("y")?, }) @@ -189,7 +189,7 @@ impl From for ComplexObject { value: PsValue::Primitive(PsPrimitiveValue::I32(size.height)), }, ); - ComplexObject { + Self { type_def: None, to_string: None, content: ComplexObjectContent::Standard, @@ -217,7 +217,7 @@ impl TryFrom<&ComplexObject> for Size { }) }; - Ok(Size { + Ok(Self { width: get_i32("width")?, height: get_i32("height")?, }) @@ -250,27 +250,24 @@ pub struct HostDefaultData { #[cfg(feature = "crossterm")] fn console_color_to_i32(color: Color) -> i32 { - use Color::*; match color { - Black => 0, - DarkBlue => 1, - DarkGreen => 2, - DarkCyan => 3, - DarkRed => 4, - DarkMagenta => 5, - DarkYellow => 6, - Grey => 7, - DarkGrey => 8, - Blue => 9, - Green => 10, - Cyan => 11, - Red => 12, - Magenta => 13, - Yellow => 14, - White => 15, + Color::Black => 0, + Color::DarkBlue => 1, + Color::DarkGreen => 2, + Color::DarkCyan => 3, + Color::DarkRed => 4, + Color::DarkMagenta => 5, + Color::DarkYellow => 6, // Map non-16-color values to nearest (Grey as fallback) - Rgb { .. } | AnsiValue(_) => 7, - Reset => 7, + Color::Grey | Color::Rgb { .. } | Color::AnsiValue(_) | Color::Reset => 7, + Color::DarkGrey => 8, + Color::Blue => 9, + Color::Green => 10, + Color::Cyan => 11, + Color::Red => 12, + Color::Magenta => 13, + Color::Yellow => 14, + Color::White => 15, } } @@ -294,39 +291,36 @@ impl HostDefaultData { let bg_color = Color::Black; // -> 0 // Convert to console color integers - let fg_i32 = console_color_to_i32(fg_color); - let bg_i32 = console_color_to_i32(bg_color); + let foreground_color = console_color_to_i32(fg_color); + let background_color = console_color_to_i32(bg_color); // Convert terminal dimensions to i32 - let cols_i32 = cols as i32; - let rows_i32 = rows as i32; - let cursor_x_i32 = cursor_x as i32; - let cursor_y_i32 = cursor_y as i32; + let cols = cols as i32; + let rows = rows as i32; + let x = cursor_x as i32; + let y = cursor_y as i32; Ok(Self { - foreground_color: fg_i32, - background_color: bg_i32, - cursor_position: Coordinates { - x: cursor_x_i32, - y: cursor_y_i32, - }, + foreground_color, + background_color, + cursor_position: Coordinates { x, y }, window_position: Coordinates { x: 0, y: 0 }, // Not exposed by crossterm cursor_size: 25, // Default cursor size (0-100%) buffer_size: Size { - width: cols_i32, - height: rows_i32, + width: cols, + height: rows, }, window_size: Size { - width: cols_i32, - height: rows_i32, + width: cols, + height: rows, }, max_window_size: Size { - width: cols_i32, - height: rows_i32, + width: cols, + height: rows, }, max_physical_window_size: Size { - width: cols_i32, - height: rows_i32, + width: cols, + height: rows, }, window_title: "PowerShell".to_string(), locale: "en-US".to_string(), @@ -397,7 +391,7 @@ impl TryFrom> for HostDefaultData { dict.get(&PsValue::Primitive(PsPrimitiveValue::I32(key))) .and_then(|v| match v { PsValue::Object(obj) => ValueWrapper::try_from(obj).ok(), - _ => None, + PsValue::Primitive(_) => None, }) .ok_or_else(|| { Self::Error::InvalidMessage(format!( @@ -431,7 +425,7 @@ impl TryFrom> for HostDefaultData { let wrapper = get_value_wrapper(key)?; match wrapper.value { PsValue::Object(obj) => Coordinates::try_from(&obj), - _ => Err(Self::Error::InvalidMessage(format!( + PsValue::Primitive(_) => Err(Self::Error::InvalidMessage(format!( "Expected Coordinates object for key {key}" ))), } @@ -441,13 +435,13 @@ impl TryFrom> for HostDefaultData { let wrapper = get_value_wrapper(key)?; match wrapper.value { PsValue::Object(obj) => Size::try_from(&obj), - _ => Err(Self::Error::InvalidMessage(format!( + PsValue::Primitive(_) => Err(Self::Error::InvalidMessage(format!( "Expected Size object for key {key}" ))), } }; - Ok(HostDefaultData { + Ok(Self { foreground_color: get_i32_from_wrapper(0)?, background_color: get_i32_from_wrapper(1)?, cursor_position: get_coords_from_wrapper(2)?, diff --git a/crates/ironposh-psrp/src/messages/init_runspace_pool/host_info.rs b/crates/ironposh-psrp/src/messages/init_runspace_pool/host_info.rs index aab70ef..e4f6df4 100644 --- a/crates/ironposh-psrp/src/messages/init_runspace_pool/host_info.rs +++ b/crates/ironposh-psrp/src/messages/init_runspace_pool/host_info.rs @@ -4,6 +4,7 @@ use crate::ps_value::{ }; use std::{borrow::Cow, collections::BTreeMap}; +#[expect(clippy::struct_excessive_bools)] #[derive(Debug, Clone, PartialEq, Eq, typed_builder::TypedBuilder)] pub struct HostInfo { #[builder(default = false)] @@ -19,7 +20,7 @@ pub struct HostInfo { impl HostInfo { pub fn enabled_all(host_data: HostDefaultData) -> Self { - HostInfo { + Self { is_host_null: true, is_host_ui_null: true, is_host_raw_ui_null: true, @@ -70,7 +71,7 @@ impl From for ComplexObject { "data".to_string(), PsProperty { name: "data".to_string(), - value: PsValue::Object(ComplexObject { + value: PsValue::Object(Self { type_def: Some(PsType { type_names: vec![ Cow::Borrowed("System.Collections.Hashtable"), @@ -87,7 +88,7 @@ impl From for ComplexObject { }, )]); - let host_data_obj = ComplexObject { + let host_data_obj = Self { type_def: None, to_string: None, content: ComplexObjectContent::Standard, @@ -103,7 +104,7 @@ impl From for ComplexObject { }, ); - ComplexObject { + Self { type_def: None, to_string: None, content: ComplexObjectContent::Standard, @@ -162,17 +163,17 @@ impl TryFrom for HostInfo { "Expected Dictionary for data property content".to_string(), )), }, - _ => Err(Self::Error::InvalidMessage( + PsValue::Primitive(_) => Err(Self::Error::InvalidMessage( "Expected Object for data property".to_string(), )), } } - _ => Err(Self::Error::InvalidMessage( + PsValue::Primitive(_) => Err(Self::Error::InvalidMessage( "Expected Object for _hostDefaultData property".to_string(), )), })?; - Ok(HostInfo { + Ok(Self { is_host_null, is_host_ui_null, is_host_raw_ui_null, diff --git a/crates/ironposh-psrp/src/messages/init_runspace_pool/mod.rs b/crates/ironposh-psrp/src/messages/init_runspace_pool/mod.rs index 0f74b98..7a3351a 100644 --- a/crates/ironposh-psrp/src/messages/init_runspace_pool/mod.rs +++ b/crates/ironposh-psrp/src/messages/init_runspace_pool/mod.rs @@ -90,7 +90,7 @@ impl From for ComplexObject { ); } - ComplexObject { + Self { content: ComplexObjectContent::Standard, extended_properties, ..Default::default() diff --git a/crates/ironposh-psrp/src/messages/init_runspace_pool/ps_thread_options.rs b/crates/ironposh-psrp/src/messages/init_runspace_pool/ps_thread_options.rs index 3583b93..34b0b3b 100644 --- a/crates/ironposh-psrp/src/messages/init_runspace_pool/ps_thread_options.rs +++ b/crates/ironposh-psrp/src/messages/init_runspace_pool/ps_thread_options.rs @@ -27,7 +27,7 @@ impl From for ComplexObject { PSThreadOptions::UseCurrentThread => "UseCurrentThread".to_string(), }; - ComplexObject { + Self { type_def: Some(type_def), to_string: Some(to_string), content: ComplexObjectContent::PsEnums(PsEnums { diff --git a/crates/ironposh-psrp/src/messages/pipeline_host_call.rs b/crates/ironposh-psrp/src/messages/pipeline_host_call.rs index d88f310..8e7fd1f 100644 --- a/crates/ironposh-psrp/src/messages/pipeline_host_call.rs +++ b/crates/ironposh-psrp/src/messages/pipeline_host_call.rs @@ -61,7 +61,7 @@ impl From for ComplexObject { ); // Host method identifier (mi) - let method_id_obj = ComplexObject { + let method_id_obj = Self { type_def: Some(PsType::remote_host_method_id()), to_string: Some(host_call.method_name), content: ComplexObjectContent::ExtendedPrimitive(PsPrimitiveValue::I32( @@ -80,7 +80,7 @@ impl From for ComplexObject { ); // Method parameters (mp) as ArrayList - let parameters_obj = ComplexObject { + let parameters_obj = Self { type_def: Some(PsType::array_list()), to_string: None, content: ComplexObjectContent::Container(Container::List(host_call.parameters)), @@ -96,7 +96,7 @@ impl From for ComplexObject { }, ); - ComplexObject { + Self { type_def: None, to_string: None, content: ComplexObjectContent::Standard, @@ -144,25 +144,25 @@ impl TryFrom for PipelineHostCall { let method_name = mi_obj.to_string.clone().unwrap_or_default(); // Extract method parameters (mp) - let mp_property = value.extended_properties.get("mp").ok_or_else(|| { + let mp = value.extended_properties.get("mp").ok_or_else(|| { Self::Error::InvalidMessage("Missing method parameters (mp) property".to_string()) })?; - let PsValue::Object(mp_obj) = &mp_property.value else { + let PsValue::Object(obj) = &mp.value else { return Err(Self::Error::InvalidMessage( "Method parameters (mp) is not an object".to_string(), )); }; let parameters = - if let ComplexObjectContent::Container(Container::List(params)) = &mp_obj.content { + if let ComplexObjectContent::Container(Container::List(params)) = &obj.content { params.clone() } else { // Empty list case Vec::new() }; - Ok(PipelineHostCall { + Ok(Self { call_id: *call_id, method_id, method_name, diff --git a/crates/ironposh-psrp/src/messages/pipeline_host_response.rs b/crates/ironposh-psrp/src/messages/pipeline_host_response.rs index 5d593f3..0cfa1fe 100644 --- a/crates/ironposh-psrp/src/messages/pipeline_host_response.rs +++ b/crates/ironposh-psrp/src/messages/pipeline_host_response.rs @@ -65,7 +65,7 @@ impl From for ComplexObject { ); // Host method identifier (mi) - let method_id_obj = ComplexObject { + let method_id_obj = Self { type_def: Some(PsType::remote_host_method_id()), to_string: Some(host_response.method_name), content: ComplexObjectContent::ExtendedPrimitive(PsPrimitiveValue::I32( @@ -105,7 +105,7 @@ impl From for ComplexObject { ); } - ComplexObject { + Self { type_def: None, to_string: None, content: ComplexObjectContent::Standard, @@ -163,7 +163,7 @@ impl TryFrom for PipelineHostResponse { .get("me") .map(|prop| prop.value.clone()); - Ok(PipelineHostResponse { + Ok(Self { call_id: *call_id, method_id: *method_id, method_name, diff --git a/crates/ironposh-psrp/src/messages/pipeline_input.rs b/crates/ironposh-psrp/src/messages/pipeline_input.rs index d5aaf5f..9bed5bd 100644 --- a/crates/ironposh-psrp/src/messages/pipeline_input.rs +++ b/crates/ironposh-psrp/src/messages/pipeline_input.rs @@ -6,7 +6,7 @@ pub struct PipelineInput { impl PipelineInput { pub fn new(data: PsValue) -> Self { - PipelineInput { data } + Self { data } } } diff --git a/crates/ironposh-psrp/src/messages/pipeline_output.rs b/crates/ironposh-psrp/src/messages/pipeline_output.rs index 879c6e6..442fdbf 100644 --- a/crates/ironposh-psrp/src/messages/pipeline_output.rs +++ b/crates/ironposh-psrp/src/messages/pipeline_output.rs @@ -1,4 +1,4 @@ -use std::fmt::Display; +use std::fmt::{Display, Write}; use regex::Regex; use serde::{Deserialize, Serialize}; @@ -67,7 +67,7 @@ impl TryFrom<&PowerShellRemotingMessage> for PipelineOutput { "not a PipelineOutput message".into(), )); } - Ok(PipelineOutput { + Ok(Self { data: msg.parse_ps_message()?, }) } @@ -102,58 +102,52 @@ fn decode_escaped_ps_string(input: &str) -> Result { - if let Some(high) = high_surrogate { - // We have a high surrogate from before, try to form a surrogate pair - if (0xDC00..=0xDFFF).contains(&code_unit) { - // This is a low surrogate, form the pair - let code_point = 0x10000 - + ((high as u32 - 0xD800) << 10) - + (code_unit as u32 - 0xDC00); - if let Some(ch) = char::from_u32(code_point) { + if let Ok(code_unit) = u16::from_str_radix(hex_str, 16) { + if let Some(high) = high_surrogate { + // We have a high surrogate from before, try to form a surrogate pair + if (0xDC00..=0xDFFF).contains(&code_unit) { + // This is a low surrogate, form the pair + let code_point = + 0x10000 + ((high as u32 - 0xD800) << 10) + (code_unit as u32 - 0xDC00); + if let Some(ch) = char::from_u32(code_point) { + result.push(ch); + } else { + // Invalid code point, add the escaped sequence as-is + result.push_str(escaped); + } + high_surrogate = None; + } else { + // Not a low surrogate, add the previous high surrogate as-is and process this one + write!(result, "_x{high:04X}_").unwrap(); + + if (0xD800..=0xDBFF).contains(&code_unit) { + high_surrogate = Some(code_unit); + } else { + if let Some(ch) = char::from_u32(code_unit as u32) { result.push(ch); } else { - // Invalid code point, add the escaped sequence as-is result.push_str(escaped); } high_surrogate = None; - } else { - // Not a low surrogate, add the previous high surrogate as-is and process this one - result.push_str("_x"); - result.push_str(&format!("{high:04X}")); - result.push('_'); - - if (0xD800..=0xDBFF).contains(&code_unit) { - high_surrogate = Some(code_unit); - } else { - if let Some(ch) = char::from_u32(code_unit as u32) { - result.push(ch); - } else { - result.push_str(escaped); - } - high_surrogate = None; - } } - } else if (0xD800..=0xDBFF).contains(&code_unit) { - // High surrogate, save it for the next iteration - high_surrogate = Some(code_unit); + } + } else if (0xD800..=0xDBFF).contains(&code_unit) { + // High surrogate, save it for the next iteration + high_surrogate = Some(code_unit); + } else { + // Regular character or low surrogate without high surrogate + if let Some(ch) = char::from_u32(code_unit as u32) { + result.push(ch); } else { - // Regular character or low surrogate without high surrogate - if let Some(ch) = char::from_u32(code_unit as u32) { - result.push(ch); - } else { - // Invalid character, add the escaped sequence as-is - result.push_str(escaped); - } - high_surrogate = None; + // Invalid character, add the escaped sequence as-is + result.push_str(escaped); } - } - Err(_) => { - // Invalid hex, add the escaped sequence as-is - result.push_str(escaped); high_surrogate = None; } + } else { + // Invalid hex, add the escaped sequence as-is + result.push_str(escaped); + high_surrogate = None; } } else { // Not a valid escape sequence, add as-is @@ -171,9 +165,7 @@ fn decode_escaped_ps_string(input: &str) -> Result i32 { match self { - PSInvocationState::NotStarted => 0, - PSInvocationState::Running => 1, - PSInvocationState::Stopping => 2, - PSInvocationState::Stopped => 3, - PSInvocationState::Completed => 4, - PSInvocationState::Failed => 5, - PSInvocationState::Disconnected => 6, + Self::NotStarted => 0, + Self::Running => 1, + Self::Stopping => 2, + Self::Stopped => 3, + Self::Completed => 4, + Self::Failed => 5, + Self::Disconnected => 6, } } pub fn is_terminal(&self) -> bool { matches!( self, - PSInvocationState::Completed | PSInvocationState::Failed | PSInvocationState::Stopped + Self::Completed | Self::Failed | Self::Stopped ) } } @@ -41,13 +41,13 @@ impl TryFrom for PSInvocationState { fn try_from(value: i32) -> Result { match value { - 0 => Ok(PSInvocationState::NotStarted), - 1 => Ok(PSInvocationState::Running), - 2 => Ok(PSInvocationState::Stopping), - 3 => Ok(PSInvocationState::Stopped), - 4 => Ok(PSInvocationState::Completed), - 5 => Ok(PSInvocationState::Failed), - 6 => Ok(PSInvocationState::Disconnected), + 0 => Ok(Self::NotStarted), + 1 => Ok(Self::Running), + 2 => Ok(Self::Stopping), + 3 => Ok(Self::Stopped), + 4 => Ok(Self::Completed), + 5 => Ok(Self::Failed), + 6 => Ok(Self::Disconnected), _ => Err(crate::PowerShellRemotingError::InvalidMessage(format!( "Invalid PSInvocationState value: {value}" ))), @@ -94,7 +94,7 @@ impl From for ComplexObject { ); } - ComplexObject { + Self { type_def: None, to_string: None, content: ComplexObjectContent::Standard, @@ -132,7 +132,7 @@ impl TryFrom for PipelineStateMessage { .get("ExceptionAsErrorRecord") .map(|prop| prop.value.clone()); - Ok(PipelineStateMessage { + Ok(Self { pipeline_state, exception_as_error_record, }) diff --git a/crates/ironposh-psrp/src/messages/progress_record.rs b/crates/ironposh-psrp/src/messages/progress_record.rs index 4e5bfc8..a0bcace 100644 --- a/crates/ironposh-psrp/src/messages/progress_record.rs +++ b/crates/ironposh-psrp/src/messages/progress_record.rs @@ -14,15 +14,15 @@ pub enum ProgressRecordType { impl ProgressRecordType { pub fn as_i32(&self) -> i32 { match self { - ProgressRecordType::Processing => 0, - ProgressRecordType::Completed => 1, + Self::Processing => 0, + Self::Completed => 1, } } pub fn as_string(&self) -> &'static str { match self { - ProgressRecordType::Processing => "Processing", - ProgressRecordType::Completed => "Completed", + Self::Processing => "Processing", + Self::Completed => "Completed", } } } @@ -32,8 +32,8 @@ impl TryFrom for ProgressRecordType { fn try_from(value: i32) -> Result { match value { - 0 => Ok(ProgressRecordType::Processing), - 1 => Ok(ProgressRecordType::Completed), + 0 => Ok(Self::Processing), + 1 => Ok(Self::Completed), _ => Err(crate::PowerShellRemotingError::InvalidMessage(format!( "Invalid ProgressRecordType value: {value}" ))), @@ -127,7 +127,7 @@ impl From for ComplexObject { }, ); - let progress_type_obj = ComplexObject { + let progress_type_obj = Self { type_def: Some(PsType { type_names: vec![ Cow::Borrowed("System.Management.Automation.ProgressRecordType"), @@ -162,7 +162,7 @@ impl From for ComplexObject { ); } - ComplexObject { + Self { type_def: None, to_string: None, content: ComplexObjectContent::Standard, @@ -228,14 +228,14 @@ impl TryFrom for ProgressRecord { _ => None, }); - let percent_complete = value - .extended_properties - .get("PercentComplete") - .map(|prop| match &prop.value { - PsValue::Primitive(PsPrimitiveValue::I32(percent)) => *percent, - _ => -1, - }) - .unwrap_or(-1); + let percent_complete = + value + .extended_properties + .get("PercentComplete") + .map_or(-1, |prop| match &prop.value { + PsValue::Primitive(PsPrimitiveValue::I32(percent)) => *percent, + _ => -1, + }); let progress_type = value .extended_properties @@ -247,7 +247,7 @@ impl TryFrom for ProgressRecord { } _ => None, }, - _ => None, + PsValue::Primitive(_) => None, }) .unwrap_or(ProgressRecordType::Processing); @@ -260,7 +260,7 @@ impl TryFrom for ProgressRecord { _ => None, }); - Ok(ProgressRecord::builder() + Ok(Self::builder() .activity(activity) .activity_id(activity_id) .status_description(status_description) diff --git a/crates/ironposh-psrp/src/messages/runspace_pool_host_call.rs b/crates/ironposh-psrp/src/messages/runspace_pool_host_call.rs index 7441023..329e12b 100644 --- a/crates/ironposh-psrp/src/messages/runspace_pool_host_call.rs +++ b/crates/ironposh-psrp/src/messages/runspace_pool_host_call.rs @@ -53,7 +53,7 @@ impl From for ComplexObject { ); // Host method identifier (mi) - let method_id_obj = ComplexObject { + let method_id_obj = Self { type_def: Some(PsType::remote_host_method_id()), to_string: Some(host_call.method_name), content: ComplexObjectContent::ExtendedPrimitive(PsPrimitiveValue::I32( @@ -72,7 +72,7 @@ impl From for ComplexObject { ); // Method parameters (mp) as ArrayList - let parameters_obj = ComplexObject { + let parameters_obj = Self { type_def: Some(PsType::array_list()), to_string: None, content: ComplexObjectContent::Container(Container::List(host_call.parameters)), @@ -88,7 +88,7 @@ impl From for ComplexObject { }, ); - ComplexObject { + Self { type_def: None, to_string: None, content: ComplexObjectContent::Standard, @@ -135,25 +135,25 @@ impl TryFrom for RunspacePoolHostCall { let method_name = mi_obj.to_string.clone().unwrap_or_default(); // Extract method parameters (mp) - let mp_property = value.extended_properties.get("mp").ok_or_else(|| { + let mp = value.extended_properties.get("mp").ok_or_else(|| { Self::Error::InvalidMessage("Missing method parameters (mp) property".to_string()) })?; - let PsValue::Object(mp_obj) = &mp_property.value else { + let PsValue::Object(obj) = &mp.value else { return Err(Self::Error::InvalidMessage( "Method parameters (mp) is not an object".to_string(), )); }; let parameters = - if let ComplexObjectContent::Container(Container::List(params)) = &mp_obj.content { + if let ComplexObjectContent::Container(Container::List(params)) = &obj.content { params.clone() } else { // Empty list case Vec::new() }; - Ok(RunspacePoolHostCall { + Ok(Self { call_id: *call_id, method_id: *method_id, method_name, diff --git a/crates/ironposh-psrp/src/messages/runspace_pool_host_response.rs b/crates/ironposh-psrp/src/messages/runspace_pool_host_response.rs index d298c1d..0f55bc7 100644 --- a/crates/ironposh-psrp/src/messages/runspace_pool_host_response.rs +++ b/crates/ironposh-psrp/src/messages/runspace_pool_host_response.rs @@ -57,7 +57,7 @@ impl From for ComplexObject { ); // Host method identifier (mi) - let method_id_obj = ComplexObject { + let method_id_obj = Self { type_def: Some(PsType::remote_host_method_id()), to_string: Some(host_response.method_name), content: ComplexObjectContent::ExtendedPrimitive(PsPrimitiveValue::I32( @@ -97,7 +97,7 @@ impl From for ComplexObject { ); } - ComplexObject { + Self { type_def: None, to_string: None, content: ComplexObjectContent::Standard, @@ -155,7 +155,7 @@ impl TryFrom for RunspacePoolHostResponse { .get("me") .map(|prop| prop.value.clone()); - Ok(RunspacePoolHostResponse { + Ok(Self { call_id: *call_id, method_id: *method_id, method_name, diff --git a/crates/ironposh-psrp/src/messages/runspace_pool_state.rs b/crates/ironposh-psrp/src/messages/runspace_pool_state.rs index fbac5f1..ed6b47e 100644 --- a/crates/ironposh-psrp/src/messages/runspace_pool_state.rs +++ b/crates/ironposh-psrp/src/messages/runspace_pool_state.rs @@ -21,16 +21,16 @@ pub enum RunspacePoolStateValue { impl RunspacePoolStateValue { pub fn as_i32(&self) -> i32 { match self { - RunspacePoolStateValue::BeforeOpen => 0, - RunspacePoolStateValue::Opening => 1, - RunspacePoolStateValue::Opened => 2, - RunspacePoolStateValue::Closed => 3, - RunspacePoolStateValue::Closing => 4, - RunspacePoolStateValue::Broken => 5, - RunspacePoolStateValue::NegotiationSent => 6, - RunspacePoolStateValue::NegotiationSucceeded => 7, - RunspacePoolStateValue::Connecting => 8, - RunspacePoolStateValue::Disconnected => 9, + Self::BeforeOpen => 0, + Self::Opening => 1, + Self::Opened => 2, + Self::Closed => 3, + Self::Closing => 4, + Self::Broken => 5, + Self::NegotiationSent => 6, + Self::NegotiationSucceeded => 7, + Self::Connecting => 8, + Self::Disconnected => 9, } } } @@ -40,16 +40,16 @@ impl TryFrom for RunspacePoolStateValue { fn try_from(value: i32) -> Result { match value { - 0 => Ok(RunspacePoolStateValue::BeforeOpen), - 1 => Ok(RunspacePoolStateValue::Opening), - 2 => Ok(RunspacePoolStateValue::Opened), - 3 => Ok(RunspacePoolStateValue::Closed), - 4 => Ok(RunspacePoolStateValue::Closing), - 5 => Ok(RunspacePoolStateValue::Broken), - 6 => Ok(RunspacePoolStateValue::NegotiationSent), - 7 => Ok(RunspacePoolStateValue::NegotiationSucceeded), - 8 => Ok(RunspacePoolStateValue::Connecting), - 9 => Ok(RunspacePoolStateValue::Disconnected), + 0 => Ok(Self::BeforeOpen), + 1 => Ok(Self::Opening), + 2 => Ok(Self::Opened), + 3 => Ok(Self::Closed), + 4 => Ok(Self::Closing), + 5 => Ok(Self::Broken), + 6 => Ok(Self::NegotiationSent), + 7 => Ok(Self::NegotiationSucceeded), + 8 => Ok(Self::Connecting), + 9 => Ok(Self::Disconnected), _ => Err(crate::PowerShellRemotingError::InvalidMessage(format!( "Invalid RunspacePoolState value: {value}" ))), @@ -96,7 +96,7 @@ impl From for ComplexObject { ); } - ComplexObject { + Self { type_def: None, to_string: None, content: ComplexObjectContent::Standard, @@ -134,7 +134,7 @@ impl TryFrom for RunspacePoolStateMessage { .get("ExceptionAsErrorRecord") .map(|prop| prop.value.clone()); - Ok(RunspacePoolStateMessage { + Ok(Self { runspace_state, exception_as_error_record, }) diff --git a/crates/ironposh-psrp/src/messages/session_capability.rs b/crates/ironposh-psrp/src/messages/session_capability.rs index d5ed0a3..0078ad6 100644 --- a/crates/ironposh-psrp/src/messages/session_capability.rs +++ b/crates/ironposh-psrp/src/messages/session_capability.rs @@ -69,7 +69,7 @@ impl From for ComplexObject { ); } - ComplexObject { + Self { type_def: None, to_string: None, content: ComplexObjectContent::Standard, @@ -112,7 +112,7 @@ impl TryFrom for SessionCapability { _ => None, }); - Ok(SessionCapability { + Ok(Self { protocol_version, ps_version, serialization_version, diff --git a/crates/ironposh-psrp/src/ps_value/complex.rs b/crates/ironposh-psrp/src/ps_value/complex.rs index 783e689..35f67d7 100644 --- a/crates/ironposh-psrp/src/ps_value/complex.rs +++ b/crates/ironposh-psrp/src/ps_value/complex.rs @@ -79,10 +79,10 @@ pub enum ComplexObjectContent { impl Display for ComplexObjectContent { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - ComplexObjectContent::ExtendedPrimitive(p) => p.fmt(f), - ComplexObjectContent::Container(c) => c.fmt(f), - ComplexObjectContent::PsEnums(e) => e.fmt(f), - ComplexObjectContent::Standard => write!(f, "System.Object"), // Fallback + Self::ExtendedPrimitive(p) => p.fmt(f), + Self::Container(c) => c.fmt(f), + Self::PsEnums(e) => e.fmt(f), + Self::Standard => write!(f, "System.Object"), // Fallback } } } diff --git a/crates/ironposh-psrp/src/ps_value/container.rs b/crates/ironposh-psrp/src/ps_value/container.rs index 0580cd1..0b950e3 100644 --- a/crates/ironposh-psrp/src/ps_value/container.rs +++ b/crates/ironposh-psrp/src/ps_value/container.rs @@ -19,18 +19,20 @@ pub enum Container { impl Display for Container { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Container::Stack(_) => write!(f, "System.Collections.Stack"), - Container::Queue(_) => write!(f, "System.Collections.Queue"), - Container::List(items) => { - let s: Vec = items.iter().map(|v| v.to_string()).collect(); + Self::Stack(_) => write!(f, "System.Collections.Stack"), + Self::Queue(_) => write!(f, "System.Collections.Queue"), + Self::List(items) => { + let s: Vec = items.iter().map(ToString::to_string).collect(); write!(f, "{}", s.join(" ")) } - Container::Dictionary(_) => write!(f, "System.Collections.Hashtable"), + Self::Dictionary(_) => write!(f, "System.Collections.Hashtable"), } } } -/// Enums specify a value of an enumeration. An enumeration is a distinct type consisting of a set of named constants. Every enumeration type has an underlying type, which can be any integral type. The default underlying type of the enumeration elements is a 32-bit integer (see section 2.2.5.1.11). Enums never have adapted properties (see section 2.2.5.3.4.1). +/// Enums specify a value of an enumeration. +/// +/// An enumeration is a distinct type consisting of a set of named constants. Every enumeration type has an underlying type, which can be any integral type. The default underlying type of the enumeration elements is a 32-bit integer (see section 2.2.5.1.11). Enums never have adapted properties (see section 2.2.5.3.4.1). /// XML Element: element corresponding to the primitive integer type (see section 2.2.5.1) that is underlying the enumeration type. /// XML Contents: value of the enumeration converted to the underlying type. /// diff --git a/crates/ironposh-psrp/src/ps_value/deserialize.rs b/crates/ironposh-psrp/src/ps_value/deserialize.rs index 497905a..2a639ab 100644 --- a/crates/ironposh-psrp/src/ps_value/deserialize.rs +++ b/crates/ironposh-psrp/src/ps_value/deserialize.rs @@ -11,27 +11,18 @@ use tracing::trace; type Result = std::result::Result; -/// ================================================================================================ -/// PsPrimitiveValue Visitor and XmlDeserialize Implementation -/// (Kept for backwards compatibility - primitives don't need context) -/// ================================================================================================ +/// A visitor for XML deserialization. +/// +/// Kept for backward compatibility as primitives don't need context. +#[derive(Default)] pub struct PsPrimitiveValueVisitor<'a> { value: Option, _phantom: std::marker::PhantomData<&'a ()>, } -impl<'a> Default for PsPrimitiveValueVisitor<'a> { - fn default() -> Self { - Self::new() - } -} - -impl<'a> PsPrimitiveValueVisitor<'a> { +impl PsPrimitiveValueVisitor<'_> { pub fn new() -> Self { - Self { - value: None, - _phantom: std::marker::PhantomData, - } + Self::default() } } @@ -149,10 +140,7 @@ impl<'a> XmlDeserialize<'a> for PsPrimitiveValue { } } -/// ================================================================================================ -/// Context-Aware Deserialization System for Type and Object References -/// ================================================================================================ -/// Context for deserialization that maintains reference maps +/// Context for deserialization that maintains reference maps. #[derive(Debug, Default)] pub struct DeserializationContext { /// Maps RefId to PsType for type references () @@ -256,25 +244,16 @@ pub trait PsXmlDeserialize<'a>: Sized { } /// Context-aware PsType visitor that handles type references +#[derive(Default)] pub struct PsTypeContextVisitor<'a> { type_names: Vec>, resolved_type: Option, _phantom: std::marker::PhantomData<&'a ()>, } -impl<'a> Default for PsTypeContextVisitor<'a> { - fn default() -> Self { - Self::new() - } -} - -impl<'a> PsTypeContextVisitor<'a> { +impl PsTypeContextVisitor<'_> { pub fn new() -> Self { - Self { - type_names: Vec::new(), - resolved_type: None, - _phantom: std::marker::PhantomData, - } + Self::default() } } @@ -377,6 +356,7 @@ impl<'a> PsXmlDeserialize<'a> for PsType { } /// Context-aware ComplexObject visitor that uses context for type resolution +#[derive(Default)] pub struct ComplexObjectContextVisitor<'a> { type_def: Option, to_string: Option, @@ -386,22 +366,9 @@ pub struct ComplexObjectContextVisitor<'a> { _phantom: std::marker::PhantomData<&'a ()>, } -impl<'a> Default for ComplexObjectContextVisitor<'a> { - fn default() -> Self { - Self::new() - } -} - -impl<'a> ComplexObjectContextVisitor<'a> { +impl ComplexObjectContextVisitor<'_> { pub fn new() -> Self { - Self { - type_def: None, - to_string: None, - content: ComplexObjectContent::Standard, - adapted_properties: BTreeMap::new(), - extended_properties: BTreeMap::new(), - _phantom: std::marker::PhantomData, - } + Self::default() } } @@ -532,23 +499,15 @@ impl<'a> PsXmlDeserialize<'a> for ComplexObject { } /// Context-aware PsValue visitor +#[derive(Default)] pub struct PsValueContextVisitor<'a> { value: Option, _phantom: std::marker::PhantomData<&'a ()>, } -impl<'a> Default for PsValueContextVisitor<'a> { - fn default() -> Self { - Self::new() - } -} - -impl<'a> PsValueContextVisitor<'a> { +impl PsValueContextVisitor<'_> { pub fn new() -> Self { - Self { - value: None, - _phantom: std::marker::PhantomData, - } + Self::default() } } @@ -631,23 +590,15 @@ impl<'a> PsXmlDeserialize<'a> for PsValue { } /// Context-aware Container visitor +#[derive(Default)] pub struct ContainerContextVisitor<'a> { container: Option, _phantom: std::marker::PhantomData<&'a ()>, } -impl<'a> Default for ContainerContextVisitor<'a> { - fn default() -> Self { - Self::new() - } -} - -impl<'a> ContainerContextVisitor<'a> { +impl ContainerContextVisitor<'_> { pub fn new() -> Self { - Self { - container: None, - _phantom: std::marker::PhantomData, - } + Self::default() } } @@ -765,25 +716,16 @@ impl<'a> PsXmlDeserialize<'a> for Container { } /// Context-aware PsProperty visitor +#[derive(Default)] pub struct PsPropertyContextVisitor<'a> { name: Option, value: Option, _phantom: std::marker::PhantomData<&'a ()>, } -impl<'a> Default for PsPropertyContextVisitor<'a> { - fn default() -> Self { - Self::new() - } -} - -impl<'a> PsPropertyContextVisitor<'a> { +impl PsPropertyContextVisitor<'_> { pub fn new() -> Self { - Self { - name: None, - value: None, - _phantom: std::marker::PhantomData, - } + Self::default() } } diff --git a/crates/ironposh-psrp/src/ps_value/primitive.rs b/crates/ironposh-psrp/src/ps_value/primitive.rs index 0e5071e..90618ef 100644 --- a/crates/ironposh-psrp/src/ps_value/primitive.rs +++ b/crates/ironposh-psrp/src/ps_value/primitive.rs @@ -23,89 +23,89 @@ pub enum PsPrimitiveValue { impl Display for PsPrimitiveValue { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - PsPrimitiveValue::Str(s) => write!(f, "{s}"), - PsPrimitiveValue::Bool(b) => write!(f, "{b}"), - PsPrimitiveValue::I32(i) => write!(f, "{i}"), - PsPrimitiveValue::U32(u) => write!(f, "{u}"), - PsPrimitiveValue::I64(i) => write!(f, "{i}"), - PsPrimitiveValue::U64(u) => write!(f, "{u}"), - PsPrimitiveValue::Guid(g) => write!(f, "{g}"), - PsPrimitiveValue::Char(c) => write!(f, "{c}"), - PsPrimitiveValue::Nil => write!(f, ""), // PowerShell $null stringifies to empty string - PsPrimitiveValue::Bytes(_bytes) => write!(f, "System.Byte[]"), - PsPrimitiveValue::Version(v) => write!(f, "{v}"), - PsPrimitiveValue::DateTime(d) => write!(f, "{d}"), + Self::Str(s) => write!(f, "{s}"), + Self::Bool(b) => write!(f, "{b}"), + Self::I32(i) => write!(f, "{i}"), + Self::U32(u) => write!(f, "{u}"), + Self::I64(i) => write!(f, "{i}"), + Self::U64(u) => write!(f, "{u}"), + Self::Guid(g) => write!(f, "{g}"), + Self::Char(c) => write!(f, "{c}"), + Self::Nil => write!(f, ""), // PowerShell $null stringifies to empty string + Self::Bytes(_bytes) => write!(f, "System.Byte[]"), + Self::Version(v) => write!(f, "{v}"), + Self::DateTime(d) => write!(f, "{d}"), } } } impl From<()> for PsPrimitiveValue { - fn from(_: ()) -> Self { - PsPrimitiveValue::Nil + fn from(_value: ()) -> Self { + Self::Nil } } impl From for PsPrimitiveValue { fn from(guid: uuid::Uuid) -> Self { - PsPrimitiveValue::Guid(guid.to_string().to_uppercase()) + Self::Guid(guid.to_string().to_uppercase()) } } impl From<&str> for PsPrimitiveValue { fn from(s: &str) -> Self { - PsPrimitiveValue::Str(s.to_string()) + Self::Str(s.to_string()) } } impl From for PsPrimitiveValue { fn from(s: String) -> Self { - PsPrimitiveValue::Str(s) + Self::Str(s) } } impl From for PsPrimitiveValue { fn from(b: bool) -> Self { - PsPrimitiveValue::Bool(b) + Self::Bool(b) } } impl From for PsPrimitiveValue { fn from(i: i32) -> Self { - PsPrimitiveValue::I32(i) + Self::I32(i) } } impl From for PsPrimitiveValue { fn from(u: u32) -> Self { - PsPrimitiveValue::U32(u) + Self::U32(u) } } impl From for PsPrimitiveValue { fn from(i: i64) -> Self { - PsPrimitiveValue::I64(i) + Self::I64(i) } } impl From for PsPrimitiveValue { fn from(c: char) -> Self { - PsPrimitiveValue::Char(c) + Self::Char(c) } } impl From for PsPrimitiveValue { fn from(u: u64) -> Self { - PsPrimitiveValue::U64(u) + Self::U64(u) } } impl From> for PsPrimitiveValue { fn from(bytes: Vec) -> Self { - PsPrimitiveValue::Bytes(bytes) + Self::Bytes(bytes) } } impl From<&[u8]> for PsPrimitiveValue { fn from(bytes: &[u8]) -> Self { - PsPrimitiveValue::Bytes(bytes.to_vec()) + Self::Bytes(bytes.to_vec()) } } diff --git a/crates/ironposh-psrp/src/ps_value/serialize.rs b/crates/ironposh-psrp/src/ps_value/serialize.rs index 2dde9c6..3ef9e09 100644 --- a/crates/ironposh-psrp/src/ps_value/serialize.rs +++ b/crates/ironposh-psrp/src/ps_value/serialize.rs @@ -17,7 +17,7 @@ pub struct RefIdMap<'a, T> { pub next_id: u32, } -impl<'a, T> RefIdMap<'a, T> { +impl RefIdMap<'_, T> { pub fn new() -> Self { RefIdMap { map: HashMap::new(), @@ -55,18 +55,18 @@ where impl<'a> PsPrimitiveValue { pub fn to_element(&'a self) -> Result> { Ok(match self { - PsPrimitiveValue::Str(s) => Element::new("S").set_text_owned(s.clone()), - PsPrimitiveValue::Bool(b) => Element::new("B").set_text_owned(b.to_string()), - PsPrimitiveValue::I32(i) => Element::new("I32").set_text_owned(i.to_string()), - PsPrimitiveValue::U32(u) => Element::new("U32").set_text_owned(u.to_string()), - PsPrimitiveValue::I64(i) => Element::new("I64").set_text_owned(i.to_string()), - PsPrimitiveValue::U64(u) => Element::new("U64").set_text_owned(u.to_string()), - PsPrimitiveValue::Guid(g) => Element::new("G").set_text_owned(g.clone()), - PsPrimitiveValue::Char(c) => Element::new("C").set_text_owned((*c as u32).to_string()), - PsPrimitiveValue::Nil => Element::new("Nil"), // empty tag - PsPrimitiveValue::Bytes(b) => Element::new("BA").set_text_owned(B64.encode(b)), - PsPrimitiveValue::Version(v) => Element::new("Version").set_text_owned(v.clone()), - PsPrimitiveValue::DateTime(dt) => Element::new("DT").set_text_owned(dt.clone()), + Self::Str(s) => Element::new("S").set_text_owned(s.clone()), + Self::Bool(b) => Element::new("B").set_text_owned(b.to_string()), + Self::I32(i) => Element::new("I32").set_text_owned(i.to_string()), + Self::U32(u) => Element::new("U32").set_text_owned(u.to_string()), + Self::I64(i) => Element::new("I64").set_text_owned(i.to_string()), + Self::U64(u) => Element::new("U64").set_text_owned(u.to_string()), + Self::Guid(g) => Element::new("G").set_text_owned(g.clone()), + Self::Char(c) => Element::new("C").set_text_owned((*c as u32).to_string()), + Self::Nil => Element::new("Nil"), // empty tag + Self::Bytes(b) => Element::new("BA").set_text_owned(B64.encode(b)), + Self::Version(v) => Element::new("Version").set_text_owned(v.clone()), + Self::DateTime(dt) => Element::new("DT").set_text_owned(dt.clone()), }) } } @@ -84,8 +84,8 @@ impl<'a> PsValue { types_map: &mut RefIdMap<'a, PsType>, ) -> Result> { match self { - PsValue::Primitive(ps_primitive_value) => Ok(ps_primitive_value.to_element()?), - PsValue::Object(complex_object) => complex_object.to_element(objects_map, types_map), + Self::Primitive(ps_primitive_value) => Ok(ps_primitive_value.to_element()?), + Self::Object(complex_object) => complex_object.to_element(objects_map, types_map), } } } @@ -104,7 +104,7 @@ impl<'a> PsProperty { } impl<'a> PsType { - pub fn to_element(&'a self, type_maps: &mut RefIdMap<'a, PsType>) -> Result> { + pub fn to_element(&'a self, type_maps: &mut RefIdMap<'a, Self>) -> Result> { if type_maps.contains(self) { // If this type has already been serialized, return a reference element. let ref_id = type_maps.map.get(self).unwrap(); @@ -139,21 +139,21 @@ impl<'a> Container { Ok(match self { // Stacks, Queues, and Lists all serialize to an tag. // The in the parent is what differentiates their type. - Container::Stack(values) => { + Self::Stack(values) => { let mut element = Element::new("STK"); for value in values { element = element.add_child(value.to_element(objects_map, types_map)?); } element } - Container::Queue(values) => { + Self::Queue(values) => { let mut element = Element::new("QUE"); for value in values { element = element.add_child(value.to_element(objects_map, types_map)?); } element } - Container::List(values) => { + Self::List(values) => { let mut element = Element::new("LST"); for value in values { element = element.add_child(value.to_element(objects_map, types_map)?); @@ -161,7 +161,7 @@ impl<'a> Container { element } // Dictionaries serialize to a tag with entries. - Container::Dictionary(map) => { + Self::Dictionary(map) => { let mut element = Element::new("DCT"); for (key, value) in map { let key_element = key @@ -192,7 +192,7 @@ impl<'a> ComplexObject { pub fn to_element( &'a self, - objects_map: &mut RefIdMap<'a, ComplexObject>, + objects_map: &mut RefIdMap<'a, Self>, types_map: &mut RefIdMap<'a, PsType>, ) -> Result> { let ref_id = if let Some(obj_ref_id) = objects_map.map.get(self) { diff --git a/crates/ironposh-psrp/src/ps_value/types.rs b/crates/ironposh-psrp/src/ps_value/types.rs index 7c7a1ae..1aa3556 100644 --- a/crates/ironposh-psrp/src/ps_value/types.rs +++ b/crates/ironposh-psrp/src/ps_value/types.rs @@ -15,7 +15,7 @@ pub struct PsType { impl PsType { pub fn ps_primitive_dictionary() -> Self { - PsType { + Self { type_names: vec![ Cow::Borrowed("System.Management.Automation.PSPrimitiveDictionary"), Cow::Borrowed("System.Collections.Hashtable"), @@ -25,7 +25,7 @@ impl PsType { } pub fn remote_host_method_id() -> Self { - PsType { + Self { type_names: vec![ Cow::Borrowed("System.Management.Automation.Remoting.RemoteHostMethodId"), Cow::Borrowed("System.Enum"), @@ -36,7 +36,7 @@ impl PsType { } pub fn array_list() -> Self { - PsType { + Self { type_names: vec![ Cow::Borrowed("System.Collections.ArrayList"), Cow::Borrowed("System.Object"), @@ -45,7 +45,7 @@ impl PsType { } pub fn pipeline_result_types() -> Self { - PsType { + Self { type_names: vec![ Cow::Borrowed("System.Management.Automation.Runspaces.PipelineResultTypes"), Cow::Borrowed("System.Enum"), diff --git a/crates/ironposh-psrp/src/ps_value/value.rs b/crates/ironposh-psrp/src/ps_value/value.rs index b5b8dd2..3b703d0 100644 --- a/crates/ironposh-psrp/src/ps_value/value.rs +++ b/crates/ironposh-psrp/src/ps_value/value.rs @@ -15,22 +15,22 @@ where IntoPrimitive: Into, { fn from(p: IntoPrimitive) -> Self { - PsValue::Primitive(p.into()) + Self::Primitive(p.into()) } } impl Display for PsValue { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - PsValue::Primitive(p) => p.fmt(f), - PsValue::Object(o) => o.fmt(f), + Self::Primitive(p) => p.fmt(f), + Self::Object(o) => o.fmt(f), } } } impl PsValue { pub fn as_object(&self) -> Option<&ComplexObject> { - if let PsValue::Object(obj) = self { + if let Self::Object(obj) = self { Some(obj) } else { None @@ -40,7 +40,7 @@ impl PsValue { /// Extract i32 value from PsValue pub fn as_i32(&self) -> Option { match self { - PsValue::Primitive(PsPrimitiveValue::I32(val)) => Some(*val), + Self::Primitive(PsPrimitiveValue::I32(val)) => Some(*val), _ => None, } } @@ -48,7 +48,7 @@ impl PsValue { /// Extract i64 value from PsValue pub fn as_i64(&self) -> Option { match self { - PsValue::Primitive(PsPrimitiveValue::I64(val)) => Some(*val), + Self::Primitive(PsPrimitiveValue::I64(val)) => Some(*val), _ => None, } } @@ -56,7 +56,7 @@ impl PsValue { /// Extract string value from PsValue pub fn as_string(&self) -> Option { match self { - PsValue::Primitive(PsPrimitiveValue::Str(val)) => Some(val.clone()), + Self::Primitive(PsPrimitiveValue::Str(val)) => Some(val.clone()), _ => None, } } @@ -66,18 +66,18 @@ impl PsValue { // For now, simplified - in reality this would need to parse complex objects // that represent string arrays match self { - PsValue::Object(_obj) => { + Self::Object(_obj) => { // TODO: Parse array objects properly // For now return empty vec as placeholder Some(vec![]) } - _ => None, + Self::Primitive(_) => None, } } /// Create an array from a Vec of PsValues - pub fn from_array(values: Vec) -> Self { - PsValue::Object(ComplexObject { + pub fn from_array(values: Vec) -> Self { + Self::Object(ComplexObject { type_def: Some(PsType::array_list()), to_string: None, content: super::ComplexObjectContent::Container(super::Container::List(values)), @@ -88,9 +88,9 @@ impl PsValue { /// Create a string array from a Vec of strings pub fn from_string_array(strings: Vec) -> Self { - let values: Vec = strings + let values: Vec = strings .into_iter() - .map(|s| PsValue::Primitive(PsPrimitiveValue::Str(s))) + .map(|s| Self::Primitive(PsPrimitiveValue::Str(s))) .collect(); Self::from_array(values) } diff --git a/crates/ironposh-terminal/Cargo.toml b/crates/ironposh-terminal/Cargo.toml index 299c362..65738c7 100644 --- a/crates/ironposh-terminal/Cargo.toml +++ b/crates/ironposh-terminal/Cargo.toml @@ -9,3 +9,6 @@ crossterm = { version = "0.29.0", features = ["event-stream"] } event-stream = "0.1.1" vt100 = "0.16.2" tracing = "0.1" + +[lints] +workspace = true \ No newline at end of file diff --git a/crates/ironposh-terminal/src/stdio.rs b/crates/ironposh-terminal/src/stdio.rs index d313f3c..fbd9063 100644 --- a/crates/ironposh-terminal/src/stdio.rs +++ b/crates/ironposh-terminal/src/stdio.rs @@ -212,7 +212,7 @@ impl<'a> StdTerm<'a> { } } -impl<'a> IoWrite for StdTerm<'a> { +impl IoWrite for StdTerm<'_> { fn write(&mut self, buf: &[u8]) -> io::Result { // Normalize newlines: LF -> CRLF unless already CRLF for &b in buf { @@ -238,7 +238,7 @@ impl<'a> IoWrite for StdTerm<'a> { } } -impl<'a> Drop for StdTerm<'a> { +impl Drop for StdTerm<'_> { fn drop(&mut self) { // Best-effort flush on scope exit; ignore errors in Drop. let _ = IoWrite::flush(self); diff --git a/crates/ironposh-terminal/src/term/guest.rs b/crates/ironposh-terminal/src/term/guest.rs index b022cbf..33bcc92 100644 --- a/crates/ironposh-terminal/src/term/guest.rs +++ b/crates/ironposh-terminal/src/term/guest.rs @@ -32,19 +32,20 @@ impl GuestTerm { } pub fn apply(&mut self, op: TerminalOp) { - use TerminalOp::*; match op { - FeedBytes(bytes) => self.feed(&bytes), - CursorHome => self.feed(b"\x1b[H"), - SetCursor { x, y } => self.feed(format!("\x1b[{};{}H", y + 1, x + 1).as_bytes()), - ClearScreen => self.feed(b"\x1b[2J\x1b[H"), - ClearScrollback => self.feed(b"\x1b[3J\x1b[2J\x1b[H"), - Resize { rows, cols } => { + TerminalOp::FeedBytes(bytes) => self.feed(&bytes), + TerminalOp::CursorHome => self.feed(b"\x1b[H"), + TerminalOp::SetCursor { x, y } => { + self.feed(format!("\x1b[{};{}H", y + 1, x + 1).as_bytes()); + } + TerminalOp::ClearScreen => self.feed(b"\x1b[2J\x1b[H"), + TerminalOp::ClearScrollback => self.feed(b"\x1b[3J\x1b[2J\x1b[H"), + TerminalOp::Resize { rows, cols } => { self.parser.screen_mut().set_size(rows, cols); self.prev = None; self.dirty = true; } - FillRect { + TerminalOp::FillRect { left, top, right, @@ -109,11 +110,10 @@ impl GuestTerm { return None; } let screen = self.parser.screen().clone(); - let mut bytes = if let Some(prev) = &self.prev { - screen.state_diff(prev) - } else { - screen.state_formatted() - }; + let mut bytes = self + .prev + .as_ref() + .map_or_else(|| screen.state_formatted(), |prev| screen.state_diff(prev)); bytes.extend_from_slice(&screen.cursor_state_formatted()); self.prev = Some(screen); self.dirty = false; diff --git a/crates/ironposh-web/Cargo.toml b/crates/ironposh-web/Cargo.toml index b11241e..781ca50 100644 --- a/crates/ironposh-web/Cargo.toml +++ b/crates/ironposh-web/Cargo.toml @@ -18,7 +18,15 @@ ironposh-async = { path = "../ironposh-async" } ironposh-client-core = { path = "../ironposh-client-core" } ironposh-psrp = { path = "../ironposh-psrp" } js-sys = "0.3.81" -web-sys = { version = "0.3.81", features = ["console", "Request", "RequestInit", "RequestMode", "Response", "Headers", "Window"] } +web-sys = { version = "0.3.81", features = [ + "console", + "Request", + "RequestInit", + "RequestMode", + "Response", + "Headers", + "Window", +] } tracing-wasm = "0.2.1" getrandom = { version = "0.2", features = ["js"] } anyhow = "1.0" @@ -43,3 +51,6 @@ wasm-bindgen-test = "0.3.34" [profile.release] # Tell `rustc` to optimize for small code size. opt-level = "s" + +[lints] +workspace = true diff --git a/crates/ironposh-web/src/client.rs b/crates/ironposh-web/src/client.rs index da916ed..c21165c 100644 --- a/crates/ironposh-web/src/client.rs +++ b/crates/ironposh-web/src/client.rs @@ -58,7 +58,7 @@ impl WasmPowerShellClient { } })?; - let http_client = GatewayHttpViaWSClient::new(url, config.gateway_token.to_owned()); + let http_client = GatewayHttpViaWSClient::new(url, config.gateway_token.clone()); let internal_config: WinRmConfig = config.into(); let (client, host_io, session_event_rx, task) = RemoteAsyncPowershellClient::open_task(internal_config, http_client); @@ -87,9 +87,10 @@ impl WasmPowerShellClient { info!("spawning background task for PowerShell client"); // Spawn background task wasm_bindgen_futures::spawn_local(async move { + #[expect(clippy::large_futures)] if let Err(e) = task.await { error!(?e, "background task failed"); - web_sys::console::error_1(&format!("Background task failed: {}", e).into()); + web_sys::console::error_1(&format!("Background task failed: {e}").into()); } }); diff --git a/crates/ironposh-web/src/conversions.rs b/crates/ironposh-web/src/conversions.rs index 7be6ac0..0de8416 100644 --- a/crates/ironposh-web/src/conversions.rs +++ b/crates/ironposh-web/src/conversions.rs @@ -19,7 +19,7 @@ impl From for WinRmConfig { height: config.rows as i32, }; - WinRmConfig { + Self { server: ( ServerAddress::parse(&config.server).expect("Invalid server address"), config.port, @@ -52,37 +52,36 @@ impl TryFrom<&UserEvent> for WasmPowerShellEvent { type Error = crate::error::WasmError; fn try_from(value: &UserEvent) -> Result { let res = match value { - UserEvent::PipelineCreated { pipeline } => WasmPowerShellEvent::PipelineCreated { + UserEvent::PipelineCreated { pipeline } => Self::PipelineCreated { pipeline_id: pipeline.id().to_string(), }, - UserEvent::PipelineFinished { pipeline } => WasmPowerShellEvent::PipelineFinished { + UserEvent::PipelineFinished { pipeline } => Self::PipelineFinished { pipeline_id: pipeline.id().to_string(), }, - UserEvent::PipelineOutput { pipeline, output } => WasmPowerShellEvent::PipelineOutput { + UserEvent::PipelineOutput { pipeline, output } => Self::PipelineOutput { pipeline_id: pipeline.id().to_string(), - data: match output.assume_primitive_string() { - Ok(str) => str.clone(), - Err(_) => { - warn!("Pipeline output is not a primitive string, attempting to format as displayable string"); - let res = output - .format_as_displyable_string() - .map_err(|e| { - WasmError::Generic(format!( - "{e}, failed to format Pipeline output as string" - )) - })? - .clone(); + data: if let Ok(str) = output.assume_primitive_string() { + str.clone() + } else { + warn!("Pipeline output is not a primitive string, attempting to format as displayable string"); + let res = output + .format_as_displyable_string() + .map_err(|e| { + WasmError::Generic(format!( + "{e}, failed to format Pipeline output as string" + )) + })? + ; - res - } + res }, }, UserEvent::ErrorRecord { error_record, handle, - } => WasmPowerShellEvent::PipelineError { + } => Self::PipelineError { pipeline_id: handle.id().to_string(), - error: format!("{:?}", error_record), + error: format!("{error_record:?}"), }, }; diff --git a/crates/ironposh-web/src/error.rs b/crates/ironposh-web/src/error.rs index e7bc126..dbeb617 100644 --- a/crates/ironposh-web/src/error.rs +++ b/crates/ironposh-web/src/error.rs @@ -39,14 +39,14 @@ unsafe impl Sync for WasmError {} impl WasmError { pub fn name(&self) -> &str { match self { - WasmError::IOError(_) => "IOError", - WasmError::IronPoshError(_) => "IronPoshError", - WasmError::Generic(_) => "GenericError", - WasmError::WebSocket(_) => "WebSocketError", - WasmError::PowerShellError(_) => "PowerShellError", - WasmError::SerializationError(_) => "SerializationError", - WasmError::UrlParseError { .. } => "UrlParseError", - WasmError::InvalidArgument(_) => "InvalidArgument", + Self::IOError(_) => "IOError", + Self::IronPoshError(_) => "IronPoshError", + Self::Generic(_) => "GenericError", + Self::WebSocket(_) => "WebSocketError", + Self::PowerShellError(_) => "PowerShellError", + Self::SerializationError(_) => "SerializationError", + Self::UrlParseError { .. } => "UrlParseError", + Self::InvalidArgument(_) => "InvalidArgument", } } } @@ -58,7 +58,7 @@ impl From for IronPoshError { error_message = %value, "converting WasmError to IronPoshError" ); - IronPoshError { + Self { code: value.name().to_string(), message: value.to_string(), } diff --git a/crates/ironposh-web/src/hostcall.rs b/crates/ironposh-web/src/hostcall.rs index 696a893..1511123 100644 --- a/crates/ironposh-web/src/hostcall.rs +++ b/crates/ironposh-web/src/hostcall.rs @@ -96,6 +96,7 @@ macro_rules! handle_host_call { } /// This should definately be handled by JS side, but for now we leave it like this so at least the session's loop is not blocked +#[expect(clippy::too_many_lines)] pub async fn handle_host_calls( mut host_call_rx: futures::channel::mpsc::UnboundedReceiver, submitter: ironposh_async::HostSubmitter, @@ -243,7 +244,6 @@ pub async fn handle_host_calls( scope, submission, }) - .await .is_err() { error!("failed to submit host call response"); diff --git a/crates/ironposh-web/src/http_client.rs b/crates/ironposh-web/src/http_client.rs index 6c4bb98..dfb6fc1 100644 --- a/crates/ironposh-web/src/http_client.rs +++ b/crates/ironposh-web/src/http_client.rs @@ -22,6 +22,7 @@ pub(crate) struct GatewayHttpViaWSClient { gateway_url: url::Url, connection_map: Rc>>, // We here assume that the token is short lived but can be reused for multiple connections in parallel + #[expect(dead_code)] token: String, } @@ -75,7 +76,7 @@ impl HttpClient for GatewayHttpViaWSClient { }; // 2) Process initialized context → either Continue (send another token) or Done - match auth_sequence.process_sec_ctx_init(init)? { + match auth_sequence.process_sec_ctx_init(&init)? { SecContextInited::Continue { request, sequence } => { let HttpRequestAction { connection_id, @@ -143,7 +144,7 @@ impl GatewayHttpViaWSClient { s.clone() } else { info!(?con_id, gateway_url = %self.gateway_url, "creating new WebSocket connection"); - let stream = WebsocketStream::new(self.gateway_url.clone())?; + let stream = WebsocketStream::new(&self.gateway_url)?; map.insert(*con_id, stream.clone()); stream } @@ -169,7 +170,7 @@ impl WebsocketStream { info!(?request.method, url = %request.url, "serializing HTTP request"); let http_request_bytes = serialize_http_request(&request).map_err(|e| { error!(?e, "failed to serialize HTTP request"); - WasmError::IOError(format!("Failed to serialize HTTP request: {}", e)) + WasmError::IOError(format!("Failed to serialize HTTP request: {e}")) })?; debug!( @@ -187,18 +188,15 @@ impl WebsocketStream { ) { let state = ws.state(); error!(?state, "WebSocket is not open"); - return Err(WasmError::WebSocket(format!("WebSocket is not open: {:?}", state)).into()); - }; + return Err(WasmError::WebSocket(format!("WebSocket is not open: {state:?}")).into()); + } // Send the serialized HTTP request over WebSocket ws.send(gloo_net::websocket::Message::Bytes(http_request_bytes)) .await .map_err(|e| { error!(?e, "failed to send HTTP request over WebSocket"); - WasmError::IOError(format!( - "Failed to send HTTP request over WebSocket: {:?}", - e - )) + WasmError::IOError(format!("Failed to send HTTP request over WebSocket: {e:?}")) })?; // Stream response frames using the decoder @@ -209,7 +207,7 @@ impl WebsocketStream { loop { let msg = next_ws(&mut ws).await.map_err(|e| { error!(?e, "WebSocket read error"); - WasmError::IOError(format!("WS read error: {:?}", e)) + WasmError::IOError(format!("WS read error: {e:?}")) })?; let bytes = match msg { @@ -242,14 +240,14 @@ impl WebsocketStream { } impl WebsocketStream { - pub fn new(url: url::Url) -> Result { + pub fn new(url: &url::Url) -> Result { info!( url = %url, "opening WebSocket connection" ); let ws = WebSocket::open(url.as_str()).map_err(|e| { error!(?e, url = %url, "failed to open WebSocket"); - WasmError::IOError(format!("Failed to open WebSocket: {:?}", e)) + WasmError::IOError(format!("Failed to open WebSocket: {e:?}")) })?; info!(url = %url, "WebSocket connection opened successfully"); diff --git a/crates/ironposh-web/src/http_convert.rs b/crates/ironposh-web/src/http_convert.rs index 4c327c9..0a0bb17 100644 --- a/crates/ironposh-web/src/http_convert.rs +++ b/crates/ironposh-web/src/http_convert.rs @@ -23,16 +23,15 @@ pub fn serialize_http_request(request: &HttpRequest) -> Result> { }; // Request line - let request_line = format!("{} {} HTTP/1.1\r\n", method_str, path); + let request_line = format!("{method_str} {path} HTTP/1.1\r\n"); buffer.extend_from_slice(request_line.as_bytes()); // Host header (required for HTTP/1.1) if let Some(host) = url.host_str() { - let host_header = if let Some(port) = url.port() { - format!("Host: {}:{}\r\n", host, port) - } else { - format!("Host: {}\r\n", host) - }; + let host_header = url.port().map_or_else( + || format!("Host: {host}\r\n"), + |port| format!("Host: {host}:{port}\r\n"), + ); buffer.extend_from_slice(host_header.as_bytes()); } @@ -41,13 +40,13 @@ pub fn serialize_http_request(request: &HttpRequest) -> Result> { if name.eq_ignore_ascii_case("host") || name.eq_ignore_ascii_case("content-length") { continue; } - let header_line = format!("{}: {}\r\n", name, value); + let header_line = format!("{name}: {value}\r\n"); buffer.extend_from_slice(header_line.as_bytes()); } // Cookie header if present if let Some(cookie) = &request.cookie { - let cookie_line = format!("Cookie: {}\r\n", cookie); + let cookie_line = format!("Cookie: {cookie}\r\n"); buffer.extend_from_slice(cookie_line.as_bytes()); } @@ -78,7 +77,7 @@ pub fn serialize_http_request(request: &HttpRequest) -> Result> { HttpBody::None => { // No body content } - }; + } } // No body - just end headers @@ -147,11 +146,10 @@ pub fn deserialize_http_response(bytes: &[u8]) -> Result { || ct.contains("multipart/encrypted") { // Could be encrypted SOAP - check if it's valid UTF-8 - if let Ok(text) = std::str::from_utf8(body_bytes) { - HttpBody::Text(text.to_string()) - } else { - HttpBody::Encrypted(body_bytes.to_vec()) - } + std::str::from_utf8(body_bytes).map_or_else( + |_| HttpBody::Encrypted(body_bytes.to_vec()), + |text| HttpBody::Text(text.to_string()), + ) } else { // Text-based content type let text = std::str::from_utf8(body_bytes) @@ -160,11 +158,10 @@ pub fn deserialize_http_response(bytes: &[u8]) -> Result { } } else { // No content-type, try to parse as UTF-8, otherwise treat as encrypted - if let Ok(text) = std::str::from_utf8(body_bytes) { - HttpBody::Text(text.to_string()) - } else { - HttpBody::Encrypted(body_bytes.to_vec()) - } + std::str::from_utf8(body_bytes).map_or_else( + |_| HttpBody::Encrypted(body_bytes.to_vec()), + |text| HttpBody::Text(text.to_string()), + ) }; Ok(HttpResponse { diff --git a/crates/ironposh-web/src/lib.rs b/crates/ironposh-web/src/lib.rs index 2b5976a..6fe84a7 100644 --- a/crates/ironposh-web/src/lib.rs +++ b/crates/ironposh-web/src/lib.rs @@ -1,3 +1,7 @@ +// These nursery lints get tripped by wasm-bindgen. +#![allow(clippy::non_send_fields_in_send_ty)] +#![allow(clippy::future_not_send)] + use serde::{Deserialize, Serialize}; use tsify::Tsify; use wasm_bindgen::prelude::*; @@ -41,7 +45,7 @@ pub enum LogLevel { /// Initialize tracing for WASM with a custom max level /// Levels: 1=ERROR, 2=WARN, 3=INFO, 4=DEBUG, 5=TRACE #[wasm_bindgen] -pub fn init_tracing_with_level(max_level: LogLevel) { +pub fn init_tracing_with_level(max_level: &LogLevel) { use tracing::Level; use tracing_wasm::WASMLayerConfigBuilder; diff --git a/crates/ironposh-web/src/types/hostcall.rs b/crates/ironposh-web/src/types/hostcall.rs index 28fc1cf..a0adb78 100644 --- a/crates/ironposh-web/src/types/hostcall.rs +++ b/crates/ironposh-web/src/types/hostcall.rs @@ -435,100 +435,101 @@ pub enum JsHostCall { } impl From<&HostCall> for JsHostCall { + #[expect(clippy::too_many_lines)] fn from(host_call: &HostCall) -> Self { match host_call { // Host methods (1-10) - HostCall::GetName { .. } => JsHostCall::GetName { + HostCall::GetName { .. } => Self::GetName { params: (), return_type: StringReturnType::new(), }, - HostCall::GetVersion { .. } => JsHostCall::GetVersion { + HostCall::GetVersion { .. } => Self::GetVersion { params: (), return_type: StringReturnType::new(), }, - HostCall::GetInstanceId { .. } => JsHostCall::GetInstanceId { + HostCall::GetInstanceId { .. } => Self::GetInstanceId { params: (), return_type: UuidReturnType::new(), }, - HostCall::GetCurrentCulture { .. } => JsHostCall::GetCurrentCulture { + HostCall::GetCurrentCulture { .. } => Self::GetCurrentCulture { params: (), return_type: StringReturnType::new(), }, - HostCall::GetCurrentUICulture { .. } => JsHostCall::GetCurrentUICulture { + HostCall::GetCurrentUICulture { .. } => Self::GetCurrentUICulture { params: (), return_type: StringReturnType::new(), }, - HostCall::SetShouldExit { transport } => JsHostCall::SetShouldExit { + HostCall::SetShouldExit { transport } => Self::SetShouldExit { params: transport.params.0, return_type: VoidReturnType::new(), }, - HostCall::EnterNestedPrompt { .. } => JsHostCall::EnterNestedPrompt { + HostCall::EnterNestedPrompt { .. } => Self::EnterNestedPrompt { params: (), return_type: VoidReturnType::new(), }, - HostCall::ExitNestedPrompt { .. } => JsHostCall::ExitNestedPrompt { + HostCall::ExitNestedPrompt { .. } => Self::ExitNestedPrompt { params: (), return_type: VoidReturnType::new(), }, - HostCall::NotifyBeginApplication { .. } => JsHostCall::NotifyBeginApplication { + HostCall::NotifyBeginApplication { .. } => Self::NotifyBeginApplication { params: (), return_type: VoidReturnType::new(), }, - HostCall::NotifyEndApplication { .. } => JsHostCall::NotifyEndApplication { + HostCall::NotifyEndApplication { .. } => Self::NotifyEndApplication { params: (), return_type: VoidReturnType::new(), }, // UI methods (11-26) - HostCall::ReadLine { .. } => JsHostCall::ReadLine { + HostCall::ReadLine { .. } => Self::ReadLine { params: (), return_type: StringReturnType::new(), }, - HostCall::ReadLineAsSecureString { .. } => JsHostCall::ReadLineAsSecureString { + HostCall::ReadLineAsSecureString { .. } => Self::ReadLineAsSecureString { params: (), return_type: BytesReturnType::new(), }, - HostCall::Write1 { transport } => JsHostCall::Write1 { + HostCall::Write1 { transport } => Self::Write1 { params: transport.params.0.clone(), return_type: VoidReturnType::new(), }, - HostCall::Write2 { transport } => JsHostCall::Write2 { + HostCall::Write2 { transport } => Self::Write2 { params: transport.params.clone(), return_type: VoidReturnType::new(), }, - HostCall::WriteLine1 { .. } => JsHostCall::WriteLine1 { + HostCall::WriteLine1 { .. } => Self::WriteLine1 { params: (), return_type: VoidReturnType::new(), }, - HostCall::WriteLine2 { transport } => JsHostCall::WriteLine2 { + HostCall::WriteLine2 { transport } => Self::WriteLine2 { params: transport.params.0.clone(), return_type: VoidReturnType::new(), }, - HostCall::WriteLine3 { transport } => JsHostCall::WriteLine3 { + HostCall::WriteLine3 { transport } => Self::WriteLine3 { params: transport.params.clone(), return_type: VoidReturnType::new(), }, - HostCall::WriteErrorLine { transport } => JsHostCall::WriteErrorLine { + HostCall::WriteErrorLine { transport } => Self::WriteErrorLine { params: transport.params.0.clone(), return_type: VoidReturnType::new(), }, - HostCall::WriteDebugLine { transport } => JsHostCall::WriteDebugLine { + HostCall::WriteDebugLine { transport } => Self::WriteDebugLine { params: transport.params.0.clone(), return_type: VoidReturnType::new(), }, - HostCall::WriteProgress { transport } => JsHostCall::WriteProgress { + HostCall::WriteProgress { transport } => Self::WriteProgress { params: (transport.params.0, format!("{:?}", transport.params.1)), return_type: VoidReturnType::new(), }, - HostCall::WriteVerboseLine { transport } => JsHostCall::WriteVerboseLine { + HostCall::WriteVerboseLine { transport } => Self::WriteVerboseLine { params: transport.params.0.clone(), return_type: VoidReturnType::new(), }, - HostCall::WriteWarningLine { transport } => JsHostCall::WriteWarningLine { + HostCall::WriteWarningLine { transport } => Self::WriteWarningLine { params: transport.params.0.clone(), return_type: VoidReturnType::new(), }, - HostCall::Prompt { transport } => JsHostCall::Prompt { + HostCall::Prompt { transport } => Self::Prompt { params: ( transport.params.0.clone(), transport.params.1.clone(), @@ -536,20 +537,20 @@ impl From<&HostCall> for JsHostCall { .params .2 .iter() - .map(|f| format!("{:?}", f)) + .map(|f| format!("{f:?}")) .collect(), ), return_type: HashMapReturnType::new(), }, - HostCall::PromptForCredential1 { transport } => JsHostCall::PromptForCredential1 { + HostCall::PromptForCredential1 { transport } => Self::PromptForCredential1 { params: transport.params.clone(), return_type: CredentialReturnType::new(), }, - HostCall::PromptForCredential2 { transport } => JsHostCall::PromptForCredential2 { + HostCall::PromptForCredential2 { transport } => Self::PromptForCredential2 { params: transport.params.clone(), return_type: CredentialReturnType::new(), }, - HostCall::PromptForChoice { transport } => JsHostCall::PromptForChoice { + HostCall::PromptForChoice { transport } => Self::PromptForChoice { params: ( transport.params.0.clone(), transport.params.1.clone(), @@ -557,7 +558,7 @@ impl From<&HostCall> for JsHostCall { .params .2 .iter() - .map(|c| format!("{:?}", c)) + .map(|c| format!("{c:?}")) .collect(), transport.params.3, ), @@ -565,126 +566,126 @@ impl From<&HostCall> for JsHostCall { }, // RawUI methods (27-51) - HostCall::GetForegroundColor { .. } => JsHostCall::GetForegroundColor { + HostCall::GetForegroundColor { .. } => Self::GetForegroundColor { params: (), return_type: I32ReturnType::new(), }, - HostCall::SetForegroundColor { transport } => JsHostCall::SetForegroundColor { + HostCall::SetForegroundColor { transport } => Self::SetForegroundColor { params: transport.params.0, return_type: VoidReturnType::new(), }, - HostCall::GetBackgroundColor { .. } => JsHostCall::GetBackgroundColor { + HostCall::GetBackgroundColor { .. } => Self::GetBackgroundColor { params: (), return_type: I32ReturnType::new(), }, - HostCall::SetBackgroundColor { transport } => JsHostCall::SetBackgroundColor { + HostCall::SetBackgroundColor { transport } => Self::SetBackgroundColor { params: transport.params.0, return_type: VoidReturnType::new(), }, - HostCall::GetCursorPosition { .. } => JsHostCall::GetCursorPosition { + HostCall::GetCursorPosition { .. } => Self::GetCursorPosition { params: (), return_type: CoordinatesReturnType::new(), }, - HostCall::SetCursorPosition { transport } => JsHostCall::SetCursorPosition { + HostCall::SetCursorPosition { transport } => Self::SetCursorPosition { params: (transport.params.0.x, transport.params.0.y), return_type: VoidReturnType::new(), }, - HostCall::GetWindowPosition { .. } => JsHostCall::GetWindowPosition { + HostCall::GetWindowPosition { .. } => Self::GetWindowPosition { params: (), return_type: CoordinatesReturnType::new(), }, - HostCall::SetWindowPosition { transport } => JsHostCall::SetWindowPosition { + HostCall::SetWindowPosition { transport } => Self::SetWindowPosition { params: (transport.params.0.x, transport.params.0.y), return_type: VoidReturnType::new(), }, - HostCall::GetCursorSize { .. } => JsHostCall::GetCursorSize { + HostCall::GetCursorSize { .. } => Self::GetCursorSize { params: (), return_type: I32ReturnType::new(), }, - HostCall::SetCursorSize { transport } => JsHostCall::SetCursorSize { + HostCall::SetCursorSize { transport } => Self::SetCursorSize { params: transport.params.0, return_type: VoidReturnType::new(), }, - HostCall::GetBufferSize { .. } => JsHostCall::GetBufferSize { + HostCall::GetBufferSize { .. } => Self::GetBufferSize { params: (), return_type: SizeReturnType::new(), }, - HostCall::SetBufferSize { transport } => JsHostCall::SetBufferSize { + HostCall::SetBufferSize { transport } => Self::SetBufferSize { params: (transport.params.0.width, transport.params.0.height), return_type: VoidReturnType::new(), }, - HostCall::GetWindowSize { .. } => JsHostCall::GetWindowSize { + HostCall::GetWindowSize { .. } => Self::GetWindowSize { params: (), return_type: SizeReturnType::new(), }, - HostCall::SetWindowSize { transport } => JsHostCall::SetWindowSize { + HostCall::SetWindowSize { transport } => Self::SetWindowSize { params: (transport.params.0.width, transport.params.0.height), return_type: VoidReturnType::new(), }, - HostCall::GetWindowTitle { .. } => JsHostCall::GetWindowTitle { + HostCall::GetWindowTitle { .. } => Self::GetWindowTitle { params: (), return_type: StringReturnType::new(), }, - HostCall::SetWindowTitle { transport } => JsHostCall::SetWindowTitle { + HostCall::SetWindowTitle { transport } => Self::SetWindowTitle { params: transport.params.0.clone(), return_type: VoidReturnType::new(), }, - HostCall::GetMaxWindowSize { .. } => JsHostCall::GetMaxWindowSize { + HostCall::GetMaxWindowSize { .. } => Self::GetMaxWindowSize { params: (), return_type: SizeReturnType::new(), }, - HostCall::GetMaxPhysicalWindowSize { .. } => JsHostCall::GetMaxPhysicalWindowSize { + HostCall::GetMaxPhysicalWindowSize { .. } => Self::GetMaxPhysicalWindowSize { params: (), return_type: SizeReturnType::new(), }, - HostCall::GetKeyAvailable { .. } => JsHostCall::GetKeyAvailable { + HostCall::GetKeyAvailable { .. } => Self::GetKeyAvailable { params: (), return_type: BoolReturnType::new(), }, - HostCall::ReadKey { transport } => JsHostCall::ReadKey { + HostCall::ReadKey { transport } => Self::ReadKey { params: transport.params.0, return_type: KeyInfoReturnType::new(), }, - HostCall::FlushInputBuffer { .. } => JsHostCall::FlushInputBuffer { + HostCall::FlushInputBuffer { .. } => Self::FlushInputBuffer { params: (), return_type: VoidReturnType::new(), }, - HostCall::SetBufferContents1 { transport } => JsHostCall::SetBufferContents1 { + HostCall::SetBufferContents1 { transport } => Self::SetBufferContents1 { params: format!("{:?}", transport.params), return_type: VoidReturnType::new(), }, - HostCall::SetBufferContents2 { transport } => JsHostCall::SetBufferContents2 { + HostCall::SetBufferContents2 { transport } => Self::SetBufferContents2 { params: format!("{:?}", transport.params), return_type: VoidReturnType::new(), }, - HostCall::GetBufferContents { transport } => JsHostCall::GetBufferContents { + HostCall::GetBufferContents { transport } => Self::GetBufferContents { params: format!("{:?}", transport.params), return_type: BufferCellArrayReturnType::new(), }, - HostCall::ScrollBufferContents { transport } => JsHostCall::ScrollBufferContents { + HostCall::ScrollBufferContents { transport } => Self::ScrollBufferContents { params: format!("{:?}", transport.params), return_type: VoidReturnType::new(), }, // Interactive session methods (52-56) - HostCall::PushRunspace { transport } => JsHostCall::PushRunspace { + HostCall::PushRunspace { transport } => Self::PushRunspace { params: format!("{:?}", transport.params), return_type: VoidReturnType::new(), }, - HostCall::PopRunspace { .. } => JsHostCall::PopRunspace { + HostCall::PopRunspace { .. } => Self::PopRunspace { params: (), return_type: VoidReturnType::new(), }, - HostCall::GetIsRunspacePushed { .. } => JsHostCall::GetIsRunspacePushed { + HostCall::GetIsRunspacePushed { .. } => Self::GetIsRunspacePushed { params: (), return_type: BoolReturnType::new(), }, - HostCall::GetRunspace { .. } => JsHostCall::GetRunspace { + HostCall::GetRunspace { .. } => Self::GetRunspace { params: (), return_type: PsValueReturnType::new(), }, HostCall::PromptForChoiceMultipleSelection { transport } => { - JsHostCall::PromptForChoiceMultipleSelection { + Self::PromptForChoiceMultipleSelection { params: ( transport.params.0.clone(), transport.params.1.clone(), @@ -692,7 +693,7 @@ impl From<&HostCall> for JsHostCall { .params .2 .iter() - .map(|c| format!("{:?}", c)) + .map(|c| format!("{c:?}")) .collect(), transport.params.3.clone(), ), diff --git a/crates/ironposh-web/src/types/mod.rs b/crates/ironposh-web/src/types/mod.rs index 5b01a92..b2446c9 100644 --- a/crates/ironposh-web/src/types/mod.rs +++ b/crates/ironposh-web/src/types/mod.rs @@ -78,12 +78,12 @@ pub enum JsSessionEvent { impl From for JsSessionEvent { fn from(value: SessionEvent) -> Self { match value { - SessionEvent::ConnectionStarted => JsSessionEvent::ConnectionStarted, - SessionEvent::ConnectionEstablished => JsSessionEvent::ConnectionEstablished, - SessionEvent::ActiveSessionStarted => JsSessionEvent::ActiveSessionStarted, - SessionEvent::ActiveSessionEnded => JsSessionEvent::ActiveSessionEnded, - SessionEvent::Error(e) => JsSessionEvent::Error(e), - SessionEvent::Closed => JsSessionEvent::Closed, + SessionEvent::ConnectionStarted => Self::ConnectionStarted, + SessionEvent::ConnectionEstablished => Self::ConnectionEstablished, + SessionEvent::ActiveSessionStarted => Self::ActiveSessionStarted, + SessionEvent::ActiveSessionEnded => Self::ActiveSessionEnded, + SessionEvent::Error(e) => Self::Error(e), + SessionEvent::Closed => Self::Closed, } } } diff --git a/crates/ironposh-web/src/websocket.rs b/crates/ironposh-web/src/websocket.rs index bc4dfa6..716a87c 100644 --- a/crates/ironposh-web/src/websocket.rs +++ b/crates/ironposh-web/src/websocket.rs @@ -10,7 +10,7 @@ pub struct WebsocketStream { } impl WebsocketStream { - pub fn new(url: Url) -> Result { + pub fn new(url: &Url) -> Result { info!(url = %url, "opening WebSocket stream"); let s = url.as_str().to_string(); let ws = WebSocket::open(&s).map_err(|e| { diff --git a/crates/ironposh-web/src/ws_http_decoder.rs b/crates/ironposh-web/src/ws_http_decoder.rs index f77416c..c0bacd0 100644 --- a/crates/ironposh-web/src/ws_http_decoder.rs +++ b/crates/ironposh-web/src/ws_http_decoder.rs @@ -18,16 +18,14 @@ pub enum ProtocolError { impl From for WasmError { fn from(e: ProtocolError) -> Self { match e { - ProtocolError::Incomplete(s) => WasmError::IOError(format!("Incomplete: {}", s)), - ProtocolError::Malformed(s) => WasmError::IOError(format!("Malformed: {}", s)), - ProtocolError::TooLarge => WasmError::IOError("Response too large".to_string()), - ProtocolError::Timeout => WasmError::IOError("Timeout".to_string()), + ProtocolError::Incomplete(s) => Self::IOError(format!("Incomplete: {s}")), + ProtocolError::Malformed(s) => Self::IOError(format!("Malformed: {s}")), + ProtocolError::TooLarge => Self::IOError("Response too large".to_string()), + ProtocolError::Timeout => Self::IOError("Timeout".to_string()), ProtocolError::UnexpectedTextFrame => { - WasmError::IOError("Unexpected text frame".to_string()) - } - ProtocolError::WebsocketError(e) => { - WasmError::IOError(format!("WebSocket error: {:?}", e)) + Self::IOError("Unexpected text frame".to_string()) } + ProtocolError::WebsocketError(e) => Self::IOError(format!("WebSocket error: {e:?}")), } } } @@ -91,6 +89,7 @@ impl HttpResponseDecoder { } } + #[expect(clippy::too_many_lines)] pub fn feed(&mut self, bytes: &[u8]) -> Result, WasmError> { if self.buf.len() + bytes.len() > self.max_size { error!( @@ -129,7 +128,7 @@ impl HttpResponseDecoder { } // chunked init - if let BodyMode::Chunked = mode { + if mode == BodyMode::Chunked { self.chunk_cursor = hend + 4; debug!(chunk_cursor = self.chunk_cursor, "initialized chunked mode"); } @@ -200,18 +199,17 @@ impl HttpResponseDecoder { headers, body: http_body, })); - } else { - // need CRLFCRLF after trailers - if let Some(off) = find_double_crlf_from(&self.buf, self.chunk_cursor) { - debug!(offset = off, "found trailers end marker"); - self.chunk_cursor = off; // points after CRLFCRLF - self.trailers_complete = true; - // loop will complete at top - continue; - } - debug!("need more data for trailers completion"); - return Ok(None); } + // need CRLFCRLF after trailers + if let Some(off) = find_double_crlf_from(&self.buf, self.chunk_cursor) { + debug!(offset = off, "found trailers end marker"); + self.chunk_cursor = off; // points after CRLFCRLF + self.trailers_complete = true; + // loop will complete at top + continue; + } + debug!("need more data for trailers completion"); + return Ok(None); } // If mid-chunk, ensure we have enough to consume chunk data + CRLF @@ -260,13 +258,10 @@ impl HttpResponseDecoder { // terminal chunk: after this comes trailers then CRLFCRLF self.chunk_done = true; // fall through and let outer loop look for trailers completion - continue; - } else { - debug!(chunk_size = size, "parsed chunk size"); - self.cur_chunk_remaining = Some(size); - // loop will try to consume chunk data next - continue; } + debug!(chunk_size = size, "parsed chunk size"); + self.cur_chunk_remaining = Some(size); + // loop will try to consume chunk data next } else { debug!("need more data for chunk size line"); return Ok(None); // need more for size line @@ -301,10 +296,9 @@ fn parse_status_and_body_mode(hdr: &[u8]) -> Result<(u16, BodyMode), WasmError> if let Ok(n) = v.parse::() { content_len = Some(n); } - } else if n == "transfer-encoding" - && v.to_ascii_lowercase().contains("chunked") { - chunked = true; - } + } else if n == "transfer-encoding" && v.to_ascii_lowercase().contains("chunked") { + chunked = true; + } } } @@ -325,6 +319,7 @@ fn parse_status_and_body_mode(hdr: &[u8]) -> Result<(u16, BodyMode), WasmError> Ok((status, mode)) } +#[expect(clippy::type_complexity)] fn parse_headers(hdr: &[u8]) -> Result<(Vec<(String, String)>, Option), WasmError> { let s = std::str::from_utf8(hdr).map_err(|_| WasmError::IOError("hdr utf8".into()))?; let mut lines = s.lines(); @@ -379,11 +374,10 @@ fn classify_body(body_bytes: &[u8], content_type: Option<&str>) -> Result { + #[expect(clippy::large_enum_variant)] #[derive(Debug, Clone)] pub enum $enum_name<'a> { $($variant($tag_type),)* diff --git a/crates/ironposh-winrm/src/cores/attribute.rs b/crates/ironposh-winrm/src/cores/attribute.rs index b594e31..75645d0 100644 --- a/crates/ironposh-winrm/src/cores/attribute.rs +++ b/crates/ironposh-winrm/src/cores/attribute.rs @@ -149,9 +149,8 @@ impl<'a> ironposh_xml::parser::XmlVisitor<'a> for AttributeVisitor<'a> { } fn finish(self) -> Result { - self.attribute.ok_or(ironposh_xml::XmlError::InvalidXml( - "No attribute found".to_string(), - )) + self.attribute + .ok_or_else(|| ironposh_xml::XmlError::InvalidXml("No attribute found".to_string())) } } diff --git a/crates/ironposh-winrm/src/cores/namespace.rs b/crates/ironposh-winrm/src/cores/namespace.rs index 00a0b01..73fd0c8 100644 --- a/crates/ironposh-winrm/src/cores/namespace.rs +++ b/crates/ironposh-winrm/src/cores/namespace.rs @@ -103,17 +103,12 @@ define_namespaces! { // ----------------------------------------------------------------------------- // OPTIONAL GROUPING / DECLARATION TYPES // ----------------------------------------------------------------------------- -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct NamespaceDeclaration(Vec); -impl Default for NamespaceDeclaration { - fn default() -> Self { - Self::new() - } -} impl NamespaceDeclaration { pub fn new() -> Self { - Self(Vec::new()) + Self::default() } pub fn namespaces(&self) -> &[Namespace] { &self.0 diff --git a/crates/ironposh-winrm/src/cores/tag.rs b/crates/ironposh-winrm/src/cores/tag.rs index d65377c..05a16c2 100644 --- a/crates/ironposh-winrm/src/cores/tag.rs +++ b/crates/ironposh-winrm/src/cores/tag.rs @@ -281,10 +281,12 @@ where __phantom: std::marker::PhantomData, __phantom_name: std::marker::PhantomData, }) - .ok_or(ironposh_xml::XmlError::InvalidXml(format!( - "Tag visitor cannot built for tag: {}", - N::TAG_NAME - ))) + .ok_or_else(|| { + ironposh_xml::XmlError::InvalidXml(format!( + "Tag visitor cannot built for tag: {}", + N::TAG_NAME + )) + }) } } diff --git a/crates/ironposh-winrm/src/cores/tag_list.rs b/crates/ironposh-winrm/src/cores/tag_list.rs index 1d170bf..8ec876b 100644 --- a/crates/ironposh-winrm/src/cores/tag_list.rs +++ b/crates/ironposh-winrm/src/cores/tag_list.rs @@ -7,20 +7,14 @@ use crate::cores::{TagValue, anytag::AnyTag}; // This is just a temporary struct to hold a list of tags. // to replace the actual TagValue going to be implemented for tags -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct TagList<'a> { items: Vec>, } -impl<'a> Default for TagList<'a> { - fn default() -> Self { - Self::new() - } -} - impl<'a> TagList<'a> { pub fn new() -> Self { - Self { items: Vec::new() } + Self::default() } pub fn add_tag(&mut self, tag: AnyTag<'a>) { @@ -39,12 +33,7 @@ impl<'a> TagList<'a> { impl<'a> TagValue<'a> for TagList<'a> { fn append_to_element(self, element: Element<'a>) -> Element<'a> { - element.add_children( - self.items - .into_iter() - .map(|tag| tag.into_element()) - .collect(), - ) + element.add_children(self.items.into_iter().map(AnyTag::into_element).collect()) } } diff --git a/crates/ironposh-winrm/src/cores/tag_value.rs b/crates/ironposh-winrm/src/cores/tag_value.rs index 85a5671..ff0bffd 100644 --- a/crates/ironposh-winrm/src/cores/tag_value.rs +++ b/crates/ironposh-winrm/src/cores/tag_value.rs @@ -20,13 +20,13 @@ impl<'a> std::convert::From<&'a str> for Text<'a> { } } -impl<'a> std::convert::From for Text<'a> { +impl std::convert::From for Text<'_> { fn from(value: String) -> Self { Text(value.into()) } } -impl<'a> AsRef for Text<'a> { +impl AsRef for Text<'_> { fn as_ref(&self) -> &str { self.0.as_ref() } @@ -103,9 +103,9 @@ impl<'a> XmlVisitor<'a> for TextVisitor<'a> { } fn finish(self) -> Result { - self.value.ok_or(ironposh_xml::XmlError::InvalidXml( - "No text found in the node".to_string(), - )) + self.value.ok_or_else(|| { + ironposh_xml::XmlError::InvalidXml("No text found in the node".to_string()) + }) } } @@ -175,8 +175,8 @@ impl<'a> TagValue<'a> for Empty { } impl From<()> for Empty { - fn from(_: ()) -> Self { - Empty + fn from(_value: ()) -> Self { + Self } } @@ -229,11 +229,9 @@ impl<'a> XmlVisitor<'a> for WsUuidVisitor { if let Some(text) = child.text() { let uuid_str = text.trim(); // Handle WS-Management format: "uuid:9EC885D6-F5A4-4771-9D47-4BDF7DAAEA8C" - let uuid_part = if let Some(stripped) = uuid_str.strip_prefix("uuid:") { - stripped - } else { - uuid_str - }; + let uuid_part = uuid_str + .strip_prefix("uuid:") + .map_or(uuid_str, |stripped| stripped); match uuid::Uuid::parse_str(uuid_part) { Ok(uuid) => self.value = Some(WsUuid(uuid)), @@ -249,9 +247,9 @@ impl<'a> XmlVisitor<'a> for WsUuidVisitor { } fn finish(self) -> Result { - self.value.ok_or(ironposh_xml::XmlError::InvalidXml( - "No UUID found in the node".to_string(), - )) + self.value.ok_or_else(|| { + ironposh_xml::XmlError::InvalidXml("No UUID found in the node".to_string()) + }) } } @@ -269,7 +267,7 @@ impl<'a> XmlDeserialize<'a> for WsUuid { impl From for WsUuid { fn from(value: uuid::Uuid) -> Self { - WsUuid(value) + Self(value) } } @@ -362,9 +360,9 @@ impl<'a> XmlVisitor<'a> for TimeVisitor { } fn finish(self) -> Result { - self.value.ok_or(ironposh_xml::XmlError::InvalidXml( - "No time found in the node".to_string(), - )) + self.value.ok_or_else(|| { + ironposh_xml::XmlError::InvalidXml("No time found in the node".to_string()) + }) } } @@ -382,13 +380,13 @@ impl<'a> XmlDeserialize<'a> for Time { impl From for Time { fn from(value: f64) -> Self { - Time(value) + Self(value) } } impl From for Time { fn from(value: u32) -> Self { - Time(value as f64) + Self(f64::from(value)) } } @@ -443,9 +441,9 @@ impl<'a> XmlVisitor<'a> for UnparsedVisitor<'a> { } fn finish(self) -> Result { - self.value.ok_or(ironposh_xml::XmlError::InvalidXml( - "No content found in the node".to_string(), - )) + self.value.ok_or_else(|| { + ironposh_xml::XmlError::InvalidXml("No content found in the node".to_string()) + }) } } diff --git a/crates/ironposh-winrm/src/rsp/commandline.rs b/crates/ironposh-winrm/src/rsp/commandline.rs index 3d406bf..a225ac3 100644 --- a/crates/ironposh-winrm/src/rsp/commandline.rs +++ b/crates/ironposh-winrm/src/rsp/commandline.rs @@ -11,19 +11,19 @@ pub struct CommandLineValue { pub arguments: Vec, } -impl<'a> TagValue<'a> for CommandLineValue { +impl TagValue<'_> for CommandLineValue { fn append_to_element( self, mut element: ironposh_xml::builder::Element, ) -> ironposh_xml::builder::Element { - let command_element = self - .command - .map(|cmd| { + let command_element = self.command.map_or_else( + || Tag::from_name(Command).with_value(()).into_element(), + |cmd| { Tag::from_name(Command) .with_value(Text::from(cmd)) .into_element() - }) - .unwrap_or(Tag::from_name(Command).with_value(()).into_element()); + }, + ); element = element.add_child(command_element); @@ -53,7 +53,7 @@ impl<'a> ironposh_xml::parser::XmlVisitor<'a> for CommandLineValueVisitor { for node in nodes { match (node.tag_name().name(), node.tag_name().namespace()) { (Command::TAG_NAME, Command::NAMESPACE) => { - let cmd_text = node.text().map(|t| t.to_string()); + let cmd_text = node.text().map(ToString::to_string); self.command_line = cmd_text; } (Arguments::TAG_NAME, Arguments::NAMESPACE) => { @@ -80,7 +80,7 @@ impl<'a> ironposh_xml::parser::XmlVisitor<'a> for CommandLineValueVisitor { } } -impl<'a> ironposh_xml::parser::XmlDeserialize<'a> for CommandLineValue { +impl ironposh_xml::parser::XmlDeserialize<'_> for CommandLineValue { type Visitor = CommandLineValueVisitor; fn visitor() -> Self::Visitor { diff --git a/crates/ironposh-winrm/src/rsp/receive.rs b/crates/ironposh-winrm/src/rsp/receive.rs index 120e49f..dd724da 100644 --- a/crates/ironposh-winrm/src/rsp/receive.rs +++ b/crates/ironposh-winrm/src/rsp/receive.rs @@ -76,13 +76,13 @@ pub enum CommandStateValueState { impl CommandStateValueState { pub fn value(&self) -> &'static str { match self { - CommandStateValueState::Done => { + Self::Done => { "http://schemas.microsoft.com/powershell/Microsoft.PowerShell/CommandState/Done" } - CommandStateValueState::Pending => { + Self::Pending => { "http://schemas.microsoft.com/powershell/Microsoft.PowerShell/CommandState/Pending" } - CommandStateValueState::Running => { + Self::Running => { "http://schemas.microsoft.com/powershell/Microsoft.PowerShell/CommandState/Running" } } @@ -95,13 +95,13 @@ impl TryFrom<&str> for CommandStateValueState { fn try_from(value: &str) -> Result { match value { "http://schemas.microsoft.com/powershell/Microsoft.PowerShell/CommandState/Done" => { - Ok(CommandStateValueState::Done) + Ok(Self::Done) } "http://schemas.microsoft.com/powershell/Microsoft.PowerShell/CommandState/Pending" => { - Ok(CommandStateValueState::Pending) + Ok(Self::Pending) } "http://schemas.microsoft.com/powershell/Microsoft.PowerShell/CommandState/Running" => { - Ok(CommandStateValueState::Running) + Ok(Self::Running) } _ => Err(XmlError::GenericError(format!( "Unknown CommandStateValueState: {value}" diff --git a/crates/ironposh-winrm/src/ws_management/body.rs b/crates/ironposh-winrm/src/ws_management/body.rs index a772d6e..55ccadc 100644 --- a/crates/ironposh-winrm/src/ws_management/body.rs +++ b/crates/ironposh-winrm/src/ws_management/body.rs @@ -7,7 +7,7 @@ use crate::{ }; // Enumeration operations -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct EnumerateValue<'a> { pub optimize_enumeration: Option, pub max_elements: Option, @@ -16,11 +16,7 @@ pub struct EnumerateValue<'a> { impl<'a> EnumerateValue<'a> { pub fn new() -> Self { - Self { - optimize_enumeration: None, - max_elements: None, - filter: None, - } + Self::default() } pub fn with_optimization(mut self, optimize: bool) -> Self { @@ -39,12 +35,6 @@ impl<'a> EnumerateValue<'a> { } } -impl<'a> Default for EnumerateValue<'a> { - fn default() -> Self { - Self::new() - } -} - impl<'a> TagValue<'a> for EnumerateValue<'a> { fn append_to_element(self, _element: Element<'a>) -> Element<'a> { todo!("[EnumerateValue] Implement into_element"); diff --git a/crates/ironposh-winrm/src/ws_management/header.rs b/crates/ironposh-winrm/src/ws_management/header.rs index 076126c..be1d02d 100644 --- a/crates/ironposh-winrm/src/ws_management/header.rs +++ b/crates/ironposh-winrm/src/ws_management/header.rs @@ -8,16 +8,14 @@ use tracing::warn; use crate::cores::{self, OptionTagName, Selector, Tag, TagName, TagValue, Text}; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct SelectorSetValue { pub selectors: HashMap, } impl SelectorSetValue { pub fn new() -> Self { - Self { - selectors: HashMap::new(), - } + Self::default() } /// Add a selector as a key-value pair @@ -39,12 +37,6 @@ impl SelectorSetValue { } } -impl Default for SelectorSetValue { - fn default() -> Self { - Self::new() - } -} - impl<'a> TagValue<'a> for SelectorSetValue { fn append_to_element(self, mut element: Element<'a>) -> Element<'a> { for (name, value) in self.selectors { @@ -123,7 +115,7 @@ impl<'a> XmlVisitor<'a> for SelectorSetVisitor { } } -impl<'a> XmlDeserialize<'a> for SelectorSetValue { +impl XmlDeserialize<'_> for SelectorSetValue { type Visitor = SelectorSetVisitor; fn visitor() -> Self::Visitor { @@ -133,22 +125,14 @@ impl<'a> XmlDeserialize<'a> for SelectorSetValue { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct OptionSetValue { pub options: HashMap, } -impl Default for OptionSetValue { - fn default() -> Self { - Self::new() - } -} - impl OptionSetValue { pub fn new() -> Self { - Self { - options: HashMap::new(), - } + Self::default() } /// Add an option as a key-value pair @@ -245,7 +229,7 @@ impl<'a> XmlVisitor<'a> for OptionSetVisitor { } } -impl<'a> XmlDeserialize<'a> for OptionSetValue { +impl XmlDeserialize<'_> for OptionSetValue { type Visitor = OptionSetVisitor; fn visitor() -> Self::Visitor { diff --git a/crates/ironposh-winrm/src/ws_management/mod.rs b/crates/ironposh-winrm/src/ws_management/mod.rs index af91aa9..f9df455 100644 --- a/crates/ironposh-winrm/src/ws_management/mod.rs +++ b/crates/ironposh-winrm/src/ws_management/mod.rs @@ -3,7 +3,12 @@ pub mod header; pub use header::*; use crate::{ - cores::{Attribute, Tag, Time, WsUuid, namespace::Namespace, tag_name::*, tag_value::Text}, + cores::{ + Attribute, Tag, Time, WsUuid, + namespace::Namespace, + tag_name::{Action, Envelope}, + tag_value::Text, + }, soap::{SoapEnvelope, body::SoapBody, header::SoapHeaders}, ws_addressing::AddressValue, }; @@ -54,22 +59,18 @@ pub enum WsAction { impl WsAction { pub fn as_str(&self) -> &str { match self { - WsAction::Create => "http://schemas.xmlsoap.org/ws/2004/09/transfer/Create", - WsAction::Delete => "http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete", - WsAction::Get => "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get", - WsAction::Put => "http://schemas.xmlsoap.org/ws/2004/09/transfer/Put", - WsAction::Command => "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Command", - WsAction::CommandResponse => { + Self::Create => "http://schemas.xmlsoap.org/ws/2004/09/transfer/Create", + Self::Delete => "http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete", + Self::Get => "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get", + Self::Put => "http://schemas.xmlsoap.org/ws/2004/09/transfer/Put", + Self::Command => "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Command", + Self::CommandResponse => { "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandResponse" } - WsAction::ShellReceive => { - "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Receive" - } // See note below - WsAction::ShellCreate => { - "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/create" - } - WsAction::Send => "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Send", - WsAction::Signal => "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Signal", + Self::ShellReceive => "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Receive", // See note below + Self::ShellCreate => "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/create", + Self::Send => "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Send", + Self::Signal => "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Signal", } } } @@ -77,7 +78,7 @@ impl WsAction { impl WsMan { pub fn invoke<'a>( &'a self, - action: WsAction, + action: &WsAction, resource_uri: Option<&'a str>, resource_body: SoapBody<'a>, option_set: Option, @@ -151,7 +152,7 @@ impl WsMan { .with_declaration(Namespace::MsWsmanSchema); if add_rsp_declaration { - soap = soap.with_declaration(Namespace::WsmanShell) + soap = soap.with_declaration(Namespace::WsmanShell); } soap diff --git a/crates/ironposh-xml/Cargo.toml b/crates/ironposh-xml/Cargo.toml index e772619..3449c6f 100644 --- a/crates/ironposh-xml/Cargo.toml +++ b/crates/ironposh-xml/Cargo.toml @@ -13,3 +13,5 @@ roxmltree = "0.20.0" thiserror = "2.0.12" tracing = "0.1.41" +[lints] +workspace = true \ No newline at end of file diff --git a/crates/ironposh-xml/src/builder/attribute.rs b/crates/ironposh-xml/src/builder/attribute.rs index 57bdefe..ad2218e 100644 --- a/crates/ironposh-xml/src/builder/attribute.rs +++ b/crates/ironposh-xml/src/builder/attribute.rs @@ -41,7 +41,7 @@ impl<'a> Attribute<'a> { Attribute { name, value: value.into(), - namespace: namespace.map(|ns| ns.into()), + namespace: namespace.map(Into::into), } } diff --git a/crates/ironposh-xml/src/builder/declaration.rs b/crates/ironposh-xml/src/builder/declaration.rs index e8ae6a2..9d5ec1e 100644 --- a/crates/ironposh-xml/src/builder/declaration.rs +++ b/crates/ironposh-xml/src/builder/declaration.rs @@ -62,7 +62,7 @@ impl<'a> Declaration<'a> { } } -impl<'a> std::fmt::Display for Declaration<'a> { +impl std::fmt::Display for Declaration<'_> { /// Formats the declaration as an XML declaration string. fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( diff --git a/crates/ironposh-xml/src/builder/element.rs b/crates/ironposh-xml/src/builder/element.rs index 6a02b8c..3381892 100644 --- a/crates/ironposh-xml/src/builder/element.rs +++ b/crates/ironposh-xml/src/builder/element.rs @@ -133,7 +133,7 @@ impl<'a> Element<'a> { /// let element = Element::new("root") /// .add_child(child); /// ``` - pub fn add_child(mut self, child: Element<'a>) -> Self { + pub fn add_child(mut self, child: Self) -> Self { match self.content { Content::None | Content::Text(_) => { self.content = Content::Elements(vec![child]); @@ -145,7 +145,7 @@ impl<'a> Element<'a> { self } - pub fn add_children(mut self, children: Vec>) -> Self { + pub fn add_children(mut self, children: Vec) -> Self { for child in children { self = self.add_child(child); } @@ -318,7 +318,7 @@ impl crate::builder::NamespaceFmt for Element<'_> { }; match namespaces_map.get(namespace) { - Some(Some(alias)) => AliasStatus::NamespaceFoundWithAlias(alias.to_string()), + Some(Some(alias)) => AliasStatus::NamespaceFoundWithAlias((*alias).to_string()), /* For cases where the namespace is found but no alias is provided. right now this is only used for TryFrom> for crate::builder::Element<'a> { } } -pub fn parse<'a>(xml: &'a str) -> Result, crate::XmlError> { +pub fn parse(xml: &str) -> Result, crate::XmlError> { roxmltree::Document::parse(xml).map_err(crate::XmlError::ParserError) }