Show warning if using msg.sender or tx.origin in script without CLI flags being set
Component
Forge
Describe the feature you would like
Issue created after this discussion with @mds1 in the TG group: https://t.me/foundry_support/32128
If msg.sender and/or tx.origin are the defaults AND we find the CALLER or ORIGIN opcodes in the script's method being executed THEN log a warning and require the developer to confirm they want the script to run anyway.
If the sender and/or origin are not specified in the CLI but are used in the script, unintended addresses may be passed to other contracts resulting in unwanted outcomes e.g. a Uniswap output going to the wrong address.
In the warning they should instead be advised to use an address that they know e.g. the same address they are broadcasting with.
Additional context
No response
Ran into this before myself, in favor of adding this!
@devanoneth there's a check added with https://github.com/foundry-rs/foundry/pull/7141 https://github.com/foundry-rs/foundry/blob/57bb12e022fb9ea46a4a7ca8647eb016e8d43ca3/crates/script/src/broadcast.rs#L219-L223
Could you please check if the scenarios (tx.origin) you're using are covered? thank you!
@klkvr I think this one is already implemented, maybe missing for tx.origin, can you pls chime in? thanks!
already fixed in nightly