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)whenexprholding means the caller is authorized,Some(false)when it means the caller is not authorized,Nonewhenexpris not an access check. An access check readsmsg.sender/tx.origin(directly, throughaliasesor through a helper) and state (directly or through a helper).- dominating_
stmts ๐ - Collects into
outthe 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
exprreadsmsg.sender/tx.origin, one ofaliases, 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
ffor every access check that dominatesbody(runs unconditionally before the_placeholder) until it breaks.seenguards the recursion into called functions. - function_
reads_ sender - Whether the body of
func_idreadsmsg.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_idand its modifiers (up to_) depend on. - has_
access_ guard - Whether
func_idchecks the caller before its_placeholder (anywhere for functions): a guardingif, arequire/asserton 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_idthat resolve to functions, followed byfunc_iditself. - update_
sender_ ๐aliases - Applies
stmtto the set of locals holding amsg.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.