Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update lints table to contain Anchor and Non-Anchor columns #90

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions lints/arbitrary_cpi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ dylint_testing = "2.6"

[package.metadata.rust-analyzer]
rustc_private = true

[package.metadata]
anchor_programs = false
non_anchor_programs = true
4 changes: 4 additions & 0 deletions lints/bump_seed_canonicalization/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ dylint_testing = "2.6"

[package.metadata.rust-analyzer]
rustc_private = true

[package.metadata]
anchor_programs = false
non_anchor_programs = true
4 changes: 4 additions & 0 deletions lints/insecure_account_close/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ dylint_testing = "2.6"

[package.metadata.rust-analyzer]
rustc_private = true

[package.metadata]
anchor_programs = true
non_anchor_programs = true
4 changes: 4 additions & 0 deletions lints/missing_owner_check/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ dylint_testing = "2.6"

[package.metadata.rust-analyzer]
rustc_private = true

[package.metadata]
anchor_programs = true
non_anchor_programs = true
4 changes: 4 additions & 0 deletions lints/missing_signer_check/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ dylint_testing = "2.6"

[package.metadata.rust-analyzer]
rustc_private = true

[package.metadata]
anchor_programs = true
non_anchor_programs = true
4 changes: 4 additions & 0 deletions lints/type_cosplay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ dylint_testing = "2.6"

[package.metadata.rust-analyzer]
rustc_private = true

[package.metadata]
anchor_programs = false
non_anchor_programs = true
29 changes: 25 additions & 4 deletions scripts/update_readmes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down