feat: add detector for complex struct getters with omitted members#2971
Open
ep0chzer0 wants to merge 1 commit intocrytic:masterfrom
Open
feat: add detector for complex struct getters with omitted members#2971ep0chzer0 wants to merge 1 commit intocrytic:masterfrom
ep0chzer0 wants to merge 1 commit intocrytic:masterfrom
Conversation
Add a new informational detector that identifies public state variables containing structs where the automatic getter omits array and mapping members. Solidity's generated getters skip these types, which may cause confusion about data accessibility. The detector: - Finds public state variables with struct types - Identifies array and mapping members that are omitted from the getter - Recursively checks nested structs for deeply omitted members - Handles recursive struct types safely - Lists all omitted members with their types Closes crytic#2779
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new informational detector (
complex-struct-getter) that identifies public state variables containing structs where the automatic getter omits array and mapping members.Closes #2779
Problem
Solidity's auto-generated getters for public struct variables silently skip array and mapping members. This can cause confusion about data accessibility and lead to integration issues:
Detection Logic
Test Coverage
7 contracts covering:
DirectArrayMapping— struct with both arrays and mappings (flagged)NestedStruct— nested struct containing an array (flagged)MappingOnly— struct with only a mapping (flagged)SimpleStruct— struct with only elementary types (NOT flagged)PrivateComplex— complex struct but internal visibility (NOT flagged)NoStruct— plain state variables, no structs (NOT flagged)NestedSimple— nested struct with only elementary types (NOT flagged)Files Changed
slither/detectors/variables/complex_struct_getter.py— New detectorslither/detectors/all_detectors.py— Register detectortests/e2e/detectors/test_detectors.py— Add test entrytests/e2e/detectors/test_data/complex-struct-getter/— Test contract and artifacttests/e2e/detectors/snapshots/— Expected output snapshotAll 382 detector tests pass (381 existing + 1 new).