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
[WFCORE-5869] standalone.bat script does not parse JAVA_OPTS containing '|' symbol properly #5056
Conversation
Core - Full Integration Build 11490 outcome was FAILURE using a merge of 71173c7 Failed tests
|
|
||
rem If characters are already escaped then IS_SANITIZED is set to true and JAVA__OPTS are left as they are | ||
for %%C in (^^^|) do ( | ||
if not "!JAVA_OPTS:%%C=!"=="!JAVA_OPTS!" set IS_SANITIZED=true |
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.
This is done character by character, so only the last occurrence will count to know whether it is sanitized. @lvydra Is this intentional?
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.
Well, as soon as one is scaped it counts as completely sanitized. That should be fine, @lvydra, we are not going to treat scaped and non-scaped characters. If only one is scaped and not the others, the script will fail. Maybe it can be controlled better. I'm approving from my side
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.
Hi @yersan, thanks for the review, yes it is intentional as the main purpose is to avoid escaping already escaped characters and breaking that way script execution, even for the cost of leaving characters unescaped.
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.
However, I can try to improve it to handle those cases more complexly.
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.
Thanks, @lvydra , let's wait for James' input here. I think we are fine with what we have; now it can accept '|' or '^|' but not both at the same time, that could be a corner case and it is unlikely to happen.
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.
I've got no real strong opinion here as I cannot find the documentation as to how this works in batch scripts :) I trust whatever you guys feel is correct.
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.
Thanks, @jamezp , I had no idea we had those kinds of tests. For this one, I found this useful: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/for
@lvydra Could you take a look at whether we can add a test case for this one?. Code works, but a test case will ensure we will not get a regression. Let us know your findings, thanks!
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.
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.
@jamezp Could you also take a look?
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.
The only thing I can think of that would be helpful is to add a test for this in the testsuite/scripts
tests. Something could probably be added here
wildfly-core/testsuite/scripts/src/test/java/org/wildfly/common/test/ServerConfigurator.java
Line 254 in 71173c7
private static void appendConf(final Path containerHome, final String baseName, final String envName) throws IOException { |
|
||
rem If characters are already escaped then IS_SANITIZED is set to true and JAVA__OPTS are left as they are | ||
for %%C in (^^^|) do ( | ||
if not "!JAVA_OPTS:%%C=!"=="!JAVA_OPTS!" set IS_SANITIZED=true |
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.
I've got no real strong opinion here as I cannot find the documentation as to how this works in batch scripts :) I trust whatever you guys feel is correct.
@@ -86,6 +89,28 @@ public static Collection<Object> data() { | |||
return result; | |||
} | |||
|
|||
@Test | |||
public void testBatchScriptJavaOptsToEscape() throws Exception { | |||
Assume.assumeTrue(!TestSuiteEnvironment.isWindows() && Shell.BASH.isSupported()); |
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.
The assume condition needs to be fixed; it should be: Assume.assumeTrue(TestSuiteEnvironment.isWindows())
Although the test should pass on Linux, we don't need to run it there, indeed, looking at the method name, that was not your original intention.
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.
Oh sure, thanks @yersan, I don't know how did it get there :-)
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.
:) thanks, @lvydra
|
||
@Test | ||
public void testBatchScriptJavaOptsEscaped() throws Exception { | ||
Assume.assumeTrue(!TestSuiteEnvironment.isWindows() && Shell.BASH.isSupported()); |
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.
The assume condition needs to be fixed: Assume.assumeTrue(TestSuiteEnvironment.isWindows())
@yersan fixed |
Core - Full Integration Build 11594 outcome was FAILURE using a merge of f4501b7 Failed tests
|
https://issues.redhat.com/browse/WFCORE-5869