From 4b9cb512f246ce9ccb027dcbbf2513a6489a70e3 Mon Sep 17 00:00:00 2001 From: houseme Date: Thu, 18 Sep 2025 17:46:46 +0800 Subject: [PATCH] remove crate `rustfs-audit-logger` (#562) --- Cargo.lock | 430 +++++++++---------- Cargo.toml | 22 +- crates/audit-logger/Cargo.toml | 44 -- crates/audit-logger/examples/config.json | 34 -- crates/audit-logger/examples/main.rs | 17 - crates/audit-logger/src/entry/args.rs | 90 ---- crates/audit-logger/src/entry/audit.rs | 469 --------------------- crates/audit-logger/src/entry/base.rs | 108 ----- crates/audit-logger/src/entry/mod.rs | 159 ------- crates/audit-logger/src/entry/unified.rs | 266 ------------ crates/audit-logger/src/lib.rs | 8 - crates/audit-logger/src/logger/config.rs | 29 -- crates/audit-logger/src/logger/dispatch.rs | 13 - crates/audit-logger/src/logger/entry.rs | 108 ----- crates/audit-logger/src/logger/factory.rs | 13 - crates/audit-logger/src/logger/mod.rs | 36 -- rustfs/Cargo.toml | 1 - 17 files changed, 227 insertions(+), 1620 deletions(-) delete mode 100644 crates/audit-logger/Cargo.toml delete mode 100644 crates/audit-logger/examples/config.json delete mode 100644 crates/audit-logger/examples/main.rs delete mode 100644 crates/audit-logger/src/entry/args.rs delete mode 100644 crates/audit-logger/src/entry/audit.rs delete mode 100644 crates/audit-logger/src/entry/base.rs delete mode 100644 crates/audit-logger/src/entry/mod.rs delete mode 100644 crates/audit-logger/src/entry/unified.rs delete mode 100644 crates/audit-logger/src/lib.rs delete mode 100644 crates/audit-logger/src/logger/config.rs delete mode 100644 crates/audit-logger/src/logger/dispatch.rs delete mode 100644 crates/audit-logger/src/logger/entry.rs delete mode 100644 crates/audit-logger/src/logger/factory.rs delete mode 100644 crates/audit-logger/src/logger/mod.rs diff --git a/Cargo.lock b/Cargo.lock index e374f706..a15dc3b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -444,7 +444,7 @@ version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06575e6a9673580f52661c92107baabffbf41e2141373441cbcdc47cb733003c" dependencies = [ - "bzip2", + "bzip2 0.5.2", "flate2", "futures-core", "memchr", @@ -519,15 +519,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "atomic" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a89cbf775b137e9b968e67227ef7f775587cde3fd31b0d8599dbd0f598a48340" -dependencies = [ - "bytemuck", -] - [[package]] name = "atomic-waker" version = "1.1.2" @@ -643,9 +634,9 @@ dependencies = [ [[package]] name = "aws-sdk-s3" -version = "1.102.0" +version = "1.106.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ddb925e840f49446aa6338b67abdbec04b4ebf923b7da038ec4c35afb916cd" +checksum = "2c230530df49ed3f2b7b4d9c8613b72a04cdac6452eede16d587fc62addfabac" dependencies = [ "aws-credential-types", "aws-runtime", @@ -677,9 +668,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.83.0" +version = "1.84.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cd43af212d2a1c4dedff6f044d7e1961e5d9e7cfe773d70f31d9842413886" +checksum = "357a841807f6b52cb26123878b3326921e2a25faca412fabdd32bd35b7edd5d3" dependencies = [ "aws-credential-types", "aws-runtime", @@ -699,9 +690,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.84.0" +version = "1.85.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20ec4a95bd48e0db7a424356a161f8d87bd6a4f0af37204775f0da03d9e39fc3" +checksum = "67e05f33b6c9026fecfe9b3b6740f34d41bc6ff641a6a32dabaab60209245b75" dependencies = [ "aws-credential-types", "aws-runtime", @@ -721,9 +712,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.85.0" +version = "1.86.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "410309ad0df4606bc721aff0d89c3407682845453247213a0ccc5ff8801ee107" +checksum = "e7d835f123f307cafffca7b9027c14979f1d403b417d8541d67cf252e8a21e35" dependencies = [ "aws-credential-types", "aws-runtime", @@ -783,9 +774,9 @@ dependencies = [ [[package]] name = "aws-smithy-checksums" -version = "0.63.6" +version = "0.63.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9054b4cc5eda331cde3096b1576dec45365c5cbbca61d1fffa5f236e251dfce7" +checksum = "56d2df0314b8e307995a3b86d44565dfe9de41f876901a7d71886c756a25979f" dependencies = [ "aws-smithy-http", "aws-smithy-types", @@ -858,7 +849,7 @@ dependencies = [ "rustls-native-certs 0.8.1", "rustls-pki-types", "tokio", - "tokio-rustls 0.26.2", + "tokio-rustls 0.26.3", "tower", "tracing", ] @@ -1075,7 +1066,7 @@ dependencies = [ "rustls-pemfile 2.2.0", "rustls-pki-types", "tokio", - "tokio-rustls 0.26.2", + "tokio-rustls 0.26.3", "tower-service", ] @@ -1294,15 +1285,15 @@ dependencies = [ [[package]] name = "bytesize" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3c8f83209414aacf0eeae3cf730b18d6981697fba62f200fcfb92b9f082acba" +checksum = "f5c434ae3cf0089ca203e9019ebe529c47ff45cefe8af7c85ecb734ef541822f" [[package]] name = "bytestring" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e465647ae23b2823b0753f50decb2d5a86d2bb2cac04788fafd1f80e45378e5f" +checksum = "113b4343b5f6617e7ad401ced8de3cc8b012e73a594347c307b90db3e9271289" dependencies = [ "bytes", ] @@ -1316,6 +1307,15 @@ dependencies = [ "bzip2-sys", ] +[[package]] +name = "bzip2" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bea8dcd42434048e4f7a304411d9273a411f647446c1234a65ce0554923f4cff" +dependencies = [ + "libbz2-rs-sys", +] + [[package]] name = "bzip2-sys" version = "0.1.13+1.0.8" @@ -1328,11 +1328,11 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.12" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0b03af37dad7a14518b7691d81acb0f8222604ad3d1b02f6b4bed5188c0cd5" +checksum = "e1de8bc0aa9e9385ceb3bf0c152e3a9b9544f6c4a912c8ae504e80c1f0368603" dependencies = [ - "serde", + "serde_core", ] [[package]] @@ -1383,9 +1383,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.36" +version = "1.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5252b3d2648e5eedbc1a6f501e3c795e07025c1e93bbf8bbdd6eef7f447a6d54" +checksum = "65193589c6404eb80b450d618eaf9a2cafaaafd57ecce47370519ef674a7bd44" dependencies = [ "find-msvc-tools", "jobserver", @@ -1730,16 +1730,15 @@ checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" [[package]] name = "crc-fast" -version = "1.5.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61dd931a9d071dc6e36b8735c501601428c5aa5dfd6d2506b935498ef57e0098" +checksum = "6bf62af4cc77d8fe1c22dde4e721d87f2f54056139d8c412e1366b740305f56f" dependencies = [ "crc", "digest 0.10.7", "libc", "rand 0.9.2", "regex", - "rustversion", ] [[package]] @@ -2030,7 +2029,7 @@ dependencies = [ "arrow-schema", "async-trait", "bytes", - "bzip2", + "bzip2 0.5.2", "chrono", "datafusion-catalog", "datafusion-catalog-listing", @@ -2156,7 +2155,7 @@ dependencies = [ "async-compression", "async-trait", "bytes", - "bzip2", + "bzip2 0.5.2", "chrono", "datafusion-catalog", "datafusion-common", @@ -2792,11 +2791,12 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "erased-serde" -version = "0.4.6" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e004d887f51fcb9fef17317a2f3525c887d8aa3f4f50fed920816a688284a5b7" +checksum = "259d404d09818dec19332e31d94558aeb442fea04c817006456c24b5460bbd4b" dependencies = [ "serde", + "serde_core", "typeid", ] @@ -2847,20 +2847,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "figment" -version = "0.10.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cb01cd46b0cf372153850f4c6c272d9cbea2da513e07538405148f95bd789f3" -dependencies = [ - "atomic", - "pear", - "serde", - "serde_json", - "uncased", - "version_check", -] - [[package]] name = "filetime" version = "0.2.26" @@ -2930,6 +2916,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" dependencies = [ "crc32fast", + "libz-rs-sys", "miniz_oxide", ] @@ -2989,9 +2976,9 @@ dependencies = [ [[package]] name = "fs-err" -version = "3.1.1" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d7be93788013f265201256d58f04936a8079ad5dc898743aa20525f503b683" +checksum = "44f150ffc8782f35521cec2b23727707cb4045706ba3c854e86bef66b3a8cdbd" dependencies = [ "autocfg", "tokio", @@ -3148,7 +3135,7 @@ dependencies = [ "js-sys", "libc", "r-efi", - "wasi 0.14.5+wasi-0.2.4", + "wasi 0.14.7+wasi-0.2.4", "wasm-bindgen", ] @@ -3306,7 +3293,7 @@ dependencies = [ "thiserror 2.0.16", "tinyvec", "tokio", - "tokio-rustls 0.26.2", + "tokio-rustls 0.26.3", "tracing", "url", ] @@ -3330,7 +3317,7 @@ dependencies = [ "smallvec", "thiserror 2.0.16", "tokio", - "tokio-rustls 0.26.2", + "tokio-rustls 0.26.3", "tracing", ] @@ -3527,7 +3514,7 @@ dependencies = [ "rustls-native-certs 0.8.1", "rustls-pki-types", "tokio", - "tokio-rustls 0.26.2", + "tokio-rustls 0.26.3", "tower-service", "webpki-roots", ] @@ -3547,9 +3534,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d9b05277c7e8da2c93a568989bb6207bef0112e8d17df7a6eda4a3cf143bc5e" +checksum = "3c6995591a8f1380fcb4ba966a252a4b29188d51d2b89e3a252f5305be65aea8" dependencies = [ "base64 0.22.1", "bytes", @@ -3573,9 +3560,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.63" +version = "0.1.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -3583,7 +3570,7 @@ dependencies = [ "js-sys", "log", "wasm-bindgen", - "windows-core", + "windows-core 0.62.0", ] [[package]] @@ -3710,9 +3697,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.11.1" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206a8042aec68fa4a62e8d3f7aa4ceb508177d9324faf261e1959e495b7a1921" +checksum = "92119844f513ffa41556430369ab02c295a3578af21cf945caa3e9e0c2481ac3" dependencies = [ "equivalent", "hashbrown 0.15.5", @@ -3736,12 +3723,6 @@ dependencies = [ "str_stack", ] -[[package]] -name = "inlinable_string" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb" - [[package]] name = "inotify" version = "0.11.0" @@ -3884,9 +3865,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.78" +version = "0.3.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c0b063578492ceec17683ef2f8c5e89121fbd0b172cbc280635ab7567db2738" +checksum = "852f13bec5eba4ba9afbeb93fd7c13fe56147f055939ae21c43a29a0ecb2702e" dependencies = [ "once_cell", "wasm-bindgen", @@ -4000,6 +3981,12 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "libbz2-rs-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c4a545a15244c7d945065b5d392b2d2d7f21526fba56ce51467b06ed445e8f7" + [[package]] name = "libc" version = "0.2.175" @@ -4034,9 +4021,9 @@ dependencies = [ [[package]] name = "libredox" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "391290121bad3d37fbddad76d8f5d1c1c314cfc646d143d7e07a3086ddff0ce3" +checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb" dependencies = [ "bitflags 2.9.4", "libc", @@ -4061,6 +4048,15 @@ dependencies = [ "uuid", ] +[[package]] +name = "libz-rs-sys" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "840db8cf39d9ec4dd794376f38acc40d0fc65eec2a8f484f7fd375b84602becd" +dependencies = [ + "zlib-rs", +] + [[package]] name = "libz-sys" version = "1.1.22" @@ -4180,13 +4176,13 @@ dependencies = [ ] [[package]] -name = "lzma-rs" -version = "0.3.0" +name = "lzma-rust2" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "297e814c836ae64db86b36cf2a557ba54368d03f6afcd7d947c266692f71115e" +checksum = "c60a23ffb90d527e23192f1246b14746e2f7f071cb84476dd879071696c18a4a" dependencies = [ - "byteorder", "crc", + "sha2 0.10.9", ] [[package]] @@ -4988,29 +4984,6 @@ dependencies = [ "hmac 0.12.1", ] -[[package]] -name = "pear" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdeeaa00ce488657faba8ebf44ab9361f9365a97bd39ffb8a60663f57ff4b467" -dependencies = [ - "inlinable_string", - "pear_codegen", - "yansi", -] - -[[package]] -name = "pear_codegen" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bab5b985dc082b345f812b7df84e1bef27e7207b39e448439ba8bd69c93f147" -dependencies = [ - "proc-macro2", - "proc-macro2-diagnostics", - "quote", - "syn 2.0.106", -] - [[package]] name = "pem" version = "3.0.5" @@ -5205,6 +5178,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" +[[package]] +name = "ppmd-rust" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c834641d8ad1b348c9ee86dec3b9840d805acd5f24daa5f90c788951a52ff59b" + [[package]] name = "pprof" version = "0.15.0" @@ -5260,11 +5239,11 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" +checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" dependencies = [ - "toml_edit", + "toml_edit 0.23.5", ] [[package]] @@ -5276,19 +5255,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "proc-macro2-diagnostics" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.106", - "version_check", - "yansi", -] - [[package]] name = "prost" version = "0.13.5" @@ -5807,7 +5773,7 @@ dependencies = [ "serde_urlencoded", "sync_wrapper", "tokio", - "tokio-rustls 0.26.2", + "tokio-rustls 0.26.3", "tokio-util", "tower", "tower-http", @@ -5822,9 +5788,9 @@ dependencies = [ [[package]] name = "resolv-conf" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95325155c684b1c89f7765e30bc1c42e4a6da51ca513615660cb8a62ef9a88e3" +checksum = "6b3789b30bd25ba102de4beabd95d21ac45b69b1be7d14522bab988c526d6799" [[package]] name = "rfc6979" @@ -5952,7 +5918,7 @@ dependencies = [ "rustls-webpki 0.102.8", "thiserror 2.0.16", "tokio", - "tokio-rustls 0.26.2", + "tokio-rustls 0.26.3", "tokio-stream", "tokio-util", ] @@ -6045,7 +6011,6 @@ dependencies = [ "rust-embed", "rustfs-ahm", "rustfs-appauth", - "rustfs-audit-logger", "rustfs-common", "rustfs-config", "rustfs-ecstore", @@ -6074,7 +6039,7 @@ dependencies = [ "tikv-jemallocator", "time", "tokio", - "tokio-rustls 0.26.2", + "tokio-rustls 0.26.3", "tokio-stream", "tokio-tar", "tokio-util", @@ -6127,25 +6092,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "rustfs-audit-logger" -version = "0.0.5" -dependencies = [ - "async-trait", - "chrono", - "figment", - "reqwest", - "rustfs-targets", - "serde", - "serde_json", - "thiserror 2.0.16", - "tokio", - "tracing", - "tracing-core", - "url", - "uuid", -] - [[package]] name = "rustfs-checksums" version = "0.0.5" @@ -6703,7 +6649,7 @@ dependencies = [ "once_cell", "ring", "rustls-pki-types", - "rustls-webpki 0.103.5", + "rustls-webpki 0.103.6", "subtle", "zeroize", ] @@ -6783,9 +6729,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.5" +version = "0.103.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a37813727b78798e53c2bec3f5e8fe12a6d6f8389bf9ca7802add4c9905ad8" +checksum = "8572f3c2cb9934231157b45499fc41e1f58c589fdfb81a844ba873265e80f8eb" dependencies = [ "aws-lc-rs", "ring", @@ -6989,11 +6935,12 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" dependencies = [ "serde", + "serde_core", ] [[package]] @@ -7004,9 +6951,9 @@ checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc" [[package]] name = "serde" -version = "1.0.223" +version = "1.0.225" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a505d71960adde88e293da5cb5eda57093379f64e61cf77bf0e6a63af07a7bac" +checksum = "fd6c24dee235d0da097043389623fb913daddf92c76e9f5a1db88607a0bcbd1d" dependencies = [ "serde_core", "serde_derive", @@ -7014,12 +6961,13 @@ dependencies = [ [[package]] name = "serde-untagged" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34836a629bcbc6f1afdf0907a744870039b1e14c0561cb26094fa683b158eff3" +checksum = "f9faf48a4a2d2693be24c6289dbe26552776eb7737074e6722891fadbe6c5058" dependencies = [ "erased-serde", "serde", + "serde_core", "typeid", ] @@ -7047,18 +6995,18 @@ dependencies = [ [[package]] name = "serde_core" -version = "1.0.223" +version = "1.0.225" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20f57cbd357666aa7b3ac84a90b4ea328f1d4ddb6772b430caa5d9e1309bb9e9" +checksum = "659356f9a0cb1e529b24c01e43ad2bdf520ec4ceaf83047b83ddcc2251f96383" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.223" +version = "1.0.225" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d428d07faf17e306e699ec1e91996e5a165ba5d6bce5b5155173e91a8a01a56" +checksum = "0ea936adf78b1f766949a4977b91d2f5595825bd6ec079aa9543ad2685fc4516" dependencies = [ "proc-macro2", "quote", @@ -7100,12 +7048,13 @@ dependencies = [ [[package]] name = "serde_path_to_error" -version = "0.1.17" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59fab13f937fa393d08645bf3a84bdfe86e296747b506ada67bb15f10f218b2a" +checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457" dependencies = [ "itoa", "serde", + "serde_core", ] [[package]] @@ -7648,15 +7597,15 @@ dependencies = [ [[package]] name = "sysctl" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01198a2debb237c62b6826ec7081082d951f46dbb64b0e8c7649a452230d1dfc" +checksum = "cca424247104946a59dacd27eaad296223b7feec3d168a6dd04585183091eb0b" dependencies = [ "bitflags 2.9.4", "byteorder", "enum-as-inner", "libc", - "thiserror 1.0.69", + "thiserror 2.0.16", "walkdir", ] @@ -7955,9 +7904,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" +checksum = "05f63835928ca123f1bef57abbcd23bb2ba0ac9ae1235f1e65bda0d06e7786bd" dependencies = [ "rustls 0.23.31", "tokio", @@ -8024,8 +7973,8 @@ checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" dependencies = [ "serde", "serde_spanned", - "toml_datetime", - "toml_edit", + "toml_datetime 0.6.11", + "toml_edit 0.22.27", ] [[package]] @@ -8037,6 +7986,15 @@ dependencies = [ "serde", ] +[[package]] +name = "toml_datetime" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a197c0ec7d131bfc6f7e82c8442ba1595aeab35da7adbf05b6b73cd06a16b6be" +dependencies = [ + "serde_core", +] + [[package]] name = "toml_edit" version = "0.22.27" @@ -8046,11 +8004,32 @@ dependencies = [ "indexmap", "serde", "serde_spanned", - "toml_datetime", + "toml_datetime 0.6.11", "toml_write", "winnow", ] +[[package]] +name = "toml_edit" +version = "0.23.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2ad0b7ae9cfeef5605163839cb9221f453399f15cfb5c10be9885fcf56611f9" +dependencies = [ + "indexmap", + "toml_datetime 0.7.1", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b551886f449aa90d4fe2bdaa9f4a2577ad2dde302c61ecf262d80b116db95c10" +dependencies = [ + "winnow", +] + [[package]] name = "toml_write" version = "0.1.2" @@ -8381,15 +8360,6 @@ dependencies = [ "tz-rs", ] -[[package]] -name = "uncased" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1b88fcfe09e89d3866a5c11019378088af2d24c3fbd4f0543f96b479ec90697" -dependencies = [ - "version_check", -] - [[package]] name = "unicase" version = "2.8.1" @@ -8578,27 +8548,27 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasi" -version = "0.14.5+wasi-0.2.4" +version = "0.14.7+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4494f6290a82f5fe584817a676a34b9d6763e8d9d18204009fb31dceca98fd4" +checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c" dependencies = [ "wasip2", ] [[package]] name = "wasip2" -version = "1.0.0+wasi-0.2.4" +version = "1.0.1+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03fa2761397e5bd52002cd7e73110c71af2109aca4e521a9f40473fe685b0a24" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" dependencies = [ "wit-bindgen", ] [[package]] name = "wasm-bindgen" -version = "0.2.101" +version = "0.2.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e14915cadd45b529bb8d1f343c4ed0ac1de926144b746e2710f9cd05df6603b" +checksum = "ab10a69fbd0a177f5f649ad4d8d3305499c42bab9aef2f7ff592d0ec8f833819" dependencies = [ "cfg-if", "once_cell", @@ -8609,9 +8579,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.101" +version = "0.2.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28d1ba982ca7923fd01448d5c30c6864d0a14109560296a162f80f305fb93bb" +checksum = "0bb702423545a6007bbc368fde243ba47ca275e549c8a28617f56f6ba53b1d1c" dependencies = [ "bumpalo", "log", @@ -8623,9 +8593,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.51" +version = "0.4.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca85039a9b469b38336411d6d6ced91f3fc87109a2a27b0c197663f5144dffe" +checksum = "a0b221ff421256839509adbb55998214a70d829d3a28c69b4a6672e9d2a42f67" dependencies = [ "cfg-if", "js-sys", @@ -8636,9 +8606,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.101" +version = "0.2.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c3d463ae3eff775b0c45df9da45d68837702ac35af998361e2c84e7c5ec1b0d" +checksum = "fc65f4f411d91494355917b605e1480033152658d71f722a90647f56a70c88a0" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -8646,9 +8616,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.101" +version = "0.2.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bb4ce89b08211f923caf51d527662b75bdc9c9c7aab40f86dcb9fb85ac552aa" +checksum = "ffc003a991398a8ee604a401e194b6b3a39677b3173d6e74495eb51b82e99a32" dependencies = [ "proc-macro2", "quote", @@ -8659,9 +8629,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.101" +version = "0.2.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f143854a3b13752c6950862c906306adb27c7e839f7414cec8fea35beab624c1" +checksum = "293c37f4efa430ca14db3721dfbe48d8c33308096bd44d80ebaa775ab71ba1cf" dependencies = [ "unicode-ident", ] @@ -8681,9 +8651,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.78" +version = "0.3.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77e4b637749ff0d92b8fad63aa1f7cff3cbe125fd49c175cd6345e7272638b12" +checksum = "fbe734895e869dc429d78c4b433f8d17d95f8d05317440b4fad5ab2d33e596dc" dependencies = [ "js-sys", "wasm-bindgen", @@ -8728,9 +8698,9 @@ checksum = "dd7cf3379ca1aac9eea11fba24fd7e315d621f8dfe35c8d7d2be8b793726e07d" [[package]] name = "wildmatch" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68ce1ab1f8c62655ebe1350f589c61e505cf94d385bc6a12899442d9081e71fd" +checksum = "39b7d07a236abaef6607536ccfaf19b396dbe3f5110ddb73d39f4562902ed382" dependencies = [ "serde", ] @@ -8773,7 +8743,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" dependencies = [ "windows-collections", - "windows-core", + "windows-core 0.61.2", "windows-future", "windows-link 0.1.3", "windows-numerics", @@ -8785,7 +8755,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" dependencies = [ - "windows-core", + "windows-core 0.61.2", ] [[package]] @@ -8797,8 +8767,21 @@ dependencies = [ "windows-implement", "windows-interface", "windows-link 0.1.3", - "windows-result", - "windows-strings", + "windows-result 0.3.4", + "windows-strings 0.4.2", +] + +[[package]] +name = "windows-core" +version = "0.62.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57fe7168f7de578d2d8a05b07fd61870d2e73b4020e9f49aa00da8471723497c" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link 0.2.0", + "windows-result 0.4.0", + "windows-strings 0.5.0", ] [[package]] @@ -8807,7 +8790,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" dependencies = [ - "windows-core", + "windows-core 0.61.2", "windows-link 0.1.3", "windows-threading", ] @@ -8852,7 +8835,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" dependencies = [ - "windows-core", + "windows-core 0.61.2", "windows-link 0.1.3", ] @@ -8863,8 +8846,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b8a9ed28765efc97bbc954883f4e6796c33a06546ebafacbabee9696967499e" dependencies = [ "windows-link 0.1.3", - "windows-result", - "windows-strings", + "windows-result 0.3.4", + "windows-strings 0.4.2", ] [[package]] @@ -8876,6 +8859,15 @@ dependencies = [ "windows-link 0.1.3", ] +[[package]] +name = "windows-result" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7084dcc306f89883455a206237404d3eaf961e5bd7e0f312f7c91f57eb44167f" +dependencies = [ + "windows-link 0.2.0", +] + [[package]] name = "windows-strings" version = "0.4.2" @@ -8885,6 +8877,15 @@ dependencies = [ "windows-link 0.1.3", ] +[[package]] +name = "windows-strings" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7218c655a553b0bed4426cf54b20d7ba363ef543b52d515b3e48d7fd55318dda" +dependencies = [ + "windows-link 0.2.0", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -9146,9 +9147,9 @@ dependencies = [ [[package]] name = "wit-bindgen" -version = "0.45.1" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c573471f125075647d03df72e026074b7203790d41351cd6edc96f46bcccd36" +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" [[package]] name = "wrapcenum-derive" @@ -9331,34 +9332,37 @@ dependencies = [ [[package]] name = "zip" -version = "2.4.2" +version = "5.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fabe6324e908f85a1c52063ce7aa26b68dcb7eb6dbc83a2d148403c9bc3eba50" +checksum = "2f852905151ac8d4d06fdca66520a661c09730a74c6d4e2b0f27b436b382e532" dependencies = [ "aes", "arbitrary", - "bzip2", + "bzip2 0.6.0", "constant_time_eq", "crc32fast", - "crossbeam-utils", "deflate64", - "displaydoc", "flate2", "getrandom 0.3.3", "hmac 0.12.1", "indexmap", - "lzma-rs", + "lzma-rust2", "memchr", "pbkdf2", + "ppmd-rust", "sha1 0.10.6", - "thiserror 2.0.16", "time", - "xz2", "zeroize", "zopfli", "zstd", ] +[[package]] +name = "zlib-rs" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f06ae92f42f5e5c42443fd094f245eb656abf56dd7cce9b8b263236565e00f2" + [[package]] name = "zopfli" version = "0.8.2" diff --git a/Cargo.toml b/Cargo.toml index 37ccd795..8cf7602e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,6 @@ members = [ "rustfs", # Core file system implementation "crates/appauth", # Application authentication and authorization - "crates/audit-logger", # Audit logging system for file operations "crates/common", # Shared utilities and data structures "crates/config", # Configuration management "crates/crypto", # Cryptography and security features @@ -64,7 +63,6 @@ all = "warn" rustfs-ahm = { path = "crates/ahm", version = "0.0.5" } rustfs-s3select-api = { path = "crates/s3select-api", version = "0.0.5" } rustfs-appauth = { path = "crates/appauth", version = "0.0.5" } -rustfs-audit-logger = { path = "crates/audit-logger", version = "0.0.5" } rustfs-common = { path = "crates/common", version = "0.0.5" } rustfs-crypto = { path = "crates/crypto", version = "0.0.5" } rustfs-ecstore = { path = "crates/ecstore", version = "0.0.5" } @@ -98,7 +96,7 @@ async-trait = "0.1.89" async-compression = { version = "0.4.19" } atomic_enum = "0.3.0" aws-config = { version = "1.8.6" } -aws-sdk-s3 = "1.101.0" +aws-sdk-s3 = "1.106.0" axum = "0.8.4" axum-extra = "0.10.1" axum-server = "0.7.2" @@ -106,10 +104,10 @@ base64-simd = "0.8.0" base64 = "0.22.1" brotli = "8.0.2" bytes = { version = "1.10.1", features = ["serde"] } -bytesize = "2.0.1" +bytesize = "2.1.0" byteorder = "1.5.0" cfg-if = "1.0.3" -crc-fast = "1.5.0" +crc-fast = "1.3.0" chacha20poly1305 = { version = "0.10.1" } chrono = { version = "0.4.42", features = ["serde"] } clap = { version = "4.5.47", features = ["derive", "env"] } @@ -134,7 +132,7 @@ highway = { version = "1.3.0" } hickory-resolver = { version = "0.25.2", features = ["tls-ring"] } hmac = "0.12.1" hyper = "1.7.0" -hyper-util = { version = "0.1.16", features = [ +hyper-util = { version = "0.1.17", features = [ "tokio", "server-auto", "server-graceful", @@ -209,7 +207,7 @@ rustls-pki-types = "1.12.0" rustls-pemfile = "2.2.0" s3s = { version = "0.12.0-minio-preview.3" } schemars = "1.0.4" -serde = { version = "1.0.223", features = ["derive"] } +serde = { version = "1.0.225", features = ["derive"] } serde_json = { version = "1.0.145", features = ["raw_value"] } serde_urlencoded = "0.7.1" serial_test = "3.2.0" @@ -224,7 +222,7 @@ snap = "1.1.1" socket2 = "0.6.0" strum = { version = "0.27.2", features = ["derive"] } sysinfo = "0.37.0" -sysctl = "0.6.0" +sysctl = "0.7.1" tempfile = "3.22.0" temp-env = "0.3.6" test-case = "3.3.1" @@ -237,7 +235,7 @@ time = { version = "0.3.43", features = [ "serde", ] } tokio = { version = "1.47.1", features = ["fs", "rt-multi-thread"] } -tokio-rustls = { version = "0.26.2", default-features = false } +tokio-rustls = { version = "0.26.3", default-features = false } tokio-stream = { version = "0.1.17" } tokio-tar = "0.3.1" tokio-test = "0.4.4" @@ -260,14 +258,14 @@ uuid = { version = "1.18.1", features = [ "fast-rng", "macro-diagnostics", ] } -wildmatch = { version = "2.4.0", features = ["serde"] } +wildmatch = { version = "2.5.0", features = ["serde"] } winapi = { version = "0.3.9" } xxhash-rust = { version = "0.8.15", features = ["xxh64", "xxh3"] } -zip = "2.4.2" +zip = "5.1.1" zstd = "0.13.3" [workspace.metadata.cargo-shear] -ignored = ["rustfs", "rust-i18n", "rustfs-mcp", "rustfs-audit-logger", "tokio-test"] +ignored = ["rustfs", "rust-i18n", "rustfs-mcp", "tokio-test"] [profile.wasm-dev] inherits = "dev" diff --git a/crates/audit-logger/Cargo.toml b/crates/audit-logger/Cargo.toml deleted file mode 100644 index 640ea3b3..00000000 --- a/crates/audit-logger/Cargo.toml +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2024 RustFS Team -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -[package] -name = "rustfs-audit-logger" -edition.workspace = true -license.workspace = true -repository.workspace = true -rust-version.workspace = true -version.workspace = true -homepage.workspace = true -description = "Audit logging system for RustFS, providing detailed logging of file operations and system events." -documentation = "https://docs.rs/audit-logger/latest/audit_logger/" -keywords = ["audit", "logging", "file-operations", "system-events", "RustFS"] -categories = ["web-programming", "development-tools::profiling", "asynchronous", "api-bindings", "development-tools::debugging"] - -[dependencies] -rustfs-targets = { workspace = true } -async-trait = { workspace = true } -chrono = { workspace = true } -reqwest = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true } -tracing = { workspace = true, features = ["std", "attributes"] } -tracing-core = { workspace = true } -tokio = { workspace = true, features = ["sync", "fs", "rt-multi-thread", "rt", "time", "macros"] } -url = { workspace = true } -uuid = { workspace = true } -thiserror = { workspace = true } -figment = { version = "0.10", features = ["json", "env"] } - -[lints] -workspace = true diff --git a/crates/audit-logger/examples/config.json b/crates/audit-logger/examples/config.json deleted file mode 100644 index 329f26ad..00000000 --- a/crates/audit-logger/examples/config.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "console": { - "enabled": true - }, - "logger_webhook": { - "default": { - "enabled": true, - "endpoint": "http://localhost:3000/logs", - "auth_token": "secret-token-for-logs", - "batch_size": 5, - "queue_size": 1000, - "max_retry": 3, - "retry_interval": "2s" - } - }, - "audit_webhook": { - "splunk": { - "enabled": true, - "endpoint": "http://localhost:3000/audit", - "auth_token": "secret-token-for-audit", - "batch_size": 10 - } - }, - "audit_kafka": { - "default": { - "enabled": false, - "brokers": [ - "kafka1:9092", - "kafka2:9092" - ], - "topic": "minio-audit-events" - } - } -} \ No newline at end of file diff --git a/crates/audit-logger/examples/main.rs b/crates/audit-logger/examples/main.rs deleted file mode 100644 index 7cc4a0b7..00000000 --- a/crates/audit-logger/examples/main.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2024 RustFS Team -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -fn main() { - println!("Audit Logger Example"); -} diff --git a/crates/audit-logger/src/entry/args.rs b/crates/audit-logger/src/entry/args.rs deleted file mode 100644 index 1ac65af1..00000000 --- a/crates/audit-logger/src/entry/args.rs +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2024 RustFS Team -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#![allow(dead_code)] - -use crate::entry::ObjectVersion; -use serde::{Deserialize, Serialize}; -use std::collections::HashMap; - -/// Args - defines the arguments for API operations -/// Args is used to define the arguments for API operations. -/// -/// # Example -/// ``` -/// use rustfs_audit_logger::Args; -/// use std::collections::HashMap; -/// -/// let args = Args::new() -/// .set_bucket(Some("my-bucket".to_string())) -/// .set_object(Some("my-object".to_string())) -/// .set_version_id(Some("123".to_string())) -/// .set_metadata(Some(HashMap::new())); -/// ``` -#[derive(Debug, Clone, Serialize, Deserialize, Default, Eq, PartialEq)] -pub struct Args { - #[serde(rename = "bucket", skip_serializing_if = "Option::is_none")] - pub bucket: Option, - #[serde(rename = "object", skip_serializing_if = "Option::is_none")] - pub object: Option, - #[serde(rename = "versionId", skip_serializing_if = "Option::is_none")] - pub version_id: Option, - #[serde(rename = "objects", skip_serializing_if = "Option::is_none")] - pub objects: Option>, - #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] - pub metadata: Option>, -} - -impl Args { - /// Create a new Args object - pub fn new() -> Self { - Args { - bucket: None, - object: None, - version_id: None, - objects: None, - metadata: None, - } - } - - /// Set the bucket - pub fn set_bucket(mut self, bucket: Option) -> Self { - self.bucket = bucket; - self - } - - /// Set the object - pub fn set_object(mut self, object: Option) -> Self { - self.object = object; - self - } - - /// Set the version ID - pub fn set_version_id(mut self, version_id: Option) -> Self { - self.version_id = version_id; - self - } - - /// Set the objects - pub fn set_objects(mut self, objects: Option>) -> Self { - self.objects = objects; - self - } - - /// Set the metadata - pub fn set_metadata(mut self, metadata: Option>) -> Self { - self.metadata = metadata; - self - } -} diff --git a/crates/audit-logger/src/entry/audit.rs b/crates/audit-logger/src/entry/audit.rs deleted file mode 100644 index ad41b363..00000000 --- a/crates/audit-logger/src/entry/audit.rs +++ /dev/null @@ -1,469 +0,0 @@ -// Copyright 2024 RustFS Team -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#![allow(dead_code)] - -use crate::{BaseLogEntry, LogRecord, ObjectVersion}; -use chrono::{DateTime, Utc}; -use serde::{Deserialize, Serialize}; -use serde_json::Value; -use std::collections::HashMap; - -/// API details structure -/// ApiDetails is used to define the details of an API operation -/// -/// The `ApiDetails` structure contains the following fields: -/// - `name` - the name of the API operation -/// - `bucket` - the bucket name -/// - `object` - the object name -/// - `objects` - the list of objects -/// - `status` - the status of the API operation -/// - `status_code` - the status code of the API operation -/// - `input_bytes` - the input bytes -/// - `output_bytes` - the output bytes -/// - `header_bytes` - the header bytes -/// - `time_to_first_byte` - the time to first byte -/// - `time_to_first_byte_in_ns` - the time to first byte in nanoseconds -/// - `time_to_response` - the time to response -/// - `time_to_response_in_ns` - the time to response in nanoseconds -/// -/// The `ApiDetails` structure contains the following methods: -/// - `new` - create a new `ApiDetails` with default values -/// - `set_name` - set the name -/// - `set_bucket` - set the bucket -/// - `set_object` - set the object -/// - `set_objects` - set the objects -/// - `set_status` - set the status -/// - `set_status_code` - set the status code -/// - `set_input_bytes` - set the input bytes -/// - `set_output_bytes` - set the output bytes -/// - `set_header_bytes` - set the header bytes -/// - `set_time_to_first_byte` - set the time to first byte -/// - `set_time_to_first_byte_in_ns` - set the time to first byte in nanoseconds -/// - `set_time_to_response` - set the time to response -/// - `set_time_to_response_in_ns` - set the time to response in nanoseconds -/// -/// # Example -/// ``` -/// use rustfs_audit_logger::ApiDetails; -/// use rustfs_audit_logger::ObjectVersion; -/// -/// let api = ApiDetails::new() -/// .set_name(Some("GET".to_string())) -/// .set_bucket(Some("my-bucket".to_string())) -/// .set_object(Some("my-object".to_string())) -/// .set_objects(vec![ObjectVersion::new_with_object_name("my-object".to_string())]) -/// .set_status(Some("OK".to_string())) -/// .set_status_code(Some(200)) -/// .set_input_bytes(100) -/// .set_output_bytes(200) -/// .set_header_bytes(Some(50)) -/// .set_time_to_first_byte(Some("100ms".to_string())) -/// .set_time_to_first_byte_in_ns(Some("100000000ns".to_string())) -/// .set_time_to_response(Some("200ms".to_string())) -/// .set_time_to_response_in_ns(Some("200000000ns".to_string())); -/// ``` -#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq)] -pub struct ApiDetails { - #[serde(rename = "name", skip_serializing_if = "Option::is_none")] - pub name: Option, - #[serde(rename = "bucket", skip_serializing_if = "Option::is_none")] - pub bucket: Option, - #[serde(rename = "object", skip_serializing_if = "Option::is_none")] - pub object: Option, - #[serde(rename = "objects", skip_serializing_if = "Vec::is_empty", default)] - pub objects: Vec, - #[serde(rename = "status", skip_serializing_if = "Option::is_none")] - pub status: Option, - #[serde(rename = "statusCode", skip_serializing_if = "Option::is_none")] - pub status_code: Option, - #[serde(rename = "rx")] - pub input_bytes: i64, - #[serde(rename = "tx")] - pub output_bytes: i64, - #[serde(rename = "txHeaders", skip_serializing_if = "Option::is_none")] - pub header_bytes: Option, - #[serde(rename = "timeToFirstByte", skip_serializing_if = "Option::is_none")] - pub time_to_first_byte: Option, - #[serde(rename = "timeToFirstByteInNS", skip_serializing_if = "Option::is_none")] - pub time_to_first_byte_in_ns: Option, - #[serde(rename = "timeToResponse", skip_serializing_if = "Option::is_none")] - pub time_to_response: Option, - #[serde(rename = "timeToResponseInNS", skip_serializing_if = "Option::is_none")] - pub time_to_response_in_ns: Option, -} - -impl ApiDetails { - /// Create a new `ApiDetails` with default values - pub fn new() -> Self { - ApiDetails { - name: None, - bucket: None, - object: None, - objects: Vec::new(), - status: None, - status_code: None, - input_bytes: 0, - output_bytes: 0, - header_bytes: None, - time_to_first_byte: None, - time_to_first_byte_in_ns: None, - time_to_response: None, - time_to_response_in_ns: None, - } - } - - /// Set the name - pub fn set_name(mut self, name: Option) -> Self { - self.name = name; - self - } - - /// Set the bucket - pub fn set_bucket(mut self, bucket: Option) -> Self { - self.bucket = bucket; - self - } - - /// Set the object - pub fn set_object(mut self, object: Option) -> Self { - self.object = object; - self - } - - /// Set the objects - pub fn set_objects(mut self, objects: Vec) -> Self { - self.objects = objects; - self - } - - /// Set the status - pub fn set_status(mut self, status: Option) -> Self { - self.status = status; - self - } - - /// Set the status code - pub fn set_status_code(mut self, status_code: Option) -> Self { - self.status_code = status_code; - self - } - - /// Set the input bytes - pub fn set_input_bytes(mut self, input_bytes: i64) -> Self { - self.input_bytes = input_bytes; - self - } - - /// Set the output bytes - pub fn set_output_bytes(mut self, output_bytes: i64) -> Self { - self.output_bytes = output_bytes; - self - } - - /// Set the header bytes - pub fn set_header_bytes(mut self, header_bytes: Option) -> Self { - self.header_bytes = header_bytes; - self - } - - /// Set the time to first byte - pub fn set_time_to_first_byte(mut self, time_to_first_byte: Option) -> Self { - self.time_to_first_byte = time_to_first_byte; - self - } - - /// Set the time to first byte in nanoseconds - pub fn set_time_to_first_byte_in_ns(mut self, time_to_first_byte_in_ns: Option) -> Self { - self.time_to_first_byte_in_ns = time_to_first_byte_in_ns; - self - } - - /// Set the time to response - pub fn set_time_to_response(mut self, time_to_response: Option) -> Self { - self.time_to_response = time_to_response; - self - } - - /// Set the time to response in nanoseconds - pub fn set_time_to_response_in_ns(mut self, time_to_response_in_ns: Option) -> Self { - self.time_to_response_in_ns = time_to_response_in_ns; - self - } -} - -/// Entry - audit entry logs -/// AuditLogEntry is used to define the structure of an audit log entry -/// -/// The `AuditLogEntry` structure contains the following fields: -/// - `base` - the base log entry -/// - `version` - the version of the audit log entry -/// - `deployment_id` - the deployment ID -/// - `event` - the event -/// - `entry_type` - the type of audit message -/// - `api` - the API details -/// - `remote_host` - the remote host -/// - `user_agent` - the user agent -/// - `req_path` - the request path -/// - `req_host` - the request host -/// - `req_claims` - the request claims -/// - `req_query` - the request query -/// - `req_header` - the request header -/// - `resp_header` - the response header -/// - `access_key` - the access key -/// - `parent_user` - the parent user -/// - `error` - the error -/// -/// The `AuditLogEntry` structure contains the following methods: -/// - `new` - create a new `AuditEntry` with default values -/// - `new_with_values` - create a new `AuditEntry` with version, time, event and api details -/// - `with_base` - set the base log entry -/// - `set_version` - set the version -/// - `set_deployment_id` - set the deployment ID -/// - `set_event` - set the event -/// - `set_entry_type` - set the entry type -/// - `set_api` - set the API details -/// - `set_remote_host` - set the remote host -/// - `set_user_agent` - set the user agent -/// - `set_req_path` - set the request path -/// - `set_req_host` - set the request host -/// - `set_req_claims` - set the request claims -/// - `set_req_query` - set the request query -/// - `set_req_header` - set the request header -/// - `set_resp_header` - set the response header -/// - `set_access_key` - set the access key -/// - `set_parent_user` - set the parent user -/// - `set_error` - set the error -/// -/// # Example -/// ``` -/// use rustfs_audit_logger::AuditLogEntry; -/// use rustfs_audit_logger::ApiDetails; -/// use std::collections::HashMap; -/// -/// let entry = AuditLogEntry::new() -/// .set_version("1.0".to_string()) -/// .set_deployment_id(Some("123".to_string())) -/// .set_event("event".to_string()) -/// .set_entry_type(Some("type".to_string())) -/// .set_api(ApiDetails::new()) -/// .set_remote_host(Some("remote-host".to_string())) -/// .set_user_agent(Some("user-agent".to_string())) -/// .set_req_path(Some("req-path".to_string())) -/// .set_req_host(Some("req-host".to_string())) -/// .set_req_claims(Some(HashMap::new())) -/// .set_req_query(Some(HashMap::new())) -/// .set_req_header(Some(HashMap::new())) -/// .set_resp_header(Some(HashMap::new())) -/// .set_access_key(Some("access-key".to_string())) -/// .set_parent_user(Some("parent-user".to_string())) -/// .set_error(Some("error".to_string())); -#[derive(Debug, Serialize, Deserialize, Clone, Default)] -pub struct AuditLogEntry { - #[serde(flatten)] - pub base: BaseLogEntry, - pub version: String, - #[serde(rename = "deploymentid", skip_serializing_if = "Option::is_none")] - pub deployment_id: Option, - pub event: String, - // Class of audit message - S3, admin ops, bucket management - #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - pub entry_type: Option, - pub api: ApiDetails, - #[serde(rename = "remotehost", skip_serializing_if = "Option::is_none")] - pub remote_host: Option, - #[serde(rename = "userAgent", skip_serializing_if = "Option::is_none")] - pub user_agent: Option, - #[serde(rename = "requestPath", skip_serializing_if = "Option::is_none")] - pub req_path: Option, - #[serde(rename = "requestHost", skip_serializing_if = "Option::is_none")] - pub req_host: Option, - #[serde(rename = "requestClaims", skip_serializing_if = "Option::is_none")] - pub req_claims: Option>, - #[serde(rename = "requestQuery", skip_serializing_if = "Option::is_none")] - pub req_query: Option>, - #[serde(rename = "requestHeader", skip_serializing_if = "Option::is_none")] - pub req_header: Option>, - #[serde(rename = "responseHeader", skip_serializing_if = "Option::is_none")] - pub resp_header: Option>, - #[serde(rename = "accessKey", skip_serializing_if = "Option::is_none")] - pub access_key: Option, - #[serde(rename = "parentUser", skip_serializing_if = "Option::is_none")] - pub parent_user: Option, - #[serde(rename = "error", skip_serializing_if = "Option::is_none")] - pub error: Option, -} - -impl AuditLogEntry { - /// Create a new `AuditEntry` with default values - pub fn new() -> Self { - AuditLogEntry { - base: BaseLogEntry::new(), - version: String::new(), - deployment_id: None, - event: String::new(), - entry_type: None, - api: ApiDetails::new(), - remote_host: None, - user_agent: None, - req_path: None, - req_host: None, - req_claims: None, - req_query: None, - req_header: None, - resp_header: None, - access_key: None, - parent_user: None, - error: None, - } - } - - /// Create a new `AuditEntry` with version, time, event and api details - pub fn new_with_values(version: String, time: DateTime, event: String, api: ApiDetails) -> Self { - let mut base = BaseLogEntry::new(); - base.timestamp = time; - - AuditLogEntry { - base, - version, - deployment_id: None, - event, - entry_type: None, - api, - remote_host: None, - user_agent: None, - req_path: None, - req_host: None, - req_claims: None, - req_query: None, - req_header: None, - resp_header: None, - access_key: None, - parent_user: None, - error: None, - } - } - - /// Set the base log entry - pub fn with_base(mut self, base: BaseLogEntry) -> Self { - self.base = base; - self - } - - /// Set the version - pub fn set_version(mut self, version: String) -> Self { - self.version = version; - self - } - - /// Set the deployment ID - pub fn set_deployment_id(mut self, deployment_id: Option) -> Self { - self.deployment_id = deployment_id; - self - } - - /// Set the event - pub fn set_event(mut self, event: String) -> Self { - self.event = event; - self - } - - /// Set the entry type - pub fn set_entry_type(mut self, entry_type: Option) -> Self { - self.entry_type = entry_type; - self - } - - /// Set the API details - pub fn set_api(mut self, api: ApiDetails) -> Self { - self.api = api; - self - } - - /// Set the remote host - pub fn set_remote_host(mut self, remote_host: Option) -> Self { - self.remote_host = remote_host; - self - } - - /// Set the user agent - pub fn set_user_agent(mut self, user_agent: Option) -> Self { - self.user_agent = user_agent; - self - } - - /// Set the request path - pub fn set_req_path(mut self, req_path: Option) -> Self { - self.req_path = req_path; - self - } - - /// Set the request host - pub fn set_req_host(mut self, req_host: Option) -> Self { - self.req_host = req_host; - self - } - - /// Set the request claims - pub fn set_req_claims(mut self, req_claims: Option>) -> Self { - self.req_claims = req_claims; - self - } - - /// Set the request query - pub fn set_req_query(mut self, req_query: Option>) -> Self { - self.req_query = req_query; - self - } - - /// Set the request header - pub fn set_req_header(mut self, req_header: Option>) -> Self { - self.req_header = req_header; - self - } - - /// Set the response header - pub fn set_resp_header(mut self, resp_header: Option>) -> Self { - self.resp_header = resp_header; - self - } - - /// Set the access key - pub fn set_access_key(mut self, access_key: Option) -> Self { - self.access_key = access_key; - self - } - - /// Set the parent user - pub fn set_parent_user(mut self, parent_user: Option) -> Self { - self.parent_user = parent_user; - self - } - - /// Set the error - pub fn set_error(mut self, error: Option) -> Self { - self.error = error; - self - } -} - -impl LogRecord for AuditLogEntry { - fn to_json(&self) -> String { - serde_json::to_string(self).unwrap_or_else(|_| String::from("{}")) - } - - fn get_timestamp(&self) -> DateTime { - self.base.timestamp - } -} diff --git a/crates/audit-logger/src/entry/base.rs b/crates/audit-logger/src/entry/base.rs deleted file mode 100644 index 164ef3ef..00000000 --- a/crates/audit-logger/src/entry/base.rs +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2024 RustFS Team -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#![allow(dead_code)] - -use chrono::{DateTime, Utc}; -use serde::{Deserialize, Serialize}; -use serde_json::Value; -use std::collections::HashMap; - -/// Base log entry structure shared by all log types -/// This structure is used to serialize log entries to JSON -/// and send them to the log sinks -/// This structure is also used to deserialize log entries from JSON -/// This structure is also used to store log entries in the database -/// This structure is also used to query log entries from the database -/// -/// The `BaseLogEntry` structure contains the following fields: -/// - `timestamp` - the timestamp of the log entry -/// - `request_id` - the request ID of the log entry -/// - `message` - the message of the log entry -/// - `tags` - the tags of the log entry -/// -/// The `BaseLogEntry` structure contains the following methods: -/// - `new` - create a new `BaseLogEntry` with default values -/// - `message` - set the message -/// - `request_id` - set the request ID -/// - `tags` - set the tags -/// - `timestamp` - set the timestamp -/// -/// # Example -/// ``` -/// use rustfs_audit_logger::BaseLogEntry; -/// use chrono::{DateTime, Utc}; -/// use std::collections::HashMap; -/// -/// let timestamp = Utc::now(); -/// let request = Some("req-123".to_string()); -/// let message = Some("This is a log message".to_string()); -/// let tags = Some(HashMap::new()); -/// -/// let entry = BaseLogEntry::new() -/// .timestamp(timestamp) -/// .request_id(request) -/// .message(message) -/// .tags(tags); -/// ``` -#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Default)] -pub struct BaseLogEntry { - #[serde(rename = "time")] - pub timestamp: DateTime, - - #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")] - pub request_id: Option, - - #[serde(rename = "message", skip_serializing_if = "Option::is_none")] - pub message: Option, - - #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] - pub tags: Option>, -} - -impl BaseLogEntry { - /// Create a new BaseLogEntry with default values - pub fn new() -> Self { - BaseLogEntry { - timestamp: Utc::now(), - request_id: None, - message: None, - tags: None, - } - } - - /// Set the message - pub fn message(mut self, message: Option) -> Self { - self.message = message; - self - } - - /// Set the request ID - pub fn request_id(mut self, request_id: Option) -> Self { - self.request_id = request_id; - self - } - - /// Set the tags - pub fn tags(mut self, tags: Option>) -> Self { - self.tags = tags; - self - } - - /// Set the timestamp - pub fn timestamp(mut self, timestamp: DateTime) -> Self { - self.timestamp = timestamp; - self - } -} diff --git a/crates/audit-logger/src/entry/mod.rs b/crates/audit-logger/src/entry/mod.rs deleted file mode 100644 index 4fb7769f..00000000 --- a/crates/audit-logger/src/entry/mod.rs +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright 2024 RustFS Team -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#![allow(dead_code)] -pub(crate) mod args; -pub(crate) mod audit; -pub(crate) mod base; -pub(crate) mod unified; - -use serde::de::Error; -use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use tracing_core::Level; - -/// ObjectVersion is used across multiple modules -#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)] -pub struct ObjectVersion { - #[serde(rename = "name")] - pub object_name: String, - #[serde(rename = "versionId", skip_serializing_if = "Option::is_none")] - pub version_id: Option, -} - -impl ObjectVersion { - /// Create a new ObjectVersion object - pub fn new() -> Self { - ObjectVersion { - object_name: String::new(), - version_id: None, - } - } - - /// Create a new ObjectVersion with object name - pub fn new_with_object_name(object_name: String) -> Self { - ObjectVersion { - object_name, - version_id: None, - } - } - - /// Set the object name - pub fn set_object_name(mut self, object_name: String) -> Self { - self.object_name = object_name; - self - } - - /// Set the version ID - pub fn set_version_id(mut self, version_id: Option) -> Self { - self.version_id = version_id; - self - } -} - -impl Default for ObjectVersion { - fn default() -> Self { - Self::new() - } -} - -/// Log kind/level enum -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)] -pub enum LogKind { - #[serde(rename = "INFO")] - #[default] - Info, - #[serde(rename = "WARNING")] - Warning, - #[serde(rename = "ERROR")] - Error, - #[serde(rename = "FATAL")] - Fatal, -} - -/// Trait for types that can be serialized to JSON and have a timestamp -/// This trait is used by `ServerLogEntry` to convert the log entry to JSON -/// and get the timestamp of the log entry -/// This trait is implemented by `ServerLogEntry` -/// -/// # Example -/// ``` -/// use rustfs_audit_logger::LogRecord; -/// use chrono::{DateTime, Utc}; -/// use rustfs_audit_logger::ServerLogEntry; -/// use tracing_core::Level; -/// -/// let log_entry = ServerLogEntry::new(Level::INFO, "api_handler".to_string()); -/// let json = log_entry.to_json(); -/// let timestamp = log_entry.get_timestamp(); -/// ``` -pub trait LogRecord { - fn to_json(&self) -> String; - fn get_timestamp(&self) -> chrono::DateTime; -} - -/// Wrapper for `tracing_core::Level` to implement `Serialize` and `Deserialize` -/// for `ServerLogEntry` -/// This is necessary because `tracing_core::Level` does not implement `Serialize` -/// and `Deserialize` -/// This is a workaround to allow `ServerLogEntry` to be serialized and deserialized -/// using `serde` -/// -/// # Example -/// ``` -/// use rustfs_audit_logger::SerializableLevel; -/// use tracing_core::Level; -/// -/// let level = Level::INFO; -/// let serializable_level = SerializableLevel::from(level); -/// ``` -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct SerializableLevel(pub Level); - -impl From for SerializableLevel { - fn from(level: Level) -> Self { - SerializableLevel(level) - } -} - -impl From for Level { - fn from(serializable_level: SerializableLevel) -> Self { - serializable_level.0 - } -} - -impl Serialize for SerializableLevel { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_str(self.0.as_str()) - } -} - -impl<'de> Deserialize<'de> for SerializableLevel { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let s = String::deserialize(deserializer)?; - match s.as_str() { - "TRACE" => Ok(SerializableLevel(Level::TRACE)), - "DEBUG" => Ok(SerializableLevel(Level::DEBUG)), - "INFO" => Ok(SerializableLevel(Level::INFO)), - "WARN" => Ok(SerializableLevel(Level::WARN)), - "ERROR" => Ok(SerializableLevel(Level::ERROR)), - _ => Err(D::Error::custom("unknown log level")), - } - } -} diff --git a/crates/audit-logger/src/entry/unified.rs b/crates/audit-logger/src/entry/unified.rs deleted file mode 100644 index e9ae3a94..00000000 --- a/crates/audit-logger/src/entry/unified.rs +++ /dev/null @@ -1,266 +0,0 @@ -// Copyright 2024 RustFS Team -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#![allow(dead_code)] - -use crate::{AuditLogEntry, BaseLogEntry, LogKind, LogRecord, SerializableLevel}; -use chrono::{DateTime, Utc}; -use serde::{Deserialize, Serialize}; -use tracing_core::Level; - -/// Server log entry with structured fields -/// ServerLogEntry is used to log structured log entries from the server -/// -/// The `ServerLogEntry` structure contains the following fields: -/// - `base` - the base log entry -/// - `level` - the log level -/// - `source` - the source of the log entry -/// - `user_id` - the user ID -/// - `fields` - the structured fields of the log entry -/// -/// The `ServerLogEntry` structure contains the following methods: -/// - `new` - create a new `ServerLogEntry` with specified level and source -/// - `with_base` - set the base log entry -/// - `user_id` - set the user ID -/// - `fields` - set the fields -/// - `add_field` - add a field -/// -/// # Example -/// ``` -/// use rustfs_audit_logger::ServerLogEntry; -/// use tracing_core::Level; -/// -/// let entry = ServerLogEntry::new(Level::INFO, "test_module".to_string()) -/// .user_id(Some("user-456".to_string())) -/// .add_field("operation".to_string(), "login".to_string()); -/// ``` -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] -pub struct ServerLogEntry { - #[serde(flatten)] - pub base: BaseLogEntry, - - pub level: SerializableLevel, - pub source: String, - - #[serde(rename = "userId", skip_serializing_if = "Option::is_none")] - pub user_id: Option, - - #[serde(skip_serializing_if = "Vec::is_empty", default)] - pub fields: Vec<(String, String)>, -} - -impl ServerLogEntry { - /// Create a new ServerLogEntry with specified level and source - pub fn new(level: Level, source: String) -> Self { - ServerLogEntry { - base: BaseLogEntry::new(), - level: SerializableLevel(level), - source, - user_id: None, - fields: Vec::new(), - } - } - - /// Set the base log entry - pub fn with_base(mut self, base: BaseLogEntry) -> Self { - self.base = base; - self - } - - /// Set the user ID - pub fn user_id(mut self, user_id: Option) -> Self { - self.user_id = user_id; - self - } - - /// Set fields - pub fn fields(mut self, fields: Vec<(String, String)>) -> Self { - self.fields = fields; - self - } - - /// Add a field - pub fn add_field(mut self, key: String, value: String) -> Self { - self.fields.push((key, value)); - self - } -} - -impl LogRecord for ServerLogEntry { - fn to_json(&self) -> String { - serde_json::to_string(self).unwrap_or_else(|_| String::from("{}")) - } - - fn get_timestamp(&self) -> DateTime { - self.base.timestamp - } -} - -/// Console log entry structure -/// ConsoleLogEntry is used to log console log entries -/// The `ConsoleLogEntry` structure contains the following fields: -/// - `base` - the base log entry -/// - `level` - the log level -/// - `console_msg` - the console message -/// - `node_name` - the node name -/// - `err` - the error message -/// -/// The `ConsoleLogEntry` structure contains the following methods: -/// - `new` - create a new `ConsoleLogEntry` -/// - `new_with_console_msg` - create a new `ConsoleLogEntry` with console message and node name -/// - `with_base` - set the base log entry -/// - `set_level` - set the log level -/// - `set_node_name` - set the node name -/// - `set_console_msg` - set the console message -/// - `set_err` - set the error message -/// -/// # Example -/// ``` -/// use rustfs_audit_logger::ConsoleLogEntry; -/// -/// let entry = ConsoleLogEntry::new_with_console_msg("Test message".to_string(), "node-123".to_string()); -/// ``` -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct ConsoleLogEntry { - #[serde(flatten)] - pub base: BaseLogEntry, - - pub level: LogKind, - pub console_msg: String, - pub node_name: String, - - #[serde(skip)] - pub err: Option, -} - -impl ConsoleLogEntry { - /// Create a new ConsoleLogEntry - pub fn new() -> Self { - ConsoleLogEntry { - base: BaseLogEntry::new(), - level: LogKind::Info, - console_msg: String::new(), - node_name: String::new(), - err: None, - } - } - - /// Create a new ConsoleLogEntry with console message and node name - pub fn new_with_console_msg(console_msg: String, node_name: String) -> Self { - ConsoleLogEntry { - base: BaseLogEntry::new(), - level: LogKind::Info, - console_msg, - node_name, - err: None, - } - } - - /// Set the base log entry - pub fn with_base(mut self, base: BaseLogEntry) -> Self { - self.base = base; - self - } - - /// Set the log level - pub fn set_level(mut self, level: LogKind) -> Self { - self.level = level; - self - } - - /// Set the node name - pub fn set_node_name(mut self, node_name: String) -> Self { - self.node_name = node_name; - self - } - - /// Set the console message - pub fn set_console_msg(mut self, console_msg: String) -> Self { - self.console_msg = console_msg; - self - } - - /// Set the error message - pub fn set_err(mut self, err: Option) -> Self { - self.err = err; - self - } -} - -impl Default for ConsoleLogEntry { - fn default() -> Self { - Self::new() - } -} - -impl LogRecord for ConsoleLogEntry { - fn to_json(&self) -> String { - serde_json::to_string(self).unwrap_or_else(|_| String::from("{}")) - } - - fn get_timestamp(&self) -> DateTime { - self.base.timestamp - } -} - -/// Unified log entry type -/// UnifiedLogEntry is used to log different types of log entries -/// -/// The `UnifiedLogEntry` enum contains the following variants: -/// - `Server` - a server log entry -/// - `Audit` - an audit log entry -/// - `Console` - a console log entry -/// -/// The `UnifiedLogEntry` enum contains the following methods: -/// - `to_json` - convert the log entry to JSON -/// - `get_timestamp` - get the timestamp of the log entry -/// -/// # Example -/// ``` -/// use rustfs_audit_logger::{UnifiedLogEntry, ServerLogEntry}; -/// use tracing_core::Level; -/// -/// let server_entry = ServerLogEntry::new(Level::INFO, "test_module".to_string()); -/// let unified = UnifiedLogEntry::Server(server_entry); -/// ``` -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(tag = "type")] -pub enum UnifiedLogEntry { - #[serde(rename = "server")] - Server(ServerLogEntry), - - #[serde(rename = "audit")] - Audit(Box), - - #[serde(rename = "console")] - Console(ConsoleLogEntry), -} - -impl LogRecord for UnifiedLogEntry { - fn to_json(&self) -> String { - match self { - UnifiedLogEntry::Server(entry) => entry.to_json(), - UnifiedLogEntry::Audit(entry) => entry.to_json(), - UnifiedLogEntry::Console(entry) => entry.to_json(), - } - } - - fn get_timestamp(&self) -> DateTime { - match self { - UnifiedLogEntry::Server(entry) => entry.get_timestamp(), - UnifiedLogEntry::Audit(entry) => entry.get_timestamp(), - UnifiedLogEntry::Console(entry) => entry.get_timestamp(), - } - } -} diff --git a/crates/audit-logger/src/lib.rs b/crates/audit-logger/src/lib.rs deleted file mode 100644 index afa0422b..00000000 --- a/crates/audit-logger/src/lib.rs +++ /dev/null @@ -1,8 +0,0 @@ -mod entry; -mod logger; - -pub use entry::args::Args; -pub use entry::audit::{ApiDetails, AuditLogEntry}; -pub use entry::base::BaseLogEntry; -pub use entry::unified::{ConsoleLogEntry, ServerLogEntry, UnifiedLogEntry}; -pub use entry::{LogKind, LogRecord, ObjectVersion, SerializableLevel}; diff --git a/crates/audit-logger/src/logger/config.rs b/crates/audit-logger/src/logger/config.rs deleted file mode 100644 index d6f8656f..00000000 --- a/crates/audit-logger/src/logger/config.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2024 RustFS Team -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#![allow(dead_code)] - -// Default value function -fn default_batch_size() -> usize { - 10 -} -fn default_queue_size() -> usize { - 10000 -} -fn default_max_retry() -> u32 { - 5 -} -fn default_retry_interval() -> std::time::Duration { - std::time::Duration::from_secs(3) -} diff --git a/crates/audit-logger/src/logger/dispatch.rs b/crates/audit-logger/src/logger/dispatch.rs deleted file mode 100644 index 439d7a7c..00000000 --- a/crates/audit-logger/src/logger/dispatch.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2024 RustFS Team -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. diff --git a/crates/audit-logger/src/logger/entry.rs b/crates/audit-logger/src/logger/entry.rs deleted file mode 100644 index 4d2d25a3..00000000 --- a/crates/audit-logger/src/logger/entry.rs +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2024 RustFS Team -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#![allow(dead_code)] - -use chrono::{DateTime, Utc}; -use serde::Serialize; -use std::collections::HashMap; -use uuid::Uuid; - -///A Trait for a log entry that can be serialized and sent -pub trait Loggable: Serialize + Send + Sync + 'static { - fn to_json(&self) -> Result { - serde_json::to_string(self) - } -} - -/// Standard log entries -#[derive(Serialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct LogEntry { - pub deployment_id: String, - pub level: String, - pub message: String, - #[serde(skip_serializing_if = "Option::is_none")] - pub trace: Option, - pub time: DateTime, - pub request_id: String, -} - -impl Loggable for LogEntry {} - -/// Audit log entry -#[derive(Serialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct AuditEntry { - pub version: String, - pub deployment_id: String, - pub time: DateTime, - pub trigger: String, - pub api: ApiDetails, - pub remote_host: String, - pub request_id: String, - pub user_agent: String, - pub access_key: String, - #[serde(skip_serializing_if = "HashMap::is_empty")] - pub tags: HashMap, -} - -impl Loggable for AuditEntry {} - -#[derive(Serialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct Trace { - pub message: String, - pub source: Vec, - #[serde(skip_serializing_if = "HashMap::is_empty")] - pub variables: HashMap, -} - -#[derive(Serialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct ApiDetails { - pub name: String, - pub bucket: String, - pub object: String, - pub status: String, - pub status_code: u16, - pub time_to_first_byte: String, - pub time_to_response: String, -} - -// Helper functions to create entries -impl AuditEntry { - pub fn new(api_name: &str, bucket: &str, object: &str) -> Self { - AuditEntry { - version: "1".to_string(), - deployment_id: "global-deployment-id".to_string(), - time: Utc::now(), - trigger: "incoming".to_string(), - api: ApiDetails { - name: api_name.to_string(), - bucket: bucket.to_string(), - object: object.to_string(), - status: "OK".to_string(), - status_code: 200, - time_to_first_byte: "10ms".to_string(), - time_to_response: "50ms".to_string(), - }, - remote_host: "127.0.0.1".to_string(), - request_id: Uuid::new_v4().to_string(), - user_agent: "Rust-Client/1.0".to_string(), - access_key: "minioadmin".to_string(), - tags: HashMap::new(), - } - } -} diff --git a/crates/audit-logger/src/logger/factory.rs b/crates/audit-logger/src/logger/factory.rs deleted file mode 100644 index 439d7a7c..00000000 --- a/crates/audit-logger/src/logger/factory.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2024 RustFS Team -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. diff --git a/crates/audit-logger/src/logger/mod.rs b/crates/audit-logger/src/logger/mod.rs deleted file mode 100644 index a192fbcd..00000000 --- a/crates/audit-logger/src/logger/mod.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2024 RustFS Team -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#![allow(dead_code)] - -pub mod config; -pub mod dispatch; -pub mod entry; -pub mod factory; - -use async_trait::async_trait; -use std::error::Error; - -/// General Log Target Trait -#[async_trait] -pub trait Target: Send + Sync { - /// Send a single logizable entry - async fn send(&self, entry: Box) -> Result<(), Box>; - - /// Returns the unique name of the target - fn name(&self) -> &str; - - /// Close target gracefully, ensuring all buffered logs are processed - async fn shutdown(&self); -} diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index 761ee3cc..20fc2cba 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -51,7 +51,6 @@ rustfs-obs = { workspace = true } rustfs-utils = { workspace = true, features = ["full"] } rustfs-protos = { workspace = true } rustfs-s3select-query = { workspace = true } -rustfs-audit-logger = { workspace = true } rustfs-targets = { workspace = true } atoi = { workspace = true } atomic_enum = { workspace = true }