diff --git a/Cargo.lock b/Cargo.lock index d7e7010dd..bc7bf26bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -255,16 +255,6 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" -[[package]] -name = "bcder" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c627747a6774aab38beb35990d88309481378558875a41da1a4b2e373c906ef0" -dependencies = [ - "bytes", - "smallvec", -] - [[package]] name = "bincode" version = "1.3.3" @@ -694,12 +684,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "const-random" version = "0.1.17" @@ -735,16 +719,6 @@ dependencies = [ "unicode-segmentation", ] -[[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.6" @@ -1045,23 +1019,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "cryptographic-message-syntax" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43c324ba1028cef7e3a71a00cbf585637bb0215dec2f6a2b566d094190a1309b" -dependencies = [ - "bcder", - "bytes", - "chrono", - "hex", - "pem", - "reqwest", - "ring", - "signature", - "x509-certificate", -] - [[package]] name = "csscolorparser" version = "0.6.2" @@ -1122,16 +1079,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5729f5117e208430e437df2f4843f5e5952997175992d1414f94c57d61e270b4" -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - [[package]] name = "deranged" version = "0.3.11" @@ -1229,15 +1176,6 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" -[[package]] -name = "encoding_rs" -version = "0.8.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" -dependencies = [ - "cfg-if", -] - [[package]] name = "enum_dispatch" version = "0.3.12" @@ -1381,15 +1319,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "form_urlencoded" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" -dependencies = [ - "percent-encoding", -] - [[package]] name = "fraction" version = "0.14.0" @@ -1422,54 +1351,6 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" -[[package]] -name = "futures-channel" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" -dependencies = [ - "futures-core", -] - -[[package]] -name = "futures-core" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" - -[[package]] -name = "futures-io" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" - -[[package]] -name = "futures-sink" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" - -[[package]] -name = "futures-task" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" - -[[package]] -name = "futures-util" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" -dependencies = [ - "futures-core", - "futures-io", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - [[package]] name = "fxhash" version = "0.2.1" @@ -1577,25 +1458,6 @@ dependencies = [ "yansi 1.0.0-rc.1", ] -[[package]] -name = "h2" -version = "0.3.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap 2.2.2", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "half" version = "2.3.1" @@ -1684,84 +1546,12 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "http" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" -dependencies = [ - "bytes", - "http", - "pin-project-lite", -] - -[[package]] -name = "httparse" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" - -[[package]] -name = "httpdate" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" - [[package]] name = "humantime" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" -[[package]] -name = "hyper" -version = "0.14.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "hyper-rustls" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" -dependencies = [ - "futures-util", - "http", - "hyper", - "rustls", - "tokio", - "tokio-rustls", -] - [[package]] name = "iana-time-zone" version = "0.1.60" @@ -1797,16 +1587,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" -[[package]] -name = "idna" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - [[package]] name = "ignore" version = "0.4.22" @@ -1914,12 +1694,6 @@ version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa3eb1c7e05b0f9ddc99a1e9f186a434fa0bfd0087d6369acf5f2814731ab610" -[[package]] -name = "ipnet" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" - [[package]] name = "is-terminal" version = "0.4.10" @@ -2243,12 +2017,6 @@ dependencies = [ "cpufeatures", ] -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - [[package]] name = "minimal-lexical" version = "0.2.1" @@ -2433,16 +2201,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi 0.3.4", - "libc", -] - [[package]] name = "object" version = "0.32.2" @@ -2581,22 +2339,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" -[[package]] -name = "pem" -version = "3.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8fcc794035347fb64beda2d3b462595dd2753e3f268d89c5aae77e8cf2c310" -dependencies = [ - "base64 0.21.7", - "serde", -] - -[[package]] -name = "percent-encoding" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" - [[package]] name = "pest" version = "2.7.6" @@ -2712,18 +2454,6 @@ dependencies = [ "siphasher", ] -[[package]] -name = "pin-project-lite" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" - -[[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.29" @@ -2998,9 +2728,6 @@ name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] [[package]] name = "rayon" @@ -3111,47 +2838,6 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" -[[package]] -name = "reqwest" -version = "0.11.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251" -dependencies = [ - "base64 0.21.7", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper", - "hyper-rustls", - "ipnet", - "js-sys", - "log", - "mime", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls", - "rustls-pemfile", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper", - "system-configuration", - "tokio", - "tokio-rustls", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "webpki-roots", - "winreg", -] - [[package]] name = "rgb" version = "0.8.37" @@ -3161,20 +2847,6 @@ dependencies = [ "bytemuck", ] -[[package]] -name = "ring" -version = "0.17.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" -dependencies = [ - "cc", - "getrandom", - "libc", - "spin", - "untrusted", - "windows-sys 0.48.0", -] - [[package]] name = "roxmltree" version = "0.19.0" @@ -3206,37 +2878,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "rustls" -version = "0.21.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" -dependencies = [ - "log", - "ring", - "rustls-webpki", - "sct", -] - -[[package]] -name = "rustls-pemfile" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" -dependencies = [ - "base64 0.21.7", -] - -[[package]] -name = "rustls-webpki" -version = "0.101.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "rustversion" version = "1.0.14" @@ -3264,16 +2905,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sct" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "semver" version = "0.11.0" @@ -3344,18 +2975,6 @@ dependencies = [ "serde", ] -[[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 = "sha1" version = "0.10.6" @@ -3437,15 +3056,6 @@ dependencies = [ "libc", ] -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "rand_core", -] - [[package]] name = "similar" version = "2.4.0" @@ -3487,15 +3097,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "slab" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] - [[package]] name = "slice-group-by" version = "0.3.1" @@ -3511,32 +3112,6 @@ dependencies = [ "serde", ] -[[package]] -name = "socket2" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" -dependencies = [ - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "sptr" version = "0.3.2" @@ -3676,33 +3251,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - -[[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 = "tap" version = "1.0.1" @@ -3865,67 +3413,12 @@ dependencies = [ "serde_json", ] -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - [[package]] name = "tlsh-fixed" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f762ca8308eda1e38512dc88a99f021e5214699ba133de157f588c8bfd0745c7" -[[package]] -name = "tokio" -version = "1.36.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" -dependencies = [ - "backtrace", - "bytes", - "libc", - "mio", - "num_cpus", - "pin-project-lite", - "socket2", - "windows-sys 0.48.0", -] - -[[package]] -name = "tokio-rustls" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" -dependencies = [ - "rustls", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", - "tracing", -] - [[package]] name = "toml" version = "0.5.11" @@ -3935,37 +3428,6 @@ dependencies = [ "serde", ] -[[package]] -name = "tower-service" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" - -[[package]] -name = "tracing" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" -dependencies = [ - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", -] - -[[package]] -name = "try-lock" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" - [[package]] name = "typenum" version = "1.17.0" @@ -3987,27 +3449,12 @@ dependencies = [ "version_check", ] -[[package]] -name = "unicode-bidi" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" - [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "unicode-normalization" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] - [[package]] name = "unicode-segmentation" version = "1.10.1" @@ -4032,23 +3479,6 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1766d682d402817b5ac4490b3c3002d91dfa0d22812f341609f97b08757359c" -[[package]] -name = "untrusted" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" - -[[package]] -name = "url" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - [[package]] name = "utf8parse" version = "0.2.1" @@ -4117,15 +3547,6 @@ dependencies = [ "syn 1.0.109", ] -[[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.0+wasi-snapshot-preview1" @@ -4157,18 +3578,6 @@ dependencies = [ "wasm-bindgen-shared", ] -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "wasm-bindgen-macro" version = "0.2.90" @@ -4577,12 +3986,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki-roots" -version = "0.25.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" - [[package]] name = "wezterm-bidi" version = "0.2.3" @@ -4892,16 +4295,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" -[[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-parser" version = "0.13.1" @@ -4928,25 +4321,6 @@ dependencies = [ "tap", ] -[[package]] -name = "x509-certificate" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66534846dec7a11d7c50a74b7cdb208b9a581cad890b7866430d438455847c85" -dependencies = [ - "bcder", - "bytes", - "chrono", - "der", - "hex", - "pem", - "ring", - "signature", - "spki", - "thiserror", - "zeroize", -] - [[package]] name = "yaml-rust" version = "0.4.5" @@ -5009,7 +4383,6 @@ dependencies = [ "bstr 1.9.0", "crc32fast", "criterion", - "cryptographic-message-syntax", "fmmap", "globwalk", "goldenfile", @@ -5191,26 +4564,6 @@ dependencies = [ "syn 2.0.48", ] -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - [[package]] name = "zip" version = "0.6.6" diff --git a/Cargo.toml b/Cargo.toml index d8db58d92..3a446aefb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,7 +43,6 @@ chrono = "0.4.34" clap = "4.4.8" crc32fast = "1.3.2" criterion = "0.5.1" -cryptographic-message-syntax = "0.26.0" enable-ansi-support = "0.2.1" env_logger = "0.11.1" fmmap = "0.3.2" @@ -71,12 +70,12 @@ num-derive = "0.4.1" pest = "2.7.5" pest_derive = "2.7.5" pretty_assertions = "1.4.0" -protobuf = { git = "https://github.com/plusvic/rust-protobuf.git", rev="b484d8a7" } -protobuf-codegen = { git = "https://github.com/plusvic/rust-protobuf.git", rev="b484d8a7" } -protobuf-json-mapping = { git = "https://github.com/plusvic/rust-protobuf.git", rev="b484d8a7" } -protobuf-parse = { git = "https://github.com/plusvic/rust-protobuf.git", rev="b484d8a7" } -regex-syntax = { git = "https://github.com/plusvic/regex.git", rev="423493d" } -regex-automata = { git = "https://github.com/plusvic/regex.git", rev="423493d" } +protobuf = { git = "https://github.com/plusvic/rust-protobuf.git", rev = "b484d8a7" } +protobuf-codegen = { git = "https://github.com/plusvic/rust-protobuf.git", rev = "b484d8a7" } +protobuf-json-mapping = { git = "https://github.com/plusvic/rust-protobuf.git", rev = "b484d8a7" } +protobuf-parse = { git = "https://github.com/plusvic/rust-protobuf.git", rev = "b484d8a7" } +regex-syntax = { git = "https://github.com/plusvic/regex.git", rev = "423493d" } +regex-automata = { git = "https://github.com/plusvic/regex.git", rev = "423493d" } roxmltree = "0.19.0" rustc-hash = "1.1.0" smallvec = "1.10.0" diff --git a/capi/include/yara-x.h b/capi/include/yara-x.h index 75dba5c0c..a4b07befb 100644 --- a/capi/include/yara-x.h +++ b/capi/include/yara-x.h @@ -294,4 +294,24 @@ enum YRX_RESULT yrx_scanner_set_module_output(struct YRX_SCANNER *scanner, const uint8_t *data, size_t len); +// Sets the value of a global variable of type string. +enum YRX_RESULT yrx_scanner_set_global_str(struct YRX_SCANNER *scanner, + const char *ident, + const char *value); + +// Sets the value of a global variable of type bool. +enum YRX_RESULT yrx_scanner_set_global_bool(struct YRX_SCANNER *scanner, + const char *ident, + bool value); + +// Sets the value of a global variable of type int. +enum YRX_RESULT yrx_scanner_set_global_int(struct YRX_SCANNER *scanner, + const char *ident, + int64_t value); + +// Sets the value of a global variable of type float. +enum YRX_RESULT yrx_scanner_set_global_float(struct YRX_SCANNER *scanner, + const char *ident, + double value); + #endif /* YARA_X */ diff --git a/capi/src/lib.rs b/capi/src/lib.rs index 7f508ec48..ade9e2ada 100644 --- a/capi/src/lib.rs +++ b/capi/src/lib.rs @@ -325,9 +325,11 @@ pub unsafe extern "C" fn yrx_buffer_destroy(buf: *mut YRX_BUFFER) { /// the most recent function was successfully. #[no_mangle] pub unsafe extern "C" fn yrx_last_error() -> *const c_char { - if let Some(last_error) = LAST_ERROR.with(|_| None::) { - last_error.as_ptr() - } else { - std::ptr::null() - } + LAST_ERROR.with_borrow(|last_error| { + if let Some(last_error) = last_error { + last_error.as_ptr() + } else { + std::ptr::null() + } + }) } diff --git a/capi/src/scanner.rs b/capi/src/scanner.rs index 85f1bd582..e1d3edc89 100644 --- a/capi/src/scanner.rs +++ b/capi/src/scanner.rs @@ -215,6 +215,82 @@ pub unsafe extern "C" fn yrx_scanner_set_module_output( } } +unsafe extern "C" fn yrx_scanner_set_global< + T: TryInto, +>( + scanner: *mut YRX_SCANNER, + ident: *const c_char, + value: T, +) -> YRX_RESULT { + if scanner.is_null() { + return YRX_RESULT::INVALID_ARGUMENT; + } + + let ident = match CStr::from_ptr(ident).to_str() { + Ok(ident) => ident, + Err(_) => return YRX_RESULT::INVALID_ARGUMENT, + }; + + let scanner = scanner.as_mut().unwrap(); + + match scanner.inner.set_global(ident, value) { + Ok(_) => { + LAST_ERROR.set(None); + YRX_RESULT::SUCCESS + } + Err(err) => { + LAST_ERROR.set(Some(CString::new(err.to_string()).unwrap())); + YRX_RESULT::SCAN_ERROR + } + } +} + +/// Sets the value of a global variable of type string. +#[no_mangle] +pub unsafe extern "C" fn yrx_scanner_set_global_str( + scanner: *mut YRX_SCANNER, + ident: *const c_char, + value: *const c_char, +) -> YRX_RESULT { + let value = if let Ok(value) = CStr::from_ptr(value).to_str() { + value + } else { + return YRX_RESULT::INVALID_ARGUMENT; + }; + + yrx_scanner_set_global(scanner, ident, value) +} + +/// Sets the value of a global variable of type bool. +#[no_mangle] +pub unsafe extern "C" fn yrx_scanner_set_global_bool( + scanner: *mut YRX_SCANNER, + ident: *const c_char, + value: bool, +) -> YRX_RESULT { + yrx_scanner_set_global(scanner, ident, value) +} + +/// Sets the value of a global variable of type int. +#[no_mangle] +pub unsafe extern "C" fn yrx_scanner_set_global_int( + scanner: *mut YRX_SCANNER, + ident: *const c_char, + value: i64, +) -> YRX_RESULT { + yrx_scanner_set_global(scanner, ident, value) +} + +/// Sets the value of a global variable of type float. +#[no_mangle] +pub unsafe extern "C" fn yrx_scanner_set_global_float( + scanner: *mut YRX_SCANNER, + ident: *const c_char, + value: f64, +) -> YRX_RESULT { + yrx_scanner_set_global(scanner, ident, value) +} + unsafe fn slice_from_ptr_and_len<'a>( data: *const u8, len: usize, diff --git a/capi/src/tests.rs b/capi/src/tests.rs index fb2a041b0..f7e4794ee 100644 --- a/capi/src/tests.rs +++ b/capi/src/tests.rs @@ -7,7 +7,7 @@ use crate::compiler::{ use crate::{ yrx_buffer_destroy, yrx_rules_deserialize, yrx_rules_serialize, yrx_scanner_create, yrx_scanner_destroy, yrx_scanner_on_matching_rule, - yrx_scanner_scan, YRX_BUFFER, YRX_RULE, + yrx_scanner_scan, yrx_scanner_set_global_bool, YRX_BUFFER, YRX_RULE, }; use std::ffi::{c_void, CString}; @@ -75,8 +75,16 @@ fn capi() { ); yrx_scanner_scan(scanner, std::ptr::null(), 0); - yrx_scanner_destroy(scanner); - assert_eq!(matches, 1); + + matches = 0; + + // After changing the value of `some_bool` to false, the rule doesn't + // match anymore. + yrx_scanner_set_global_bool(scanner, some_bool.as_ptr(), false); + yrx_scanner_scan(scanner, std::ptr::null(), 0); + assert_eq!(matches, 0); + + yrx_scanner_destroy(scanner); } } diff --git a/go/compiler_test.go b/go/compiler_test.go index 2677be478..67bc71703 100644 --- a/go/compiler_test.go +++ b/go/compiler_test.go @@ -71,11 +71,18 @@ func TestVariables(t *testing.T) { assert.Len(t, matchingRules, 1) err := c.DefineGlobal("var", struct{}{}) - assert.Errorf(t, err, "variable `var` has unsupported type: struct{}") + assert.EqualError(t, err, "variable `var` has unsupported type: struct {}") } func TestError(t *testing.T) { c := NewCompiler() err := c.AddSource("rule test { condition: foo }") - assert.Error(t, err) + assert.EqualError(t, err, `error: unknown identifier `+"`foo`"+` + ╭─[line:1:24] + │ + 1 │ rule test { condition: foo } + │ ─┬─ + │ ╰─── this identifier has not been declared +───╯ +`) } diff --git a/go/scanner.go b/go/scanner.go index f556751c8..b7eb0b24c 100644 --- a/go/scanner.go +++ b/go/scanner.go @@ -3,6 +3,7 @@ package yara_x import "C" import ( "errors" + "fmt" "math" "runtime" "runtime/cgo" @@ -89,6 +90,46 @@ func (s *Scanner) Timeout(timeout time.Duration) { var ErrTimeout = errors.New("timeout") +// SetGlobal sets the value of a global variable. +// +// The variable must has been previously defined by calling Compiler.DefineGlobal +// and the type it has during the definition must match the type of the new +// value. +// +// The variable will retain the new value in subsequent scans, unless this +// function is called again for setting a new value. +func (s *Scanner) SetGlobal(ident string, value interface{}) error { + cIdent := C.CString(ident) + defer C.free(unsafe.Pointer(cIdent)) + var ret C.int + + runtime.LockOSThread() + defer runtime.UnlockOSThread() + + switch v := value.(type) { + case int: + ret = C.int(C.yrx_scanner_set_global_int(s.cScanner, cIdent, C.int64_t(v))) + case bool: + ret = C.int(C.yrx_scanner_set_global_bool(s.cScanner, cIdent, C.bool(v))) + case string: + cValue := C.CString(v) + defer C.free(unsafe.Pointer(cValue)) + ret = C.int(C.yrx_scanner_set_global_str(s.cScanner, cIdent, cValue)) + case float64: + ret = C.int(C.yrx_scanner_set_global_float(s.cScanner, cIdent, C.double(v))) + default: + return fmt.Errorf("variable `%s` has unsupported type: %T", ident, v) + } + + runtime.KeepAlive(s) + + if ret == C.VARIABLE_ERROR { + return errors.New(C.GoString(C.yrx_last_error())) + } + + return nil +} + // SetModuleOutput sets the output data for a YARA module. // // Each YARA module generates an output consisting of a data structure that diff --git a/go/scanner_test.go b/go/scanner_test.go index dfe13b3a5..11c394ccf 100644 --- a/go/scanner_test.go +++ b/go/scanner_test.go @@ -37,6 +37,20 @@ func TestScanner2(t *testing.T) { runtime.GC() } +func TestScanner3(t *testing.T) { + r, _ := Compile( + `rule t { condition: var_bool }`, + GlobalVars(map[string]interface{}{"var_bool": true})) + + s := NewScanner(r) + matchingRules, _ := s.Scan([]byte{}) + assert.Len(t, matchingRules, 1) + + s.SetGlobal("var_bool", false) + matchingRules, _ = s.Scan([]byte{}) + assert.Len(t, matchingRules, 0) +} + func TestScannerTimeout(t *testing.T) { r, _ := Compile("rule t { strings: $a = /a(.*)*a/ condition: $a }") s := NewScanner(r) diff --git a/lib/Cargo.toml b/lib/Cargo.toml index d93c86650..cdc37014b 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -93,7 +93,6 @@ lnk-module = [ # The `macho` module parses Mach-O files. macho-module = [ "dep:nom", - "dep:cryptographic-message-syntax", "dep:roxmltree", ] @@ -157,7 +156,6 @@ bitmask = { workspace = true } bitvec = { workspace = true } bstr = { workspace = true, features = ["serde"] } crc32fast = { workspace = true, optional = true } -cryptographic-message-syntax = { workspace = true, optional = true } fmmap = { workspace = true } indexmap = { workspace = true, features = ["serde"] } intaglio = { workspace = true } @@ -178,8 +176,8 @@ rustc-hash = { workspace = true } regex-syntax = { workspace = true } regex-automata = { workspace = true } roxmltree = { workspace = true, optional = true } -smallvec = { workspace = true, features=["serde"] } -serde = { workspace = true, features=["rc"] } +smallvec = { workspace = true, features = ["serde"] } +serde = { workspace = true, features = ["rc"] } serde_json = { workspace = true } thiserror = { workspace = true } tlsh-fixed = { workspace = true, optional = true } diff --git a/lib/src/compiler/rules.rs b/lib/src/compiler/rules.rs index 9a5678ed9..61336b391 100644 --- a/lib/src/compiler/rules.rs +++ b/lib/src/compiler/rules.rs @@ -206,7 +206,7 @@ impl Rules { self.rules.get(rule_id.0 as usize).unwrap() } - /// Returns an slice with the individual rules that were compiled. + /// Returns a slice with the individual rules that were compiled. #[inline] pub(crate) fn rules(&self) -> &[RuleInfo] { self.rules.as_slice() @@ -233,8 +233,8 @@ impl Rules { let re = types::Regexp::new(self.regexp_pool.get(regexp_id).unwrap()); let mut parser = regex_syntax::ast::parse::ParserBuilder::new() - // This the custom configuration option that turns-on support for - // the `{,n}`. This option doesn't exist in the official + // This is the custom configuration option that turns-on support + // for the `{,n}` syntax. This option doesn't exist in the official // `regex_syntax` crate. .empty_min_range(true) .build(); @@ -249,7 +249,18 @@ impl Rules { let hir = translator.translate(re.naked(), &ast).unwrap(); - regex_automata::meta::Builder::new().build_from_hir(&hir).unwrap() + // Set a size limit for the NFA automata. The default limit (10MB) is + // too small for certain regexps seen in YARA rules in the wild, see: + // https://github.com/VirusTotal/yara-x/issues/85 + let config = regex_automata::meta::Config::new() + .nfa_size_limit(Some(50 * 1024 * 1024)); + + regex_automata::meta::Builder::new() + .configure(config) + .build_from_hir(&hir) + .unwrap_or_else(|err| { + panic!("error compiling regex `{}`: {:#?}", re.as_str(), err) + }) } /// Returns a sub-pattern by [`SubPatternId`]. diff --git a/lib/src/modules/macho/parser.rs b/lib/src/modules/macho/parser.rs index 7505e3aad..efff66528 100644 --- a/lib/src/modules/macho/parser.rs +++ b/lib/src/modules/macho/parser.rs @@ -1,6 +1,5 @@ use crate::modules::protos; use bstr::{BStr, ByteSlice}; -use cryptographic_message_syntax::SignedData; #[cfg(feature = "logging")] use log::error; use nom::bytes::complete::take; @@ -33,7 +32,7 @@ const _CS_MAGIC_REQUIREMENTS: u32 = 0xfade0c01; const _CS_MAGIC_CODEDIRECTORY: u32 = 0xfade0c02; const _CS_MAGIC_EMBEDDED_SIGNATURE: u32 = 0xfade0cc0; const _CS_MAGIC_DETACHED_SIGNATURE: u32 = 0xfade0cc1; -const CS_MAGIC_BLOBWRAPPER: u32 = 0xfade0b01; +const _CS_MAGIC_BLOBWRAPPER: u32 = 0xfade0b01; const CS_MAGIC_EMBEDDED_ENTITLEMENTS: u32 = 0xfade7171; /// Mach-O dynamic linker constant @@ -124,7 +123,7 @@ impl<'a> MachO<'a> { FAT_MAGIC | FAT_CIGAM | FAT_MAGIC_64 | FAT_CIGAM_64 ) }) - .parse(data)?; + .parse(data)?; // The magic number indicates the endianness. let endianness = match magic { @@ -203,7 +202,7 @@ impl<'a> MachO<'a> { let (remainder, magic) = verify(be_u32, |magic| { matches!(*magic, MH_MAGIC | MH_CIGAM | MH_MAGIC_64 | MH_CIGAM_64) }) - .parse(data)?; + .parse(data)?; let endianness = match magic { MH_MAGIC | MH_MAGIC_64 => Endianness::Big, @@ -228,14 +227,14 @@ impl<'a> MachO<'a> { cond(!is_32_bits, u32(endianness)), // reserved, only in 64-bits )), |( - cputype, - cpusubtype, - filetype, - ncmds, - sizeofcmds, - flags, - reserved, - )| { + cputype, + cpusubtype, + filetype, + ncmds, + sizeofcmds, + flags, + reserved, + )| { MachOHeader { magic, cputype, @@ -395,19 +394,19 @@ impl<'a> MachOFile<'a> { cond(!self.is_32_bits, u32(self.endianness)), // reserved3 )), |( - sectname, - segname, - addr, - size, - offset, - align, - reloff, - nreloc, - flags, - reserved1, - reserved2, - reserved3, - )| { + sectname, + segname, + addr, + size, + offset, + align, + reloff, + nreloc, + flags, + reserved1, + reserved2, + reserved3, + )| { Section { sectname, segname, @@ -686,23 +685,23 @@ impl<'a> MachOFile<'a> { u32(self.endianness), // nlocrel )), |( - ilocalsym, - nlocalsym, - iextdefsym, - nextdefsym, - tocoff, - ntoc, - modtaboff, - nmodtab, - extrefsymoff, - nextrefsyms, - indirectsymoff, - nindirectsyms, - extreloff, - nextrel, - locreloff, - nlocrel, - )| { + ilocalsym, + nlocalsym, + iextdefsym, + nextdefsym, + tocoff, + ntoc, + modtaboff, + nmodtab, + extrefsymoff, + nextrefsyms, + indirectsymoff, + nindirectsyms, + extreloff, + nextrel, + locreloff, + nlocrel, + )| { Dysymtab { ilocalsym, nlocalsym, @@ -797,67 +796,32 @@ impl<'a> MachOFile<'a> { let offset = blob_index.offset as usize; let length = blob.length as usize; let size_of_blob = std::mem::size_of::(); - match blob.magic { - CS_MAGIC_EMBEDDED_ENTITLEMENTS => { - let xml_data = &super_data - [offset + size_of_blob..offset + length]; - let xml_string = std::str::from_utf8(xml_data) - .unwrap_or_default(); - - let opt = roxmltree::ParsingOptions { - allow_dtd: true, - ..roxmltree::ParsingOptions::default() - }; - - if let Ok(parsed_xml) = - roxmltree::Document::parse_with_options( - xml_string, opt, - ) + if blob.magic == CS_MAGIC_EMBEDDED_ENTITLEMENTS { + let xml_data = &super_data + [offset + size_of_blob..offset + length]; + let xml_string = std::str::from_utf8(xml_data) + .unwrap_or_default(); + + let opt = roxmltree::ParsingOptions { + allow_dtd: true, + ..roxmltree::ParsingOptions::default() + }; + + if let Ok(parsed_xml) = + roxmltree::Document::parse_with_options( + xml_string, opt, + ) + { + for node in parsed_xml + .descendants() + .filter(|n| n.has_tag_name("key")) { - for node in parsed_xml - .descendants() - .filter(|n| n.has_tag_name("key")) - { - if let Some(entitlement) = node.text() { - self.entitlements - .push(entitlement.to_string()); - } + if let Some(entitlement) = node.text() { + self.entitlements + .push(entitlement.to_string()); } } } - CS_MAGIC_BLOBWRAPPER => { - if let Ok(signage) = SignedData::parse_ber( - &super_data - [offset + size_of_blob..offset + length], - ) { - let signers = signage.signers(); - let certs = signage.certificates(); - let mut cert_info = Certificates { - common_names: Vec::new(), - signer_names: Vec::new(), - }; - - certs.for_each(|cert| { - let name = - cert.subject_common_name().unwrap(); - cert_info.common_names.push(name); - }); - - signers.for_each(|signer| { - let (name, _) = signer - .certificate_issuer_and_serial() - .unwrap(); - cert_info.signer_names.push( - name.user_friendly_str() - .unwrap() - .to_string(), - ); - }); - - self.certificates = Some(cert_info); - } - } - _ => {} } } } @@ -884,17 +848,17 @@ impl<'a> MachOFile<'a> { u32(self.endianness), // export_size )), |( - rebase_off, - rebase_size, - bind_off, - bind_size, - weak_bind_off, - weak_bind_size, - lazy_bind_off, - lazy_bind_size, - export_off, - export_size, - )| { + rebase_off, + rebase_size, + bind_off, + bind_size, + weak_bind_off, + weak_bind_size, + lazy_bind_off, + lazy_bind_size, + export_off, + export_size, + )| { DyldInfo { rebase_off, rebase_size, @@ -1679,7 +1643,7 @@ impl From<&MinVersion> for protos::macho::MinVersion { protobuf::EnumOrUnknown::::from_i32( mv.device as i32, ) - .unwrap(), + .unwrap(), ); result.set_version(convert_to_version_string(mv.version)); result.set_sdk(convert_to_version_string(mv.sdk)); diff --git a/lib/src/modules/macho/tests/testdata/01ac68a14f0ff5faa72bb33e768bfaae4d21de61f776e2405324c498ef52b21b.out b/lib/src/modules/macho/tests/testdata/01ac68a14f0ff5faa72bb33e768bfaae4d21de61f776e2405324c498ef52b21b.out index 87e46e880..1d0453fb4 100644 --- a/lib/src/modules/macho/tests/testdata/01ac68a14f0ff5faa72bb33e768bfaae4d21de61f776e2405324c498ef52b21b.out +++ b/lib/src/modules/macho/tests/testdata/01ac68a14f0ff5faa72bb33e768bfaae4d21de61f776e2405324c498ef52b21b.out @@ -450,13 +450,6 @@ dyld_info: lazy_bind_size: 2464 export_off: 31816 export_size: 2448 -certificates: - common_names: - - "Developer ID Certification Authority" - - "Apple Root CA" - - "Developer ID Application: EFI Inc (82PCFB3NFC)" - signer_names: - - "CN=Developer ID Certification Authority, OU=Apple Certification Authority, O=Apple Inc., C=US" uuid: "B23FC3D5-BDF8-3056-930A-C93E0F547B78" min_version: device: MACOSX diff --git a/lib/src/modules/macho/tests/testdata/chess.out b/lib/src/modules/macho/tests/testdata/chess.out index 58923b9c6..34cf6f9e9 100644 --- a/lib/src/modules/macho/tests/testdata/chess.out +++ b/lib/src/modules/macho/tests/testdata/chess.out @@ -821,13 +821,6 @@ entitlements: - "com.apple.security.device.microphone" - "com.apple.security.files.user-selected.read-write" - "com.apple.security.network.client" -certificates: - common_names: - - "Apple Code Signing Certification Authority" - - "Apple Root CA" - - "Software Signing" - signer_names: - - "CN=Apple Code Signing Certification Authority, OU=Apple Certification Authority, O=Apple Inc., C=US" uuid: "18455A71-F835-3D0F-8F7C-215BF86BC7AF" build_version: platform: 1 diff --git a/lib/src/types/structure.rs b/lib/src/types/structure.rs index 7440af3c9..0004f5408 100644 --- a/lib/src/types/structure.rs +++ b/lib/src/types/structure.rs @@ -3,7 +3,7 @@ use std::ops::Deref; use std::rc::Rc; use bstr::BString; -use indexmap::IndexMap; +use indexmap::{IndexMap, IndexSet}; use protobuf::reflect::{ EnumDescriptor, FieldDescriptor, MessageDescriptor, ReflectMapRef, ReflectRepeatedRef, ReflectValueRef, RuntimeFieldType, RuntimeType, @@ -34,7 +34,7 @@ pub(crate) struct StructField { /// A dynamic structure with one or more fields. /// /// These structures are used during the compilation of YARA rules and the -/// evaluation of conditions. Fields can be of any of the primitive types like +/// evaluation of conditions. Fields can be any of the primitive types like /// integers, floats or strings, or more complex types like maps, arrays and /// other structures. /// @@ -185,14 +185,14 @@ impl Struct { /// /// The `generate_fields_for_enums` controls whether the enums defined /// by the proto will be included as fields in the structure. Enums are - /// required only at compile time, so that the compiler can lookup the + /// required only at compile time, so that the compiler can look up the /// enums by name and resolve their values, but at scan time enums are /// not necessary because their values are already embedded in the code. /// The scanner never asks for an enum by field index. /// /// Also notice that a .proto file can define enums at the top level, - /// outside of any message. Those enums will be handled as if they were - /// defined inside of the module's root message, in other words, if you + /// outside any message. Those enums will be handled as if they were + /// defined inside the module's root message, in other words, if you /// have this proto that defines a YARA module... /// /// ```text @@ -299,22 +299,27 @@ impl Struct { fields.sort_by(|a, b| a.1.number.cmp(&b.1.number)); if generate_fields_for_enums { + let mut enums = IndexSet::new(); + // Enums declared inside a message are treated as a nested // structure where each field is an enum item, and each // field has a constant value. - let enums = msg_descriptor.nested_enums(); + for enum_ in msg_descriptor.nested_enums() { + enums.insert(enum_); + } // If the message is the module's root message, the enums that are - // declared in the file outside of any structures are also added as - // fields of this structure. - let enums: Box> = - if Self::is_root_msg(msg_descriptor) { - Box::new( - enums.chain(msg_descriptor.file_descriptor().enums()), - ) - } else { - Box::new(enums) - }; + // declared in the file outside any structures, and those that are + // used by the root message (either directly or indirectly) are + // added as fields of this structure too. + if Self::is_root_msg(msg_descriptor) { + for enum_ in msg_descriptor.file_descriptor().enums() { + enums.insert(enum_); + } + Self::enums_used(msg_descriptor, &mut |enum_| { + enums.insert(enum_); + }); + } for enum_ in enums { if Self::enum_is_inline(&enum_) { @@ -403,8 +408,39 @@ impl Struct { } } + /// Calls `f` for every enum type used by a protobuf message, both directly + /// (fields of type enum declared in the message), or indirectly (fields of + /// message type that use some enum type). + fn enums_used(msg_descriptor: &MessageDescriptor, f: &mut F) + where + F: FnMut(EnumDescriptor), + { + for fd in msg_descriptor.fields() { + if Self::ignore_field(&fd) { + continue; + } + match fd.runtime_field_type() { + RuntimeFieldType::Singular(RuntimeType::Enum(e)) => f(e), + RuntimeFieldType::Repeated(RuntimeType::Enum(e)) => f(e), + RuntimeFieldType::Singular(RuntimeType::Message(m)) => { + if m.full_name() == msg_descriptor.full_name() { + panic!("recursive protobuf type: {}", m.full_name()) + } + Self::enums_used(&m, f); + } + RuntimeFieldType::Repeated(RuntimeType::Message(m)) => { + if m.full_name() == msg_descriptor.full_name() { + panic!("recursive protobuf type: {}", m.full_name()) + } + Self::enums_used(&m, f); + } + _ => {} + } + } + } + /// Given a [`EnumDescriptor`] returns the name that this enum will - /// have in YARA.. + /// have in YARA. /// /// By default, the name of the enum will be the same one that it has in /// the protobuf definition. However, the name can be set to something