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

[WFCORE-5869] standalone.bat script does not parse JAVA_OPTS containing '|' symbol properly #5056

Merged
merged 2 commits into from May 19, 2022

Conversation

lvydra
Copy link
Contributor

@lvydra lvydra commented Apr 19, 2022

@github-actions github-actions bot added the deps-ok Dependencies have been checked, and there are no significant changes label Apr 19, 2022
@wildfly-ci
Copy link

Core - Full Integration Build 11490 outcome was FAILURE using a merge of 71173c7
Summary: Tests failed: 1 (1 new), passed: 7224, ignored: 140 Build time: 03:42:53

Failed tests

org.jboss.as.test.integration.messaging.jms.external.prefix.ExternalJMSDestinationDefinitionMessagingDeploymentTestCase.testSendMessage: java.io.IOException: java.util.concurrent.ExecutionException: java.io.IOException: HTTP Status 500 Response: <html><head><title>ERROR</title><style>
body {
    font-family: "Lucida Grande", "Lucida Sans Unicode", "Trebuchet MS", Helvetica, Arial, Verdana, sans-serif;
    margin: 5px;
}

.header {
    background-image: linear-gradient(bottom, rgb(153,151,153) 8%, rgb(199,199,199) 54%);
    background-image: -o-linear-gradient(bottom, rgb(153,151,153) 8%, rgb(199,199,199) 54%);
    background-image: -moz-linear-gradient(bottom, rgb(153,151,153) 8%, rgb(199,199,199) 54%);
    background-image: -webkit-linear-gradient(bottom, rgb(153,151,153) 8%, rgb(199,199,199) 54%);
    background-image: -ms-linear-gradient(bottom, rgb(153,151,153) 8%, rgb(199,199,199) 54%);
    
    background-image: -webkit-gradient(
        linear,
        left bottom,
        left top,
        color-stop(0.08, rgb(153,151,153)),
        color-stop(0.54, rgb(199,199,199))
    );
    color: black;
    padding: 2px;
    font-weight: normal;
    border: solid 1px;
    font-size: 170%;
    text-align: left;
    vertical-align: middle; 
    height: 32px; 
    margin-bottom: 10px;
}
.error-div {
    display: inline-block;
    width: 32px;
    height: 32px;
    background: url('data:image/png;base64,iVBORw0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A6IE4GuA34EQFtoBUQuwGm7kbwb+eaEEXmuV5dAAAAJXRFWHRjcmVhdGUtZGF0ZQAyMDA5LTExLTEwVDE5OjM4OjI0LTA3OjAwdDKp4gAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxMC0wMi0yMFQyMzoyNjoyNC0wNzowMC7DUNYAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTAtMDEtMTFUMDg6NTc6MzUtMDc6MDCruapPAAAAMnRFWHRMaWNlbnNlAGh0dHA6Ly9lbi53aWtpcGVkaWEub3JnL3dpa2kvUHVibGljX2RvbWFpbj/96s8AAAAldEVYdG1vZGlmeS1kYXRlADIwMDktMTEtMTBUMTk6Mzg6MjQtMDc6MDArg9/WAAAAGXRFWHRTb3VyY2UAVGFuZ28gSWNvbiBMaWJyYXJ5VM/tggAAADp0RVh0U291cmNlX1VSTABodHRwOi8vdGFuZ28uZnJlZWRlc2t0b3Aub3JnL1RhbmdvX0ljb25fTGlicmFyebzIrdYAAAAASUVORK5CYII=') left center no-repeat;
}
.error-text-div {
    display: inline-block;
    vertical-align: top;
    height: 32px;
}
.label {
    font-weight:bold;
    display: inline-block;
}
.value {
    display: inline-block;
    margin-left: 5px;
}
pre {
    font-size: 110%;



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
Copy link
Collaborator

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?

Copy link
Collaborator

@yersan yersan May 9, 2022

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Member

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.

Copy link
Collaborator

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!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @jamezp, sure @yersan I will look at the tests.

Copy link
Collaborator

@yersan yersan left a 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?

Copy link
Member

@jamezp jamezp left a 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

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
Copy link
Member

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.

@lvydra
Copy link
Contributor Author

lvydra commented May 13, 2022

Hi @jamezp @yersan, tests added.

@@ -86,6 +89,28 @@ public static Collection<Object> data() {
return result;
}

@Test
public void testBatchScriptJavaOptsToEscape() throws Exception {
Assume.assumeTrue(!TestSuiteEnvironment.isWindows() && Shell.BASH.isSupported());
Copy link
Collaborator

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.

Copy link
Contributor Author

@lvydra lvydra May 18, 2022

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 :-)

Copy link
Collaborator

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());
Copy link
Collaborator

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())

@lvydra
Copy link
Contributor Author

lvydra commented May 18, 2022

@yersan fixed

@wildfly-ci
Copy link

Core - Full Integration Build 11594 outcome was FAILURE using a merge of f4501b7
Summary: Tests failed: 2 (2 new), passed: 7222, ignored: 150 Build time: 03:41:51

Failed tests

org.wildfly.extension.undertow.ServerServiceTestCase.testDefinedDefaultAttributes1: java.lang.AssertionError: expected:<1> but was:<0>
	at org.wildfly.extension.undertow.ServerServiceTestCase.testDefinedDefaultAttributes1(ServerServiceTestCase.java:111)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)


org.wildfly.extension.undertow.ServerServiceTestCase.testDefinedDefaultAttributes2: java.lang.AssertionError: expected:<1> but was:<0>
	at org.wildfly.extension.undertow.ServerServiceTestCase.testDefinedDefaultAttributes2(ServerServiceTestCase.java:126)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)


@yersan yersan added the ready-for-merge This PR is ready to be merged and fulfills all requirements label May 19, 2022
@yersan yersan merged commit b4053f1 into wildfly:main May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deps-ok Dependencies have been checked, and there are no significant changes ready-for-merge This PR is ready to be merged and fulfills all requirements
Projects
None yet
4 participants