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 filename collusion #1582

Merged
merged 2 commits into from
Aug 20, 2024
Merged

Fix filename collusion #1582

merged 2 commits into from
Aug 20, 2024

Conversation

kuzdogan
Copy link
Member

@kuzdogan kuzdogan commented Aug 20, 2024

Found in the failin CI chain test (6119), where it was unexpectedly fetching files from IPFS when the files are already provided.

Turns out when there are files with the same name, the files get overwritten by the readFilesRecursively function. Fixed by using a relative path as the key in the files object.

Also adds a log line to debug easier missing files when checking contracts

…e name

Found in the [failin CI chain test (6119)](https://app.circleci.com/pipelines/github/ethereum/sourcify/6708/workflows/691eabb9-fba5-4a94-a762-a9344bc32471/jobs/40656), where it was unexpectedly fetching files from IPFS when the files are already provided.

Turns out when there are files with the same name, the files get overwritten by the `readFilesRecursively` function. Fixed by using a relative path as the key in the `files` object.

Also adds a log line to debug easier missing files when checking contracts
Copy link
Member

@marcocastignoli marcocastignoli left a comment

Choose a reason for hiding this comment

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

Is it expected that once baseDirectory is set in the first call (baseDirectory = baseDirectory || directoryPath) then it never changes?

It's not clear why isn't enough to use filePath instead of file in files[file] = fs.readFileSync(filePath).toString();

@kuzdogan
Copy link
Member Author

Yes baseDirectory is only passed in recursive calls.

The reason I used a relativePath was to make it nicer, as filePath is the full absolute path. That could be more failproof actually.

@kuzdogan kuzdogan merged commit 9a0f427 into staging Aug 20, 2024
3 of 4 checks passed
@kuzdogan kuzdogan deleted the fix-filename-collusion branch September 9, 2024 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: COMPLETED
Development

Successfully merging this pull request may close these issues.

2 participants