-
Notifications
You must be signed in to change notification settings - Fork 126
Rely on os.Root for checking paths #2752
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
Conversation
@@ -845,13 +855,13 @@ func TestLinksFS_WorkDirValidation(t *testing.T) { | |||
name: "invalid absolute workDir outside repo", | |||
workDir: outsideDir, | |||
expectError: true, | |||
errorMsg: "is outside the repository root", | |||
errorMsg: "path escapes from parent", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it could be kept like this for now.
internal/files/linkedfiles_test.go
Outdated
errorMsg: "escapes the repository root", | ||
errorMsg: "no such file or directory", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the issue solved by this PR.
@@ -845,13 +855,13 @@ func TestLinksFS_WorkDirValidation(t *testing.T) { | |||
name: "invalid absolute workDir outside repo", | |||
workDir: outsideDir, | |||
expectError: true, | |||
errorMsg: "is outside the repository root", | |||
errorMsg: "path escapes from parent", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it could be kept like this for now.
test integrations |
Created or updated PR in integrations repository to test this version. Check elastic/integrations#14614 |
💚 Build Succeeded
History
cc @jsoriano |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fix #2751.
Remove
pathIsInRepositoryRoot
, and rely on implicitos.Root
operations to check if a path is under the repository root.