From 86dec18f9c5c9fa347bd090d5e15e3776dcb19ee Mon Sep 17 00:00:00 2001 From: Vara Prasad Bandaru Date: Wed, 6 Mar 2024 16:41:15 +0530 Subject: [PATCH 1/2] Update lints table to contain Anchor and Non-Anchor columns --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e8ef8b7..832562a 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,14 @@ The lints are inspired by the [Sealevel Attacks]. (See also @pencilflip's [Twitt The current lints are: -| Library | Description | -| ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | -| [`arbitrary_cpi`](lints/arbitrary_cpi) | lint for [5-arbitrary-cpi](https://github.com/coral-xyz/sealevel-attacks/tree/master/programs/5-arbitrary-cpi) | -| [`bump_seed_canonicalization`](lints/bump_seed_canonicalization) | lint for [6-bump-seed-canonicalization](https://github.com/coral-xyz/sealevel-attacks/tree/master/programs/7-bump-seed-canonicalization) | -| [`insecure_account_close`](lints/insecure_account_close) | lint for [9-closing-accounts](https://github.com/coral-xyz/sealevel-attacks/tree/master/programs/9-closing-accounts) | -| [`missing_owner_check`](lints/missing_owner_check) | lint for [2-owner-checks](https://github.com/coral-xyz/sealevel-attacks/tree/master/programs/2-owner-checks) | -| [`missing_signer_check`](lints/missing_signer_check) | lint for [0-signer-authorization](https://github.com/coral-xyz/sealevel-attacks/tree/master/programs/0-signer-authorization) | -| [`type_cosplay`](lints/type_cosplay) | lint for [3-type-cosplay](https://github.com/coral-xyz/sealevel-attacks/tree/master/programs/3-type-cosplay) | +| Library | Description | Anchor | Non-Anchor | +| ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ------------------ | +| [`arbitrary_cpi`](lints/arbitrary_cpi) | lint for [5-arbitrary-cpi](https://github.com/coral-xyz/sealevel-attacks/tree/master/programs/5-arbitrary-cpi) | | :heavy_check_mark: | +| [`bump_seed_canonicalization`](lints/bump_seed_canonicalization) | lint for [6-bump-seed-canonicalization](https://github.com/coral-xyz/sealevel-attacks/tree/master/programs/7-bump-seed-canonicalization) | | :heavy_check_mark: | +| [`insecure_account_close`](lints/insecure_account_close) | lint for [9-closing-accounts](https://github.com/coral-xyz/sealevel-attacks/tree/master/programs/9-closing-accounts) | :heavy_check_mark: | :heavy_check_mark: | +| [`missing_owner_check`](lints/missing_owner_check) | lint for [2-owner-checks](https://github.com/coral-xyz/sealevel-attacks/tree/master/programs/2-owner-checks) | :heavy_check_mark: | :heavy_check_mark: | +| [`missing_signer_check`](lints/missing_signer_check) | lint for [0-signer-authorization](https://github.com/coral-xyz/sealevel-attacks/tree/master/programs/0-signer-authorization) | :heavy_check_mark: | :heavy_check_mark: | +| [`type_cosplay`](lints/type_cosplay) | lint for [3-type-cosplay](https://github.com/coral-xyz/sealevel-attacks/tree/master/programs/3-type-cosplay) | | :heavy_check_mark: | ## Usage From a68906bfb9072b588590be8c2dde6f943494d750 Mon Sep 17 00:00:00 2001 From: Vara Prasad Bandaru Date: Wed, 6 Mar 2024 18:45:04 +0530 Subject: [PATCH 2/2] Update scripts/update_readmes.sh to parse anchor non anchor fields in cargo.toml --- README.md | 2 +- lints/arbitrary_cpi/Cargo.toml | 4 +++ lints/bump_seed_canonicalization/Cargo.toml | 4 +++ lints/insecure_account_close/Cargo.toml | 4 +++ lints/missing_owner_check/Cargo.toml | 4 +++ lints/missing_signer_check/Cargo.toml | 4 +++ lints/type_cosplay/Cargo.toml | 4 +++ scripts/update_readmes.sh | 29 ++++++++++++++++++--- 8 files changed, 50 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 832562a..c64e316 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ The lints are inspired by the [Sealevel Attacks]. (See also @pencilflip's [Twitt The current lints are: -| Library | Description | Anchor | Non-Anchor | +| Library | Description | Anchor | Non Anchor | | ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ------------------ | | [`arbitrary_cpi`](lints/arbitrary_cpi) | lint for [5-arbitrary-cpi](https://github.com/coral-xyz/sealevel-attacks/tree/master/programs/5-arbitrary-cpi) | | :heavy_check_mark: | | [`bump_seed_canonicalization`](lints/bump_seed_canonicalization) | lint for [6-bump-seed-canonicalization](https://github.com/coral-xyz/sealevel-attacks/tree/master/programs/7-bump-seed-canonicalization) | | :heavy_check_mark: | diff --git a/lints/arbitrary_cpi/Cargo.toml b/lints/arbitrary_cpi/Cargo.toml index 82caf05..3633b12 100644 --- a/lints/arbitrary_cpi/Cargo.toml +++ b/lints/arbitrary_cpi/Cargo.toml @@ -40,3 +40,7 @@ dylint_testing = "2.6" [package.metadata.rust-analyzer] rustc_private = true + +[package.metadata] +anchor_programs = false +non_anchor_programs = true diff --git a/lints/bump_seed_canonicalization/Cargo.toml b/lints/bump_seed_canonicalization/Cargo.toml index 458172f..690d26e 100644 --- a/lints/bump_seed_canonicalization/Cargo.toml +++ b/lints/bump_seed_canonicalization/Cargo.toml @@ -43,3 +43,7 @@ dylint_testing = "2.6" [package.metadata.rust-analyzer] rustc_private = true + +[package.metadata] +anchor_programs = false +non_anchor_programs = true diff --git a/lints/insecure_account_close/Cargo.toml b/lints/insecure_account_close/Cargo.toml index 3967ee2..95a7052 100644 --- a/lints/insecure_account_close/Cargo.toml +++ b/lints/insecure_account_close/Cargo.toml @@ -43,3 +43,7 @@ dylint_testing = "2.6" [package.metadata.rust-analyzer] rustc_private = true + +[package.metadata] +anchor_programs = true +non_anchor_programs = true diff --git a/lints/missing_owner_check/Cargo.toml b/lints/missing_owner_check/Cargo.toml index 76d2f20..7dbed79 100644 --- a/lints/missing_owner_check/Cargo.toml +++ b/lints/missing_owner_check/Cargo.toml @@ -48,3 +48,7 @@ dylint_testing = "2.6" [package.metadata.rust-analyzer] rustc_private = true + +[package.metadata] +anchor_programs = true +non_anchor_programs = true diff --git a/lints/missing_signer_check/Cargo.toml b/lints/missing_signer_check/Cargo.toml index de69b6a..567ba6a 100644 --- a/lints/missing_signer_check/Cargo.toml +++ b/lints/missing_signer_check/Cargo.toml @@ -35,3 +35,7 @@ dylint_testing = "2.6" [package.metadata.rust-analyzer] rustc_private = true + +[package.metadata] +anchor_programs = true +non_anchor_programs = true diff --git a/lints/type_cosplay/Cargo.toml b/lints/type_cosplay/Cargo.toml index 2cedcbd..77e6391 100644 --- a/lints/type_cosplay/Cargo.toml +++ b/lints/type_cosplay/Cargo.toml @@ -55,3 +55,7 @@ dylint_testing = "2.6" [package.metadata.rust-analyzer] rustc_private = true + +[package.metadata] +anchor_programs = false +non_anchor_programs = true diff --git a/scripts/update_readmes.sh b/scripts/update_readmes.sh index 0be168a..a38348a 100755 --- a/scripts/update_readmes.sh +++ b/scripts/update_readmes.sh @@ -25,10 +25,31 @@ cat ../README.md | while read X; do if [[ "$X" =~ ^\| ]]; then if [[ -z "$LISTED" ]]; then - echo '| Library | Description |' - echo '| - | - |' - grep -H '^description = "[^"]*"$' */Cargo.toml | - sed 's,^\([^/]*\)/Cargo.toml:description = "\([^"]*\)"$,| [`\1`](lints/\1) | \2 |,' + echo '| Library | Description | Anchor | Non Anchor |' + echo '| - | - | - | - |' + for CARGO_TOML in */Cargo.toml; do + DESC=$( + grep -H '^description = "[^"]*"$' "$CARGO_TOML" | + sed 's,^\([^/]*\)/Cargo.toml:description = "\([^"]*\)"$,| [`\1`](lints/\1) | \2,' + ) + ANCHOR=$( + grep '^anchor_programs = \(true\|false\)$' "$CARGO_TOML" | + sed 's,^anchor_programs = \([a-z]*\)$,\1,' + ) + NON_ANCHOR=$( + grep '^non_anchor_programs = \(true\|false\)$' "$CARGO_TOML" | + sed 's,^non_anchor_programs = \([a-z]*\)$,\1,' + ) + ANCHOR_COLUMN=" " + if [[ "$ANCHOR" == "true" ]]; then + ANCHOR_COLUMN=":heavy_check_mark:" + fi + NON_ANCHOR_COLUMN=" " + if [[ "$NON_ANCHOR" == "true" ]]; then + NON_ANCHOR_COLUMN=":heavy_check_mark:" + fi + echo "$DESC | $ANCHOR_COLUMN | $NON_ANCHOR_COLUMN |" + done LISTED=1 fi continue