Skip to content

Fixed commands with paths passed as String to process execution #155

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

Merged
merged 1 commit into from
Aug 6, 2019

Conversation

vodorok
Copy link
Collaborator

@vodorok vodorok commented Apr 25, 2019

Depends on #145.

Fixed commands with paths passed as String to process execution

Modified every ShellExecutorHelper method signature. Now contains an
optional substitution map for adding Paths as File for proper escaping.
Extended test with test case that test Change directory into a directory
with spaces.

Added a test case that tests getting the checkers from various path
sequences. Look in CodeCheckEnvironmentCheckerTest.java for more info.
For this purpose, a CodeChecker stub was created that return some
checkers. This Resides in the Unit test's resources folder. Current
functionality only support getting the checkers.

Resolves #147

@vodorok vodorok requested a review from gyorb April 25, 2019 09:42
@vodorok vodorok self-assigned this Apr 25, 2019
@vodorok vodorok added this to the v0.0.7 milestone Apr 25, 2019
@vodorok vodorok added the bugfix label Apr 25, 2019
" -j "+ getConfigValue(ConfigTypes.ANAL_THREADS) + " -n javarunner" +
" -o "+ getConfigValue(ConfigTypes.CHECKER_WORKSPACE)+"/results/ " + buildLog;
public String createAnalyzeCommmand(String buildLog) {
return "'" + Utils.esc(codeCheckerCommand) + "'" +
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't be easier to handle the command line options as a list of strings until the CommandLine type construction in the buildScriptCommandLine

There is a CommandLineParser which could be useful too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks @gyorb for the suggestion. This section was revised, and modified according to this https://commons.apache.org/proper/commons-exec/tutorial.html . The cli parser you mentioned was being used already but extended a bit.

* {@link https://unix.stackexchange.com/a/357932}
*/
public static String esc(String path) {
return path.replace("'", "'\\''");
Copy link
Contributor

Choose a reason for hiding this comment

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

There are some string escaping methods could we use them? Should we escape other characters too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This section was replaced with the path substitution map.

@vodorok vodorok force-pushed the pathSpecChar_patch branch from d42645f to 420316a Compare April 26, 2019 12:41
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Apr 26, 2019
@Ericsson Ericsson deleted a comment Jun 29, 2019
@Ericsson Ericsson deleted a comment Jun 29, 2019
@Ericsson Ericsson deleted a comment Jun 29, 2019
@Ericsson Ericsson deleted a comment Jun 29, 2019
@Ericsson Ericsson deleted a comment Jun 29, 2019
@Ericsson Ericsson deleted a comment Jun 29, 2019
@Ericsson Ericsson deleted a comment Jun 29, 2019
@vodorok vodorok force-pushed the pathSpecChar_patch branch from d768ace to 09a0d9f Compare July 1, 2019 10:39
@Ericsson Ericsson deleted a comment Jul 1, 2019
@vodorok vodorok force-pushed the pathSpecChar_patch branch from 09a0d9f to 3d15467 Compare July 1, 2019 11:19
@Ericsson Ericsson deleted a comment Jul 1, 2019
@Ericsson Ericsson deleted a comment Jul 1, 2019
@Ericsson Ericsson deleted a comment Jul 1, 2019
@Ericsson Ericsson deleted a comment Jul 1, 2019
@@ -1,34 +1,42 @@
package org.codechecker.eclipse.plugin.runtime;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A large part of modification is related to this class. Paths in Shell command scripts got misinterpreted before. This was corrected with the usage of String - File Command substitution maps.

@@ -3,15 +3,20 @@
import com.google.common.base.Optional;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The other large part is in this class that actually makes the calls. Method signatures were changed to be able to use the command substitution maps.

@@ -6,6 +6,17 @@ CodeChecker Stub used to emulate some CodeChecker commands for the tests.
import sys
import argparse

"""
Copy link
Collaborator Author

@vodorok vodorok Jul 1, 2019

Choose a reason for hiding this comment

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

The dummy Codechecker got a new functionality. Now it can return some checkers.

@@ -0,0 +1,97 @@
package org.codechecker.eclipse.plugin.runtime;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tests that the checkers are correctly returned.

@@ -1,16 +1,18 @@
package org.codechecker.eclipse.plugin.runtime;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Modified because the method signatures were changed.

@vodorok vodorok removed the WIP label Jul 1, 2019
Copy link
Contributor

@gyorb gyorb left a comment

Choose a reason for hiding this comment

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

One comment only, otherwise LGTM.

Modified every  ShellExecutorHelper method signature. Now contains an
optional substitution map for adding Paths as File for proper escaping.
Extended test with test case that test Change directory into a directory
with spaces.

Added a test case that tests getting the checkers from various path
sequences. Look in CodeCheckEnvironmentCheckerTest.java for more info.
For this purpose, a CodeChecker stub was created that return some
checkers. This Resides in the Unit test's resources folder. Current
functionality only support getting the checkers.
@vodorok vodorok force-pushed the pathSpecChar_patch branch from 3d15467 to 5861f7e Compare July 25, 2019 09:31
@Ericsson Ericsson deleted a comment Jul 25, 2019
@Ericsson Ericsson deleted a comment Jul 25, 2019
@Ericsson Ericsson deleted a comment Jul 25, 2019
@Ericsson Ericsson deleted a comment from vodorok Jul 25, 2019
Copy link
Member

@dkrupp dkrupp left a comment

Choose a reason for hiding this comment

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

LGTM

@dkrupp dkrupp merged commit bfac6b0 into Ericsson:master Aug 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quote paths in analyze command
3 participants