From df16602b3b2d2d8baf39acfee392cb008829b742 Mon Sep 17 00:00:00 2001 From: Caleb Jasik Date: Sat, 1 Jun 2024 08:38:06 -0500 Subject: [PATCH 1/4] Add fuzz target `checker/fuzz/check_project_naive` --- checker/fuzz/.gitignore | 4 + checker/fuzz/Cargo.lock | 693 ++++++++++++++++++ checker/fuzz/Cargo.toml | 28 + .../fuzz/fuzz_targets/check_project_naive.rs | 34 + 4 files changed, 759 insertions(+) create mode 100644 checker/fuzz/.gitignore create mode 100644 checker/fuzz/Cargo.lock create mode 100644 checker/fuzz/Cargo.toml create mode 100644 checker/fuzz/fuzz_targets/check_project_naive.rs diff --git a/checker/fuzz/.gitignore b/checker/fuzz/.gitignore new file mode 100644 index 00000000..1a45eee7 --- /dev/null +++ b/checker/fuzz/.gitignore @@ -0,0 +1,4 @@ +target +corpus +artifacts +coverage diff --git a/checker/fuzz/Cargo.lock b/checker/fuzz/Cargo.lock new file mode 100644 index 00000000..41ecf126 --- /dev/null +++ b/checker/fuzz/Cargo.lock @@ -0,0 +1,693 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "binary-serialize-derive" +version = "0.0.1" +dependencies = [ + "syn-helpers", +] + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "cc" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" +dependencies = [ + "jobserver", + "libc", + "once_cell", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "derive-debug-extras" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b06a04c5959ac637aa6063625751357337a9067038e9cb194fd197861b01aa0d" +dependencies = [ + "syn-helpers", +] + +[[package]] +name = "derive-enum-from-into" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42e5ddace13a8459cb452b19e01f59f16d3e2049c8b808f338a13eeadc326e33" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "derive-finite-automaton" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c7422b4dd6fa30fcdc1a90811502d5212697fae80568dca8d5a4e4965f4cc3d" +dependencies = [ + "derive-finite-automaton-derive", +] + +[[package]] +name = "derive-finite-automaton-derive" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c26ee8656bfb9b2763f2522162e43752d983c0c43cf1c5364028fd5e219df693" +dependencies = [ + "either_n", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "derive-partial-eq-extras" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de8afba3dd2062a2b599b198b30118f902c29bea9c8f82ea071023122079bdf" +dependencies = [ + "syn-helpers", +] + +[[package]] +name = "either" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" + +[[package]] +name = "either_n" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c91ae510829160d5cfb19eb4ae7b6e01d44b767ca8f727c6cee936e53cc9ae5" + +[[package]] +name = "enum-variants-strings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf78b873650dcfe36b4f4b39cbad0615bfdda80b0dbd302bcc43f729e26d9cfc" +dependencies = [ + "enum-variants-strings-derive", +] + +[[package]] +name = "enum-variants-strings-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c219bbaeb0dfcf75ef2a911d080245affeb04ad8da4b53986a0e4bbe6b966a2" +dependencies = [ + "either_n", + "proc-macro2", + "quote", + "string-cases", + "syn", +] + +[[package]] +name = "ezno-checker" +version = "0.0.16" +dependencies = [ + "binary-serialize-derive", + "derive-debug-extras", + "derive-enum-from-into", + "either", + "enum-variants-strings", + "ezno-parser", + "iterator-endiate", + "levenshtein", + "ordered-float", + "path-absolutize", + "simple-json-parser", + "source-map", + "temporary-annex", + "tsify", + "wasm-bindgen", +] + +[[package]] +name = "ezno-parser" +version = "0.1.5" +dependencies = [ + "derive-debug-extras", + "derive-enum-from-into", + "derive-finite-automaton", + "derive-partial-eq-extras", + "enum-variants-strings", + "ezno-parser-visitable-derive", + "get-field-by-type", + "iterator-endiate", + "macro_rules_attribute", + "self-rust-tokenize", + "serde", + "source-map", + "temporary-annex", + "tokenizer-lib", + "tsify", + "wasm-bindgen", +] + +[[package]] +name = "ezno-parser-fuzz" +version = "0.0.0" +dependencies = [ + "ezno-checker", + "libfuzzer-sys", +] + +[[package]] +name = "ezno-parser-visitable-derive" +version = "0.0.7" +dependencies = [ + "string-cases", + "syn-helpers", +] + +[[package]] +name = "get-field-by-type" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "510f901658aa70b274793aeb82d6ca00f423a7421c82024f64f3bb79f39bb0fc" +dependencies = [ + "get-field-by-type-derive", +] + +[[package]] +name = "get-field-by-type-derive" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3931371c1191271ed6608fb4ac821fbab479f0defa5b1d85cdc756736209225c" +dependencies = [ + "syn-helpers", +] + +[[package]] +name = "gloo-utils" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037fcb07216cb3a30f7292bd0176b050b7b9a052ba830ef7d5d65f6dc64ba58e" +dependencies = [ + "js-sys", + "serde", + "serde_json", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "iterator-endiate" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab947031a0a0cb37f982ef2a0ab3bacfd3de5ed97dd5c7e98bcc92bba357112" + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "jobserver" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +dependencies = [ + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "levenshtein" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "libfuzzer-sys" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a96cfd5557eb82f2b83fed4955246c988d331975a002961b07c81584d107e7f7" +dependencies = [ + "arbitrary", + "cc", + "once_cell", +] + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + +[[package]] +name = "macro_rules_attribute" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a82271f7bc033d84bbca59a3ce3e4159938cb08a9c3aebbe54d215131518a13" +dependencies = [ + "macro_rules_attribute-proc_macro", + "paste", +] + +[[package]] +name = "macro_rules_attribute-proc_macro" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8dd856d451cc0da70e2ef2ce95a18e39a93b7558bedf10201ad28503f918568" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "ordered-float" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a76df7075c7d4d01fdcb46c912dd17fba5b60c78ea480b475f2b6ab6f666584e" +dependencies = [ + "num-traits", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "path-absolutize" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4af381fe79fa195b4909485d99f73a80792331df0625188e707854f0b3383f5" +dependencies = [ + "path-dedot", +] + +[[package]] +name = "path-dedot" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07ba0ad7e047712414213ff67533e6dd477af0a4e1d14fb52343e53d30ea9397" +dependencies = [ + "once_cell", +] + +[[package]] +name = "proc-macro2" +version = "1.0.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "self-rust-tokenize" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45c3191133be4b3e5c19f3a9f23efb784e982060373c0f3c9f3362fcfcb5d1e6" +dependencies = [ + "proc-macro2", + "quote", + "self-rust-tokenize-derive", +] + +[[package]] +name = "self-rust-tokenize-derive" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f0d9ce060439c2bc0821a7e8b3123ee1743bebd88101a9357c3405010ed7826" +dependencies = [ + "syn-helpers", +] + +[[package]] +name = "serde" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_derive_internals" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e578a843d40b4189a4d66bba51d7684f57da5bd7c304c64e14bd63efbef49509" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "simple-json-parser" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "837c5f8866aeabd3ac8addcf50ef1e2779fe8c2a8d74bdd97102bdfe5605c629" + +[[package]] +name = "source-map" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0ceb78c22f3230575820b8fc921eedab317383bd3f3648d221f80549e6e4d16" +dependencies = [ + "codespan-reporting", + "self-rust-tokenize", + "serde", + "tsify", + "wasm-bindgen", +] + +[[package]] +name = "string-cases" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31d23461f9e0fbe756cf9d5a36be93740fe12c8b094409a5f78f0f912ee2b6f" + +[[package]] +name = "syn" +version = "2.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn-helpers" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59c391dcee7e7a1efd7dc921922b97b4be54129a195b6baec95bb2a223203d9d" +dependencies = [ + "either_n", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "temporary-annex" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e9c16d33fb2759286102fa235fd7029a8de2c2961165b2942c9cac81607a044" + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "tokenizer-lib" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54d3d4f6575cd226038dbe804ec4b0e142e1cfe5db49c526c0147d71aea3467f" +dependencies = [ + "source-map", +] + +[[package]] +name = "tsify" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6b26cf145f2f3b9ff84e182c448eaf05468e247f148cf3d2a7d67d78ff023a0" +dependencies = [ + "gloo-utils", + "serde", + "serde_json", + "tsify-macros", + "wasm-bindgen", +] + +[[package]] +name = "tsify-macros" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a94b0f0954b3e59bfc2c246b4c8574390d94a4ad4ad246aaf2fb07d7dfd3b47" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-width" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" + +[[package]] +name = "wasm-bindgen" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" + +[[package]] +name = "web-sys" +version = "0.3.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" diff --git a/checker/fuzz/Cargo.toml b/checker/fuzz/Cargo.toml new file mode 100644 index 00000000..788146ed --- /dev/null +++ b/checker/fuzz/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "ezno-parser-fuzz" +version = "0.0.0" +publish = false +edition = "2021" + +[package.metadata] +cargo-fuzz = true + +[dependencies] +libfuzzer-sys = "0.4" + +[dependencies.ezno-checker] +path = ".." + +# Prevent this from interfering with workspaces +[workspace] +members = ["."] + +[profile.release] +debug = 1 + +[[bin]] +name = "check_project_naive" +path = "fuzz_targets/check_project_naive.rs" +test = false +doc = false +bench = false diff --git a/checker/fuzz/fuzz_targets/check_project_naive.rs b/checker/fuzz/fuzz_targets/check_project_naive.rs new file mode 100644 index 00000000..c7c97516 --- /dev/null +++ b/checker/fuzz/fuzz_targets/check_project_naive.rs @@ -0,0 +1,34 @@ +#![no_main] + +use ezno_checker::{check_project, synthesis, TypeCheckOptions}; +use libfuzzer_sys::{fuzz_target, Corpus}; +use std::collections::HashSet; +use std::str; + +/// check_project_naive throws random strings into the ezno checker, validating that none of them make the checker panic. +fn do_fuzz(data: &str) -> Corpus { + let input = data.trim_start(); + + let definition_file = ezno_checker::INTERNAL_DEFINITION_FILE_PATH.into(); + let type_definition_files = HashSet::from_iter([definition_file]); + + // `lsp_mode` <=> partial syntax + let options = TypeCheckOptions { lsp_mode: true, ..Default::default() }; + + let root = "index.ts"; + + let _result = check_project::<_, synthesis::EznoParser>( + vec![root.into()], + type_definition_files, + |_path: &std::path::Path| Some(input.to_owned()), + options, + (), + None, + ); + + Corpus::Keep +} + +fuzz_target!(|data: &str| { + do_fuzz(data); +}); From 34eecf1198229424560bf390fd87b0ec82d407db Mon Sep 17 00:00:00 2001 From: Caleb Jasik Date: Sat, 1 Jun 2024 08:44:40 -0500 Subject: [PATCH 2/4] Create `fuzzing_parser` and `fuzzing_checker` CI jobs --- .github/workflows/rust.yml | 52 +++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 841ef39a..3a6dc644 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -193,7 +193,7 @@ jobs: working-directory: src/js-cli-and-library shell: bash - fuzzing: + fuzzing_parser: needs: validity runs-on: ubuntu-latest timeout-minutes: 15 @@ -244,6 +244,56 @@ jobs: fi working-directory: parser/fuzz + fuzzing_checker: + needs: validity + runs-on: ubuntu-latest + timeout-minutes: 15 + continue-on-error: true + strategy: + matrix: + fuzz-target: [check_project_naive] + + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: actions/cache@v4 + with: + path: ${{ env.CACHE_PATHS }} + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - uses: dorny/paths-filter@v3 + id: changes + with: + filters: | + checker: + - 'checker/**' + + - name: Install latest nightly and set it as default + if: steps.changes.outputs.checker == 'true' + run: | + rustup install nightly + rustup default nightly + + - uses: brndnmtthws/rust-action-cargo-binstall@v1 + if: steps.changes.outputs.checker == 'true' + with: + packages: cargo-fuzz + + - name: Run fuzzing + env: + SHORT_CIRCUIT: true + if: steps.changes.outputs.checker == 'true' + run: | + if ${{ env.SHORT_CIRCUIT }}; then + cargo fuzz run -s none ${{ matrix.fuzz-target }} -- -timeout=10 -use_value_profile=1 -max_total_time=120 + else + cargo fuzz run -s none ${{ matrix.fuzz-target }} -- -timeout=10 -use_value_profile=1 -max_total_time=300 -fork=1 -ignore_crashes=1 + + # if test -d fuzz/artifacts; then + # find fuzz/artifacts -type f -print -exec xxd {} \; -exec cargo fuzz fmt -s none module_roundtrip_structured {} \;; false; + # fi + fi + working-directory: checker/fuzz clippy: needs: validity runs-on: ubuntu-latest From a765c39208296159eca503020c35cdc1ee952138 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 16 Aug 2024 17:38:40 +0100 Subject: [PATCH 3/4] Update rust.yml - `cargo install` from git source because current cargo-fuzz release is broken --- .github/workflows/rust.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 59c0d97e..ee34938b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -7,7 +7,7 @@ name: Rust # - That crates that are published are publish-able (works most of the time) # - Testing # - Standard Rust integration and unit tests -# - Fuzz tests +# - Fuzz tests (parser and checker) # - WASM edition works tests on: @@ -280,10 +280,9 @@ jobs: rustup install nightly rustup default nightly - - uses: brndnmtthws/rust-action-cargo-binstall@v1 + - name: Install cargo-fuzz if: steps.changes.outputs.checker == 'true' - with: - packages: cargo-fuzz + run: cargo install --git https://github.com/rust-fuzz/cargo-fuzz.git - name: Run fuzzing env: @@ -300,6 +299,7 @@ jobs: # fi fi working-directory: checker/fuzz + clippy: needs: validity runs-on: ubuntu-latest From 6f750f8d6447e6ab932c3a55bc4d10f9fed5fb14 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 16 Aug 2024 17:44:17 +0100 Subject: [PATCH 4/4] Fix after check API change - `HashSet` -> `Vec` for type definition files --- checker/fuzz/fuzz_targets/check_project_naive.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checker/fuzz/fuzz_targets/check_project_naive.rs b/checker/fuzz/fuzz_targets/check_project_naive.rs index c7c97516..b8666254 100644 --- a/checker/fuzz/fuzz_targets/check_project_naive.rs +++ b/checker/fuzz/fuzz_targets/check_project_naive.rs @@ -10,7 +10,7 @@ fn do_fuzz(data: &str) -> Corpus { let input = data.trim_start(); let definition_file = ezno_checker::INTERNAL_DEFINITION_FILE_PATH.into(); - let type_definition_files = HashSet::from_iter([definition_file]); + let type_definition_files = vec![definition_file]; // `lsp_mode` <=> partial syntax let options = TypeCheckOptions { lsp_mode: true, ..Default::default() };