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 arbitrary_cpi lint to check for Instruction and CpiContext::new calls #91

Merged
merged 3 commits into from
Mar 14, 2024

Conversation

S3v3ru5
Copy link
Contributor

@S3v3ru5 S3v3ru5 commented Mar 8, 2024

The lint is updated to check for Instruction {...} initialization instead of invoke calls. As a result,

  • The lint is not needed check for both invoke, invoke_signed calls.
  • Instead of traversing from invoke -> Instruction -> program, the lint can directly get Instruction -> program
  • The updated lint does not report if the Instruction used by invoke is returned by a function defined in a dependency.

The updated lint also checks for calls to CpiContext::new and CpiContext::new_with_signer which are common in Anchor programs. The lint reports the call unless the program is the return value of .to_account_info() called on Anchor Program or Interface.

The majority of the updates could be implemented using HIR. However, some of the old functions written in MIR are reused and The lint requires further updates which most probably can only be implemented in MIR. Hence, the updates to lint also rely on MIR.

@S3v3ru5 S3v3ru5 merged commit f9087f8 into signer-anchor Mar 14, 2024
3 checks passed
@S3v3ru5 S3v3ru5 deleted the arb-cpi-anchor branch March 14, 2024 17:07
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