crytic / amarna

Amarna is a static-analyzer and linter for the Cairo programming language.
https://blog.trailofbits.com/2022/04/20/amarna-static-analysis-for-cairo-programs/
GNU Affero General Public License v3.0
149 stars 7 forks source link

Don't flag constructor as never called #9

Closed milancermak closed 2 years ago

milancermak commented 2 years ago

I've enabled Amarna on one of my Cairo repos. It flagged an issue that @constructor is never called (even though the repo is public I don't think I can link directly to the static analysis issue so here's a screenshot):

Screenshot 2022-04-21 at 10 25 16

I would say this rule should be disabled for @constructors.

milancermak commented 2 years ago

Amarna will actually flag @view and @external functions as unused as well.

fcasal commented 2 years ago

Hi @milancermak, thanks for reporting this. I've fixed the @constructor false positive in https://github.com/crytic/amarna/commit/42b5ddddbdb45847d40d310331a4c7dfa2bad1b2. Regarding the view and external functions, running Amarna on your repo only shows Ownable_get_owner and Ownable_transfer_ownership, and neither of them are @view or @external. Do you have another codebase where this happens?

milancermak commented 2 years ago

Thanks for fixing the @constructor.

I added Amarna to another repo and thought I had a false positive for @external there, but looking it now, it was also a constructor. I got my line numbers wrong.

fcasal commented 2 years ago

Thanks for looking into it!