diff --git a/.github/workflows/packages-cfn_guard_rs-CI.yml b/.github/workflows/packages-cfn_guard_rs-CI.yml index d6f927e9..e3953605 100644 --- a/.github/workflows/packages-cfn_guard_rs-CI.yml +++ b/.github/workflows/packages-cfn_guard_rs-CI.yml @@ -12,14 +12,16 @@ on: - "packages/cfn_guard_rs/**" - "packages/cfn_guard_rs_hook/**" jobs: - linux: + unitlint: strategy: matrix: + os: [ubuntu-latest, macos-latest, windows-latest] target: [aarch64, x86_64] + python: [ 3.8, 3.9, "3.10", "3.11" ] directory: - ./packages/cfn_guard_rs - ./packages/cfn_guard_rs_hook - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} defaults: run: working-directory: ${{ matrix.directory }} @@ -28,53 +30,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v1 with: - python-version: "3.7" - - name: Install Tox and any other packages - run: pip3 install tox - - name: Run Tox - run: | - python3 --version - tox -e py - - windows: - strategy: - matrix: - directory: - - ./packages/cfn_guard_rs - - ./packages/cfn_guard_rs_hook - runs-on: windows-latest - defaults: - run: - working-directory: ${{ matrix.directory }} - steps: - - uses: actions/checkout@v3 - - name: Setup Python - uses: actions/setup-python@v1 - with: - python-version: "3.7" - - name: Install Tox and any other packages - run: pip3 install tox - - name: Run Tox - run: | - python3 --version - tox -e py - - macos: - strategy: - matrix: - directory: - - ./packages/cfn_guard_rs - - ./packages/cfn_guard_rs_hook - runs-on: macos-latest - defaults: - run: - working-directory: ${{ matrix.directory }} - steps: - - uses: actions/checkout@v3 - - name: Setup Python - uses: actions/setup-python@v1 - with: - python-version: "3.7" + python-version: ${{ matrix.python }} - name: Install Tox and any other packages run: pip3 install tox - name: Run Tox diff --git a/packages/cfn_guard_rs/Cargo.lock b/packages/cfn_guard_rs/Cargo.lock index 69cb1669..6368757d 100644 --- a/packages/cfn_guard_rs/Cargo.lock +++ b/packages/cfn_guard_rs/Cargo.lock @@ -22,12 +22,51 @@ dependencies = [ ] [[package]] -name = "ansi_term" -version = "0.12.1" +name = "anstream" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" dependencies = [ - "winapi", + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" + +[[package]] +name = "anstyle-parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" +dependencies = [ + "anstyle", + "windows-sys 0.48.0", ] [[package]] @@ -53,6 +92,21 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + [[package]] name = "bitflags" version = "1.3.2" @@ -84,31 +138,34 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cfn-guard" -version = "2.1.2" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c30bced6fce7c1040b223362681668004589dfb95d2ceac40d404b18a63cdb7" +checksum = "ef9055689904ad94ffbf5551a0f93deffc1f50bf9ffb24918b386bb221618334" dependencies = [ "Inflector", "clap", - "colored 2.0.0", + "clap_complete", + "colored", "enumflags2", "enumflags2_derive", + "fancy-regex", "grep-matcher", "grep-regex", "grep-searcher", "heck", "indexmap", + "indoc", "itertools", "lazy_static", "nom", "nom_locate", - "regex", "rstest", "serde", "serde_json", "serde_yaml", - "simple_logger", "string-builder", + "strip-ansi-escapes", + "thiserror", "unsafe-libyaml", "urlencoding", "walkdir", @@ -116,7 +173,7 @@ dependencies = [ [[package]] name = "cfn_guard_rs" -version = "0.2.3" +version = "0.3.0" dependencies = [ "cfn-guard", "pyo3", @@ -124,30 +181,46 @@ dependencies = [ [[package]] name = "clap" -version = "2.34.0" +version = "4.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +checksum = "7c8d502cbaec4595d2e7d5f61e318f05417bd2b66fdc3809498f0d3fdf0bea27" dependencies = [ - "ansi_term", - "atty", - "bitflags", + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5891c7bc0edb3e1c2204fc5e94009affabeb1821c9e5fdc3959536c5c0bb984d" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", "strsim", - "textwrap", - "unicode-width", - "vec_map", ] [[package]] -name = "colored" -version = "1.9.3" +name = "clap_complete" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59" +checksum = "586a385f7ef2f8b4d86bddaa0c094794e7ccbfe5ffef1f434fe928143fc783a5" dependencies = [ - "atty", - "lazy_static", - "winapi", + "clap", ] +[[package]] +name = "clap_lex" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "colored" version = "2.0.0" @@ -194,7 +267,17 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.29", +] + +[[package]] +name = "fancy-regex" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2" +dependencies = [ + "bit-set", + "regex", ] [[package]] @@ -368,9 +451,9 @@ dependencies = [ [[package]] name = "indoc" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adab1eaa3408fb7f0c777a73e7465fd5656136fc93b670eb6df3c88c2c1344e3" +checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306" [[package]] name = "itertools" @@ -445,9 +528,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.5" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" dependencies = [ "autocfg", ] @@ -474,15 +557,6 @@ dependencies = [ "nom", ] -[[package]] -name = "num_threads" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" -dependencies = [ - "libc", -] - [[package]] name = "once_cell" version = "1.16.0" @@ -509,7 +583,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-sys", + "windows-sys 0.42.0", ] [[package]] @@ -526,18 +600,18 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] [[package]] name = "pyo3" -version = "0.17.3" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "268be0c73583c183f2b14052337465768c07726936a260f480f0857cb95ba543" +checksum = "e681a6cfdc4adcc93b4d3cf993749a4552018ee0a9b65fc0ccfad74352c72a38" dependencies = [ "cfg-if", "indoc", @@ -552,9 +626,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.17.3" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28fcd1e73f06ec85bf3280c48c67e731d8290ad3d730f8be9dc07946923005c8" +checksum = "076c73d0bc438f7a4ef6fdd0c3bb4732149136abd952b110ac93e4edb13a6ba5" dependencies = [ "once_cell", "target-lexicon", @@ -562,9 +636,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.17.3" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f6cb136e222e49115b3c51c32792886defbfb0adead26a688142b346a0b9ffc" +checksum = "e53cee42e77ebe256066ba8aa77eff722b3bb91f3419177cf4cd0f304d3284d9" dependencies = [ "libc", "pyo3-build-config", @@ -572,9 +646,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.17.3" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94144a1266e236b1c932682136dc35a9dee8d3589728f68130c7c3861ef96b28" +checksum = "dfeb4c99597e136528c6dd7d5e3de5434d1ceaf487436a3f03b2d56b6fc9efd1" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -584,9 +658,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.17.3" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8df9be978a2d2f0cdebabb03206ed73b11314701a5bfe71b0d753b81997777f" +checksum = "947dc12175c254889edc0c02e399476c2f652b4b9ebd123aa655c224de259536" dependencies = [ "proc-macro2", "quote", @@ -595,9 +669,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.26" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -740,19 +814,6 @@ dependencies = [ "unsafe-libyaml", ] -[[package]] -name = "simple_logger" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45b60258a35dc3cb8a16890b8fd6723349bfa458d7960e25e633f1b1c19d7b5e" -dependencies = [ - "atty", - "colored 1.9.3", - "log", - "time", - "winapi", -] - [[package]] name = "slab" version = "0.4.7" @@ -780,11 +841,20 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bd10a070fb1f2796a288abec42695db4682a82b6f12ffacd60fb8d5ad3a4a12" +[[package]] +name = "strip-ansi-escapes" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "011cbb39cf7c1f62871aea3cc46e5817b0937b49e9447370c93cacbe93a766d8" +dependencies = [ + "vte", +] + [[package]] name = "strsim" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" @@ -799,9 +869,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.15" +version = "2.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" dependencies = [ "proc-macro2", "quote", @@ -815,50 +885,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c02424087780c9b71cc96799eaeddff35af2bc513278cda5c99fc1f5d026d3c1" [[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - -[[package]] -name = "thread_local" -version = "1.1.4" +name = "thiserror" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" dependencies = [ - "once_cell", + "thiserror-impl", ] [[package]] -name = "time" -version = "0.3.16" +name = "thiserror-impl" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fab5c8b9980850e06d92ddbe3ab839c062c801f3927c0fb8abd6fc8e918fbca" +checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" dependencies = [ - "itoa", - "libc", - "num_threads", - "serde", - "time-core", - "time-macros", + "proc-macro2", + "quote", + "syn 2.0.29", ] [[package]] -name = "time-core" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" - -[[package]] -name = "time-macros" -version = "0.2.5" +name = "thread_local" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65bb801831d812c562ae7d2bfb531f26e66e4e1f6b17307ba4149c5064710e5b" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" dependencies = [ - "time-core", + "once_cell", ] [[package]] @@ -873,12 +925,6 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - [[package]] name = "unindent" version = "0.1.10" @@ -898,10 +944,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8db7427f936968176eaa7cdf81b7f98b980b18495ec28f1b5791ac3bfe3eea9" [[package]] -name = "vec_map" -version = "0.8.2" +name = "utf8parse" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "version_check" @@ -909,6 +955,27 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "vte" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cbce692ab4ca2f1f3047fcf732430249c0e971bfdd2b234cf2c47ad93af5983" +dependencies = [ + "arrayvec", + "utf8parse", + "vte_generate_state_changes", +] + +[[package]] +name = "vte_generate_state_changes" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d257817081c7dffcdbab24b9e62d2def62e2ff7d00b1c20062551e6cccc145ff" +dependencies = [ + "proc-macro2", + "quote", +] + [[package]] name = "walkdir" version = "2.3.2" @@ -957,13 +1024,37 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.0", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm 0.42.0", + "windows_x86_64_msvc 0.42.0", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -972,38 +1063,80 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_i686_gnu" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_x86_64_gnu" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" diff --git a/packages/cfn_guard_rs/Cargo.toml b/packages/cfn_guard_rs/Cargo.toml index 0f129069..9ff745b7 100644 --- a/packages/cfn_guard_rs/Cargo.toml +++ b/packages/cfn_guard_rs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cfn_guard_rs" -version = "0.2.3" +version = "0.3.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -8,9 +8,6 @@ edition = "2021" name = "cfn_guard_rs" crate-type = ["cdylib"] -[package.metadata.maturin] -python-source = "python" - [dependencies] -pyo3 = { version = "0.17.3", features = ["extension-module"] } -cfn-guard = "2.1.2" +pyo3 = { version = "0.19.2", features = ["extension-module"] } +cfn-guard = "3.0.0" diff --git a/packages/cfn_guard_rs/pyproject.toml b/packages/cfn_guard_rs/pyproject.toml index a364a283..32765951 100644 --- a/packages/cfn_guard_rs/pyproject.toml +++ b/packages/cfn_guard_rs/pyproject.toml @@ -2,6 +2,9 @@ requires = ["maturin>=0.13,<0.14"] build-backend = "maturin" +[tool.maturin] +python-source = "python" + [project] name = "cfn_guard_rs" requires-python = ">=3.7" diff --git a/packages/cfn_guard_rs/python/cfn_guard_rs/__init__.py b/packages/cfn_guard_rs/python/cfn_guard_rs/__init__.py index 53a800ba..eec590ee 100644 --- a/packages/cfn_guard_rs/python/cfn_guard_rs/__init__.py +++ b/packages/cfn_guard_rs/python/cfn_guard_rs/__init__.py @@ -9,7 +9,15 @@ from .api import run_checks from .interface import ( - DataOutput, - Comparison, - NameInfo, + FileReport, + RuleReport, + Messages, + ClauseReport, + UnaryReport, + BinaryReport, + UnaryComparison, + UnaryCheck, + GuardClauseReport, + BinaryCheck, + BinaryComparison, ) diff --git a/packages/cfn_guard_rs/python/cfn_guard_rs/api.py b/packages/cfn_guard_rs/python/cfn_guard_rs/api.py index 4469b87a..dddb52f5 100644 --- a/packages/cfn_guard_rs/python/cfn_guard_rs/api.py +++ b/packages/cfn_guard_rs/python/cfn_guard_rs/api.py @@ -6,7 +6,7 @@ """ import logging import json -from cfn_guard_rs.interface import DataOutput +from cfn_guard_rs.interface import FileReport # pylint: disable=no-name-in-module from cfn_guard_rs.cfn_guard_rs import ( @@ -20,7 +20,7 @@ LOG = logging.getLogger(__name__) -def run_checks(data: dict, rules: str) -> DataOutput: +def run_checks(data: dict, rules: str) -> FileReport: """ Executes run_checks against Guard @@ -41,10 +41,8 @@ def run_checks(data: dict, rules: str) -> DataOutput: try: raw_output = run_checks_rs(json.dumps(data), rules, False) output = json.loads(raw_output) - # remove the lib set items and replace with our defaults - result = DataOutput(**output) - return result + return FileReport.from_object(output) except json.JSONDecodeError as err: LOG.debug( "JSON decoding error when processing return value [%s] got error: %s", diff --git a/packages/cfn_guard_rs/python/cfn_guard_rs/interface.py b/packages/cfn_guard_rs/python/cfn_guard_rs/interface.py index 9cf8aaf9..14e80168 100644 --- a/packages/cfn_guard_rs/python/cfn_guard_rs/interface.py +++ b/packages/cfn_guard_rs/python/cfn_guard_rs/interface.py @@ -2,83 +2,299 @@ Defines the non-verbose output format returned from run_checks """ +from __future__ import annotations -from dataclasses import dataclass -from typing import Any, List, Dict, Optional - - -@dataclass(eq=True) -class Comparison: - """Comparison Output""" - - operator: str - not_operator_exists: bool - - -@dataclass(eq=True) -class NameInfo: - """NameInfo which is per error""" - - rule: str - path: str - provided: Any - expected: Any - comparison: Optional[Comparison] - message: str - error: Optional[str] - - # pylint: disable=too-many-arguments - def __init__( - self, - rule: str, - path: str, - provided: Any, - expected: Any, - comparison: Optional[Comparison], - message: str, - error: Optional[str], - ) -> None: - self.rule = rule - self.path = path - self.provided = provided - self.expected = expected - self.message = message - self.error = error - if isinstance(comparison, dict): - self.comparison = Comparison(**comparison) - else: - self.comparison = comparison - - -@dataclass(eq=True) -class DataOutput: - """Primary Data Output""" - - not_compliant: Dict[str, List[NameInfo]] - not_applicable: List[str] - compliant: List[str] - data_from: str = "cfn_guard_rs" - rules_from: str = "cfn_guard_rs" - - # pylint: disable=unused-argument,too-many-arguments - def __init__( - self, - not_compliant: Dict[str, List[NameInfo]], - not_applicable: List[str], - compliant: List[str], - data_from: str = "cfn_guard_rs", - rules_from: str = "cfn_guard_rs", - ) -> None: - self.not_applicable = not_applicable - self.compliant = compliant - self.data_from = "cfn_guard_rs" - self.rules_from = "cfn_guard_rs" - self.not_compliant = {} - if isinstance(not_compliant, dict): - for key, value in not_compliant.items(): - self.not_compliant[key] = [] - for name_item in value: - if isinstance(name_item, dict): - self.not_compliant[key].append(NameInfo(**name_item)) - else: - self.not_compliant[key].append(name_item) +from dataclasses import dataclass, field +from typing import Any, List, Dict, Sequence, Tuple + +# pylint: disable=missing-class-docstring,missing-function-docstring,invalid-name + +@dataclass(eq=True, frozen=True) +class Messages: + """Messages Output""" + + custom_message: str | None = field(default=None) + error_message: str | None = field(default=None) + + @classmethod + def from_object(cls, obj) -> "Messages": + return cls( + custom_message=obj.get("custom_message"), + error_message=obj.get("error_message"), + ) + + +@dataclass(eq=True, frozen=True) +class RuleReport: + """Messages Output""" + + name: str = field() + metadata: Dict[str, Any] = field() + messages: Messages = field() + checks: Sequence[ClauseReport] = field() + + @classmethod + def from_object(cls, obj) -> "RuleReport" | None: + if obj is None: + return None + + return cls( + name=obj.get("name"), + metadata=obj.get("metadata"), + messages=Messages.from_object(obj.get("messages")), + checks=ClauseReport.from_array(obj.get("checks")), + ) + + +@dataclass(eq=True, frozen=True) +class GuardBlockReport: + """Guard Block Report""" + + context: str = field() + messages: Messages = field() + unresolved: Any = field() + + @classmethod + def from_object(cls, obj): + if obj is None: + return obj + + return cls( + context=obj.get("context"), + messages=Messages.from_object(obj.get("messages")), + unresolved=obj.get("resolved"), + ) + + +@dataclass(eq=True, frozen=True) +class DisjunctionsReport: + """Disjunctions""" + + checks: ClauseReport = field() + + @classmethod + def from_object(cls, obj): + if obj is None: + return obj + + return cls(checks=ClauseReport.from_object(obj.get("checks"))) + +@dataclass(eq=True, frozen=True) +class UnaryComparison: + """Unary Comparison""" + + value: Any = field() + comparison: Tuple[str, bool] = field() + + @classmethod + def from_object(cls, obj): + return cls( + value=obj.get("value"), + comparison=tuple(obj.get("comparison")), + ) + + +@dataclass(eq=True, frozen=True) +class UnResolved: + """Unresolved""" + + traversed_to: Any = field() + remaining_query: Any = field() + reason: Any = field() + + @classmethod + def from_object(cls, obj): + if obj is None: + return None + return cls( + traversed_to=obj.get("traversed_to"), + remaining_query=obj.get("remaining_query"), + reason=obj.get("reason"), + ) + + +@dataclass(eq=True, frozen=True) +class ValueUnResolved: + value: Any = field() + comparison: Any = field() + + @classmethod + def from_object(cls, obj): + return cls( + value=obj.get("value"), + comparison=obj.get("comparison"), + ) + + +@dataclass(eq=True, frozen=True) +class UnaryCheck: + """Unary Check""" + + Resolved: UnaryComparison | None = field(default=None) + UnResolved: UnResolved | None = field(default=None) + UnresolvedContext: Any | None = field(default=None) + + @classmethod + def from_object(cls, obj): + if obj is None: + return obj + + return cls( + Resolved=UnaryComparison.from_object(obj.get("Resolved")), + UnResolved=UnResolved.from_object(obj.get("UnResolved")), + UnresolvedContext=obj.get("UnresolvedContext"), + ) + + +@dataclass(eq=True, frozen=True) +class UnaryReport: + """Unary Report""" + + context: str = field() + messages: Messages = field() + check: UnaryCheck = field() + + @classmethod + def from_object(cls, obj): + if obj is None: + return None + + return cls( + context=obj.get("context"), + messages=Messages.from_object(obj.get("messages")), + check=UnaryCheck.from_object(obj.get("check")), + ) + + +@dataclass(eq=True, frozen=True) +class BinaryComparison: + from_: Any = field() + to_: Any = field() + comparison: Any = field() + + @classmethod + def from_object(cls, obj): + if obj is None: + return None + return cls( + from_=obj.get("from"), to_=obj.get("to"), comparison=obj.get("comparison") + ) + + +@dataclass(eq=True, frozen=True) +class InComparison: + def __init__(self, **kwargs) -> None: + self.from_ = kwargs["from"] + self.to_ = kwargs["to"] + self.comparison = kwargs["comparison"] + + @classmethod + def from_object(cls, obj) -> "InComparison" | None: + return cls( + from_=obj.get("from"), + to_=obj.get("to"), + comparison=obj.get("comparison"), + ) + + +@dataclass(eq=True, frozen=True) +class BinaryCheck: + Resolved: BinaryComparison | None = field(default=None) + UnResolved: UnResolved | None = field(default=None) + InResolved: Any = field(default=None) + + @classmethod + def from_object(cls, obj): + return cls( + Resolved=BinaryComparison.from_object(obj.get("Resolved")), + UnResolved=UnResolved.from_object(obj.get("UnResolved")), + InResolved=obj.get("InResolved"), + ) + + +@dataclass(eq=True, frozen=True) +class BinaryReport: + context: str = field() + messages: Messages = field() + check: BinaryCheck = field() + + @classmethod + def from_object(cls, obj): + if obj is None: + return obj + return cls( + context=obj.get("context"), + messages=Messages.from_object(obj.get("messages")), + check=BinaryCheck.from_object(obj.get("check")), + ) + + +@dataclass(eq=True, frozen=True) +class GuardClauseReport: + """Guard Clause Report""" + + Unary: UnaryReport | None = field(default=None) + Binary: BinaryReport | None = field(default=None) + + @classmethod + def from_object(cls, obj): + if obj is None: + return obj + + return cls( + Unary=UnaryReport.from_object(obj.get("Unary")), + Binary=BinaryReport.from_object(obj.get("Binary")), + ) + + +@dataclass(eq=True, frozen=True) +class ClauseReport: + """Clause Report""" + + Rule: RuleReport | None = field(default=None) + Disjunctions: DisjunctionsReport | None = field(default=None) + GuardBlock: GuardBlockReport | None = field(default=None) + Clause: GuardClauseReport | None = field(default=None) + + @classmethod + def from_object(cls, obj): + return cls( + Rule=RuleReport.from_object(obj.get("Rule")), + Disjunctions=DisjunctionsReport.from_object(obj.get("Disjunctions")), + GuardBlock=GuardBlockReport.from_object(obj.get("GuardBlock")), + Clause=GuardClauseReport.from_object(obj.get("Clause")), + ) + + @classmethod + def from_array(cls, items): + results = [] + for item in items: + results.append(ClauseReport.from_object(item)) + + return results + + +# pylint: disable=too-many-instance-attributes +@dataclass(eq=True, frozen=True) +class FileReport: + name: str = field() + metadata: Dict[str, Any] = field() + status: str = field() + not_compliant: List[ClauseReport] = field() + not_applicable: List[str] = field() + compliant: List[str] = field() + data_from: str = field(default="cfn_guard_rs") + rules_from: str = field(default="cfn_guard_rs") + + @classmethod + def from_object(cls, obj) -> "FileReport": + return cls( + name=obj.get("name"), + metadata=obj.get("metadata"), + status=obj.get("status"), + not_compliant=ClauseReport.from_array(obj.get("not_compliant")), + not_applicable=obj.get("not_applicable"), + compliant=obj.get("compliant"), + data_from=obj.get("data_from", "cfn_guard_rs"), + rules_from=obj.get("rules_from", "cfn_guard_rs"), + ) diff --git a/packages/cfn_guard_rs/python/tests/test_cfn_guard_rs.py b/packages/cfn_guard_rs/python/tests/test_cfn_guard_rs.py index 37b8d8c9..0a555e0d 100644 --- a/packages/cfn_guard_rs/python/tests/test_cfn_guard_rs.py +++ b/packages/cfn_guard_rs/python/tests/test_cfn_guard_rs.py @@ -6,7 +6,20 @@ import yaml import pytest import cfn_guard_rs.errors -from cfn_guard_rs import Comparison, run_checks, DataOutput, NameInfo +from cfn_guard_rs import ( + run_checks, + FileReport, + RuleReport, + Messages, + ClauseReport, + UnaryReport, + BinaryReport, + UnaryComparison, + UnaryCheck, + GuardClauseReport, + BinaryCheck, + BinaryComparison, +) @pytest.mark.parametrize( @@ -15,10 +28,13 @@ ( "python/tests/fixtures/templates/s3_bucket_name_valid.yaml", "python/tests/fixtures/rules/s3_bucket_name.guard", - DataOutput( + FileReport( + name="", + metadata={}, + status="PASS", data_from="cfn_guard_rs", rules_from="cfn_guard_rs", - not_compliant={}, + not_compliant=[], not_applicable=[], compliant=["default"], ), @@ -26,24 +42,50 @@ ( "python/tests/fixtures/templates/s3_bucket_name_invalid.yaml", "python/tests/fixtures/rules/s3_bucket_name.guard", - DataOutput( + FileReport( + name="", + metadata={}, + status="FAIL", data_from="cfn_guard_rs", rules_from="cfn_guard_rs", - not_compliant={ - "default": [ - NameInfo( - rule="default", - path="/Resources/Bucket/Properties/BucketName", - provided=1, - expected=None, - comparison=Comparison( - operator="IsString", not_operator_exists=False - ), - message="", - error=None, - ) - ] - }, + not_compliant=[ + ClauseReport( + Rule=RuleReport( + name="default", + metadata={}, + messages=Messages(), + checks=[ + ClauseReport( + Clause=GuardClauseReport( + Unary=UnaryReport( + context=" BucketName IS STRING ", + messages=Messages( + custom_message="", + error_message=( + "Check was not compliant as " + "property [/Resources/Bucket/Properties" + "/BucketName[L:0,C:0]] was not string." + ), + ), + check=UnaryCheck( + Resolved=UnaryComparison( + value={ + "path": ( + "/Resources/Bucket/" + "Properties/BucketName" + ), + "value": 1, + }, + comparison=("IsString", False), + ) + ), + ), + ), + ), + ], + ), + ) + ], not_applicable=[], compliant=[], ), @@ -51,10 +93,13 @@ ( "python/tests/fixtures/templates/s3_bucket_public_access_valid.yaml", "python/tests/fixtures/rules/s3_bucket_public_access.guard", - DataOutput( + FileReport( + name="", + metadata={}, + status="PASS", data_from="cfn_guard_rs", rules_from="cfn_guard_rs", - not_compliant={}, + not_compliant=[], not_applicable=[], compliant=["S3_BUCKET_LEVEL_PUBLIC_ACCESS_PROHIBITED"], ), @@ -62,25 +107,59 @@ ( "python/tests/fixtures/templates/s3_bucket_public_access_invalid.yaml", "python/tests/fixtures/rules/s3_bucket_public_access.guard", - DataOutput( + FileReport( + name="", + metadata={}, + status="FAIL", data_from="cfn_guard_rs", rules_from="cfn_guard_rs", - not_compliant={ - "S3_BUCKET_LEVEL_PUBLIC_ACCESS_PROHIBITED": [ - NameInfo( - rule="S3_BUCKET_LEVEL_PUBLIC_ACCESS_PROHIBITED", - # pylint: disable=line-too-long - path="/Resources/Bucket/Properties/PublicAccessBlockConfiguration/BlockPublicAcls", - provided="false", - expected="true", - comparison=Comparison( - operator="Eq", not_operator_exists=False - ), - message="", - error=None, - ) - ] - }, + not_compliant=[ + ClauseReport( + Rule=RuleReport( + name="S3_BUCKET_LEVEL_PUBLIC_ACCESS_PROHIBITED", + metadata={}, + messages=Messages(), + checks=[ + ClauseReport( + Clause=GuardClauseReport( + Binary=BinaryReport( + context=( + " %s3_buckets_level_public_access_" + "prohibited[*].Properties." + "PublicAccessBlockConfiguration." + 'BlockPublicAcls EQUALS "true"' + ), + messages=Messages( + custom_message="", + error_message=( + "Check was not compliant as property" + " value [Path=/Resources/Bucket/Properties/" + "PublicAccessBlockConfiguration/BlockPublicAcls" + '[L:0,C:0] Value="false"] not equal to value ' + '[Path=[L:0,C:0] Value="true"].' + ), + ), + check=BinaryCheck( + Resolved=BinaryComparison( + from_={ + "path": ( + "/Resources/Bucket/Properties/" + "PublicAccessBlockConfiguration/" + "BlockPublicAcls" + ), + "value": "false", + }, + to_={"path": "", "value": "true"}, + comparison=["Eq", False], + ) + ), + ), + ), + ), + ], + ), + ) + ], not_applicable=[], compliant=[], ), @@ -95,6 +174,8 @@ def test_run_checks(template, rules, expected): rules = file.read() result = run_checks(template_str, rules) + print(result) + print(expected) assert result == expected @@ -117,9 +198,9 @@ def test_run_checks(template, rules, expected): cfn_guard_rs.errors.ParseError, ValueError, ( - "Parser Error when parsing Parsing Error Error parsing file " + "Parser Error when parsing `Parsing Error Error parsing file " "at line 1 at column 17, when handling , fragment " - "{\n Properties\n BucketName is_string\n }\n}\n" + "{\n Properties\n BucketName is_string\n }\n}`" ), ), ], diff --git a/packages/cfn_guard_rs/requirements.txt b/packages/cfn_guard_rs/requirements.txt index 0a1e92d0..263d1118 100644 --- a/packages/cfn_guard_rs/requirements.txt +++ b/packages/cfn_guard_rs/requirements.txt @@ -1,3 +1,3 @@ -maturin==0.13.2 +maturin==1.2.3 tomli==2.0.1 -PyYAML==5.4.1 +PyYAML==6.0.1 diff --git a/packages/cfn_guard_rs/src/errors.rs b/packages/cfn_guard_rs/src/errors.rs index 9e0f6785..ebffeab0 100644 --- a/packages/cfn_guard_rs/src/errors.rs +++ b/packages/cfn_guard_rs/src/errors.rs @@ -4,7 +4,7 @@ use pyo3::{ import_exception, exceptions, }; -use cfn_guard::{Error, ErrorKind}; +use cfn_guard::Error; import_exception!(json, JSONDecodeError); import_exception!(yaml, YAMLError); @@ -13,6 +13,8 @@ create_exception!(cfn_guard_rs, CfnGuardJsonError, JSONDecodeError); create_exception!(cfn_guard_rs, CfnGuardYamlError, YAMLError); create_exception!(cfn_guard_rs, CfnGuardIoError, exceptions::PyIOError); create_exception!(cfn_guard_rs, CfnGuardFileNotFoundError, exceptions::PyFileNotFoundError); +create_exception!(cfn_guard_rs, CfnGuardIllegalArguments, exceptions::PyValueError); +create_exception!(cfn_guard_rs, CfnGuardInternalError, exceptions::PyException); // ParseError create_exception!(cfn_guard_rs, CfnGuardParseError, exceptions::PyValueError); @@ -44,25 +46,26 @@ impl From for CfnGuardError { impl From for PyErr { fn from(err: CfnGuardError) -> Self { - let e = &err.0; - match &e.0 { - ErrorKind::JsonError(err) => CfnGuardJsonError::new_err(format!("{}", err)), - ErrorKind::YamlError(err) => CfnGuardYamlError::new_err(format!("{}", err)), - ErrorKind::FormatError(err) => CfnGuardFormatError::new_err(format!("{}", err)), - ErrorKind::IoError(err) => CfnGuardIoError::new_err(format!("{}", err)), - ErrorKind::ParseError(err) => CfnGuardParseError::new_err(format!("{}", err)), - ErrorKind::RegexError(err) => CfnGuardRegexError::new_err(format!("{}", err)), - ErrorKind::MissingProperty(err) => CfnGuardMissingProperty::new_err(format!("{}", err)), - ErrorKind::MissingVariable(err) => CfnGuardMissingVariable::new_err(format!("{}", err)), - ErrorKind::MultipleValues(err) => CfnGuardMultipleValues::new_err(format!("{}", err)), - ErrorKind::IncompatibleRetrievalError(err) => CfnGuardIncompatibleRetrievalError::new_err(format!("{}", err)), - ErrorKind::IncompatibleError(err) => CfnGuardIncompatibleError::new_err(format!("{}", err)), - ErrorKind::NotComparable(err) => CfnGuardNotComparable::new_err(format!("{}", err)), - ErrorKind::ConversionError(err) => CfnGuardConversionError::new_err(format!("{}", err)), - ErrorKind::Errors(_err) => CfnGuardErrors::new_err("multiple errors"), - ErrorKind::RetrievalError(err) => CfnGuardRetrievalError::new_err(format!("{}", err)), - ErrorKind::MissingValue(err) => CfnGuardMissingValue::new_err(format!("{}", err)), - ErrorKind::FileNotFoundError(err) => CfnGuardFileNotFoundError::new_err(format!("{}", err)), + match &err.0 { + Error::JsonError(err) => CfnGuardJsonError::new_err(format!("{}", err)), + Error::YamlError(err) => CfnGuardYamlError::new_err(format!("{}", err)), + Error::FormatError(err) => CfnGuardFormatError::new_err(format!("{}", err)), + Error::IoError(err) => CfnGuardIoError::new_err(format!("{}", err)), + Error::ParseError(err) => CfnGuardParseError::new_err(format!("{}", err)), + Error::RegexError(err) => CfnGuardRegexError::new_err(format!("{}", err)), + Error::MissingProperty(err) => CfnGuardMissingProperty::new_err(format!("{}", err)), + Error::MissingVariable(err) => CfnGuardMissingVariable::new_err(format!("{}", err)), + Error::MultipleValues(err) => CfnGuardMultipleValues::new_err(format!("{}", err)), + Error::IncompatibleRetrievalError(err) => CfnGuardIncompatibleRetrievalError::new_err(format!("{}", err)), + Error::IncompatibleError(err) => CfnGuardIncompatibleError::new_err(format!("{}", err)), + Error::NotComparable(err) => CfnGuardNotComparable::new_err(format!("{}", err)), + Error::ConversionError(err) => CfnGuardConversionError::new_err(format!("{}", err)), + Error::Errors(_err) => CfnGuardErrors::new_err("multiple errors"), + Error::RetrievalError(err) => CfnGuardRetrievalError::new_err(format!("{}", err)), + Error::MissingValue(err) => CfnGuardMissingValue::new_err(format!("{}", err)), + Error::FileNotFoundError(err) => CfnGuardFileNotFoundError::new_err(format!("{}", err)), + Error::IllegalArguments(err) => CfnGuardIllegalArguments::new_err(format!("{}", err)), + Error::InternalError(err) => CfnGuardInternalError::new_err(format!("{}", err)), } } -} \ No newline at end of file +} diff --git a/packages/cfn_guard_rs/tox.ini b/packages/cfn_guard_rs/tox.ini index 21c42840..ce09d8c8 100644 --- a/packages/cfn_guard_rs/tox.ini +++ b/packages/cfn_guard_rs/tox.ini @@ -1,6 +1,6 @@ [tox] isolated_build = true -envlist = py37, py38, py39, py310 +envlist = py38, py39, py310 [testenv] deps = diff --git a/packages/cfn_guard_rs_hook/poetry.lock b/packages/cfn_guard_rs_hook/poetry.lock index f3966e57..1151448f 100644 --- a/packages/cfn_guard_rs_hook/poetry.lock +++ b/packages/cfn_guard_rs_hook/poetry.lock @@ -1,6 +1,6 @@ [[package]] name = "astroid" -version = "2.14.2" +version = "2.15.6" description = "An abstract syntax tree for Python with inference support." category = "dev" optional = false @@ -15,54 +15,16 @@ wrapt = [ {version = ">=1.14,<2", markers = "python_version >= \"3.11\""}, ] -[[package]] -name = "atomicwrites" -version = "1.4.1" -description = "Atomic file writes." -category = "dev" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" - -[[package]] -name = "attrs" -version = "22.2.0" -description = "Classes Without Boilerplate" -category = "main" -optional = false -python-versions = ">=3.6" - -[package.extras] -cov = ["attrs", "coverage-enable-subprocess", "coverage[toml] (>=5.3)"] -dev = ["attrs"] -docs = ["furo", "sphinx", "myst-parser", "zope.interface", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier"] -tests = ["attrs", "zope.interface"] -tests-no-zope = ["hypothesis", "pympler", "pytest (>=4.3.0)", "pytest-xdist", "cloudpickle", "mypy (>=0.971,<0.990)", "pytest-mypy-plugins"] -tests_no_zope = ["hypothesis", "pympler", "pytest (>=4.3.0)", "pytest-xdist", "cloudpickle", "mypy (>=0.971,<0.990)", "pytest-mypy-plugins"] - -[[package]] -name = "aws-encryption-sdk" -version = "3.1.0" -description = "AWS Encryption SDK implementation for Python" -category = "main" -optional = false -python-versions = "*" - -[package.dependencies] -attrs = ">=17.4.0" -boto3 = ">=1.10.0" -cryptography = ">=2.5.0" -wrapt = ">=1.10.11" - [[package]] name = "boto3" -version = "1.26.74" +version = "1.28.38" description = "The AWS SDK for Python" category = "main" optional = false python-versions = ">= 3.7" [package.dependencies] -botocore = ">=1.29.74,<1.30.0" +botocore = ">=1.31.38,<1.32.0" jmespath = ">=0.7.1,<2.0.0" s3transfer = ">=0.6.0,<0.7.0" @@ -71,7 +33,7 @@ crt = ["botocore[crt] (>=1.21.0,<2.0a0)"] [[package]] name = "botocore" -version = "1.29.74" +version = "1.31.38" description = "Low-level, data-driven core of boto 3." category = "main" optional = false @@ -83,22 +45,11 @@ python-dateutil = ">=2.1,<3.0.0" urllib3 = ">=1.25.4,<1.27" [package.extras] -crt = ["awscrt (==0.16.9)"] - -[[package]] -name = "cffi" -version = "1.15.1" -description = "Foreign Function Interface for Python calling C code." -category = "main" -optional = false -python-versions = "*" - -[package.dependencies] -pycparser = "*" +crt = ["awscrt (==0.16.26)"] [[package]] name = "cfn-guard-rs" -version = "0.2.1" +version = "0.2.3" description = "" category = "main" optional = false @@ -109,14 +60,13 @@ pyyaml = ">=5.0.0" [[package]] name = "cloudformation-cli-python-lib" -version = "2.1.15" +version = "2.1.17" description = "Support library to enable Python-based CloudFormation resource types" category = "main" optional = false python-versions = ">=3.6" [package.dependencies] -aws-encryption-sdk = "3.1.0" boto3 = ">=1.10.20" [[package]] @@ -127,27 +77,6 @@ category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" -[[package]] -name = "cryptography" -version = "39.0.1" -description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." -category = "main" -optional = false -python-versions = ">=3.6" - -[package.dependencies] -cffi = ">=1.12" - -[package.extras] -docs = ["sphinx (>=5.3.0)", "sphinx-rtd-theme (>=1.1.1)"] -docstest = ["pyenchant (>=1.6.11)", "twine (>=1.12.0)", "sphinxcontrib-spelling (>=4.0.1)"] -pep8test = ["black", "ruff", "mypy", "types-pytz", "types-requests", "check-manifest"] -sdist = ["setuptools-rust (>=0.11.4)"] -ssh = ["bcrypt (>=3.1.5)"] -test = ["pytest (>=6.2.0)", "pytest-shard (>=0.1.2)", "pytest-benchmark", "pytest-cov", "pytest-subtests", "pytest-xdist", "pretend", "iso8601", "pytz", "hypothesis (>=1.11.4,!=3.79.2)"] -test-randomorder = ["pytest-randomly"] -tox = ["tox"] - [[package]] name = "decorator" version = "5.1.1" @@ -158,8 +87,8 @@ python-versions = ">=3.5" [[package]] name = "dill" -version = "0.3.6" -description = "serialize all of python" +version = "0.3.7" +description = "serialize all of Python" category = "dev" optional = false python-versions = ">=3.7" @@ -167,9 +96,20 @@ python-versions = ">=3.7" [package.extras] graph = ["objgraph (>=1.7.2)"] +[[package]] +name = "exceptiongroup" +version = "1.1.3" +description = "Backport of PEP 654 (exception groups)" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.extras] +test = ["pytest (>=6)"] + [[package]] name = "importlib-metadata" -version = "6.0.0" +version = "6.7.0" description = "Read metadata from Python packages" category = "dev" optional = false @@ -182,7 +122,15 @@ zipp = ">=0.5" [package.extras] docs = ["sphinx (>=3.5)", "jaraco.packaging (>=9)", "rst.linker (>=1.9)", "furo", "sphinx-lint", "jaraco.tidelift (>=1.4)"] perf = ["ipython"] -testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "flake8 (<5)", "pytest-cov", "pytest-enabler (>=1.3)", "packaging", "pyfakefs", "flufl.flake8", "pytest-perf (>=0.9.2)", "pytest-black (>=0.3.7)", "pytest-mypy (>=0.9.1)", "pytest-flake8", "importlib-resources (>=1.3)"] +testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-ruff", "packaging", "pyfakefs", "flufl.flake8", "pytest-perf (>=0.9.2)", "pytest-black (>=0.3.7)", "pytest-mypy (>=0.9.1)", "importlib-resources (>=1.3)"] + +[[package]] +name = "iniconfig" +version = "2.0.0" +description = "brain-dead simple config-ini parsing" +category = "dev" +optional = false +python-versions = ">=3.7" [[package]] name = "isort" @@ -243,7 +191,7 @@ python-versions = ">=3.7" [[package]] name = "markupsafe" -version = "2.1.2" +version = "2.1.3" description = "Safely add untrusted strings to HTML/XML markup." category = "main" optional = false @@ -257,30 +205,23 @@ category = "dev" optional = false python-versions = ">=3.6" -[[package]] -name = "more-itertools" -version = "9.0.0" -description = "More routines for operating on iterables, beyond itertools" -category = "dev" -optional = false -python-versions = ">=3.7" - [[package]] name = "mypy" -version = "0.971" +version = "1.4.1" description = "Optional static typing for Python" category = "dev" optional = false -python-versions = ">=3.6" +python-versions = ">=3.7" [package.dependencies] -mypy-extensions = ">=0.4.3" +mypy-extensions = ">=1.0.0" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} typed-ast = {version = ">=1.4.0,<2", markers = "python_version < \"3.8\""} -typing-extensions = ">=3.10" +typing-extensions = ">=4.1.0" [package.extras] dmypy = ["psutil (>=4.0)"] +install-types = ["pip"] python2 = ["typed-ast (>=1.4.0,<2)"] reports = ["lxml"] @@ -294,7 +235,7 @@ python-versions = ">=3.5" [[package]] name = "packaging" -version = "23.0" +version = "23.1" description = "Core utilities for Python packages" category = "dev" optional = false @@ -302,32 +243,33 @@ python-versions = ">=3.7" [[package]] name = "platformdirs" -version = "3.0.0" +version = "3.10.0" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." category = "dev" optional = false python-versions = ">=3.7" [package.dependencies] -typing-extensions = {version = ">=4.4", markers = "python_version < \"3.8\""} +typing-extensions = {version = ">=4.7.1", markers = "python_version < \"3.8\""} [package.extras] -docs = ["furo (>=2022.12.7)", "proselint (>=0.13)", "sphinx-autodoc-typehints (>=1.22,!=1.23.4)", "sphinx (>=6.1.3)"] -test = ["appdirs (==1.4.4)", "covdefaults (>=2.2.2)", "pytest-cov (>=4)", "pytest-mock (>=3.10)", "pytest (>=7.2.1)"] +docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx-autodoc-typehints (>=1.24)", "sphinx (>=7.1.1)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)", "pytest (>=7.4)"] [[package]] name = "pluggy" -version = "0.13.1" +version = "1.2.0" description = "plugin and hook calling mechanisms for python" category = "dev" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +python-versions = ">=3.7" [package.dependencies] importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} [package.extras] dev = ["pre-commit", "tox"] +testing = ["pytest", "pytest-benchmark"] [[package]] name = "ply" @@ -337,32 +279,16 @@ category = "main" optional = false python-versions = "*" -[[package]] -name = "py" -version = "1.11.0" -description = "library with cross-python path, ini-parsing, io, code, log facilities" -category = "dev" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" - -[[package]] -name = "pycparser" -version = "2.21" -description = "C parser in Python" -category = "main" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" - [[package]] name = "pylint" -version = "2.16.2" +version = "2.17.5" description = "python code static checker" category = "dev" optional = false python-versions = ">=3.7.2" [package.dependencies] -astroid = ">=2.14.2,<=2.16.0-dev0" +astroid = ">=2.15.6,<=2.17.0-dev0" colorama = {version = ">=0.4.5", markers = "sys_platform == \"win32\""} dill = [ {version = ">=0.2", markers = "python_version < \"3.11\""}, @@ -381,26 +307,23 @@ testutils = ["gitpython (>3)"] [[package]] name = "pytest" -version = "5.4.3" +version = "7.4.0" description = "pytest: simple powerful testing with Python" category = "dev" optional = false -python-versions = ">=3.5" +python-versions = ">=3.7" [package.dependencies] -atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""} -attrs = ">=17.4.0" colorama = {version = "*", markers = "sys_platform == \"win32\""} +exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} -more-itertools = ">=4.0.0" +iniconfig = "*" packaging = "*" -pluggy = ">=0.12,<1.0" -py = ">=1.5.0" -wcwidth = "*" +pluggy = ">=0.12,<2.0" +tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} [package.extras] -checkqa-mypy = ["mypy (==v0.761)"] -testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xmlschema"] +testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] [[package]] name = "python-dateutil" @@ -415,15 +338,15 @@ six = ">=1.5" [[package]] name = "pyyaml" -version = "5.4.1" +version = "6.0.1" description = "YAML parser and emitter for Python" category = "main" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" +python-versions = ">=3.6" [[package]] name = "s3transfer" -version = "0.6.0" +version = "0.6.2" description = "An Amazon S3 Transfer Manager" category = "main" optional = false @@ -453,15 +376,15 @@ python-versions = ">=3.7" [[package]] name = "tomlkit" -version = "0.11.6" +version = "0.12.1" description = "Style preserving TOML library" category = "dev" optional = false -python-versions = ">=3.6" +python-versions = ">=3.7" [[package]] name = "typed-ast" -version = "1.5.4" +version = "1.5.5" description = "a fork of Python 2 and 3 ast modules with type comment support" category = "dev" optional = false @@ -469,7 +392,7 @@ python-versions = ">=3.6" [[package]] name = "typing-extensions" -version = "4.5.0" +version = "4.7.1" description = "Backported and Experimental Type Hints for Python 3.7+" category = "dev" optional = false @@ -477,7 +400,7 @@ python-versions = ">=3.7" [[package]] name = "urllib3" -version = "1.26.14" +version = "1.26.16" description = "HTTP library with thread-safe connection pooling, file post, and more." category = "main" optional = false @@ -488,25 +411,17 @@ brotli = ["brotlicffi (>=0.8.0)", "brotli (>=1.0.9)", "brotlipy (>=0.6.0)"] secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "urllib3-secure-extra", "ipaddress"] socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] -[[package]] -name = "wcwidth" -version = "0.2.6" -description = "Measures the displayed width of unicode strings in a terminal" -category = "dev" -optional = false -python-versions = "*" - [[package]] name = "wrapt" -version = "1.14.1" +version = "1.15.0" description = "Module for decorators, wrappers and monkey patching." -category = "main" +category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" [[package]] name = "zipp" -version = "3.13.0" +version = "3.15.0" description = "Backport of pathlib-compatible object wrapper for zip files" category = "dev" optional = false @@ -514,28 +429,25 @@ python-versions = ">=3.7" [package.extras] docs = ["sphinx (>=3.5)", "jaraco.packaging (>=9)", "rst.linker (>=1.9)", "furo", "sphinx-lint", "jaraco.tidelift (>=1.4)"] -testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "flake8 (<5)", "pytest-cov", "pytest-enabler (>=1.3)", "jaraco.itertools", "func-timeout", "jaraco.functools", "more-itertools", "pytest-black (>=0.3.7)", "pytest-mypy (>=0.9.1)", "pytest-flake8"] +testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "flake8 (<5)", "pytest-cov", "pytest-enabler (>=1.3)", "jaraco.itertools", "jaraco.functools", "more-itertools", "big-o", "pytest-black (>=0.3.7)", "pytest-mypy (>=0.9.1)", "pytest-flake8"] [metadata] lock-version = "1.1" python-versions = "^3.7.2" -content-hash = "623043ce6f68dd1dfe2581bb907a0ead657e8d5ec47dd4a496bbbc2af09c0cad" +content-hash = "1e4eca4bb3fb0076821b93c2dc745539f63c8dd8cbbd45beb078cc92111646d3" [metadata.files] astroid = [] -atomicwrites = [] -attrs = [] -aws-encryption-sdk = [] boto3 = [] botocore = [] -cffi = [] cfn-guard-rs = [] cloudformation-cli-python-lib = [] colorama = [] -cryptography = [] decorator = [] dill = [] +exceptiongroup = [] importlib-metadata = [] +iniconfig = [] isort = [] jinja2 = [] jmespath = [] @@ -543,15 +455,12 @@ jsonpath-rw = [] lazy-object-proxy = [] markupsafe = [] mccabe = [] -more-itertools = [] mypy = [] mypy-extensions = [] packaging = [] platformdirs = [] pluggy = [] ply = [] -py = [] -pycparser = [] pylint = [] pytest = [] python-dateutil = [] @@ -563,6 +472,5 @@ tomlkit = [] typed-ast = [] typing-extensions = [] urllib3 = [] -wcwidth = [] wrapt = [] zipp = [] diff --git a/packages/cfn_guard_rs_hook/pyproject.toml b/packages/cfn_guard_rs_hook/pyproject.toml index 22ab0e06..95a5541f 100644 --- a/packages/cfn_guard_rs_hook/pyproject.toml +++ b/packages/cfn_guard_rs_hook/pyproject.toml @@ -8,14 +8,14 @@ authors = ["Kevin DeJong "] python = "^3.7.2" cloudformation-cli-python-lib = "^2.1.12" cfn-guard-rs = "^0.2.1" -pyyaml = "~5.4.1" +pyyaml = "~6.0.1" Jinja2 = "^3.0.0" jsonpath-rw = "^1.0.0" [tool.poetry.dev-dependencies] -pytest = "^5.2" -mypy = "^0.971" -pylint = "^2.15.0" +pytest = "^7.4" +mypy = "^1.4.0" +pylint = "^2.17.0" [build-system] requires = ["poetry-core>=1.0.0"]