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

Remove the calls to realpath in FileIntegrity checks #22723

Merged
merged 6 commits into from
Dec 23, 2024

Conversation

danielpunkass
Copy link
Contributor

@danielpunkass danielpunkass commented Oct 29, 2024

Description:

If the FileIntegrity check discovers an unexpected symlink in the source tree, it causes Matomo to suggest to the user deleting the target of the symlink, instead of the symlink itself. At best this would be a nuisance, and at worst it could be catastrophic (if the user kept a symlink to files outside of Matomo's directory, for example). Fixes #16551.

Review

… user. Calling realpath on a symlink that was found in the tree, for example, causes Matomo to suggest to the user deleting the target of the symlink. At best this would be a nuisance, and at worst it could be catastrophic (if the user kept a symlink to files outside of Matomo's directory, for example). Fixes matomo-org#16551.
@sgiehl sgiehl requested a review from a team October 30, 2024 10:21
@sgiehl sgiehl added the Needs Review PRs that need a code review label Oct 30, 2024
Copy link
Contributor

github-actions bot commented Nov 7, 2024

This issue is in "needs review" but there has been no activity for 7 days. ping @matomo-org/core-reviewers

@github-actions github-actions bot added the Stale The label used by the Close Stale Issues action label Nov 7, 2024
@caddoo
Copy link
Contributor

caddoo commented Nov 12, 2024

@danielpunkass Thanks a lot for your contribution, really appreciated 🎉

I tested this locally and while it does work and achieve what is expected, we do lose a little user-friendliness with the messaging to our users.

Removing realpath means a relative filename is given which means the rm or rm -rF will only work when they are in their Matomo install directory whereas before they could be anywhere in their filesystem.

Maybe an idea would be to change it to use something like:
htmlspecialchars(realpath(dirname($fileFoundNotExpected)). '/' .basename($fileFoundNotExpected))

This seems to get the symlink location with the full absolute path and the resulting rm command doesn't touch the source file.

@matomo-org/core-reviewers any other opinions here?

@github-actions github-actions bot removed the Stale The label used by the Close Stale Issues action label Nov 13, 2024
Copy link
Contributor

This issue is in "needs review" but there has been no activity for 7 days. ping @matomo-org/core-reviewers

@github-actions github-actions bot added the Stale The label used by the Close Stale Issues action label Nov 20, 2024
Copy link
Contributor

@caddoo caddoo left a comment

Choose a reason for hiding this comment

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

@danielpunkass I don't have push access to your fork, but i've made some suggested changes, can you add them as commits and we can see how the tests react 😄

core/FileIntegrity.php Outdated Show resolved Hide resolved
core/FileIntegrity.php Outdated Show resolved Hide resolved
Copy link
Contributor Author

@danielpunkass danielpunkass left a comment

Choose a reason for hiding this comment

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

Incorporate changes suggested by @caddoo

@danielpunkass
Copy link
Contributor Author

I will figure out how to quiet the style errors.

@caddoo caddoo requested a review from a team December 19, 2024 23:49
@caddoo caddoo merged commit e1bdd44 into matomo-org:5.x-dev Dec 23, 2024
23 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review Stale The label used by the Close Stale Issues action
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File integrity gives bad advice on symlinks
3 participants