helidon-io / helidon-build-tools

Build tools for the Helidon Project
https://helidon.io
Apache License 2.0
35 stars 35 forks source link

[JLINK] Generated PowerShell script does not guard jvm options passed by user on Windows #1088

Open tvallin opened 1 day ago

tvallin commented 1 day ago

Problem description

There are two issues:

  1. The JVM option passed to *\start.ps1 using the --jvm option are not guarded by ' " ' character.
  2. The default JVM option provided in configuration is not guarded as well.

Reproducer

Using the Helidon application https://github.com/helidon-io/helidon/tree/main/tests/integration/packaging/se-1

  1. Exposes the issue by providing -Dapp.static.path=../../web
mvn -Pjlink-image verify
.\target\helidon-tests-integration-packaging-se-1-jri\bin\start.ps1 --jvm "-Dapp.static.path=../../web"

The workaround is to use this command:

.\target\helidon-tests-integration-packaging-se-1-jri\bin\start.ps1 --jvm "`"-Dapp.static.path=../../web`""

Question is: Should we keep this behavior ?

  1. Exposes this issue by providing app.static.path option through configuration.
mvn -Pjlink-image verify
.\target\helidon-tests-integration-packaging-se-1-jri\bin\start.ps1
romain-grecourt commented 1 day ago

You are running these command in powershell, so the outer quotes might be interpreted by your shell.

The backtick character is an escape similar to \, so if you do

"`"-Dfoo.bar`""

It's equivalent to this java code:

"\"-Dfoo.bar\""

Have you tried with single quotes instead of double quotes ?