Rely on os.Root for checking paths#2752
Merged
jsoriano merged 3 commits intoelastic:mainfrom Jul 22, 2025
Merged
Conversation
jsoriano
commented
Jul 21, 2025
| workDir: outsideDir, | ||
| expectError: true, | ||
| errorMsg: "is outside the repository root", | ||
| errorMsg: "path escapes from parent", |
Member
Author
There was a problem hiding this comment.
Error from the stdlib is directly returned now, but we cannot check for it to convert it as it is not public (https://github.com/golang/go/blob/e5502e0959bb54ec70ca500e8d2b6f5ac5efbc53/src/os/file.go#L421).
We could check the error message and replace it, but not sure if it is worth it.
Contributor
There was a problem hiding this comment.
I guess it could be kept like this for now.
jsoriano
commented
Jul 21, 2025
internal/files/linkedfiles_test.go
Outdated
Comment on lines
+788
to
+793
| errorMsg: "escapes the repository root", | ||
| errorMsg: "no such file or directory", |
Member
Author
There was a problem hiding this comment.
This is the issue solved by this PR.
mrodm
reviewed
Jul 21, 2025
| workDir: outsideDir, | ||
| expectError: true, | ||
| errorMsg: "is outside the repository root", | ||
| errorMsg: "path escapes from parent", |
Contributor
There was a problem hiding this comment.
I guess it could be kept like this for now.
Member
Author
|
test integrations |
|
Created or updated PR in integrations repository to test this version. Check elastic/integrations#14614 |
Collaborator
💚 Build Succeeded
History
cc @jsoriano |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #2751.
Remove
pathIsInRepositoryRoot, and rely on implicitos.Rootoperations to check if a path is under the repository root.