Skip to content

Commit

Permalink
Update scripts/update_readmes.sh to parse anchor non anchor fields in…
Browse files Browse the repository at this point in the history
… cargo.toml
  • Loading branch information
Vara Prasad Bandaru committed Mar 6, 2024
1 parent 86dec18 commit a68906b
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
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

0 comments on commit a68906b

Please sign in to comment.