diff --git a/crate/src/paths.rs b/crate/src/paths.rs index 2bf04d7..60301c1 100644 --- a/crate/src/paths.rs +++ b/crate/src/paths.rs @@ -1,6 +1,9 @@ pub const ANCHOR_LANG_CONTEXT: [&str; 3] = ["anchor_lang", "context", "Context"]; pub const ANCHOR_LANG_SIGNER: [&str; 4] = ["anchor_lang", "accounts", "signer", "Signer"]; - +pub const ANCHOR_ACCOUNT: [&str; 4] = ["anchor_lang", "accounts", "account", "Account"]; pub const SOLANA_PROGRAM_ACCOUNT_INFO: [&str; 3] = ["solana_program", "account_info", "AccountInfo"]; pub const BORSH_TRY_FROM_SLICE: [&str; 4] = ["borsh", "de", "BorshDeserialize", "try_from_slice"]; +pub const BINCODE_DESERIALIZE: [&str; 2] = ["bincode", "deserialize"]; +pub const ANCHOR_SYSVAR_TRAIT: [&str; 3] = ["anchor_lang", "prelude", "SolanaSysvar"]; +pub const SOLANA_SYSVAR_TRAIT: [&str; 3] = ["solana_program", "sysvar", "Sysvar"]; diff --git a/lints/sysvar_address_check/.cargo/config.toml b/lints/sysvar_address_check/.cargo/config.toml new file mode 100644 index 0000000..46d1571 --- /dev/null +++ b/lints/sysvar_address_check/.cargo/config.toml @@ -0,0 +1,11 @@ +[target.aarch64-apple-darwin] +linker = "dylint-link" + +[target.x86_64-apple-darwin] +linker = "dylint-link" + +[target.x86_64-unknown-linux-gnu] +linker = "dylint-link" + +[target.x86_64-pc-windows-msvc] +linker = "dylint-link" diff --git a/lints/sysvar_address_check/.gitignore b/lints/sysvar_address_check/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/lints/sysvar_address_check/.gitignore @@ -0,0 +1 @@ +/target diff --git a/lints/sysvar_address_check/Cargo.lock b/lints/sysvar_address_check/Cargo.lock new file mode 100644 index 0000000..52dd50e --- /dev/null +++ b/lints/sysvar_address_check/Cargo.lock @@ -0,0 +1,1918 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom 0.2.7", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + +[[package]] +name = "anchor-attribute-access-control" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70f6ee9518f50ff4d434471ccf569186022bdd5ef65a21d14da3ea5231af944f" +dependencies = [ + "anchor-syn", + "anyhow", + "proc-macro2", + "quote", + "regex", + "syn", +] + +[[package]] +name = "anchor-attribute-account" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32c92bcf5388b52676d990f85bbfd838a8f5672393135063a50dc79b2b837c79" +dependencies = [ + "anchor-syn", + "anyhow", + "bs58 0.4.0", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + +[[package]] +name = "anchor-attribute-constant" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0844974ac35e8ced62056b0d63777ebcdc5807438b8b189c881e2b647450b70a" +dependencies = [ + "anchor-syn", + "proc-macro2", + "syn", +] + +[[package]] +name = "anchor-attribute-error" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f7467345e67a6f1d4b862b9763a4160ad89d18c247b8c902807768f7b6e23df" +dependencies = [ + "anchor-syn", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "anchor-attribute-event" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8774e4c1ac71f71a5aea7e4932fb69c30e3b8155c4fa59fd69401195434528a9" +dependencies = [ + "anchor-syn", + "anyhow", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "anchor-attribute-interface" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90eeb6e1c80f9f94fcef93a52813f6472186200e275e83cb3fac92b801de92f7" +dependencies = [ + "anchor-syn", + "anyhow", + "heck 0.3.3", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "anchor-attribute-program" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac515a7a5a4fea7fc768b1cec40ddb948e148ea657637c75f94f283212326cb9" +dependencies = [ + "anchor-syn", + "anyhow", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "anchor-attribute-state" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43dc667b62ff71450f19dcfcc37b0c408fd4ddd89e8650368c2b0984b110603f" +dependencies = [ + "anchor-syn", + "anyhow", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "anchor-derive-accounts" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7354d583a06701d24800a8ec4c2b0491f62581a331af349205e23421e0b56643" +dependencies = [ + "anchor-syn", + "anyhow", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "anchor-lang" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff5f57ec5e12fa6874b27f3d5c1f6f44302d3ad86c1266197ff7611bf6f5d251" +dependencies = [ + "anchor-attribute-access-control", + "anchor-attribute-account", + "anchor-attribute-constant", + "anchor-attribute-error", + "anchor-attribute-event", + "anchor-attribute-interface", + "anchor-attribute-program", + "anchor-attribute-state", + "anchor-derive-accounts", + "arrayref", + "base64 0.13.0", + "bincode", + "borsh", + "bytemuck", + "solana-program", + "thiserror", +] + +[[package]] +name = "anchor-syn" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55aa1e680d9471342122ed5b6bc13bf5da473b0f7e4677d41a6954e5cc8ad155" +dependencies = [ + "anyhow", + "bs58 0.3.1", + "heck 0.3.3", + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "serde", + "serde_json", + "sha2 0.9.9", + "syn", + "thiserror", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anyhow" +version = "1.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base64" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitmaps" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2" +dependencies = [ + "typenum", +] + +[[package]] +name = "blake3" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a08e53fc5a564bb15bfe6fae56bd71522205f1f91893f9c0116edad6496c183f" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", + "digest 0.10.3", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +dependencies = [ + "generic-array", +] + +[[package]] +name = "borsh" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa" +dependencies = [ + "borsh-derive", + "hashbrown", +] + +[[package]] +name = "borsh-derive" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775" +dependencies = [ + "borsh-derive-internal", + "borsh-schema-derive-internal", + "proc-macro-crate", + "proc-macro2", + "syn", +] + +[[package]] +name = "borsh-derive-internal" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "borsh-schema-derive-internal" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "bs58" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "476e9cd489f9e121e02ffa6014a8ef220ecb15c05ed23fc34cca13925dc283fb" + +[[package]] +name = "bs58" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" + +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "memchr", +] + +[[package]] +name = "bumpalo" +version = "3.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" + +[[package]] +name = "bv" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8834bb1d8ee5dc048ee3124f2c7c1afcc6bc9aed03f11e9dfd8c69470a5db340" +dependencies = [ + "feature-probe", + "serde", +] + +[[package]] +name = "bytemuck" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5377c8865e74a160d21f29c2d40669f53286db6eab59b88540cbb12ffc8b835" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfd2f4180c5721da6335cc9e9061cce522b87a35e51cc57636d28d22a9863c80" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "camino" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "869119e97797867fd90f5e22af7d0bd274bd4635ebb9eb68c04f3f513ae6c412" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3abb7553d5b9b8421c6de7cb02606ff15e0c6eea7d8eadd75ef013fd636bec36" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", +] + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clippy_utils" +version = "0.1.64" +source = "git+https://github.com/rust-lang/rust-clippy?rev=0cb0f7636851f9fcc57085cf80197a2ef6db098f#0cb0f7636851f9fcc57085cf80197a2ef6db098f" +dependencies = [ + "arrayvec", + "if_chain", + "rustc-semver", +] + +[[package]] +name = "compiletest_rs" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "262134ef87408da1ddfe45e33daa0ca43b75286d6b1076446e602d264cf9847e" +dependencies = [ + "diff", + "filetime", + "getopts", + "lazy_static", + "libc", + "log", + "miow", + "regex", + "rustfix", + "serde", + "serde_derive", + "serde_json", + "tester", + "winapi", +] + +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + +[[package]] +name = "console_log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501a375961cef1a0d44767200e66e4a559283097e91d0730b1d75dfb2f8a1494" +dependencies = [ + "log", + "web-sys", +] + +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + +[[package]] +name = "cpufeatures" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +dependencies = [ + "libc", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", + "once_cell", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "curve25519-dalek" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +dependencies = [ + "block-buffer 0.10.2", + "crypto-common", + "subtle", +] + +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "dylint" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd14a51dd176304a879c6d41bcce9b537618c7cbe67a0e0edf8015681ad5d3d" +dependencies = [ + "ansi_term", + "anyhow", + "atty", + "cargo_metadata", + "dirs", + "dylint_internal", + "heck 0.4.0", + "lazy_static", + "log", + "once_cell", + "semver", + "serde", + "serde_json", + "tempfile", + "walkdir", +] + +[[package]] +name = "dylint_internal" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7fbed59f03a099ecc70f53214c4da67aa92ffb75c115418b6e74364b9185837" +dependencies = [ + "ansi_term", + "anyhow", + "cargo_metadata", + "if_chain", + "log", + "rust-embed", + "sedregex", + "walkdir", +] + +[[package]] +name = "dylint_linting" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0d3be89f70c448bbecb3dcb30d76caeae6c14a4cc826d86226b7862ef778f8d" +dependencies = [ + "paste", +] + +[[package]] +name = "dylint_testing" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d39ee540202ded889a1f660b3cbf25dce88c453bdccbb59eb8d5e2d4079883f9" +dependencies = [ + "anyhow", + "cargo_metadata", + "compiletest_rs", + "dylint", + "dylint_internal", + "env_logger", + "lazy_static", + "once_cell", + "regex", + "serde_json", + "tempfile", +] + +[[package]] +name = "either" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" + +[[package]] +name = "env_logger" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + +[[package]] +name = "feature-probe" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835a3dc7d1ec9e75e2b5fb4ba75396837112d2060b03f7d43bc1897c7f7211da" + +[[package]] +name = "filetime" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94a7bbaa59354bc20dd75b67f23e2797b4490e9d6928203fb105c79e448c86c" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "windows-sys", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "generic-array" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +dependencies = [ + "serde", + "typenum", + "version_check", +] + +[[package]] +name = "getopts" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "globset" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a1e17342619edbc21a964c2afbeb6c820c6a2560032872f397bb97ea127bd0a" +dependencies = [ + "aho-corasick", + "bstr", + "fnv", + "log", + "regex", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash", +] + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hmac" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" +dependencies = [ + "crypto-mac", + "digest 0.9.0", +] + +[[package]] +name = "hmac-drbg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" +dependencies = [ + "digest 0.9.0", + "generic-array", + "hmac", +] + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "if_chain" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" + +[[package]] +name = "im" +version = "15.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0acd33ff0285af998aaf9b57342af478078f53492322fafc47450e09397e0e9" +dependencies = [ + "bitmaps", + "rand_core 0.6.3", + "rand_xoshiro", + "rayon", + "serde", + "sized-chunks", + "typenum", + "version_check", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "itertools" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" + +[[package]] +name = "js-sys" +version = "0.3.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "keccak" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" + +[[package]] +name = "libsecp256k1" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9d220bc1feda2ac231cb78c3d26f27676b8cf82c96971f7aeef3d0cf2797c73" +dependencies = [ + "arrayref", + "base64 0.12.3", + "digest 0.9.0", + "hmac-drbg", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand", + "serde", + "sha2 0.9.9", + "typenum", +] + +[[package]] +name = "libsecp256k1-core" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0f6ab710cec28cef759c5f18671a27dae2a5f952cdaaee1d8e2908cb2478a80" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle", +] + +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccab96b584d38fac86a83f07e659f0deafd0253dc096dab5a36d53efe653c5c3" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67abfe149395e3aa1c48a2beb32b068e2334402df8181f818d3aee2b304c4f5d" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "lock_api" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memmap2" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a79b39c93a7a5a27eeaf9a23b5ff43f1b9e0ad6b1cdd441140ae53c35613fc7" +dependencies = [ + "libc", +] + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "miow" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +dependencies = [ + "winapi", +] + +[[package]] +name = "num-derive" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + +[[package]] +name = "paste" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" + +[[package]] +name = "ppv-lite86" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", +] + +[[package]] +name = "proc-macro2" +version = "1.0.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c278e965f1d8cf32d6e0e96de3d3e79712178ae67986d9cf9151f51e95aac89b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "proc-macro2-diagnostics" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bf29726d67464d49fa6224a1d07936a8c08bb3fba727c7493f6cf1616fdaada" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "version_check", + "yansi", +] + +[[package]] +name = "quote" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha", + "rand_core 0.5.1", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_xoshiro" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" +dependencies = [ + "rand_core 0.6.3", +] + +[[package]] +name = "rayon" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" +dependencies = [ + "autocfg", + "crossbeam-deque", + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "num_cpus", +] + +[[package]] +name = "redox_syscall" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534cfe58d6a18cc17120fbf4635d53d14691c1fe4d951064df9bd326178d7d5a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom 0.2.7", + "redox_syscall", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "rust-embed" +version = "6.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a17e5ac65b318f397182ae94e532da0ba56b88dd1200b774715d36c4943b1c3" +dependencies = [ + "rust-embed-impl", + "rust-embed-utils", + "walkdir", +] + +[[package]] +name = "rust-embed-impl" +version = "6.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94e763e24ba2bf0c72bc6be883f967f794a019fafd1b86ba1daff9c91a7edd30" +dependencies = [ + "proc-macro2", + "quote", + "rust-embed-utils", + "syn", + "walkdir", +] + +[[package]] +name = "rust-embed-utils" +version = "7.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "756feca3afcbb1487a1d01f4ecd94cf8ec98ea074c55a69e7136d29fb6166029" +dependencies = [ + "globset", + "sha2 0.9.9", + "walkdir", +] + +[[package]] +name = "rustc-semver" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be1bdc7edf596692617627bbfeaba522131b18e06ca4df2b6b689e3c5d5ce84" + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "rustfix" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd2853d9e26988467753bd9912c3a126f642d05d229a4b53f5752ee36c56481" +dependencies = [ + "anyhow", + "log", + "serde", + "serde_json", +] + +[[package]] +name = "rustversion" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24c8ad4f0c00e1eb5bc7614d236a7f1300e3dbd76b68cac8e06fb00b015ad8d8" + +[[package]] +name = "ryu" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sedregex" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19411e23596093f03bbd11dc45603b6329bb4bfec77b9fd13e2b9fc9b02efe3e" +dependencies = [ + "regex", +] + +[[package]] +name = "semver" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1" +dependencies = [ + "serde", +] + +[[package]] +name = "serde" +version = "1.0.142" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e590c437916fb6b221e1d00df6e3294f3fccd70ca7e92541c475d6ed6ef5fee2" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_bytes" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212e73464ebcde48d723aa02eb270ba62eff38a9b732df31f33f1b4e145f3a54" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.142" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34b5b8d809babe02f538c2cfec6f2c1ed10804c0e5a6a041a049a4f5588ccc2e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.3", +] + +[[package]] +name = "sha3" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "881bf8156c87b6301fc5ca6b27f11eeb2761224c7081e69b409d5a1951a70c86" +dependencies = [ + "digest 0.10.3", + "keccak", +] + +[[package]] +name = "sized-chunks" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e" +dependencies = [ + "bitmaps", + "typenum", +] + +[[package]] +name = "smallvec" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" + +[[package]] +name = "solana-frozen-abi" +version = "1.10.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "433475665200079c4d520fdf274cfb021fedaaa48cf43b2bf552db9737a09afc" +dependencies = [ + "bs58 0.4.0", + "bv", + "generic-array", + "im", + "lazy_static", + "log", + "memmap2", + "rustc_version", + "serde", + "serde_bytes", + "serde_derive", + "sha2 0.10.2", + "solana-frozen-abi-macro", + "thiserror", +] + +[[package]] +name = "solana-frozen-abi-macro" +version = "1.10.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb65eeda364de9ee86c59f99aa4a9a8599ed3464cbe8cd0adf71a288f5bfde16" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "syn", +] + +[[package]] +name = "solana-lints" +version = "0.1.0" + +[[package]] +name = "solana-program" +version = "1.10.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41b1ec362f0681e0a4285aa3cd746736755b0e3a71dad61657060b50df834f06" +dependencies = [ + "base64 0.13.0", + "bincode", + "bitflags", + "blake3", + "borsh", + "borsh-derive", + "bs58 0.4.0", + "bv", + "bytemuck", + "console_error_panic_hook", + "console_log", + "curve25519-dalek", + "getrandom 0.1.16", + "itertools", + "js-sys", + "lazy_static", + "libsecp256k1", + "log", + "num-derive", + "num-traits", + "parking_lot", + "rand", + "rustc_version", + "rustversion", + "serde", + "serde_bytes", + "serde_derive", + "sha2 0.10.2", + "sha3", + "solana-frozen-abi", + "solana-frozen-abi-macro", + "solana-sdk-macro", + "thiserror", + "wasm-bindgen", +] + +[[package]] +name = "solana-sdk-macro" +version = "1.10.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2e144e75370b150f182307b075489e330b81a3ced608f00965c08d04e398df5" +dependencies = [ + "bs58 0.4.0", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sysvar_address_check" +version = "0.1.0" +dependencies = [ + "anchor-lang", + "bincode", + "clippy_utils", + "dylint_linting", + "dylint_testing", + "if_chain", + "serde", + "solana-lints", + "solana-program", +] + +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "term" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" +dependencies = [ + "dirs-next", + "rustversion", + "winapi", +] + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "tester" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0639d10d8f4615f223a57275cf40f9bdb7cfbb806bcb7f7cc56e3beb55a576eb" +dependencies = [ + "cfg-if", + "getopts", + "libc", + "num_cpus", + "term", +] + +[[package]] +name = "thiserror" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "unicode-ident" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" + +[[package]] +name = "unicode-segmentation" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" + +[[package]] +name = "unicode-width" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a" + +[[package]] +name = "web-sys" +version = "0.3.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed055ab27f941423197eb86b2035720b1a3ce40504df082cac2ecc6ed73335a1" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + +[[package]] +name = "zeroize" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" diff --git a/lints/sysvar_address_check/Cargo.toml b/lints/sysvar_address_check/Cargo.toml new file mode 100644 index 0000000..828e30f --- /dev/null +++ b/lints/sysvar_address_check/Cargo.toml @@ -0,0 +1,44 @@ +[package] +name = "sysvar_address_check" +version = "0.1.0" +authors = ["authors go here"] +description = "description goes here" +edition = "2018" +publish = false + +[lib] +crate-type = ["cdylib"] + +[[example]] +name = "insecure-anchor" +path = "ui/insecure-anchor/src/lib.rs" + +[[example]] +name = "recommended" +path = "ui/recommended/src/lib.rs" + +[[example]] +name = "insecure-2" +path = "ui/insecure-2/src/lib.rs" + +[[example]] +name = "secure-2" +path = "ui/secure-2/src/lib.rs" + +[dependencies] +clippy_utils = { git = "https://github.com/rust-lang/rust-clippy", rev = "0cb0f7636851f9fcc57085cf80197a2ef6db098f" } +dylint_linting = "2.0.7" +if_chain = "1.0.2" +solana-lints = { path = "../../crate" } + +[dev-dependencies] +anchor-lang = "0.25.0" +bincode = "1.3.3" +dylint_testing = "2.0.7" +serde = { version = "1.0.141", features = ["derive"] } +solana-program = "1.10.29" + +[workspace] + +[package.metadata.rust-analyzer] +rustc_private = true diff --git a/lints/sysvar_address_check/README.md b/lints/sysvar_address_check/README.md new file mode 100644 index 0000000..9271718 --- /dev/null +++ b/lints/sysvar_address_check/README.md @@ -0,0 +1,59 @@ +# sysvar_address_check + +**What it does:** This lint checks to ensure that programs using Solana types that derive the +`Sysvar` trait (e.g. Rent, Clock) check the address of the account. The recommended way to +deal with these types is using the `from_account_info()` method from the `Sysvar` trait. +This method performs the ID check and only deserializes from an `AccountInfo` if the check +passes, and is thus secure. + +This lint catches direct calls to deserialize (via `bincode::deserialize`) a byte array into +a type deriving Sysvar. Furthermore, if using the Anchor framework, this lint will catch +uses of `Account<'info, T>`, where `T` derives `Sysvar`. This is insecure since Anchor +will not perform the ID check in this case. + +**Why is this bad?** If a program deserializes an `AccountInfo.data` directly, without +checking the ID first, a malicious user could pass in an `AccountInfo` with spoofed data +and the same structure as a `Sysvar` type. Then the program would be dealing with incorrect +data. + +**Known problems:** This lint will flag any calls to deserialize some bytes into a type deriving +`Sysvar`, regardless of whether the ID check is done or not. Thus, if a program manually does the ID +check and deserialization, the lint will still flag this as insecure, thus possibly generating +some false positives. However, one should really prefer to use `from_account_info()`. + +**Example:** + +```rust +pub fn check_sysvar_address(ctx: Context) -> Result<()> { + let rent: Rent = bincode::deserialize(&ctx.accounts.rent.data.borrow()).unwrap(); + msg!("Rent -> {}", rent.lamports_per_byte_year); + Ok(()) +} +``` + +Use instead: + +```rust +pub fn check_sysvar_address(ctx: Context) -> Result<()> { + let rent = Rent::from_account_info(&ctx.accounts.rent).unwrap(); + msg!("Rent -> {}", rent.lamports_per_byte_year); + Ok(()) +} +``` + +## Note on Tests + +**insecure-2:** an actual insecure example since it does deserialization without checking ID. Essentially what +the sealevel insecure example was trying to demonstrate (see below). +**secure-2:** Fixes the "insecure-2" case. Uses the `from_account_info()` method, which performs the ID check. +**insecure-anchor:** an insecure example that uses `Account<'info, T>`, where `T` +derives Sysvar. This doesn't do the ID check that the `anchor::Sysvar` type does. +**recommended:** the secure way to use Anchor to check IDs. Directly fixes "insecure-anchor" by using +the `anchor::Sysvar` type. + +### NOT TESTED: + +**insecure:** sealevel-example; not tested because it's technically not insecure as it never attempts +a deserialization. +**secure:** sealevel-example; oes key check, but never deserializes, so technically the vulnerability is +non-existent in this example. diff --git a/lints/sysvar_address_check/rust-toolchain b/lints/sysvar_address_check/rust-toolchain new file mode 100644 index 0000000..2056264 --- /dev/null +++ b/lints/sysvar_address_check/rust-toolchain @@ -0,0 +1,3 @@ +[toolchain] +channel = "nightly-2022-06-30" +components = ["llvm-tools-preview", "rustc-dev"] diff --git a/lints/sysvar_address_check/src/lib.rs b/lints/sysvar_address_check/src/lib.rs new file mode 100644 index 0000000..562251f --- /dev/null +++ b/lints/sysvar_address_check/src/lib.rs @@ -0,0 +1,194 @@ +#![feature(rustc_private)] +#![warn(unused_extern_crates)] +#![recursion_limit = "256"] + +extern crate rustc_hir; +extern crate rustc_middle; +extern crate rustc_span; + +use rustc_hir::{ + def::Res, + intravisit::{walk_expr, FnKind, Visitor}, + Body, Expr, ExprKind, FieldDef, FnDecl, GenericArg, HirId, QPath, TyKind as HirTyKind, +}; +use rustc_lint::{LateContext, LateLintPass}; +use rustc_middle::ty::TyKind; +use rustc_span::Span; + +use clippy_utils::{ + diagnostics::span_lint_and_help, + get_trait_def_id, match_def_path, + ty::{implements_trait, match_type}, +}; +use if_chain::if_chain; +use solana_lints::paths; + +dylint_linting::declare_late_lint! { + /// **What it does:** This lint checks to ensure that programs using Solana types that derive the + /// `Sysvar` trait (e.g. Rent, Clock) check the address of the account. The recommended way to + /// deal with these types is using the `from_account_info()` method from the `Sysvar` trait. + /// This method performs the ID check and only deserializes from an `AccountInfo` if the check + /// passes, and is thus secure. + + /// This lint catches direct calls to deserialize (via `bincode::deserialize`) a byte array into + /// a type deriving Sysvar. Furthermore, if using the Anchor framework, this lint will catch + /// uses of `Account<'info, T>`, where `T` derives `Sysvar`. This is insecure since Anchor + /// will not perform the ID check in this case. + /// + /// **Why is this bad?** If a program deserializes an `AccountInfo.data` directly, without + /// checking the ID first, a malicious user could pass in an `AccountInfo` with spoofed data + /// and the same structure as a `Sysvar` type. Then the program would be dealing with incorrect + /// data. + /// + /// **Known problems:** This lint will flag any calls to deserialize some bytes into a type deriving + /// `Sysvar`, regardless of whether the ID check is done or not. Thus, if a program manually does the ID + /// check and deserialization, the lint will still flag this as insecure, thus possibly generating + /// some false positives. However, one should really prefer to use `from_account_info()`. + /// + /// **Example:** + /// + /// ```rust + /// pub fn check_sysvar_address(ctx: Context) -> Result<()> { + /// let rent: Rent = bincode::deserialize(&ctx.accounts.rent.data.borrow()).unwrap(); + /// msg!("Rent -> {}", rent.lamports_per_byte_year); + /// Ok(()) + /// } + /// ``` + /// Use instead: + /// ```rust + /// pub fn check_sysvar_address(ctx: Context) -> Result<()> { + /// let rent = Rent::from_account_info(&ctx.accounts.rent).unwrap(); + /// msg!("Rent -> {}", rent.lamports_per_byte_year); + /// Ok(()) + /// } + /// ``` + pub SYSVAR_ADDRESS_CHECK, + Warn, + "missing address check for Sysvar types" +} + +impl<'tcx> LateLintPass<'tcx> for SysvarAddressCheck { + fn check_field_def(&mut self, cx: &LateContext<'tcx>, field: &'tcx FieldDef<'tcx>) { + // if field is Anchor Account<'info, T> + // grab type T and if it derives Sysvar trait, flag lint + if_chain! { + // check field is type Account<'info, T> + if let HirTyKind::Path(qpath) = &field.ty.kind; + let res = cx.qpath_res(qpath, field.hir_id); + if let Res::Def(_, def_id) = res; + let middle_ty = cx.tcx.type_of(def_id); + if match_type(cx, middle_ty, &paths::ANCHOR_ACCOUNT); + // grab type T + if let QPath::Resolved(_, path) = qpath; + if !path.segments.is_empty(); + if let Some(generic_args) = &path.segments[0].args; + if generic_args.args.len() > 1; + if let GenericArg::Type(ty) = &generic_args.args[1]; + if let HirTyKind::Path(ty_qpath) = &ty.kind; + let ty_res = cx.qpath_res(ty_qpath, ty.hir_id); + if let Res::Def(_, type_def_id) = ty_res; + let account_type = cx.tcx.type_of(type_def_id); + // check if T derives Sysvar trait + if let Some(trait_id) = get_trait_def_id(cx, &paths::SOLANA_SYSVAR_TRAIT); + if implements_trait(cx, account_type, trait_id, &[]); + then { + span_lint_and_help( + cx, + SYSVAR_ADDRESS_CHECK, + field.span, + &format!( + "Anchor Account type T is '{}', which derives the Sysvar trait", + account_type + ), + None, + &format!( + "Account type does not perform an ID check. Use Sysvar<'info, {}> instead", + account_type + ), + ); + } + } + } + + fn check_fn( + &mut self, + cx: &LateContext<'tcx>, + _: FnKind<'tcx>, + _: &'tcx FnDecl<'tcx>, + body: &'tcx Body<'tcx>, + _: Span, + _: HirId, + ) { + // 1. walk function body and search for calls to bincode::deserialize + // 2. retrieve the type of this expression (which is what is being deserialized to), + // and check that the type implements the Sysvar trait + // 3. if so, flag the lint and issue warning that user should not deserialize directly, + // but instead use from_account_info() method from Sysvar trait + let mut accounts = AccountUses { cx }; + accounts.visit_expr(&body.value); + } +} + +struct AccountUses<'cx, 'tcx> { + cx: &'cx LateContext<'tcx>, +} + +impl<'cx, 'tcx> Visitor<'tcx> for AccountUses<'cx, 'tcx> { + fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) { + if_chain! { + // check if bincode::deserialize call + if let ExprKind::Call(fnc_expr, _args_expr) = expr.kind; + if let ExprKind::Path(qpath) = &fnc_expr.kind; + let res = self.cx.qpath_res(qpath, fnc_expr.hir_id); + if let Res::Def(_, def_id) = res; + if match_def_path(self.cx, def_id, &paths::BINCODE_DESERIALIZE); + // check type of expr + let ty = self.cx.typeck_results().expr_ty(expr); + // assumes type is always Result type, which should be the case + if let TyKind::Adt(_, substs) = ty.kind(); + if !substs.is_empty(); + let deser_type = substs[0].expect_ty(); + // check type implements Sysvar + if let Some(trait_id) = get_trait_def_id(self.cx, &paths::SOLANA_SYSVAR_TRAIT); + if implements_trait(self.cx, deser_type, trait_id, &[]); + then { + span_lint_and_help( + self.cx, + SYSVAR_ADDRESS_CHECK, + expr.span, + "raw deserialization of a type that implements Sysvar", + None, + "use from_account_info() instead", + ); + } + } + walk_expr(self, expr); + } +} + +// Not checking sealevel insecure case because in its current form, it is technically not even +// insecure. It does not deserialize from `rent.data`, thus possibly incorrectly assuming that +// this is a Rent struct. It is insecure in the sense there is no key check. + +// Not testing sealevel secure case because this lint will flag any attempt to do a "raw" +// deserialization. The canonical way should be using from_account_info(). + +#[test] +fn insecure_2() { + dylint_testing::ui_test_example(env!("CARGO_PKG_NAME"), "insecure-2"); +} + +#[test] +fn secure_2() { + dylint_testing::ui_test_example(env!("CARGO_PKG_NAME"), "secure-2"); +} + +#[test] +fn insecure_anchor() { + dylint_testing::ui_test_example(env!("CARGO_PKG_NAME"), "insecure-anchor"); +} + +#[test] +fn recommended() { + dylint_testing::ui_test_example(env!("CARGO_PKG_NAME"), "recommended"); +} diff --git a/lints/sysvar_address_check/ui/insecure-2/Cargo.toml b/lints/sysvar_address_check/ui/insecure-2/Cargo.toml new file mode 100644 index 0000000..e652a7d --- /dev/null +++ b/lints/sysvar_address_check/ui/insecure-2/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "insecure" +version = "0.1.0" +description = "Created with Anchor" +edition = "2021" + +[lib] +crate-type = ["cdylib", "lib"] +name = "insecure" + +[features] +no-entrypoint = [] +no-idl = [] +no-log-ix-name = [] +cpi = ["no-entrypoint"] +default = [] + +[profile.release] +overflow-checks = true + +[workspace] + +[dependencies] +anchor-lang = "0.25.0" +bincode = "1.3.3" diff --git a/lints/sysvar_address_check/ui/insecure-2/Xargo.toml b/lints/sysvar_address_check/ui/insecure-2/Xargo.toml new file mode 100644 index 0000000..475fb71 --- /dev/null +++ b/lints/sysvar_address_check/ui/insecure-2/Xargo.toml @@ -0,0 +1,2 @@ +[target.bpfel-unknown-unknown.dependencies.std] +features = [] diff --git a/lints/sysvar_address_check/ui/insecure-2/src/lib.rs b/lints/sysvar_address_check/ui/insecure-2/src/lib.rs new file mode 100644 index 0000000..a5344da --- /dev/null +++ b/lints/sysvar_address_check/ui/insecure-2/src/lib.rs @@ -0,0 +1,21 @@ +use anchor_lang::prelude::*; + +declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); + +#[program] +pub mod insecure { + use super::*; + + pub fn check_sysvar_address(ctx: Context) -> Result<()> { + let rent: Rent = bincode::deserialize(&ctx.accounts.rent.data.borrow()).unwrap(); + msg!("Rent -> {}", rent.lamports_per_byte_year); + Ok(()) + } +} + +#[derive(Accounts)] +pub struct CheckSysvarAddress<'info> { + rent: AccountInfo<'info>, +} + +fn main() {} diff --git a/lints/sysvar_address_check/ui/insecure-2/src/lib.stderr b/lints/sysvar_address_check/ui/insecure-2/src/lib.stderr new file mode 100644 index 0000000..af758c5 --- /dev/null +++ b/lints/sysvar_address_check/ui/insecure-2/src/lib.stderr @@ -0,0 +1,11 @@ +error: raw deserialization of a type that implements Sysvar + --> $DIR/lib.rs:10:26 + | +LL | let rent: Rent = bincode::deserialize(&ctx.accounts.rent.data.borrow()).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `-D sysvar-address-check` implied by `-D warnings` + = help: use from_account_info() instead + +error: aborting due to previous error + diff --git a/lints/sysvar_address_check/ui/insecure-anchor/Cargo.toml b/lints/sysvar_address_check/ui/insecure-anchor/Cargo.toml new file mode 100644 index 0000000..ff1ace7 --- /dev/null +++ b/lints/sysvar_address_check/ui/insecure-anchor/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "recommended" +version = "0.1.0" +description = "Created with Anchor" +edition = "2021" + +[lib] +crate-type = ["cdylib", "lib"] +name = "secure" + +[features] +no-entrypoint = [] +no-idl = [] +no-log-ix-name = [] +cpi = ["no-entrypoint"] +default = [] + +[profile.release] +overflow-checks = true + +[dependencies] +anchor-lang = "0.25.0" +serde = { version = "1.0.141", features = ["derive"] } +solana-program = "1.10.29" diff --git a/lints/sysvar_address_check/ui/insecure-anchor/Xargo.toml b/lints/sysvar_address_check/ui/insecure-anchor/Xargo.toml new file mode 100644 index 0000000..475fb71 --- /dev/null +++ b/lints/sysvar_address_check/ui/insecure-anchor/Xargo.toml @@ -0,0 +1,2 @@ +[target.bpfel-unknown-unknown.dependencies.std] +features = [] diff --git a/lints/sysvar_address_check/ui/insecure-anchor/src/lib.rs b/lints/sysvar_address_check/ui/insecure-anchor/src/lib.rs new file mode 100644 index 0000000..28549d9 --- /dev/null +++ b/lints/sysvar_address_check/ui/insecure-anchor/src/lib.rs @@ -0,0 +1,43 @@ +use anchor_lang::prelude::*; +use serde::{Deserialize, Serialize}; +use solana_program::pubkey; +use solana_program::sysvar::SysvarId; + +declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); + +#[program] +pub mod recommended { + use super::*; + + pub fn check_sysvar_address(ctx: Context) -> Result<()> { + msg!("Rent -> {}", ctx.accounts.rent.lamports_per_byte_year); + Ok(()) + } +} + +#[derive(Accounts)] +pub struct CheckSysvarAddress<'info> { + rent: Account<'info, RentCopy>, +} + +#[account] +#[derive(Default, Serialize, Deserialize)] +pub struct RentCopy { + pub lamports_per_byte_year: u64, + pub exemption_threshold: f64, + pub burn_percent: u8, +} + +impl SolanaSysvar for RentCopy {} + +impl SysvarId for RentCopy { + fn id() -> Pubkey { + pubkey!("SysvarRent111111111111111111111111111111111") + } + + fn check_id(pubkey: &Pubkey) -> bool { + id() == *pubkey + } +} + +fn main() {} diff --git a/lints/sysvar_address_check/ui/insecure-anchor/src/lib.stderr b/lints/sysvar_address_check/ui/insecure-anchor/src/lib.stderr new file mode 100644 index 0000000..f57103d --- /dev/null +++ b/lints/sysvar_address_check/ui/insecure-anchor/src/lib.stderr @@ -0,0 +1,11 @@ +error: Anchor Account type T is 'RentCopy', which derives the Sysvar trait + --> $DIR/lib.rs:20:5 + | +LL | rent: Account<'info, RentCopy>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `-D sysvar-address-check` implied by `-D warnings` + = help: Account type does not perform an ID check. Use Sysvar<'info, RentCopy> instead + +error: aborting due to previous error + diff --git a/lints/sysvar_address_check/ui/insecure/Cargo.toml b/lints/sysvar_address_check/ui/insecure/Cargo.toml new file mode 100644 index 0000000..00bb8f8 --- /dev/null +++ b/lints/sysvar_address_check/ui/insecure/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "insecure" +version = "0.1.0" +description = "Created with Anchor" +edition = "2021" + +[lib] +crate-type = ["cdylib", "lib"] +name = "insecure" + +[features] +no-entrypoint = [] +no-idl = [] +no-log-ix-name = [] +cpi = ["no-entrypoint"] +default = [] + +[profile.release] +overflow-checks = true + +[dependencies] +anchor-lang = "0.25.0" diff --git a/lints/sysvar_address_check/ui/insecure/Xargo.toml b/lints/sysvar_address_check/ui/insecure/Xargo.toml new file mode 100644 index 0000000..475fb71 --- /dev/null +++ b/lints/sysvar_address_check/ui/insecure/Xargo.toml @@ -0,0 +1,2 @@ +[target.bpfel-unknown-unknown.dependencies.std] +features = [] diff --git a/lints/sysvar_address_check/ui/insecure/src/lib.rs b/lints/sysvar_address_check/ui/insecure/src/lib.rs new file mode 100644 index 0000000..95f9800 --- /dev/null +++ b/lints/sysvar_address_check/ui/insecure/src/lib.rs @@ -0,0 +1,20 @@ +use anchor_lang::prelude::*; + +declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); + +#[program] +pub mod insecure { + use super::*; + + pub fn check_sysvar_address(ctx: Context) -> Result<()> { + msg!("Rent Key -> {}", ctx.accounts.rent.key().to_string()); + Ok(()) + } +} + +#[derive(Accounts)] +pub struct CheckSysvarAddress<'info> { + rent: AccountInfo<'info>, +} + +fn main() {} diff --git a/lints/sysvar_address_check/ui/recommended/Cargo.toml b/lints/sysvar_address_check/ui/recommended/Cargo.toml new file mode 100644 index 0000000..2bdd671 --- /dev/null +++ b/lints/sysvar_address_check/ui/recommended/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "recommended" +version = "0.1.0" +description = "Created with Anchor" +edition = "2021" + +[lib] +crate-type = ["cdylib", "lib"] +name = "secure" + +[features] +no-entrypoint = [] +no-idl = [] +no-log-ix-name = [] +cpi = ["no-entrypoint"] +default = [] + +[profile.release] +overflow-checks = true + +[dependencies] +anchor-lang = "0.25.0" diff --git a/lints/sysvar_address_check/ui/recommended/Xargo.toml b/lints/sysvar_address_check/ui/recommended/Xargo.toml new file mode 100644 index 0000000..475fb71 --- /dev/null +++ b/lints/sysvar_address_check/ui/recommended/Xargo.toml @@ -0,0 +1,2 @@ +[target.bpfel-unknown-unknown.dependencies.std] +features = [] diff --git a/lints/sysvar_address_check/ui/recommended/src/lib.rs b/lints/sysvar_address_check/ui/recommended/src/lib.rs new file mode 100644 index 0000000..098997a --- /dev/null +++ b/lints/sysvar_address_check/ui/recommended/src/lib.rs @@ -0,0 +1,20 @@ +use anchor_lang::prelude::*; + +declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); + +#[program] +pub mod recommended { + use super::*; + + pub fn check_sysvar_address(ctx: Context) -> Result<()> { + msg!("Rent Key -> {}", ctx.accounts.rent.key().to_string()); + Ok(()) + } +} + +#[derive(Accounts)] +pub struct CheckSysvarAddress<'info> { + rent: Sysvar<'info, Rent>, +} + +fn main() {} diff --git a/lints/sysvar_address_check/ui/recommended/src/lib.stderr b/lints/sysvar_address_check/ui/recommended/src/lib.stderr new file mode 100644 index 0000000..e69de29 diff --git a/lints/sysvar_address_check/ui/secure-2/Cargo.toml b/lints/sysvar_address_check/ui/secure-2/Cargo.toml new file mode 100644 index 0000000..b3f0146 --- /dev/null +++ b/lints/sysvar_address_check/ui/secure-2/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "insecure" +version = "0.1.0" +description = "Created with Anchor" +edition = "2021" + +[lib] +crate-type = ["cdylib", "lib"] +name = "insecure" + +[features] +no-entrypoint = [] +no-idl = [] +no-log-ix-name = [] +cpi = ["no-entrypoint"] +default = [] + +[profile.release] +overflow-checks = true + +[workspace] + +[dependencies] +anchor-lang = "0.25.0" diff --git a/lints/sysvar_address_check/ui/secure-2/Xargo.toml b/lints/sysvar_address_check/ui/secure-2/Xargo.toml new file mode 100644 index 0000000..475fb71 --- /dev/null +++ b/lints/sysvar_address_check/ui/secure-2/Xargo.toml @@ -0,0 +1,2 @@ +[target.bpfel-unknown-unknown.dependencies.std] +features = [] diff --git a/lints/sysvar_address_check/ui/secure-2/src/lib.rs b/lints/sysvar_address_check/ui/secure-2/src/lib.rs new file mode 100644 index 0000000..bcf4be5 --- /dev/null +++ b/lints/sysvar_address_check/ui/secure-2/src/lib.rs @@ -0,0 +1,21 @@ +use anchor_lang::prelude::*; + +declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); + +#[program] +pub mod insecure { + use super::*; + + pub fn check_sysvar_address(ctx: Context) -> Result<()> { + let rent = Rent::from_account_info(&ctx.accounts.rent).unwrap(); + msg!("Rent -> {}", rent.lamports_per_byte_year); + Ok(()) + } +} + +#[derive(Accounts)] +pub struct CheckSysvarAddress<'info> { + rent: AccountInfo<'info>, +} + +fn main() {} diff --git a/lints/sysvar_address_check/ui/secure-2/src/lib.stderr b/lints/sysvar_address_check/ui/secure-2/src/lib.stderr new file mode 100644 index 0000000..e69de29 diff --git a/lints/sysvar_address_check/ui/secure/Cargo.toml b/lints/sysvar_address_check/ui/secure/Cargo.toml new file mode 100644 index 0000000..7ddb184 --- /dev/null +++ b/lints/sysvar_address_check/ui/secure/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "secure" +version = "0.1.0" +description = "Created with Anchor" +edition = "2021" + +[lib] +crate-type = ["cdylib", "lib"] +name = "secure" + +[features] +no-entrypoint = [] +no-idl = [] +no-log-ix-name = [] +cpi = ["no-entrypoint"] +default = [] + +[dependencies] +anchor-lang = "0.25.0" diff --git a/lints/sysvar_address_check/ui/secure/Xargo.toml b/lints/sysvar_address_check/ui/secure/Xargo.toml new file mode 100644 index 0000000..475fb71 --- /dev/null +++ b/lints/sysvar_address_check/ui/secure/Xargo.toml @@ -0,0 +1,2 @@ +[target.bpfel-unknown-unknown.dependencies.std] +features = [] diff --git a/lints/sysvar_address_check/ui/secure/src/lib.rs b/lints/sysvar_address_check/ui/secure/src/lib.rs new file mode 100644 index 0000000..fb8cb9f --- /dev/null +++ b/lints/sysvar_address_check/ui/secure/src/lib.rs @@ -0,0 +1,19 @@ +use anchor_lang::prelude::*; +use anchor_lang::solana_program::sysvar; +declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); + +#[program] +pub mod secure { + use super::*; + + pub fn check_sysvar_address(ctx: Context) -> Result<()> { + require_eq!(ctx.accounts.rent.key(), sysvar::rent::ID); + msg!("Rent Key -> {}", ctx.accounts.rent.key().to_string()); + Ok(()) + } +} + +#[derive(Accounts)] +pub struct CheckSysvarAddress<'info> { + rent: AccountInfo<'info>, +}