mviereck / x11docker

Run GUI applications and desktops in docker and podman containers. Focus on security.
MIT License
5.5k stars 370 forks source link

Fix discrepancies in parser scripts, bad newlines in cmdrc #525

Closed echuber2 closed 3 months ago

echuber2 commented 4 months ago

There were discrepancies between the jq and python versions of the injected parser script for the container info. In particular, the jq version was behaving badly and injecting newlines into the parsed result. Further, the generated cmdrc was splitting some messages with newlines, causing erroneous commands.

I posted an old/new comparison with output here (note the issue with test 3 especially): https://github.com/echuber2/x11docker-parser-test

Fixes https://github.com/mviereck/x11docker/issues/485 Fixes https://github.com/mviereck/x11docker/issues/493 Fixes https://github.com/mviereck/x11docker/issues/504

(I hope others can test and confirm the fixed issues. There may have been additional issues related to this. Test at your own risk. I can't guarantee this won't remove files unexpectedly based on the parsed results.)

The issues with parsing here make me nervous for safety of using the scripts, especially in relation to the cleanup command that removes files and directories. I hope I haven't made things any worse with these changes.

Since the container runtimes have a built-in parser (using --format, see the Docker docs for example), maybe it would be better to remove these parsers entirely and just let the runtime fetch what you need. Or, make one of either jq or python a hard requirement, to at least ensure consistency or simplify testing. I suppose that jq is smaller than python to keep as a system requirement, but the python version might be easier to debug and maintain.

echuber2 commented 4 months ago

Note that in the old version, Pythonbin was being set to jq by preference, which is kind of confusing. The new Jqbin variable tries to make that explicit.

mviereck commented 3 months ago

Thank you very much!

I admit that I did not do a deep check of your code, just have read it and it looked well.