Skip to content

Commit 40d587b

Browse files
author
Vara Prasad Bandaru
committed
Add sysvar_get lint
1 parent 6af3613 commit 40d587b

File tree

16 files changed

+4035
-0
lines changed

16 files changed

+4035
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ The current lints are:
1515
| [`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) |
1616
| [`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) |
1717
| [`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) |
18+
| [`sysvar_get`](lints/sysvar_get) | Reports uses of `Sysvar::from_account_info` instead of `Sysvar::get` |
1819
| [`type_cosplay`](lints/type_cosplay) | lint for [3-type-cosplay](https://github.com/coral-xyz/sealevel-attacks/tree/master/programs/3-type-cosplay) |
1920

2021
## Usage

crate/src/paths.rs

+10
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,13 @@ pub const SOLANA_PROGRAM_CREATE_PROGRAM_ADDRESS: [&str; 4] = [
4444
];
4545

4646
pub const SPL_TOKEN_INSTRUCTION: [&str; 2] = ["spl_token", "instruction"];
47+
48+
pub const SYSVAR_FROM_ACCOUNT_INFO: [&str; 4] =
49+
["solana_program", "sysvar", "Sysvar", "from_account_info"];
50+
pub const SYSVAR_CLOCK: [&str; 3] = ["solana_program", "clock", "Clock"];
51+
pub const SYSVAR_EPOCH_REWARDS: [&str; 3] = ["solana_program", "epoch_rewards", "EpochRewards"];
52+
pub const SYSVAR_EPOCH_SCHEDULE: [&str; 3] = ["solana_program", "epoch_schedule", "EpochSchedule"];
53+
pub const SYSVAR_FEES: [&str; 3] = ["solana_program", "fees", "Fees"];
54+
pub const SYSVAR_LAST_RESTART_SLOT: [&str; 3] =
55+
["solana_program", "last_restart_slot", "LastRestartSlot"];
56+
pub const SYSVAR_RENT: [&str; 3] = ["solana_program", "rent", "Rent"];

lints/sysvar_get/.cargo/config.toml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[build]
2+
target-dir = "../../target"
3+
4+
[target.aarch64-apple-darwin]
5+
linker = "dylint-link"
6+
7+
[target.x86_64-apple-darwin]
8+
linker = "dylint-link"
9+
10+
[target.x86_64-unknown-linux-gnu]
11+
linker = "dylint-link"
12+
13+
[target.x86_64-pc-windows-msvc]
14+
linker = "dylint-link"

0 commit comments

Comments
 (0)