-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
filesync: fix handling non-ascii in file paths #3946
Conversation
Signed-off-by: Justin Chadwell <me@jedevc.com> (cherry picked from commit f9f2a00)
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
A couple funky edge cases I'm a bit worried about:
It's a bit messy, but I think this is probably the way to go 😢 We can fully encode/decode on both sides, so avoids issue 1, and since the old property is still as before, we avoid issue 2. There could also be a very hacky way to do this with a new capability? Though I'm less of a fan of that, since it would involve inspecting pathnames to check if they have unicode characters on the client side. |
What case do you think is problematic? https://go.dev/play/p/TQgcNwLizWp
Is there a practical example for this? If there is, then for this, we don't need a full set of new fields. Just one field saying |
https://go.dev/play/p/o2VQ9OtsJo4: fmt.Println(decode(encode("foo?abc=aa&def=bb%2F")))
// foo?abc=aa&def=bb/ <nil> If the original path contains these escape strings, we reconstruct an incorrect path on the client.
Low risk here, but again becomes an issue with the above as well. Assuming two files on the client: If the buildkit server has this patch, doing
Previously though, this behavior would have just errored in buildkit - so maybe the change doesn't matter hugely? |
The cases that previously errored do not matter. But I guess if someone has an actual file |
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Added a commit to detect old versions with raw values and not try to decode in that case. |
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
Not related but I don't think I've ever seen this test fail: https://github.com/moby/buildkit/actions/runs/5472440199/jobs/9964675293?pr=3946#step:7:2870
=== Failed
=== FAIL: worker/runc TestRuncWorkerExec (0.85s)
common.go:77: Stdout: hello
common.go:78: Stderr:
common.go:114: Stdout:
common.go:115: Stderr:
common.go:116:
Error Trace: /src/worker/tests/common.go:116
Error: Received unexpected error:
exit code: 1
github.com/moby/buildkit/util/stack.Enable
/src/util/stack/stack.go:77
github.com/moby/buildkit/executor/runcexecutor.exitError
/src/executor/runcexecutor/executor.go:372
github.com/moby/buildkit/executor/runcexecutor.(*runcExecutor).Run
/src/executor/runcexecutor/executor.go:336
github.com/moby/buildkit/worker/tests.TestWorkerExec.func2
/src/worker/tests/common.go:87
golang.org/x/sync/errgroup.(*Group).Go.func1
/src/vendor/golang.org/x/sync/errgroup/errgroup.go:75
runtime.goexit
/usr/local/go/src/runtime/asm_amd64.s:1598
container gt4ph8x3w9ki0dxvcvq81xnda has exited with error
github.com/moby/buildkit/executor/runcexecutor.(*runcExecutor).Exec
/src/executor/runcexecutor/executor.go:407
github.com/moby/buildkit/worker/tests.TestWorkerExec
/src/worker/tests/common.go:107
github.com/moby/buildkit/worker/runc.TestRuncWorkerExec
/src/worker/runc/runc_test.go:218
testing.tRunner
/usr/local/go/src/testing/testing.go:1576
runtime.goexit
/usr/local/go/src/runtime/asm_amd64.s:1598
Test: TestRuncWorkerExec
Wonder if this is not related to the runner the test runs on.
var output strings.Builder | ||
for _, runeVal := range input { | ||
// Only encode non-ASCII characters. | ||
if runeVal > unicode.MaxASCII { |
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.
if runeVal > unicode.MaxASCII || runeVal == '%' {
would fix this case I think #3946 (comment).
fixes #3927
Another option would be to create a second set of keys that use encoded values, but I think this should be safe enough and maintain backward compatibility.