Skip to main content

Module access_control

Module access_control 

Source
Expand description

Access-control guard detection: whether a function dominates its body with a check comparing the caller against contract state, and which state that check depends on.

Enumsยง

Guard ๐Ÿ”’
An access check among the dominating statements of a function body.

Functionsยง

access_check_polarity
Some(true) when expr holding means the caller is authorized, Some(false) when it means the caller is not authorized, None when expr is not an access check. An access check reads msg.sender/tx.origin (directly, through aliases or through a helper) and state (directly or through a helper).
dominating_stmts ๐Ÿ”’
Collects into out the statements that run unconditionally before the _ placeholder (all of them for functions), descending into blocks and loops. Breaks when the placeholder is reached.
expr_reads_sender
Whether expr reads msg.sender/tx.origin, one of aliases, or calls a user function that reads the sender.
expr_reads_state ๐Ÿ”’
expr_state_vars
State variables read by expr, following calls into user functions.
for_each_guard ๐Ÿ”’
Calls f for every access check that dominates body (runs unconditionally before the _ placeholder) until it breaks. seen guards the recursion into called functions.
function_reads_sender
Whether the body of func_id reads msg.sender/tx.origin, following calls.
function_state_vars
State variables read by the body of func_id, following calls into user functions.
guard_vars
State variables the access checks of func_id and its modifiers (up to _) depend on.
has_access_guard
Whether func_id checks the caller before its _ placeholder (anywhere for functions): a guarding if, a require/assert on an access check, or a call into a function that does. Bodyless declarations (interface functions, virtual modifiers) fall back to a name heuristic.
is_protected
True when the function or one of its modifiers contains a dominating access check.
looks_like_access_control
A function whose name marks it as an access check (auth, onlyOwner, _checkRole, โ€ฆ) and that returns nothing, so calling it for its effect is meaningful.
modifiers_and_self
The modifiers of func_id that resolve to functions, followed by func_id itself.
update_sender_aliases ๐Ÿ”’
Applies stmt to the set of locals holding a msg.sender-derived value: a local initialized or assigned from a value that reads the sender becomes an alias, and one reassigned from anything else stops being one.