Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(remappings): check if remapping to add starts with existing remapping name #9246

Merged
merged 3 commits into from
Nov 5, 2024

Conversation

grandizzy
Copy link
Collaborator

@grandizzy grandizzy commented Nov 1, 2024

Motivation

Closes #9146

check if name of new remapping to be added starts with existing remapping name instead the other way around
e.g. if @utils remapping is already added in proj root then @utils/libraries from lib should not be added

Solution

Copy link
Member

@zerosnacks zerosnacks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, confirming this resolves #9146

$ forge test -vvvv --decode-internal
[⠊] Compiling...
[⠒] Compiling 26 files with Solc 0.8.28
[⠑] Solc 0.8.28 finished in 477.00ms
Compiler run successful!

Ran 1 test for test/ERC20Test.sol:CounterTest
[PASS] testTotalSupply() (gas: 10770)
Traces:
  [10770] CounterTest::testTotalSupply()
    ├─ [2261] ERC20::totalSupply() [staticcall]
    │   └─ ← [Return] 500000000 [5e8]
    ├─ [3201] StdAssertions::assertGt(500000000 [5e8], 0, "No token minted !")
    │   ├─ [0] VM::assertGt(500000000 [5e8], 0, "No token minted !") [staticcall]
    │   │   └─ ← [Return] 
    │   └─ ← 
    └─ ← [Stop] 

Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.77ms (671.20µs CPU time)

Ran 1 test suite in 52.59ms (1.77ms CPU time): 1 tests passed, 0 failed, 0 skipped (1 total tests)

with remappings:

@utils/=src/
forge-std/=lib/forge-std/src/
interesting-project/=lib/interesting-project/src/

as opposed to

@utils/=src/
@utils/libraries/=lib/interesting-project/src/
forge-std/=lib/forge-std/src/
interesting-project/=lib/interesting-project/src/

@grandizzy grandizzy merged commit 455ba9b into foundry-rs:master Nov 5, 2024
21 checks passed
@grandizzy grandizzy deleted the issue-9146 branch November 5, 2024 03:06
leovct pushed a commit to leovct/foundry that referenced this pull request Nov 6, 2024
…ping name (foundry-rs#9246)

* fix(remappings): check if remapping to add starts with existing remapping name

* Push remapping fn doesn't have to be pub, proper test remappings
grandizzy added a commit to grandizzy/foundry that referenced this pull request Nov 6, 2024
grandizzy added a commit that referenced this pull request Nov 6, 2024
@frontier159
Copy link
Contributor

frontier159 commented Nov 20, 2024

@grandizzy FYI this required me to add extra remappings in:

prev:

...
test/=src/test/
...

This require a couple of extra explicit paths:

...
test/=src/test/
test/mocks=src/test/mocks
test/lib=src/test/lib
...

Was that intended?

Example repo: https://github.com/OlympusDAO/olympus-v3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

security: automatic remappings can be dangerous
4 participants