From 1b5c18ec43be1fc6f8b6d221bc0efc46cf5cfe0e Mon Sep 17 00:00:00 2001 From: Tobias Herber <22559657+herber@users.noreply.github.com> Date: Fri, 5 Dec 2025 16:11:27 -0800 Subject: [PATCH 1/7] Import from private repo --- Cargo.lock | 2086 ++++++++++++++++++++++++++++++++++++ Cargo.toml | 19 + Dockerfile | 35 + src/main.rs | 805 ++++++++++++++ tests/integration_tests.rs | 129 +++ 5 files changed, 3074 insertions(+) create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 Dockerfile create mode 100644 src/main.rs create mode 100644 tests/integration_tests.rs diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..db3a92c --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2086 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "anyhow" +version = "1.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" + +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "auto-future" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c1e7e457ea78e524f48639f551fd79703ac3f2237f5ecccdf4708f8a75ad373" + +[[package]] +name = "axum" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" +dependencies = [ + "async-trait", + "axum-core", + "bytes", + "futures-util", + "http 1.4.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.8.1", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper 1.0.2", + "tokio", + "tower 0.5.2", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 1.4.0", + "http-body 1.0.1", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper 1.0.2", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-test" +version = "15.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac63648e380fd001402a02ec804e7686f9c4751f8cad85b7de0b53dae483a128" +dependencies = [ + "anyhow", + "auto-future", + "axum", + "bytes", + "cookie", + "http 1.4.0", + "http-body-util", + "hyper 1.8.1", + "hyper-util", + "mime", + "pretty_assertions", + "reserve-port", + "rust-multipart-rfc7578_2", + "serde", + "serde_json", + "serde_urlencoded", + "smallvec", + "tokio", + "tower 0.5.2", + "url", +] + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" + +[[package]] +name = "bumpalo" +version = "3.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" + +[[package]] +name = "bytes" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" + +[[package]] +name = "cc" +version = "1.2.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c481bdbf0ed3b892f6f806287d72acd515b352a4ec27a208489b8c1bc839633a" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "cookie" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747" +dependencies = [ + "time", + "version_check", +] + +[[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-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "deranged" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + +[[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 = "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 = "error-outpost" +version = "0.1.0" +dependencies = [ + "axum", + "axum-test", + "hyper 1.8.1", + "regex", + "reqwest", + "serde", + "serde_json", + "tokio", + "tower 0.4.13", + "tracing", + "tracing-subscriber", +] + +[[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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-core", + "futures-io", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", +] + +[[package]] +name = "h2" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0beca50380b1fc32983fc1cb4587bfa4bb9e78fc259aad4a0032d2080309222d" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.12", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[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 = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http 1.4.0", +] + +[[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 1.4.0", + "http-body 1.0.1", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http 0.2.12", + "http-body 0.4.6", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2 0.5.10", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[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", + "http 1.4.0", + "http-body 1.0.1", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "pin-utils", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper 0.14.32", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "hyper-util" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e9a2a24dc5c6821e71a7030e1e14b7b632acac55c40e9d2e082c621261bb56" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http 1.4.0", + "http-body 1.0.1", + "hyper 1.8.1", + "libc", + "pin-project-lite", + "socket2 0.6.1", + "tokio", + "tower-service", + "tracing", +] + +[[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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e93fcd3157766c0c8da2f8cff6ce651a31f0810eaa1c51ec363ef790bbb5fb99" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02845b3647bb045f1100ecd6480ff52f34c35f82d9880e029d329c21d1054899" + +[[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 = "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.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "ipnet" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "js-sys" +version = "0.3.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.177" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" + +[[package]] +name = "linux-raw-sys" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" + +[[package]] +name = "litemap" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" + +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + +[[package]] +name = "memchr" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" + +[[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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "native-tls" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "openssl" +version = "0.10.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" +dependencies = [ + "bitflags 2.10.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" + +[[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 = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[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 = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "pretty_assertions" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d" +dependencies = [ + "diff", + "yansi", +] + +[[package]] +name = "proc-macro2" +version = "1.0.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.16", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.10.0", +] + +[[package]] +name = "regex" +version = "1.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" + +[[package]] +name = "reqwest" +version = "0.11.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.32", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper 0.1.2", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "reserve-port" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21918d6644020c6f6ef1993242989bf6d4952d2e025617744f184c02df51c356" +dependencies = [ + "thiserror 2.0.17", +] + +[[package]] +name = "rust-multipart-rfc7578_2" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03b748410c0afdef2ebbe3685a6a862e2ee937127cdaae623336a459451c8d57" +dependencies = [ + "bytes", + "futures-core", + "futures-util", + "http 0.2.12", + "mime", + "mime_guess", + "rand", + "thiserror 1.0.69", +] + +[[package]] +name = "rustix" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" +dependencies = [ + "bitflags 2.10.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64", +] + +[[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.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[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 = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags 2.10.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc1f0cbffaac4852523ce30d8bd3c5cdc873501d96ff467ca09b6767bb8cd5c0" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.145" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", + "serde_core", +] + +[[package]] +name = "serde_path_to_error" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457" +dependencies = [ + "itoa", + "serde", + "serde_core", +] + +[[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 = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7664a098b8e616bdfcc2dc0e9ac44eb231eedf41db4e9fe95d8d32ec728dedad" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "socket2" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" +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 = "syn" +version = "2.0.111" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" + +[[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.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" +dependencies = [ + "fastrand", + "getrandom 0.3.4", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" +dependencies = [ + "thiserror-impl 2.0.17", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "time" +version = "0.3.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e7d9e3bb61134e77bde20dd4825b97c010155709965fedf0f49bb138e52a9d" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40868e7c1d2f0b8d73e4a8c7f0ff63af4f6d19be117e90bd73eb1d62cf831c6b" + +[[package]] +name = "time-macros" +version = "0.2.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30cfb0125f12d9c277f35663a0a33f8c30190f4e4574868a330595412d34ebf3" +dependencies = [ + "num-conv", + "time-core", +] + +[[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.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" +dependencies = [ + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2 0.6.1", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[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-util" +version = "0.7.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2efa149fe76073d6e8fd97ef4f4eca7b67f599660115591483572e406e165594" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper 1.0.2", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[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.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d15d90a0b5c19378952d479dc858407149d7bb45a14de0142f6c534b16fc647" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a04e24fab5c89c6a36eb8558c9656f30d81de51dfa4d3b45f26b21d61fa0a6c" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" +dependencies = [ + "nu-ansi-term", + "sharded-slab", + "smallvec", + "thread_local", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicase" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" + +[[package]] +name = "unicode-ident" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" + +[[package]] +name = "url" +version = "2.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08bc136a29a3d1758e07a9cca267be308aeebf5cfd5a10f3f67ab2097683ef5b" +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 = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[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.1+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836d9622d604feee9e5de25ac10e3ea5f2d65b41eac0d9ce72eb5deae707ce7c" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b32828d774c412041098d182a8b38b16ea816958e07cf40eec2bc080ae137ac" +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-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[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 = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "wit-bindgen" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" + +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + +[[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 = "zerocopy" +version = "0.8.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd74ec98b9250adb3ca554bdde269adf631549f51d8a8f8f0a10b50f1cb298c3" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[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 = "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", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..3bb395b --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "error-outpost" +version = "0.1.0" +edition = "2024" + +[dependencies] +axum = "0.7" +tokio = { version = "1", features = ["full"] } +serde = { version = "1", features = ["derive"] } +serde_json = "1" +regex = "1" +reqwest = { version = "0.11", features = ["json"] } +tracing = "0.1" +tracing-subscriber = "0.3" + +[dev-dependencies] +axum-test = "15" +tower = "0.4" +hyper = "1" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a65aa4a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +# Build stage +FROM rust:1.75-slim as builder + +WORKDIR /app + +# Copy manifests +COPY Cargo.toml Cargo.lock ./ + +# Copy source code +COPY src ./src + +# Build the application +RUN cargo build --release + +# Runtime stage +FROM debian:bookworm-slim + +# Install CA certificates for HTTPS requests +RUN apt-get update && \ + apt-get install -y ca-certificates && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /app + +# Copy the built binary from builder +COPY --from=builder /app/target/release/error-outpost /app/error-outpost + +# Expose the default port +EXPOSE 9000 + +# Set default environment variables (can be overridden at runtime) +ENV PORT=9000 + +# Run the binary +CMD ["/app/error-outpost"] diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..49b80d2 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,805 @@ +use axum::{ + body::Bytes, + extract::{Path, Query, State}, + http::{HeaderMap, StatusCode}, + response::IntoResponse, + routing::{get, post}, + Json, Router, +}; +use regex::Regex; +use serde::{Deserialize, Serialize}; +use serde_json::{json, Value}; +use std::collections::HashMap; +use std::sync::Arc; +use tracing::{error, info, warn}; + +#[derive(Clone)] +struct AppState { + tenant_id: String, + cluster_id: String, + relay_url: String, + client: reqwest::Client, + pii_patterns: PiiPatterns, + sensitive_fields: Vec, +} + +#[derive(Clone)] +struct PiiPatterns { + email: Regex, + phone: Regex, + ssn: Regex, + credit_card: Regex, + ipv4: Regex, + ipv6: Regex, + uuid: Regex, + api_key: Regex, + jwt: Regex, +} + +impl PiiPatterns { + fn new() -> Self { + Self { + email: Regex::new(r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b").unwrap(), + phone: Regex::new(r"\b(\+\d{1,3}[-.]?)?\(?\d{3}\)?[-.]?\d{3}[-.]?\d{4}\b").unwrap(), + ssn: Regex::new(r"\b\d{3}-\d{2}-\d{4}\b").unwrap(), + credit_card: Regex::new(r"\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b").unwrap(), + ipv4: Regex::new(r"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b").unwrap(), + ipv6: Regex::new(r"\b([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\b").unwrap(), + uuid: Regex::new(r"\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b") + .unwrap(), + api_key: Regex::new(r"\b[A-Za-z0-9_-]{32,}\b").unwrap(), + jwt: Regex::new(r"\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b").unwrap(), + } + } +} + + +#[derive(Serialize, Deserialize)] +struct EnvelopeItem { + header: Value, + payload: Value, +} + +struct Envelope { + header: Value, + items: Vec, +} + +fn get_sensitive_fields() -> Vec { + vec![ + "password", "passwd", "pwd", "secret", "api_key", "apikey", "api-key", + "token", "access_token", "refresh_token", "private_key", "privatekey", + "authorization", "auth", "cookie", "cookies", "session", "sessionid", + "ssn", "social_security", "credit_card", "creditcard", "cc_number", + "cvv", "card_number", "banking", "account_number", "medical", "health", + ] + .into_iter() + .map(String::from) + .collect() +} + +fn is_sensitive_key(key: &str, sensitive_fields: &[String]) -> bool { + let lower_key = key.to_lowercase(); + sensitive_fields.iter().any(|field| lower_key.contains(field)) +} + +fn scrub_string(value: &str, patterns: &PiiPatterns) -> String { + let mut scrubbed = value.to_string(); + + scrubbed = patterns.email.replace_all(&scrubbed, "[EMAIL]").to_string(); + scrubbed = patterns.phone.replace_all(&scrubbed, "[PHONE]").to_string(); + scrubbed = patterns.ssn.replace_all(&scrubbed, "[SSN]").to_string(); + scrubbed = patterns.credit_card.replace_all(&scrubbed, "[CREDIT-CARD]").to_string(); + scrubbed = patterns.ipv4.replace_all(&scrubbed, "[IP]").to_string(); + scrubbed = patterns.ipv6.replace_all(&scrubbed, "[IP]").to_string(); + scrubbed = patterns.jwt.replace_all(&scrubbed, "[JWT-TOKEN]").to_string(); + scrubbed = patterns.uuid.replace_all(&scrubbed, "[UUID]").to_string(); + scrubbed = patterns.api_key.replace_all(&scrubbed, "[KEY]").to_string(); + + scrubbed +} + +fn scrub_value(value: &mut Value, state: &AppState) { + match value { + Value::String(s) => { + *s = scrub_string(s, &state.pii_patterns); + } + Value::Array(arr) => { + for item in arr.iter_mut() { + scrub_value(item, state); + } + } + Value::Object(obj) => { + let keys: Vec = obj.keys().cloned().collect(); + for key in keys { + if is_sensitive_key(&key, &state.sensitive_fields) { + obj.insert(key, Value::String("[REDACTED]".to_string())); + } else if let Some(val) = obj.get_mut(&key) { + scrub_value(val, state); + } + } + } + _ => {} + } +} + +fn scrub_pii(mut event_data: Value, state: &AppState) -> Value { + if let Some(request) = event_data.get_mut("request") { + if let Some(headers) = request.get_mut("headers").and_then(|h| h.as_object_mut()) { + headers.remove("Authorization"); + headers.remove("authorization"); + headers.remove("Cookie"); + headers.remove("cookie"); + headers.remove("X-API-Key"); + headers.remove("x-api-key"); + headers.remove("X-Auth-Token"); + headers.remove("x-auth-token"); + } + + if request.get("cookies").is_some() { + request["cookies"] = Value::String("[REDACTED]".to_string()); + } + + if let Some(query_string) = request.get_mut("query_string").and_then(|q| q.as_str()) { + request["query_string"] = Value::String(scrub_string(query_string, &state.pii_patterns)); + } + + if let Some(data) = request.get_mut("data") { + scrub_value(data, state); + } + + if let Some(url) = request.get_mut("url").and_then(|u| u.as_str()) { + request["url"] = Value::String(scrub_string(url, &state.pii_patterns)); + } + } + + if let Some(user) = event_data.get_mut("user").and_then(|u| u.as_object_mut()) { + if user.contains_key("email") { + user.insert("email".to_string(), Value::String("[EMAIL]".to_string())); + } + if user.contains_key("ip_address") { + user.insert("ip_address".to_string(), Value::String("[IP]".to_string())); + } + if let Some(username) = user.get("username").and_then(|u| u.as_str()) { + let prefix = username.chars().take(3).collect::(); + user.insert("username".to_string(), Value::String(format!("{}***", prefix))); + } + } + + if let Some(env) = event_data + .get_mut("contexts") + .and_then(|c| c.get_mut("runtime")) + .and_then(|r| r.get_mut("environment")) + { + scrub_value(env, state); + } + + if let Some(exception_values) = event_data + .get_mut("exception") + .and_then(|e| e.get_mut("values")) + .and_then(|v| v.as_array_mut()) + { + for exception in exception_values.iter_mut() { + if let Some(value) = exception.get_mut("value") { + scrub_value(value, state); + } + if let Some(frames) = exception + .get_mut("stacktrace") + .and_then(|s| s.get_mut("frames")) + .and_then(|f| f.as_array_mut()) + { + for frame in frames.iter_mut() { + if let Some(vars) = frame.get_mut("vars") { + scrub_value(vars, state); + } + } + } + } + } + + if let Some(breadcrumbs) = event_data.get_mut("breadcrumbs").and_then(|b| b.as_array_mut()) { + for breadcrumb in breadcrumbs.iter_mut() { + if let Some(message) = breadcrumb.get_mut("message") { + scrub_value(message, state); + } + if let Some(data) = breadcrumb.get_mut("data") { + scrub_value(data, state); + } + } + } + + if let Some(extra) = event_data.get_mut("extra") { + scrub_value(extra, state); + } + + if let Some(tags) = event_data.get_mut("tags") { + scrub_value(tags, state); + } + + event_data +} + +fn enrich_with_tenant_info(mut event_data: Value, state: &AppState) -> Value { + let tags = event_data.get_mut("tags").and_then(|t| t.as_object_mut()); + if let Some(tags) = tags { + tags.insert("tenant_id".to_string(), Value::String(state.tenant_id.clone())); + tags.insert("cluster_id".to_string(), Value::String(state.cluster_id.clone())); + tags.insert("deployment_type".to_string(), Value::String("on-prem".to_string())); + tags.insert("pii_scrubbed".to_string(), Value::String("on-prem".to_string())); + } else { + event_data["tags"] = json!({ + "tenant_id": state.tenant_id, + "cluster_id": state.cluster_id, + "deployment_type": "on-prem", + "pii_scrubbed": "on-prem" + }); + } + + let contexts = event_data.get_mut("contexts").and_then(|c| c.as_object_mut()); + if let Some(contexts) = contexts { + contexts.insert("tenant".to_string(), json!({ + "id": state.tenant_id, + "cluster": state.cluster_id, + "deployment": "on-prem", + "proxy_version": "2.0.0", + "pii_scrubbing": "enabled" + })); + } else { + event_data["contexts"] = json!({ + "tenant": { + "id": state.tenant_id, + "cluster": state.cluster_id, + "deployment": "on-prem", + "proxy_version": "2.0.0", + "pii_scrubbing": "enabled" + } + }); + } + + if let Some(user) = event_data.get_mut("user").and_then(|u| u.as_object_mut()) { + user.insert("tenant_id".to_string(), Value::String(state.tenant_id.clone())); + user.insert("cluster_id".to_string(), Value::String(state.cluster_id.clone())); + } + + event_data["environment"] = Value::String(format!("on-prem-{}", state.tenant_id)); + + event_data +} + +fn parse_envelope(envelope_text: &str) -> Result { + let lines: Vec<&str> = envelope_text.trim().split('\n').collect(); + + if lines.len() < 2 { + return Err("Invalid envelope: too few lines".to_string()); + } + + let envelope_header: Value = serde_json::from_str(lines[0]) + .map_err(|e| format!("Invalid envelope header: {}", e))?; + + let mut items = Vec::new(); + let mut i = 1; + + while i < lines.len() { + if i + 1 >= lines.len() { + warn!("Incomplete item pair at line {}, skipping", i); + break; + } + + let item_header: Value = match serde_json::from_str(lines[i]) { + Ok(h) => h, + Err(e) => { + error!("Invalid item header at line {}: {}", i, e); + i += 2; + continue; + } + }; + + let item_type = item_header.get("type").and_then(|t| t.as_str()).unwrap_or(""); + + let item_payload: Value = if matches!(item_type, "attachment" | "user_report") { + Value::String(lines[i + 1].to_string()) + } else { + serde_json::from_str(lines[i + 1]).unwrap_or_else(|_| Value::String(lines[i + 1].to_string())) + }; + + items.push(EnvelopeItem { + header: item_header, + payload: item_payload, + }); + + i += 2; + } + + Ok(Envelope { + header: envelope_header, + items, + }) +} + +fn serialize_envelope(envelope: &Envelope) -> String { + let mut lines = Vec::new(); + + lines.push(serde_json::to_string(&envelope.header).unwrap()); + + for item in &envelope.items { + lines.push(serde_json::to_string(&item.header).unwrap()); + + let payload_str = if item.payload.is_string() { + item.payload.as_str().unwrap().to_string() + } else { + serde_json::to_string(&item.payload).unwrap() + }; + lines.push(payload_str); + } + + lines.join("\n") +} + +fn process_envelope(mut envelope: Envelope, state: &AppState) -> Envelope { + if let Some(obj) = envelope.header.as_object_mut() { + obj.insert("tenant_id".to_string(), Value::String(state.tenant_id.clone())); + + if let Some(trace) = obj.get_mut("trace") { + if let Some(trace_obj) = trace.as_object_mut() { + trace_obj.insert("tenant_id".to_string(), Value::String(state.tenant_id.clone())); + } + } + } + + envelope.items = envelope.items.into_iter().map(|mut item| { + let item_type = item.header.get("type").and_then(|t| t.as_str()).unwrap_or(""); + + match item_type { + "event" | "transaction" => { + item.payload = scrub_pii(item.payload, state); + item.payload = enrich_with_tenant_info(item.payload, state); + } + "session" => { + if let Some(attrs) = item.payload.get_mut("attrs") { + scrub_value(attrs, state); + if let Some(attrs_obj) = attrs.as_object_mut() { + attrs_obj.insert("tenant_id".to_string(), Value::String(state.tenant_id.clone())); + } + } + } + "attachment" => { + info!("[{}] Forwarding attachment", state.tenant_id); + } + _ => {} + } + + item + }).collect(); + + envelope +} + +async fn health_check(State(state): State>) -> impl IntoResponse { + Json(json!({ + "status": "ok", + "tenant": state.tenant_id, + "relay": state.relay_url, + "pii_scrubbing": "enabled", + "envelope_support": "enabled" + })) +} + +async fn store_endpoint( + State(state): State>, + Path(project_id): Path, + Query(_params): Query>, + headers: HeaderMap, + Json(body): Json, +) -> impl IntoResponse { + info!("[{}] Processing event for project {}", state.tenant_id, project_id); + + let scrubbed_event = scrub_pii(body, &state); + let enriched_event = enrich_with_tenant_info(scrubbed_event, &state); + + let relay_url = format!("{}/api/{}/store/", state.relay_url, project_id); + + let mut request = state.client.post(&relay_url).json(&enriched_event); + + if let Some(auth) = headers.get("x-sentry-auth") { + if let Ok(auth_str) = auth.to_str() { + request = request.header("X-Sentry-Auth", auth_str); + } + } + if let Some(ua) = headers.get("user-agent") { + if let Ok(ua_str) = ua.to_str() { + request = request.header("User-Agent", ua_str); + } + } + + match request.timeout(std::time::Duration::from_secs(5)).send().await { + Ok(_response) => { + info!("[{}] Event forwarded successfully", state.tenant_id); + (StatusCode::OK, Json(json!({"status": "ok"}))) + } + Err(e) => { + error!("[{}] Proxy error: {}", state.tenant_id, e); + (StatusCode::OK, Json(json!({"status": "queued"}))) + } + } +} + +async fn envelope_endpoint( + State(state): State>, + Path(project_id): Path, + Query(_params): Query>, + headers: HeaderMap, + body: Bytes, +) -> impl IntoResponse { + info!("[{}] Processing envelope for project {}", state.tenant_id, project_id); + + let envelope_text = match String::from_utf8(body.to_vec()) { + Ok(text) => text, + Err(e) => { + error!("[{}] Invalid UTF-8 in envelope: {}", state.tenant_id, e); + return (StatusCode::OK, Json(json!({"status": "queued"}))); + } + }; + + let envelope = match parse_envelope(&envelope_text) { + Ok(env) => env, + Err(e) => { + error!("[{}] Envelope parsing error: {}", state.tenant_id, e); + return (StatusCode::OK, Json(json!({"status": "queued"}))); + } + }; + + info!("[{}] Envelope contains {} items", state.tenant_id, envelope.items.len()); + + let processed_envelope = process_envelope(envelope, &state); + let serialized_envelope = serialize_envelope(&processed_envelope); + + let relay_url = format!("{}/api/{}/envelope/", state.relay_url, project_id); + + let mut request = state.client + .post(&relay_url) + .header("Content-Type", "application/x-sentry-envelope") + .body(serialized_envelope); + + if let Some(auth) = headers.get("x-sentry-auth") { + if let Ok(auth_str) = auth.to_str() { + request = request.header("X-Sentry-Auth", auth_str); + } + } + if let Some(ua) = headers.get("user-agent") { + if let Ok(ua_str) = ua.to_str() { + request = request.header("User-Agent", ua_str); + } + } + + match request.timeout(std::time::Duration::from_secs(5)).send().await { + Ok(_) => { + info!("[{}] Envelope forwarded successfully", state.tenant_id); + (StatusCode::OK, Json(json!({"status": "ok"}))) + } + Err(e) => { + error!("[{}] Envelope proxy error: {}", state.tenant_id, e); + (StatusCode::OK, Json(json!({"status": "queued"}))) + } + } +} + +#[tokio::main] +async fn main() { + tracing_subscriber::fmt::init(); + + let tenant_id = std::env::var("TENANT_ID").expect("TENANT_ID must be set"); + let cluster_id = std::env::var("CLUSTER_ID").expect("CLUSTER_ID must be set"); + let port = std::env::var("PORT").unwrap_or_else(|_| "9000".to_string()); + + let state = Arc::new(AppState { + tenant_id: tenant_id.clone(), + cluster_id: cluster_id.clone(), + relay_url: "https://errors.metorial-enterprise.com".to_string().clone(), + client: reqwest::Client::new(), + pii_patterns: PiiPatterns::new(), + sensitive_fields: get_sensitive_fields(), + }); + + info!("Sentry proxy starting..."); + info!("Tenant: {}", tenant_id); + info!("PII scrubbing: ENABLED"); + info!("Envelope support: ENABLED"); + info!("Forwarding to: {}", state.relay_url); + + let app = Router::new() + .route("/health", get(health_check)) + .route("/api/:project_id/store/", post(store_endpoint)) + .route("/api/:project_id/envelope/", post(envelope_endpoint)) + .with_state(state); + + let addr = format!("0.0.0.0:{}", port); + let listener = tokio::net::TcpListener::bind(&addr).await.unwrap(); + + info!("Sentry proxy running on {}", addr); + + axum::serve(listener, app).await.unwrap(); +} + +#[cfg(test)] +mod tests { + use super::*; + use serde_json::json; + + fn create_test_state() -> AppState { + AppState { + tenant_id: "test-tenant".to_string(), + cluster_id: "test-cluster".to_string(), + relay_url: "https://test-relay.example.com".to_string(), + client: reqwest::Client::new(), + pii_patterns: PiiPatterns::new(), + sensitive_fields: get_sensitive_fields(), + } + } + + #[test] + fn test_pii_patterns_email() { + let state = create_test_state(); + let input = "Contact user@example.com for help"; + let result = scrub_string(input, &state.pii_patterns); + assert_eq!(result, "Contact [EMAIL] for help"); + } + + #[test] + fn test_pii_patterns_phone() { + let state = create_test_state(); + let input = "Call me at 555-123-4567"; + let result = scrub_string(input, &state.pii_patterns); + assert_eq!(result, "Call me at [PHONE]"); + } + + #[test] + fn test_pii_patterns_ssn() { + let state = create_test_state(); + let input = "SSN: 123-45-6789"; + let result = scrub_string(input, &state.pii_patterns); + assert_eq!(result, "SSN: [SSN]"); + } + + #[test] + fn test_pii_patterns_credit_card() { + let state = create_test_state(); + let input = "Card: 4532-1234-5678-9010"; + let result = scrub_string(input, &state.pii_patterns); + assert_eq!(result, "Card: [CREDIT-CARD]"); + } + + #[test] + fn test_pii_patterns_ipv4() { + let state = create_test_state(); + let input = "Server at 192.168.1.1"; + let result = scrub_string(input, &state.pii_patterns); + assert_eq!(result, "Server at [IP]"); + } + + #[test] + fn test_pii_patterns_jwt() { + let state = create_test_state(); + let input = "Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U"; + let result = scrub_string(input, &state.pii_patterns); + assert!(result.contains("[JWT-TOKEN]")); + } + + #[test] + fn test_scrub_value_string() { + let state = create_test_state(); + let mut value = Value::String("Email: test@example.com".to_string()); + scrub_value(&mut value, &state); + assert_eq!(value.as_str().unwrap(), "Email: [EMAIL]"); + } + + #[test] + fn test_scrub_value_nested_object() { + let state = create_test_state(); + let mut value = json!({ + "user": { + "email": "test@example.com", + "password": "secret123" + } + }); + scrub_value(&mut value, &state); + assert_eq!(value["user"]["password"], "[REDACTED]"); + } + + #[test] + fn test_scrub_value_array() { + let state = create_test_state(); + let mut value = json!(["user@example.com", "another@test.com"]); + scrub_value(&mut value, &state); + assert_eq!(value[0].as_str().unwrap(), "[EMAIL]"); + assert_eq!(value[1].as_str().unwrap(), "[EMAIL]"); + } + + #[test] + fn test_is_sensitive_key() { + let sensitive_fields = get_sensitive_fields(); + assert!(is_sensitive_key("password", &sensitive_fields)); + assert!(is_sensitive_key("api_key", &sensitive_fields)); + assert!(is_sensitive_key("API_KEY", &sensitive_fields)); + assert!(is_sensitive_key("user_password", &sensitive_fields)); + assert!(!is_sensitive_key("username", &sensitive_fields)); + } + + #[test] + fn test_scrub_pii_request_headers() { + let state = create_test_state(); + let event = json!({ + "request": { + "headers": { + "Authorization": "Bearer token123", + "Cookie": "session=abc123", + "X-API-Key": "secret-key", + "Content-Type": "application/json" + } + } + }); + let result = scrub_pii(event, &state); + let headers = result["request"]["headers"].as_object().unwrap(); + assert!(!headers.contains_key("Authorization")); + assert!(!headers.contains_key("Cookie")); + assert!(!headers.contains_key("X-API-Key")); + assert!(headers.contains_key("Content-Type")); + } + + #[test] + fn test_scrub_pii_user_data() { + let state = create_test_state(); + let event = json!({ + "user": { + "email": "user@example.com", + "ip_address": "192.168.1.1", + "username": "testuser" + } + }); + let result = scrub_pii(event, &state); + assert_eq!(result["user"]["email"], "[EMAIL]"); + assert_eq!(result["user"]["ip_address"], "[IP]"); + assert_eq!(result["user"]["username"], "tes***"); + } + + #[test] + fn test_scrub_pii_exception_values() { + let state = create_test_state(); + let event = json!({ + "exception": { + "values": [{ + "value": "Error: API key abc123xyz_very_long_api_key_string_here failed", + "stacktrace": { + "frames": [{ + "vars": { + "password": "secret123", + "user_email": "test@example.com" + } + }] + } + }] + } + }); + let result = scrub_pii(event, &state); + assert!(result["exception"]["values"][0]["value"].as_str().unwrap().contains("[KEY]")); + assert_eq!(result["exception"]["values"][0]["stacktrace"]["frames"][0]["vars"]["password"], "[REDACTED]"); + } + + #[test] + fn test_enrich_with_tenant_info() { + let state = create_test_state(); + let event = json!({ + "message": "Test event" + }); + let result = enrich_with_tenant_info(event, &state); + + assert_eq!(result["tags"]["tenant_id"], "test-tenant"); + assert_eq!(result["tags"]["cluster_id"], "test-cluster"); + assert_eq!(result["tags"]["deployment_type"], "on-prem"); + assert_eq!(result["contexts"]["tenant"]["id"], "test-tenant"); + assert_eq!(result["contexts"]["tenant"]["cluster"], "test-cluster"); + assert_eq!(result["environment"], "on-prem-test-tenant"); + } + + #[test] + fn test_parse_envelope_simple() { + let envelope_text = r#"{"event_id":"12345"} +{"type":"event"} +{"message":"test"}"#; + + let result = parse_envelope(envelope_text); + assert!(result.is_ok()); + let envelope = result.unwrap(); + assert_eq!(envelope.items.len(), 1); + assert_eq!(envelope.items[0].header["type"], "event"); + } + + #[test] + fn test_parse_envelope_multiple_items() { + let envelope_text = r#"{"event_id":"12345"} +{"type":"event"} +{"message":"test1"} +{"type":"transaction"} +{"message":"test2"}"#; + + let result = parse_envelope(envelope_text); + assert!(result.is_ok()); + let envelope = result.unwrap(); + assert_eq!(envelope.items.len(), 2); + } + + #[test] + fn test_parse_envelope_invalid() { + let envelope_text = "invalid json"; + let result = parse_envelope(envelope_text); + assert!(result.is_err()); + } + + #[test] + fn test_serialize_envelope() { + let envelope = Envelope { + header: json!({"event_id": "12345"}), + items: vec![ + EnvelopeItem { + header: json!({"type": "event"}), + payload: json!({"message": "test"}), + } + ], + }; + + let serialized = serialize_envelope(&envelope); + let lines: Vec<&str> = serialized.split('\n').collect(); + assert_eq!(lines.len(), 3); + assert!(lines[0].contains("event_id")); + assert!(lines[1].contains("event")); + assert!(lines[2].contains("test")); + } + + #[test] + fn test_process_envelope_enrichment() { + let state = create_test_state(); + let envelope = Envelope { + header: json!({"event_id": "12345"}), + items: vec![ + EnvelopeItem { + header: json!({"type": "event"}), + payload: json!({"message": "test event"}), + } + ], + }; + + let processed = process_envelope(envelope, &state); + assert_eq!(processed.header["tenant_id"], "test-tenant"); + assert_eq!(processed.items[0].payload["tags"]["tenant_id"], "test-tenant"); + } + + #[test] + fn test_process_envelope_scrubbing() { + let state = create_test_state(); + let envelope = Envelope { + header: json!({"event_id": "12345"}), + items: vec![ + EnvelopeItem { + header: json!({"type": "event"}), + payload: json!({ + "user": { + "email": "user@example.com" + } + }), + } + ], + }; + + let processed = process_envelope(envelope, &state); + assert_eq!(processed.items[0].payload["user"]["email"], "[EMAIL]"); + } + + #[test] + fn test_multiple_pii_patterns() { + let state = create_test_state(); + let input = "Contact user@example.com at 555-123-4567 or 192.168.1.1"; + let result = scrub_string(input, &state.pii_patterns); + assert!(result.contains("[EMAIL]")); + assert!(result.contains("[PHONE]")); + assert!(result.contains("[IP]")); + } +} \ No newline at end of file diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs new file mode 100644 index 0000000..8ed751a --- /dev/null +++ b/tests/integration_tests.rs @@ -0,0 +1,129 @@ +use serde_json::{json, Value}; + +// Note: These are placeholder integration tests that demonstrate the structure. +// To run full integration tests, you would need to refactor main.rs to export +// the router creation logic or use axum-test with a test server. + +#[tokio::test] +async fn test_health_endpoint_structure() { + // This test demonstrates the expected structure + // In a full implementation, you would create the actual router and test it + let expected_response = json!({ + "status": "ok", + "tenant": "test-tenant", + "relay": "https://test-relay.example.com", + "pii_scrubbing": "enabled", + "envelope_support": "enabled" + }); + + assert_eq!(expected_response["status"], "ok"); + assert_eq!(expected_response["pii_scrubbing"], "enabled"); +} + +#[tokio::test] +async fn test_store_endpoint_structure() { + let test_event = json!({ + "message": "Test error message", + "level": "error", + "user": { + "email": "test@example.com" + } + }); + + assert!(test_event.get("message").is_some()); + assert!(test_event.get("user").is_some()); +} + +#[tokio::test] +async fn test_envelope_parsing() { + let envelope_text = r#"{"event_id":"12345","sent_at":"2024-01-01T00:00:00Z"} +{"type":"event","length":100} +{"message":"test event","level":"error"}"#; + + let lines: Vec<&str> = envelope_text.split('\n').collect(); + assert_eq!(lines.len(), 3); + + // Verify header is valid JSON + let header: Value = serde_json::from_str(lines[0]).unwrap(); + assert_eq!(header["event_id"], "12345"); + + // Verify item header is valid JSON + let item_header: Value = serde_json::from_str(lines[1]).unwrap(); + assert_eq!(item_header["type"], "event"); + + // Verify item payload is valid JSON + let item_payload: Value = serde_json::from_str(lines[2]).unwrap(); + assert_eq!(item_payload["message"], "test event"); +} + +#[test] +fn test_sensitive_headers_list() { + let sensitive_headers = vec![ + "Authorization", + "Cookie", + "X-API-Key", + "X-Auth-Token", + ]; + + assert!(sensitive_headers.contains(&"Authorization")); + assert!(sensitive_headers.contains(&"Cookie")); + assert!(!sensitive_headers.contains(&"Content-Type")); +} + +#[test] +fn test_tenant_enrichment_structure() { + let tenant_id = "test-tenant-123"; + let cluster_id = "cluster-456"; + + let tags = json!({ + "tenant_id": tenant_id, + "cluster_id": cluster_id, + "deployment_type": "on-prem", + "pii_scrubbed": "on-prem" + }); + + assert_eq!(tags["tenant_id"], tenant_id); + assert_eq!(tags["cluster_id"], cluster_id); + assert_eq!(tags["deployment_type"], "on-prem"); +} + +#[test] +fn test_environment_variables() { + // Test that environment variable keys are correctly defined + let required_env_vars = vec!["TENANT_ID", "CLUSTER_ID", "PORT"]; + + assert!(required_env_vars.contains(&"TENANT_ID")); + assert!(required_env_vars.contains(&"CLUSTER_ID")); + assert!(required_env_vars.contains(&"PORT")); +} + +#[test] +fn test_api_endpoints_paths() { + let endpoints = vec![ + "/health", + "/api/:project_id/store/", + "/api/:project_id/envelope/", + ]; + + assert!(endpoints.contains(&"/health")); + assert!(endpoints.contains(&"/api/:project_id/store/")); + assert!(endpoints.contains(&"/api/:project_id/envelope/")); +} + +#[tokio::test] +async fn test_json_serialization() { + let event = json!({ + "event_id": "test-123", + "message": "Test message", + "tags": { + "tenant_id": "tenant-1" + } + }); + + let serialized = serde_json::to_string(&event).unwrap(); + assert!(serialized.contains("test-123")); + assert!(serialized.contains("tenant-1")); + + let deserialized: Value = serde_json::from_str(&serialized).unwrap(); + assert_eq!(deserialized["event_id"], "test-123"); +} From 11cbf0b96fa4fd08325fc7c3ae15bce067bc2e62 Mon Sep 17 00:00:00 2001 From: Tobias Herber <22559657+herber@users.noreply.github.com> Date: Fri, 5 Dec 2025 16:11:32 -0800 Subject: [PATCH 2/7] Add readme --- README.md | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..ae8dc3c --- /dev/null +++ b/README.md @@ -0,0 +1,80 @@ +# Error Outpost (Sentry Proxy) + +A Sentry proxy with PII scrubbing and tenant enrichment for on-premise deployments. + +## Motivation + +Metorial is a system meant to be deployed on-premises, but we still want to leverage Sentry for error tracking. However, sending raw error data directly to Sentry can expose sensitive information and is simply not acceptable for many organizations. This proxy addresses these concerns by: +- Scrubbing Personally Identifiable Information (PII) from error events +- Enriching events with tenant and cluster metadata +- Limiting which Sentry features are used to reduce data exposure + +## Features + +- **PII Scrubbing**: Automatically scrubs sensitive data including: + - Email addresses + - Phone numbers + - Social Security Numbers (SSN) + - Credit card numbers + - IP addresses (IPv4 & IPv6) + - JWT tokens + - API keys + - UUIDs + - Sensitive headers (Authorization, Cookie, etc.) + - Sensitive field names (password, api_key, etc.) +- **Tenant Enrichment**: Adds tenant and cluster information to all events +- **Envelope Support**: Full support for Sentry's envelope protocol + +## Configuration + +Set the following environment variables: + +- `TENANT_ID` (required): Unique identifier for the tenant +- `CLUSTER_ID` (required): Unique identifier for the cluster +- `PORT` (optional, default: 9000): Port to listen on + +## Usage + +### Local Development + +```bash +export TENANT_ID=my-tenant +export CLUSTER_ID=my-cluster +export PORT=9000 +cargo run +``` + +### Docker + +```bash +# Build the image +docker build -t ghcr.io/metorial/error-outpost . + +# Run the container +docker run -p 9000:9000 \ + -e TENANT_ID=my-tenant \ + -e CLUSTER_ID=my-cluster \ + ghcr.io/metorial/error-outpost +``` + +## Security + +This proxy is designed for on-premise deployments and includes: +- Automatic PII scrubbing before forwarding to central relay +- Removal of authentication headers and cookies +- Redaction of sensitive environment variables +- Scrubbing of stack trace variables + +## Architecture + +``` +[Sentry SDK] -> [Error Outpost] -> [Central Relay] -> [Sentry.io] + | + +-> PII Scrubbing + +-> Tenant Enrichment + +-> Metadata Tagging +``` + +## License + +Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) file for details. From 10f43becfdcaabbc83b9b1ac3f4cf0ffdc607ea2 Mon Sep 17 00:00:00 2001 From: Tobias Herber <22559657+herber@users.noreply.github.com> Date: Fri, 5 Dec 2025 16:11:58 -0800 Subject: [PATCH 3/7] Add ci workflow --- .github/workflows/ci.yml | 127 ++++++++++++++++++++++++++++++++++++ .github/workflows/legal.yml | 12 ++++ 2 files changed, 139 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/legal.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b132a06 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,127 @@ +name: CI/CD + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + release: + types: [ created ] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + components: rustfmt, clippy + + - name: Cache cargo registry + uses: actions/cache@v4 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-registry- + + - name: Cache cargo index + uses: actions/cache@v4 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-git- + + - name: Cache target directory + uses: actions/cache@v4 + with: + path: target + key: ${{ runner.os }}-target-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-target- + + - name: Check formatting + run: cargo fmt --all -- --check + + - name: Run clippy + run: cargo clippy -- -D warnings + + - name: Run tests + run: cargo test --verbose + + - name: Run tests with coverage + run: cargo test --verbose --all-features + + build: + name: Build Docker Image + runs-on: ubuntu-latest + needs: test + permissions: + contents: read + packages: write + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha,prefix={{branch}}- + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + platforms: linux/amd64,linux/arm64 + + security: + name: Security Audit + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + + - name: Run cargo audit + uses: actions-rs/audit-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/legal.yml b/.github/workflows/legal.yml new file mode 100644 index 0000000..b7cc1b6 --- /dev/null +++ b/.github/workflows/legal.yml @@ -0,0 +1,12 @@ +name: Check Legal Boilerplate + +on: + pull_request: + types: [opened, edited, synchronize, reopened] + +jobs: + legal: + permissions: + pull-requests: write + contents: read + uses: metorial/.github/.github/workflows/legal-boilerplate.yml@main From 206f0dee79735dc8e688892a3ec3c96601c93497 Mon Sep 17 00:00:00 2001 From: Tobias Herber <22559657+herber@users.noreply.github.com> Date: Fri, 5 Dec 2025 16:14:03 -0800 Subject: [PATCH 4/7] oops --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b132a06..1d8e679 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,9 +50,6 @@ jobs: restore-keys: | ${{ runner.os }}-target- - - name: Check formatting - run: cargo fmt --all -- --check - - name: Run clippy run: cargo clippy -- -D warnings From 44353555da27aad37d6824db3e017f922f15555e Mon Sep 17 00:00:00 2001 From: Tobias Herber <22559657+herber@users.noreply.github.com> Date: Fri, 5 Dec 2025 16:18:03 -0800 Subject: [PATCH 5/7] Fix build --- src/main.rs | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main.rs b/src/main.rs index 49b80d2..6be657a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -339,10 +339,10 @@ fn process_envelope(mut envelope: Envelope, state: &AppState) -> Envelope { if let Some(obj) = envelope.header.as_object_mut() { obj.insert("tenant_id".to_string(), Value::String(state.tenant_id.clone())); - if let Some(trace) = obj.get_mut("trace") { - if let Some(trace_obj) = trace.as_object_mut() { - trace_obj.insert("tenant_id".to_string(), Value::String(state.tenant_id.clone())); - } + if let Some(trace) = obj.get_mut("trace") + && let Some(trace_obj) = trace.as_object_mut() + { + trace_obj.insert("tenant_id".to_string(), Value::String(state.tenant_id.clone())); } } @@ -400,15 +400,15 @@ async fn store_endpoint( let mut request = state.client.post(&relay_url).json(&enriched_event); - if let Some(auth) = headers.get("x-sentry-auth") { - if let Ok(auth_str) = auth.to_str() { - request = request.header("X-Sentry-Auth", auth_str); - } + if let Some(auth) = headers.get("x-sentry-auth") + && let Ok(auth_str) = auth.to_str() + { + request = request.header("X-Sentry-Auth", auth_str); } - if let Some(ua) = headers.get("user-agent") { - if let Ok(ua_str) = ua.to_str() { - request = request.header("User-Agent", ua_str); - } + if let Some(ua) = headers.get("user-agent") + && let Ok(ua_str) = ua.to_str() + { + request = request.header("User-Agent", ua_str); } match request.timeout(std::time::Duration::from_secs(5)).send().await { @@ -460,15 +460,15 @@ async fn envelope_endpoint( .header("Content-Type", "application/x-sentry-envelope") .body(serialized_envelope); - if let Some(auth) = headers.get("x-sentry-auth") { - if let Ok(auth_str) = auth.to_str() { - request = request.header("X-Sentry-Auth", auth_str); - } + if let Some(auth) = headers.get("x-sentry-auth") + && let Ok(auth_str) = auth.to_str() + { + request = request.header("X-Sentry-Auth", auth_str); } - if let Some(ua) = headers.get("user-agent") { - if let Ok(ua_str) = ua.to_str() { - request = request.header("User-Agent", ua_str); - } + if let Some(ua) = headers.get("user-agent") + && let Ok(ua_str) = ua.to_str() + { + request = request.header("User-Agent", ua_str); } match request.timeout(std::time::Duration::from_secs(5)).send().await { From d2c0440ad61a923d4b49e64afd3ed35dcb00d190 Mon Sep 17 00:00:00 2001 From: Tobias Herber <22559657+herber@users.noreply.github.com> Date: Fri, 5 Dec 2025 16:28:36 -0800 Subject: [PATCH 6/7] oops --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d8e679..c4feab6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,7 +92,7 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} - type=sha,prefix={{branch}}- + type=sha,prefix=sha- type=raw,value=latest,enable={{is_default_branch}} - name: Build and push Docker image From 5823a2020498ff1d6daf449d0127ad027cd4e074 Mon Sep 17 00:00:00 2001 From: Tobias Herber <22559657+herber@users.noreply.github.com> Date: Fri, 5 Dec 2025 16:53:00 -0800 Subject: [PATCH 7/7] Fix build --- Cargo.toml | 2 +- Dockerfile | 7 ++++++- src/main.rs | 42 ++++++++++++++++++++++-------------------- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3bb395b..b2dbcc8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "error-outpost" version = "0.1.0" -edition = "2024" +edition = "2021" [dependencies] axum = "0.7" diff --git a/Dockerfile b/Dockerfile index a65aa4a..05efd73 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,13 @@ # Build stage -FROM rust:1.75-slim as builder +FROM rust:1.91-slim AS builder WORKDIR /app +# Install build dependencies +RUN apt-get update && \ + apt-get install -y pkg-config libssl-dev && \ + rm -rf /var/lib/apt/lists/* + # Copy manifests COPY Cargo.toml Cargo.lock ./ diff --git a/src/main.rs b/src/main.rs index 6be657a..aa3d2bf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +#![allow(clippy::collapsible_if)] + use axum::{ body::Bytes, extract::{Path, Query, State}, @@ -339,10 +341,10 @@ fn process_envelope(mut envelope: Envelope, state: &AppState) -> Envelope { if let Some(obj) = envelope.header.as_object_mut() { obj.insert("tenant_id".to_string(), Value::String(state.tenant_id.clone())); - if let Some(trace) = obj.get_mut("trace") - && let Some(trace_obj) = trace.as_object_mut() - { - trace_obj.insert("tenant_id".to_string(), Value::String(state.tenant_id.clone())); + if let Some(trace) = obj.get_mut("trace") { + if let Some(trace_obj) = trace.as_object_mut() { + trace_obj.insert("tenant_id".to_string(), Value::String(state.tenant_id.clone())); + } } } @@ -400,15 +402,15 @@ async fn store_endpoint( let mut request = state.client.post(&relay_url).json(&enriched_event); - if let Some(auth) = headers.get("x-sentry-auth") - && let Ok(auth_str) = auth.to_str() - { - request = request.header("X-Sentry-Auth", auth_str); + if let Some(auth) = headers.get("x-sentry-auth") { + if let Ok(auth_str) = auth.to_str() { + request = request.header("X-Sentry-Auth", auth_str); + } } - if let Some(ua) = headers.get("user-agent") - && let Ok(ua_str) = ua.to_str() - { - request = request.header("User-Agent", ua_str); + if let Some(ua) = headers.get("user-agent") { + if let Ok(ua_str) = ua.to_str() { + request = request.header("User-Agent", ua_str); + } } match request.timeout(std::time::Duration::from_secs(5)).send().await { @@ -460,15 +462,15 @@ async fn envelope_endpoint( .header("Content-Type", "application/x-sentry-envelope") .body(serialized_envelope); - if let Some(auth) = headers.get("x-sentry-auth") - && let Ok(auth_str) = auth.to_str() - { - request = request.header("X-Sentry-Auth", auth_str); + if let Some(auth) = headers.get("x-sentry-auth") { + if let Ok(auth_str) = auth.to_str() { + request = request.header("X-Sentry-Auth", auth_str); + } } - if let Some(ua) = headers.get("user-agent") - && let Ok(ua_str) = ua.to_str() - { - request = request.header("User-Agent", ua_str); + if let Some(ua) = headers.get("user-agent") { + if let Ok(ua_str) = ua.to_str() { + request = request.header("User-Agent", ua_str); + } } match request.timeout(std::time::Duration::from_secs(5)).send().await {