reporting: fix incorrect converting of list based commands#919
Conversation
Thank you for contributing to the Leapp project!Please note that every PR needs to comply with the Leapp Guidelines and must pass all tests in order to be mergeable.
To launch regression testing public members of oamg organization can leave the following comment:
Please open ticket in case you experience technical problem with the CI. (RH internal only) Note: In case there are problems with tests not being triggered automatically on new PR/commit or pending for a long time, please consider rerunning the CI by commenting leapp-ci build (might require several comments). If the problem persists, contact leapp-infra. |
5706e6f to
4149eeb
Compare
The reporting module handled conversion between shell command representations for the text and json reports incorrectly. The list of strings representation was converted without preserving the argument separation correctly which results in malformed commands in the text report. This patch utilizes the built-in shlex Python library for the conversion which preserves the argument separation by wrapping arguments in quotes when necessary. Jira: RHEL-156521
4149eeb to
e8ac23d
Compare
|
Added tests, and bumped framework version in spec file. I'd like to point out that this implementation has a flaw that stems from the implementation of the shlex.quote. It quotes the strings in A possible solution to this would be to reimplement shlex.quote in a way that would use |
|
Added a custom implementation of the quoting that simply handles the cases where Added this so that we can chose between two concrete implementations, which will hopefully make it easier. Note: It is also worth going through the influenced cases in the leapp-repository PR to have better idea of what we really use. |
|
We should also decide whether to expose the current |
d43db15 to
2e8f17b
Compare
|
/packit copr-build |
|
nice solution with a test coverage. I tried to find a broken example but I have not found any in the end. |
The reporting module handled conversion between shell command representations for the text and json reports incorrectly. The list of strings representation was converted without preserving the argument separation correctly which results in malformed commands in the text report.
This patch utilizes the built-in shlex Python library for the conversion which preserves the argument separation by wrapping arguments in quotes when necessary.
See the Jira for a lengthy description with examples.
Jira: RHEL-156521
NOTE: The shlex.join is available from Python 3.8+ as the failing tests show. However, the shlex.quote is available from Python 3.3 and the join function uses quote function anyway so we can just replicate the implementation of shlex.join in here to achieve the same.