From c3de7f5e74e9086b596ca5ba8ca887c16bb87768 Mon Sep 17 00:00:00 2001 From: Kieran Klukas Date: Wed, 25 Feb 2026 21:09:19 -0800 Subject: [PATCH] feat: add api tools --- Cargo.lock | 1309 ++++++++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 2 + README.md | 10 +- src/api.rs | 649 ++++++++++++++++++++++++ src/config.rs | 46 ++ src/main.rs | 317 +++++++++++- 6 files changed, 2328 insertions(+), 5 deletions(-) create mode 100644 src/api.rs create mode 100644 src/config.rs diff --git a/Cargo.lock b/Cargo.lock index fbeb349..0d9834b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -38,7 +38,7 @@ version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys", + "windows-sys 0.61.2", ] [[package]] @@ -49,7 +49,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys", + "windows-sys 0.61.2", ] [[package]] @@ -58,6 +58,18 @@ version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "bitflags" version = "2.11.0" @@ -79,6 +91,22 @@ version = "3.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" + +[[package]] +name = "cc" +version = "1.2.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2" +dependencies = [ + "find-msvc-tools", + "shlex", +] + [[package]] name = "cfg-if" version = "1.0.4" @@ -140,6 +168,32 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "cpufeatures" version = "0.2.17" @@ -179,6 +233,17 @@ dependencies = [ "subtle", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "ectf-tools" version = "0.1.0" @@ -189,24 +254,136 @@ dependencies = [ "crc32fast", "hmac", "libc", + "reqwest", "serde", "serde_json", + "serde_yaml", "sha2", "uuid", ] +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + [[package]] name = "equivalent" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "foldhash" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -217,6 +394,17 @@ dependencies = [ "version_check", ] +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "getrandom" version = "0.4.1" @@ -230,6 +418,25 @@ dependencies = [ "wasip3", ] +[[package]] +name = "h2" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f44da3a8150a6703ed5d34e164b875fd14c2cdab9af1252a9a1020bde2bdc54" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hashbrown" version = "0.15.5" @@ -260,12 +467,232 @@ dependencies = [ "digest", ] +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "hyper" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "pin-utils", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" +dependencies = [ + "base64", + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "system-configuration", + "tokio", + "tower-service", + "tracing", + "windows-registry", +] + +[[package]] +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + [[package]] name = "id-arena" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + [[package]] name = "indexmap" version = "2.13.0" @@ -278,6 +705,22 @@ dependencies = [ "serde_core", ] +[[package]] +name = "ipnet" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" + +[[package]] +name = "iri-string" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c91338f0783edbd6195decb37bae672fd3b165faffb89bf7b9e6942f8b1a731a" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.2" @@ -312,6 +755,18 @@ version = "0.2.182" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" + [[package]] name = "log" version = "0.4.29" @@ -324,6 +779,50 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "mio" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "native-tls" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "once_cell" version = "1.21.3" @@ -336,6 +835,83 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" +[[package]] +name = "openssl" +version = "0.10.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + +[[package]] +name = "openssl-sys" +version = "0.9.111" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + [[package]] name = "prettyplease" version = "0.2.37" @@ -370,12 +946,153 @@ version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" +[[package]] +name = "reqwest" +version = "0.12.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-tls", + "hyper-util", + "js-sys", + "log", + "mime", + "mime_guess", + "native-tls", + "percent-encoding", + "pin-project-lite", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-native-tls", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustix" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "758025cb5fccfd3bc2fd74708fd4682be41d99e5dff73c377c0646c6012c73a4" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "schannel" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags", + "core-foundation 0.10.1", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "1.0.27" @@ -425,6 +1142,31 @@ dependencies = [ "zmij", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + [[package]] name = "sha2" version = "0.10.9" @@ -436,6 +1178,40 @@ dependencies = [ "digest", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0" +dependencies = [ + "libc", + "windows-sys 0.60.2", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + [[package]] name = "strsim" version = "0.11.1" @@ -459,12 +1235,199 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "system-configuration" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b" +dependencies = [ + "bitflags", + "core-foundation 0.9.4", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82a72c767771b47409d2345987fda8628641887d5466101319899796367354a0" +dependencies = [ + "fastrand", + "getrandom 0.4.1", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.49.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86" +dependencies = [ + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" +dependencies = [ + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "iri-string", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "typenum" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" +[[package]] +name = "unicase" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142" + [[package]] name = "unicode-ident" version = "1.0.24" @@ -477,6 +1440,36 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" @@ -489,17 +1482,38 @@ version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b672338555252d43fd2240c714dc444b8c6fb0a5c5335e65a07bba7742735ddb" dependencies = [ - "getrandom", + "getrandom 0.4.1", "js-sys", "wasm-bindgen", ] +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + [[package]] name = "wasip2" version = "1.0.2+wasi-0.2.9" @@ -531,6 +1545,20 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a89f4650b770e4521aa6573724e2aed4704372151bd0de9d16a3bbabb87441a" +dependencies = [ + "cfg-if", + "futures-util", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.113" @@ -597,12 +1625,69 @@ dependencies = [ "semver", ] +[[package]] +name = "web-sys" +version = "0.3.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "705eceb4ce901230f8625bd1d665128056ccbe4b7408faa625eec1ba80f59a97" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "windows-link" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" +[[package]] +name = "windows-registry" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" +dependencies = [ + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.5", +] + [[package]] name = "windows-sys" version = "0.61.2" @@ -612,6 +1697,135 @@ dependencies = [ "windows-link", ] +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +dependencies = [ + "windows-link", + "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]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" + [[package]] name = "wit-bindgen" version = "0.51.0" @@ -700,6 +1914,95 @@ dependencies = [ "wasmparser", ] +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "zmij" version = "1.0.21" diff --git a/Cargo.toml b/Cargo.toml index 99d59fb..3c52094 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,4 +13,6 @@ hmac = "0.12" sha2 = "0.10" serde = { version = "1", features = ["derive"] } serde_json = "1" +serde_yaml = "0.9" clap_complete = "4" +reqwest = { version = "0.12", features = ["blocking", "multipart", "json"] } diff --git a/README.md b/README.md index a8874ec..596d8b2 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,20 @@ Drop-in replacement for MITRE's `uvx ectf` CLI, rewritten in Rust with reliable serial I/O. Uses raw termios instead of pyserial to avoid macOS CDC-ACM data corruption bugs. -## Usage +## Install + +```bash +brew install taciturnaxolotl/tap/ectf-tools +``` + +Or build from source: ```bash cargo build --release ``` +## Usage + ### HSM Host Tools ```bash diff --git a/src/api.rs b/src/api.rs new file mode 100644 index 0000000..78ef372 --- /dev/null +++ b/src/api.rs @@ -0,0 +1,649 @@ +use std::io::{Read as _, Write as _}; +use std::net::TcpStream; +use std::path::PathBuf; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::Arc; +use std::time::{Duration, Instant}; + +use anyhow::{Context, Result, bail}; + +use crate::config::Config; +use crate::log; +use crate::protocol::{HSMIntf, Opcode}; +use crate::serial; + +// ─── Types ─── + +#[derive(Debug, serde::Deserialize)] +#[allow(dead_code)] +pub struct Flow { + pub id: String, + pub submit_time: String, + pub name: String, + pub completed: bool, + pub params: serde_json::Value, + pub jobs: Vec, +} + +#[derive(Debug, serde::Deserialize)] +#[allow(dead_code)] +pub struct Job { + pub name: String, + pub id: String, + pub has_artifacts: bool, + pub private: bool, + pub status: String, +} + +fn status_color(s: &str) -> &'static str { + match s { + "succeeded" | "completed" => "\x1b[38;5;114m", + "queued" | "running" | "pending" => "\x1b[38;5;221m", + "canceled" => "\x1b[38;5;242m", + "failed" => "\x1b[38;5;203m", + _ => "", + } +} + +fn titlecase(s: &str) -> String { + let mut c = s.chars(); + match c.next() { + None => String::new(), + Some(f) => f.to_uppercase().collect::() + c.as_str(), + } +} + +fn relative_time(iso: &str) -> String { + // Parse ISO 8601 timestamp and compute relative time + let ts = iso + .split('T') + .next() + .and_then(|d| { + let parts: Vec<&str> = d.split('-').collect(); + if parts.len() == 3 { + let y: i64 = parts[0].parse().ok()?; + let m: i64 = parts[1].parse().ok()?; + let d: i64 = parts[2].parse().ok()?; + Some(y * 365 + m * 30 + d) + } else { + None + } + }); + + let now = { + let output = std::process::Command::new("date") + .arg("+%Y-%m-%d") + .output() + .ok(); + output.and_then(|o| { + let s = String::from_utf8(o.stdout).ok()?; + let parts: Vec<&str> = s.trim().split('-').collect(); + if parts.len() == 3 { + let y: i64 = parts[0].parse().ok()?; + let m: i64 = parts[1].parse().ok()?; + let d: i64 = parts[2].parse().ok()?; + Some(y * 365 + m * 30 + d) + } else { + None + } + }) + }; + + match (ts, now) { + (Some(t), Some(n)) => { + let days = n - t; + if days < 0 { + "in the future".to_string() + } else if days == 0 { + "today".to_string() + } else if days == 1 { + "yesterday".to_string() + } else if days < 7 { + format!("{days} days ago") + } else if days < 14 { + "a week ago".to_string() + } else if days < 30 { + format!("{} weeks ago", days / 7) + } else if days < 60 { + "a month ago".to_string() + } else if days < 365 { + format!("{} months ago", days / 30) + } else { + format!("{} years ago", days / 365) + } + } + _ => iso.to_string(), + } +} + +const RESET: &str = "\x1b[0m"; +const BOLD: &str = "\x1b[1m"; +const UNDERLINE: &str = "\x1b[4m"; +const CYAN: &str = "\x1b[36m"; +const YELLOW: &str = "\x1b[33m"; +const GREEN: &str = "\x1b[32m"; +const RED: &str = "\x1b[31m"; +const BLUE: &str = "\x1b[34m"; +const DIM: &str = "\x1b[38;5;242m"; + +/// Auto-highlight a value like Rich's highlighter: +/// UUIDs/hashes → yellow, booleans → green/red, URLs → blue, else → cyan +fn highlight(val: &str) -> String { + if val.eq_ignore_ascii_case("true") { + format!("{GREEN}{val}{RESET}") + } else if val.eq_ignore_ascii_case("false") { + format!("{RED}{val}{RESET}") + } else if val.starts_with("http://") || val.starts_with("https://") || val.starts_with("ssh://") || val.starts_with("git@") { + format!("{BLUE}{val}{RESET}") + } else if val.contains('-') && val.len() >= 32 && val.chars().all(|c| c.is_ascii_hexdigit() || c == '-') { + // UUIDs → yellow + format!("{YELLOW}{val}{RESET}") + } else if val.len() >= 32 && val.chars().all(|c| c.is_ascii_hexdigit()) { + // Commit hashes → blue + format!("{BLUE}{val}{RESET}") + } else { + format!("{CYAN}{val}{RESET}") + } +} + +// ─── Client ─── + +pub struct ApiClient { + pub config: Config, + client: reqwest::blocking::Client, +} + +impl ApiClient { + pub fn new() -> Result { + let config = Config::load()?; + let client = reqwest::blocking::Client::new(); + Ok(Self { config, client }) + } + + fn url(&self, path: &str) -> String { + // Trailing slash must come before query string + if let Some((base, query)) = path.split_once('?') { + format!("{}/api/{base}/?{query}", self.config.api_url) + } else { + format!("{}/api/{path}/", self.config.api_url) + } + } + + fn get(&self, path: &str) -> Result { + let resp = self + .client + .get(self.url(path)) + .bearer_auth(&self.config.token) + .send()?; + check_status(resp) + } + + fn post_json( + &self, + path: &str, + body: &serde_json::Value, + ) -> Result { + let resp = self + .client + .post(self.url(path)) + .bearer_auth(&self.config.token) + .json(body) + .send()?; + check_status(resp) + } + + fn post_file( + &self, + path: &str, + name: &str, + data: Vec, + ) -> Result { + let part = reqwest::blocking::multipart::Part::bytes(data).file_name(name.to_string()); + let form = reqwest::blocking::multipart::Form::new().part("file", part); + let resp = self + .client + .post(self.url(path)) + .bearer_auth(&self.config.token) + .multipart(form) + .send()?; + check_status(resp) + } + + // ─── Flow operations ─── + + pub fn flow_list(&self, flow: &str, count: usize) -> Result> { + let resp = self.get(&format!("flow/{flow}?num={count}"))?; + Ok(resp.json()?) + } + + pub fn flow_info(&self, flow: &str, id: &str) -> Result { + let resp = self.get(&format!("flow/{flow}/{id}"))?; + Ok(resp.json()?) + } + + pub fn flow_submit(&self, flow: &str, body: &serde_json::Value) -> Result { + let resp = self.post_json(&format!("flow/{flow}"), body)?; + Ok(resp.text()?) + } + + pub fn flow_cancel(&self, flow: &str, id: &str) -> Result<()> { + let resp = self + .client + .post(self.url(&format!("flow/{flow}/{id}/cancel"))) + .bearer_auth(&self.config.token) + .send()?; + check_status(resp)?; + Ok(()) + } + + pub fn flow_pull(&self, flow: &str, job_id: &str) -> Result> { + let resp = self.get(&format!("flow/{flow}/job/{job_id}"))?; + Ok(resp.bytes()?.to_vec()) + } + + // ─── Package operations ─── + + pub fn list_packages(&self) -> Result> { + let resp = self.get("package")?; + Ok(resp.json()?) + } + + pub fn get_package(&self, package: &str) -> Result> { + let resp = self.get(&format!("package/{package}"))?; + Ok(resp.bytes()?.to_vec()) + } + + // ─── Flag operations ─── + + pub fn submit_flag(&self, flag: &str, body: &serde_json::Value) -> Result { + let resp = self.post_json(&format!("flag/{flag}"), body)?; + Ok(resp.text()?) + } + + pub fn submit_flag_file(&self, flag: &str, name: &str, data: Vec) -> Result { + let resp = self.post_file(&format!("flag/{flag}"), name, data)?; + Ok(resp.text()?) + } +} + +fn check_status(resp: reqwest::blocking::Response) -> Result { + let status = resp.status(); + let url = resp.url().to_string(); + if status.is_success() { + return Ok(resp); + } + let code = status.as_u16(); + let text = resp.text().unwrap_or_default(); + log::debug(&format!("API {code} from {url}: {text}")); + // Try to extract {"detail": "..."} from JSON responses + let detail = serde_json::from_str::(&text) + .ok() + .and_then(|v| v["detail"].as_str().map(|s| s.to_string())) + .unwrap_or(text); + match code { + 401 => bail!("Authentication failed. Check your API token."), + _ => bail!("{detail}"), + } +} + +// ─── Command implementations ─── + +fn flow_overall_status(f: &Flow) -> String { + // Derive status from jobs like the Python tool does + if f.jobs.iter().any(|j| j.status == "failed") { + "Failed".to_string() + } else if f.completed { + "Succeeded".to_string() + } else if f.jobs.iter().any(|j| j.status == "running") { + "Running".to_string() + } else { + "Queued".to_string() + } +} + +pub fn cmd_flow_list(flow: &str, count: usize) -> Result<()> { + let api = ApiClient::new()?; + let flows = api.flow_list(flow, count)?; + if flows.is_empty() { + log::info("No flows found"); + return Ok(()); + } + + let flow_title = titlecase(flow); + let id_header = format!("{flow_title} ID"); + + // Calculate column widths + let id_w = flows.iter().map(|f| f.id.len()).max().unwrap_or(36).max(id_header.len()); + let time_w = 14; // "When Submitted" + let status_w = 9; + + let total = id_w + time_w + status_w + 10; // 10 for borders + padding + let title = format!("Submitted {flow_title} Flows"); + let pad = total.saturating_sub(title.len()) / 2; + + // Title + println!("{BOLD}{:>pad$}{title}{RESET}", ""); + // Top border + println!("┏{:━ Result<()> { + let api = ApiClient::new()?; + let f = api.flow_info(flow, id)?; + let status = flow_overall_status(&f); + let sc = status_color(&status.to_lowercase()); + let when = relative_time(&f.submit_time); + + println!("{BOLD}{UNDERLINE}Flow {flow}{RESET}"); + println!("├── ID: {}", highlight(&f.id)); + // Format like Python: "2026-02-11 22:05:47+00:00" + let display_time = f.submit_time + .replace('T', " ") + .split('.') + .next() + .unwrap_or(&f.submit_time) + .to_string() + + "+00:00"; + println!("├── Submitted: {} ({when})", highlight(&display_time)); + println!("├── Status: {sc}{status}{RESET}"); + + // Parameters + if let Some(obj) = f.params.as_object() { + if !obj.is_empty() { + println!("├── Parameters"); + let params: Vec<_> = obj.iter().collect(); + for (i, (k, v)) in params.iter().enumerate() { + let connector = if i == params.len() - 1 { "└" } else { "├" }; + let fallback = v.to_string(); + let val = v.as_str().unwrap_or(&fallback); + println!("│ {connector}── {k}: {}", highlight(val)); + } + } + } + + // Jobs + if !f.jobs.is_empty() { + println!("└── Jobs"); + for (i, job) in f.jobs.iter().enumerate() { + let is_last = i == f.jobs.len() - 1; + let branch = if is_last { "└" } else { "├" }; + let prefix = if is_last { " " } else { "│" }; + let jsc = status_color(&job.status); + println!(" {branch}── {BOLD}{}{RESET}", job.name); + println!(" {prefix} ├── ID: {}", highlight(&job.id)); + println!(" {prefix} ├── Has Output: {}", highlight(&titlecase(&job.has_artifacts.to_string()))); + println!(" {prefix} ├── Private: {}", highlight(&titlecase(&job.private.to_string()))); + println!(" {prefix} └── Status: {jsc}{}{RESET}", titlecase(&job.status)); + } + } + + Ok(()) +} + +pub fn cmd_flow_submit(flow: &str, commit: &str, url: Option<&str>) -> Result<()> { + let api = ApiClient::new()?; + let git_url = url + .map(|s| s.to_string()) + .unwrap_or_else(|| api.config.git_url.clone()); + let body = serde_json::json!({ + "git_url": git_url, + "commit_hash": commit, + }); + let id = api.flow_submit(flow, &body)?; + log::success(&format!("Submitted {flow} flow: {id}")); + Ok(()) +} + +pub fn cmd_flow_cancel(flow: &str, id: &str) -> Result<()> { + let api = ApiClient::new()?; + api.flow_cancel(flow, id)?; + log::success(&format!("Cancelled flow {id}")); + Ok(()) +} + +pub fn cmd_flow_get(flow: &str, job_id: &str, out: &PathBuf) -> Result<()> { + let api = ApiClient::new()?; + let data = api.flow_pull(flow, job_id)?; + std::fs::write(out, &data)?; + log::success(&format!("Downloaded to {}", out.display())); + Ok(()) +} + +pub fn cmd_submit(commit: &str) -> Result<()> { + cmd_flow_submit("submit", commit, None) +} + +pub fn cmd_photo(file: &PathBuf) -> Result<()> { + let api = ApiClient::new()?; + let data = std::fs::read(file).context("Failed to read file")?; + let name = file + .file_name() + .context("No filename")? + .to_str() + .context("Invalid filename")?; + let resp = api.submit_flag_file("photo", name, data)?; + log::success(&format!("Photo submitted: {resp}")); + Ok(()) +} + +pub fn cmd_design(file: &PathBuf) -> Result<()> { + let api = ApiClient::new()?; + let data = std::fs::read(file).context("Failed to read file")?; + let name = file + .file_name() + .context("No filename")? + .to_str() + .context("Invalid filename")?; + let resp = api.submit_flag_file("design", name, data)?; + log::success(&format!("Design doc submitted: {resp}")); + Ok(()) +} + +pub fn cmd_steal(team: &str, digest: &str) -> Result<()> { + let api = ApiClient::new()?; + let body = serde_json::json!({ + "team": team, + "digest": digest, + }); + let resp = api.submit_flag("steal", &body)?; + log::success(&format!("Steal submitted: {resp}")); + Ok(()) +} + +pub fn cmd_list_packages() -> Result<()> { + let api = ApiClient::new()?; + let packages = api.list_packages()?; + if packages.is_empty() { + log::info("No packages available"); + } else { + for p in &packages { + log::info(p); + } + } + Ok(()) +} + +pub fn cmd_get_package(package: &str, out: Option<&PathBuf>, force: bool) -> Result<()> { + let api = ApiClient::new()?; + let data = api.get_package(package)?; + let path = out.cloned().unwrap_or_else(|| PathBuf::from(package)); + if !force && path.exists() { + bail!( + "File {} already exists (use --force to overwrite)", + path.display() + ); + } + std::fs::write(&path, &data)?; + log::success(&format!("Downloaded {} to {}", package, path.display())); + Ok(()) +} + +// ─── Remote scenario ─── + +const REMOTE_HOST: &str = "54.163.176.58"; + +pub fn cmd_remote_connect( + mgmt_port: &str, + transfer_port: &str, + team: &str, + timeout: u64, +) -> Result<()> { + let api = ApiClient::new()?; + + // Submit remote flow + let body = serde_json::json!({"team": team}); + let flow_id = api.flow_submit("remote", &body)?; + log::info(&format!("Submitted remote flow: {flow_id}")); + + // Poll for get_ports job + log::info("Waiting for port assignment..."); + let port: u16 = loop { + std::thread::sleep(Duration::from_secs(3)); + let flow = api.flow_info("remote", &flow_id)?; + if let Some(job) = flow.jobs.iter().find(|j| j.name == "get_ports") { + match job.status.as_str() { + "succeeded" => { + let data = api.flow_pull("remote", &job.id)?; + let port_str = String::from_utf8(data)?.trim().to_string(); + break port_str.parse().context("Invalid port number")?; + } + "canceled" | "failed" => bail!("Port assignment failed"), + _ => continue, + } + } + }; + + log::info(&format!("Assigned port {port}, connecting...")); + + // Connect to remote server + let tcp = TcpStream::connect((REMOTE_HOST, port)).context("Failed to connect to remote")?; + tcp.set_nodelay(true)?; + log::success("Connected to remote server"); + + // Open serial ports + let transfer_file = serial::open_serial(transfer_port, None)?; + let mgmt_port_str = mgmt_port.to_string(); + + let done = Arc::new(AtomicBool::new(false)); + + // Bridge: TCP → transfer serial + let tcp_r = tcp.try_clone()?; + let mut transfer_w = transfer_file.try_clone()?; + let done1 = done.clone(); + let h1 = std::thread::spawn(move || { + let mut reader = tcp_r; + let mut buf = [0u8; 4096]; + while !done1.load(Ordering::Relaxed) { + match reader.read(&mut buf) { + Ok(0) => break, + Ok(n) => { + if transfer_w.write_all(&buf[..n]).is_err() { + break; + } + } + Err(_) => break, + } + } + }); + + // Bridge: transfer serial → TCP + let mut tcp_w = tcp.try_clone()?; + let done2 = done.clone(); + let h2 = std::thread::spawn(move || { + let mut reader = transfer_file; + let mut buf = [0u8; 4096]; + while !done2.load(Ordering::Relaxed) { + match reader.read(&mut buf) { + Ok(0) => continue, + Ok(n) => { + if tcp_w.write_all(&buf[..n]).is_err() { + break; + } + } + Err(_) => break, + } + } + }); + + // HSM listen on management port + let done3 = done.clone(); + let h3 = std::thread::spawn(move || { + if done3.load(Ordering::Relaxed) { + return; + } + match HSMIntf::open(&mgmt_port_str) { + Ok(mut hsm) => { + let _ = hsm.send_respond(Opcode::Listen, &[]); + } + Err(e) => log::warning(&format!("Management port error: {e}")), + } + }); + + // Poll flow status with timeout + let start = Instant::now(); + let timeout_dur = Duration::from_secs(timeout); + loop { + std::thread::sleep(Duration::from_secs(3)); + if start.elapsed() > timeout_dur { + log::warning("Remote scenario timed out"); + break; + } + match api.flow_info("remote", &flow_id) { + Ok(flow) => { + if let Some(job) = flow + .jobs + .iter() + .find(|j| j.name == "run_remote_scenario") + { + match job.status.as_str() { + "succeeded" => { + log::success("Remote scenario completed successfully"); + break; + } + "canceled" | "failed" => { + log::error("Remote scenario failed"); + break; + } + _ => { + log::debug(&format!("Scenario status: {}", job.status)); + } + } + } + } + Err(e) => log::warning(&format!("Failed to check status: {e}")), + } + } + + done.store(true, Ordering::Relaxed); + + // Shutdown TCP to unblock threads + let _ = tcp.shutdown(std::net::Shutdown::Both); + + let _ = h1.join(); + let _ = h2.join(); + let _ = h3.join(); + + Ok(()) +} diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..69aaff1 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,46 @@ +use anyhow::{Context, Result}; +use serde::{Deserialize, Serialize}; +use std::path::PathBuf; + +pub const DEFAULT_API_URL: &str = "https://api.ectf.mitre.org"; + +#[derive(Debug, Serialize, Deserialize)] +pub struct Config { + pub token: String, + pub git_url: String, + #[serde(default = "default_api_url")] + pub api_url: String, +} + +fn default_api_url() -> String { + DEFAULT_API_URL.to_string() +} + +impl Config { + pub fn path() -> Result { + let home = std::env::var("HOME").context("HOME not set")?; + Ok(PathBuf::from(home).join(".ectf-config")) + } + + pub fn exists() -> bool { + Self::path().map(|p| p.exists()).unwrap_or(false) + } + + pub fn load() -> Result { + let path = Self::path()?; + let contents = std::fs::read_to_string(&path).with_context(|| { + format!( + "Config not found at {}. Run `ectf-tools config` first.", + path.display() + ) + })?; + serde_yaml::from_str(&contents).context("Failed to parse config file") + } + + pub fn save(&self) -> Result<()> { + let path = Self::path()?; + let contents = serde_yaml::to_string(self)?; + std::fs::write(&path, contents)?; + Ok(()) + } +} diff --git a/src/main.rs b/src/main.rs index 0e877ba..506863d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +mod api; +mod config; mod fthr; mod log; mod protocol; @@ -68,6 +70,164 @@ enum TopLevel { /// Shell to generate completions for shell: Shell, }, + /// Create or update the configuration file + Config { + /// Team API token + #[arg(long)] + token: Option, + /// Git repository URL + #[arg(long)] + git_url: Option, + /// API URL + #[arg(long)] + api_url: Option, + /// Overwrite existing config + #[arg(short, long)] + force: bool, + }, + /// Open the API documentation website + Docs, + /// Open the eCTF rules website + Rules, + /// Interact with the API + #[command(arg_required_else_help = true)] + Api { + #[command(subcommand)] + command: ApiCmd, + }, +} + +// ─── API subcommands ─── + +#[derive(Subcommand)] +enum ApiCmd { + /// Submit your design to Handoff + Submit { + /// Git commit hash + commit: String, + }, + /// Submit a PNG for the Team Photo flag + Photo { + /// PNG file to submit + file: PathBuf, + }, + /// Submit a PDF for the Design Doc flag + Design { + /// PDF file to submit + file: PathBuf, + }, + /// Submit a digest for the Steal Design flag + Steal { + /// Target team identifier + team: String, + /// Hex digest string + digest: String, + }, + /// Get the list of available packages + List, + /// Download an Attack Package + Get { + /// Package name + package: String, + /// Output path + #[arg(short, long)] + out: Option, + /// Overwrite if file exists + #[arg(short, long)] + force: bool, + }, + /// Test that your design can be cloned by the API + #[command(arg_required_else_help = true)] + Clone { + #[command(subcommand)] + command: FlowCmd, + }, + /// Test your design with the API + #[command(arg_required_else_help = true)] + Test { + #[command(subcommand)] + command: FlowCmd, + }, + /// Submit to the remote attack scenario + #[command(arg_required_else_help = true)] + Remote { + #[command(subcommand)] + command: RemoteCmd, + }, +} + +#[derive(Subcommand)] +enum FlowCmd { + /// List recent flows + Ls { + /// Number of flows to show (0 for all) + #[arg(short, long, default_value = "5")] + number: usize, + }, + /// Get flow details + Info { + /// Flow ID + id: String, + }, + /// Submit a commit + Submit { + /// Git commit hash + commit: String, + /// Override git URL + #[arg(short, long)] + url: Option, + }, + /// Cancel a flow + Cancel { + /// Flow ID + id: String, + }, + /// Download job output + Get { + /// Job ID + job_id: String, + /// Output file path + out: PathBuf, + }, +} + +#[derive(Subcommand)] +enum RemoteCmd { + /// Connect to the remote attack scenario + Connect { + /// HSM management serial port + management_port: String, + /// Transfer interface UART port + transfer_port: String, + /// Target team identifier + team: String, + /// Timeout in seconds + #[arg(short, long, default_value = "120")] + timeout: u64, + }, + /// List recent remote flows + Ls { + /// Number of flows to show (0 for all) + #[arg(short, long, default_value = "5")] + number: usize, + }, + /// Get remote flow details + Info { + /// Flow ID + id: String, + }, + /// Cancel a remote flow + Cancel { + /// Flow ID + id: String, + }, + /// Download remote job output + Get { + /// Job ID + job_id: String, + /// Output file path + out: PathBuf, + }, } // ─── Tools subcommands ─── @@ -273,14 +433,169 @@ fn main() { } } +fn open_url(url: &str) -> Result<()> { + #[cfg(target_os = "macos")] + { + std::process::Command::new("open").arg(url).spawn()?; + } + #[cfg(not(target_os = "macos"))] + { + std::process::Command::new("xdg-open").arg(url).spawn()?; + } + Ok(()) +} + fn run(cli: Cli) -> Result<()> { match cli.command { TopLevel::Tools { port, command } => run_tools(&port, command), TopLevel::Hw { port, command } => run_hw(&port, command), TopLevel::Completions { shell } => { - clap_complete::generate(shell, &mut Cli::command(), "ectf-tools", &mut std::io::stdout()); + clap_complete::generate( + shell, + &mut Cli::command(), + "ectf-tools", + &mut std::io::stdout(), + ); Ok(()) } + TopLevel::Config { + token, + git_url, + api_url, + force, + } => run_config(token, git_url, api_url, force), + TopLevel::Docs => { + open_url("https://sb.ectf.mitre.org/")?; + log::success("Opened API documentation"); + Ok(()) + } + TopLevel::Rules => { + open_url("https://rules.ectf.mitre.org/")?; + log::success("Opened eCTF rules"); + Ok(()) + } + TopLevel::Api { command } => run_api(command), + } +} + +// ─── Config ─── + +fn prompt(label: &str, default: Option<&str>) -> Result { + use std::io::Write; + match default { + Some(d) => eprint!("{label} [{d}]: "), + None => eprint!("{label}: "), + } + std::io::stderr().flush()?; + let mut input = String::new(); + std::io::stdin().read_line(&mut input)?; + let input = input.trim().to_string(); + if input.is_empty() { + default + .map(|d| d.to_string()) + .context(format!("{label} is required")) + } else { + Ok(input) + } +} + +fn run_config( + token: Option, + git_url: Option, + api_url: Option, + force: bool, +) -> Result<()> { + let has_args = token.is_some() || git_url.is_some() || api_url.is_some() || force; + + // No args: print existing config or prompt for new one + if !has_args && config::Config::exists() { + let cfg = config::Config::load()?; + log::info(&format!("token: {}", cfg.token)); + log::info(&format!("git_url: {}", cfg.git_url)); + log::info(&format!("api_url: {}", cfg.api_url)); + return Ok(()); + } + + let existing = if config::Config::exists() && !force { + Some(config::Config::load()?) + } else { + None + }; + + let token = match token { + Some(t) => t, + None => prompt("Token", existing.as_ref().map(|c| c.token.as_str()))?, + }; + let git_url = match git_url { + Some(g) => g, + None => prompt("Git URL", existing.as_ref().map(|c| c.git_url.as_str()))?, + }; + let api_url = match api_url { + Some(a) => a, + None => prompt( + "API URL", + Some( + existing + .as_ref() + .map(|c| c.api_url.as_str()) + .unwrap_or(config::DEFAULT_API_URL), + ), + )?, + }; + + config::Config { token, git_url, api_url }.save()?; + + log::success(&format!( + "Config saved to {}", + config::Config::path()?.display() + )); + Ok(()) +} + +// ─── API commands ─── + +fn run_api(cmd: ApiCmd) -> Result<()> { + match cmd { + ApiCmd::Submit { commit } => api::cmd_submit(&commit), + ApiCmd::Photo { file } => api::cmd_photo(&file), + ApiCmd::Design { file } => api::cmd_design(&file), + ApiCmd::Steal { team, digest } => api::cmd_steal(&team, &digest), + ApiCmd::List => api::cmd_list_packages(), + ApiCmd::Get { + package, + out, + force, + } => api::cmd_get_package(&package, out.as_ref(), force), + ApiCmd::Clone { command } => run_flow("clone", command), + ApiCmd::Test { command } => run_flow("test", command), + ApiCmd::Remote { command } => run_remote(command), + } +} + +fn run_flow(flow: &str, cmd: FlowCmd) -> Result<()> { + match cmd { + FlowCmd::Ls { number } => api::cmd_flow_list(flow, number), + FlowCmd::Info { id } => api::cmd_flow_info(flow, &id), + FlowCmd::Submit { commit, url } => { + api::cmd_flow_submit(flow, &commit, url.as_deref()) + } + FlowCmd::Cancel { id } => api::cmd_flow_cancel(flow, &id), + FlowCmd::Get { job_id, out } => api::cmd_flow_get(flow, &job_id, &out), + } +} + +fn run_remote(cmd: RemoteCmd) -> Result<()> { + match cmd { + RemoteCmd::Connect { + management_port, + transfer_port, + team, + timeout, + } => api::cmd_remote_connect(&management_port, &transfer_port, &team, timeout), + RemoteCmd::Ls { number } => api::cmd_flow_list("remote", number), + RemoteCmd::Info { id } => api::cmd_flow_info("remote", &id), + RemoteCmd::Cancel { id } => api::cmd_flow_cancel("remote", &id), + RemoteCmd::Get { job_id, out } => api::cmd_flow_get("remote", &job_id, &out), } }