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 missing-signer-check lint to handle anchor programs separately #86

Merged
merged 8 commits into from
Mar 15, 2024

Conversation

S3v3ru5
Copy link
Contributor

@S3v3ru5 S3v3ru5 commented Feb 20, 2024

The PR updates the missing-signer-check lint to print Accounts structs in anchor programs. The lint will highlight accounts that might need to be signers. It uses the type of the account to determine if the account should be reported.

The lint will report accounts of type AccountInfo, UncheckedAccount and SystemProgramAccount. The chances of reported field being a false positive are high. But the number of results is bounded by the number of different #[derive(Accounts)] structs.

Example warning:

warning: Account `drift_signer` might need to be a signer
    --> programs/drift/src/instructions/user.rs:2113:5
     |
2090 | pub struct Withdraw<'info> {
     |            -------- Accounts of this instruction
...
2113 |     pub drift_signer: AccountInfo<'info>,
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: Accounts `drift_signer`, and `instructions` might need to be signers
    --> programs/drift/src/instructions/user.rs:2321:5
     |
2279 | pub struct Swap<'info> {
     |            ---- Accounts of this instruction
...
2321 |     pub drift_signer: AccountInfo<'info>,
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
2325 |     pub instructions: UncheckedAccount<'info>,
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The tests need to be updated: The lint is updated to determine whether the Solana program is an anchor program. And based on that different logic is executed. The test programs are written using Anchor but the results are of the non-anchor logic. Have to discuss and make appropriate changes.

@S3v3ru5 S3v3ru5 marked this pull request as ready for review March 5, 2024 17:27
Base automatically changed from owner-constraints to master March 14, 2024 13:44
@S3v3ru5 S3v3ru5 enabled auto-merge March 14, 2024 16:52
@S3v3ru5 S3v3ru5 disabled auto-merge March 14, 2024 16:59
@S3v3ru5 S3v3ru5 enabled auto-merge March 14, 2024 17:16
@S3v3ru5 S3v3ru5 added this pull request to the merge queue Mar 14, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Mar 14, 2024
@S3v3ru5 S3v3ru5 added this pull request to the merge queue Mar 14, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Mar 14, 2024
@S3v3ru5 S3v3ru5 added this pull request to the merge queue Mar 14, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Mar 14, 2024
@S3v3ru5 S3v3ru5 added this pull request to the merge queue Mar 14, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Mar 14, 2024
@S3v3ru5 S3v3ru5 enabled auto-merge March 14, 2024 18:31
@S3v3ru5 S3v3ru5 added this pull request to the merge queue Mar 14, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Mar 14, 2024
@S3v3ru5 S3v3ru5 added this pull request to the merge queue Mar 15, 2024
Merged via the queue into master with commit 0a26b57 Mar 15, 2024
3 checks passed
@S3v3ru5 S3v3ru5 deleted the signer-anchor branch March 15, 2024 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants