Skip to content
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

[fix] Quote command line segment using shlex #3578

Merged
merged 1 commit into from
Jan 21, 2022

Conversation

steakhal
Copy link
Contributor

Simply joining command segments is not enough for acquiring a valid
command. One should escape the necessary characters prior to that.
Escaping can be done manually, but using shlex is the preferred way
of doing so.

This patch might not fix all of the issues.

There were multiple places where this was not done adequately:

  • at calling intercept-build
  • at parsing the compile_commands.json's arguments field
  • at extending the command with the referred response file's content
  • at extending the command without response files
  • at the libtest/codechecker.py/all_command() helper function
  • at a bunch of other places where a command is being logged - but
    for brevity, I've just fixed the two most important places of this
    • analyzer_base.py/analyze()
    • analysis_manager.py/handle_reproducer()

@csordasmarton csordasmarton added analyzer 📈 Related to the analyze commands (analysis driver) bugfix 🔨 test ☑️ Adding or refactoring tests labels Jan 13, 2022
@csordasmarton csordasmarton added this to the release 6.19.0 milestone Jan 13, 2022
Copy link
Contributor

@csordasmarton csordasmarton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some tiny comments, otherwise LGTM!

analyzer/tests/libtest/codechecker.py Outdated Show resolved Hide resolved
analyzer/tests/libtest/codechecker.py Outdated Show resolved Hide resolved
@steakhal steakhal force-pushed the shlex-quote-command-segments branch from e1893f3 to 1a0782a Compare January 13, 2022 15:08
@steakhal steakhal force-pushed the shlex-quote-command-segments branch 2 times, most recently from 6f9bb89 to 134dd2b Compare January 15, 2022 09:54
Simply joining command segments is not enough for acquiring a valid
command. One should escape the necessary characters prior to that.
Escaping can be done manually, but using shlex is the preferred way
of doing so.

This patch might not fix all of the issues.

There were multiple places where this was not done adequately:
 * at calling `intercept-build`
 * at parsing the `compile_commands.json`'s `arguments` field
 * at extending the command with the referred response file's content
 * at extending the command without response files
 * at the `libtest/codechecker.py/all_command()` helper function
 * at a bunch of other places where a command is being logged - but
   for brevity, I've just fixed the two most important places of this
   - `analyzer_base.py/analyze()`
   - `analysis_manager.py/handle_reproducer()`
@steakhal steakhal force-pushed the shlex-quote-command-segments branch from 134dd2b to 7bd706c Compare January 15, 2022 12:23
Copy link
Contributor

@csordasmarton csordasmarton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@steakhal
Copy link
Contributor Author

Ping.

@bruntib bruntib merged commit 9287db8 into Ericsson:master Jan 21, 2022
@steakhal steakhal deleted the shlex-quote-command-segments branch January 21, 2022 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer 📈 Related to the analyze commands (analysis driver) bugfix 🔨 test ☑️ Adding or refactoring tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants