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

Maven local 2 #130

Closed
wants to merge 727 commits into from
Closed

Maven local 2 #130

wants to merge 727 commits into from

Conversation

tiagobento
Copy link
Owner

Maven local 2

radtriste and others added 30 commits October 18, 2022 10:21
apache#1335)

* [KOGITO-7697] - Group all Jobs service jdbc flavors on one container image

Signed-off-by: spolti <[email protected]>

* review and improvements

Signed-off-by: spolti <[email protected]>

review changes and remove leftovers

Signed-off-by: spolti <[email protected]>

Update build-kogito-apps-components.sh

Update build-kogito-apps-components.sh

update script

* make the all in one module independent

Signed-off-by: spolti <[email protected]>

* Apply suggestions from code review

Signed-off-by: spolti <[email protected]>
Co-authored-by: Tristan Radisson <[email protected]>
* [main] Bump Quarkus version to 2.14.0.Final

* Update GraalVM module to 22.2.0

Co-authored-by: Jenkins CI <[email protected]>
Co-authored-by: radtriste <[email protected]>
* Build `kogito-swf-builder` quarkus app locally

* review comments
…pache#1381)

* [KOGITO-8304] - Document the usage of all-in-one jobs-service image

Signed-off-by: spolti <[email protected]>

* Update README.md

* Update README.md

Co-authored-by: Tristan Radisson <[email protected]>

* Update README.md

Co-authored-by: Tristan Radisson <[email protected]>

* Update README.md

Signed-off-by: spolti <[email protected]>
Co-authored-by: Tristan Radisson <[email protected]>
* [main] Bump Quarkus version to 2.15.0.CR1

* [main] Bump Quarkus version to 2.15.0.Final

* Update tests/features/kogito-swf-builder.feature

* update

* added backporting

* Revert "added backporting"

This reverts commit 7d28f58bf908136f0c33b4e4716284bdc9a09c49.

Co-authored-by: Jenkins CI <[email protected]>
Co-authored-by: radtriste <[email protected]>
- fixes KOGITO-8420
- fixes KOGITO-8421
- remove unnecessary files from builder image

Signed-off-by: Your Name <[email protected]>
apache#1402)

* [KOGITO-8421] - [SW] Ensure that the Kogito SW builder image has the correct Quarkus version

- Apply review suggestions

Signed-off-by: Spolti <[email protected]>

* Update scripts/build-quarkus-app.sh

* Update modules/kogito-swf-builder/added/create-app.sh

Signed-off-by: Spolti <[email protected]>
* KOGITO-8510 Solve kogito-swf-builder long builds
* KOGITO-8393 Clean release notes on branching

* Update .ci/jenkins/Jenkinsfile.setup-branch
…y default (apache#1404)

* [KOGITO-8469] Adapt Kogito SWF Builder image to run quarkus devmode by default

Signed-off-by: Ricardo Zanini <[email protected]>

* Add RELEASE NOTES

Signed-off-by: Ricardo Zanini <[email protected]>

* Add behave tests for running the app in devmode

Signed-off-by: Ricardo Zanini <[email protected]>

* Remove service description from ports

Signed-off-by: Ricardo Zanini <[email protected]>

* Forcing quarkus version to the runner

Signed-off-by: Ricardo Zanini <[email protected]>

* Formatting runner command

Co-authored-by: Tristan Radisson <[email protected]>

* Updating docs

Signed-off-by: Ricardo Zanini <[email protected]>

* Apply suggestions from code review

Co-authored-by: Tristan Radisson <[email protected]>

Signed-off-by: Ricardo Zanini <[email protected]>
Co-authored-by: Tristan Radisson <[email protected]>
packages/maven-config-setup-helper/index.js Fixed Show fixed Hide fixed
packages/maven-config-setup-helper/index.js Fixed Show fixed Hide fixed
packages/maven-config-setup-helper/index.js Fixed Show fixed Hide fixed
packages/maven-config-setup-helper/index.js Fixed Show fixed Hide fixed
packages/maven-config-setup-helper/index.js Fixed Show fixed Hide fixed
packages/maven-config-setup-helper/index.js Fixed Show fixed Hide fixed
packages/maven-config-setup-helper/index.js Fixed Show fixed Hide fixed
packages/maven-config-setup-helper/index.js Fixed Show fixed Hide fixed
packages/maven-config-setup-helper/index.js Fixed Show fixed Hide fixed
packages/maven-config-setup-helper/index.js Fixed Show fixed Hide fixed
@tiagobento tiagobento force-pushed the maven-local-2 branch 4 times, most recently from 1d0dd07 to 840e606 Compare September 30, 2024 14:44
Rename

Fix build reproducibility

v2

Oops

Fix DashBuilder configuration of maven-deploy-plugin

Oops

Fix maven-m2-repo-via-http-image configuration

.

Fix config
`.trim();

const DEFAULT_LOCAL_REPO = String(
cp.execSync(`mvn help:evaluate -Dexpression=settings.localRepository -q -DforceStdout -f ${EMPTY_POM_XML_PATH}`, {

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium

This shell command depends on an uncontrolled
absolute path
.

Copilot Autofix AI 3 months ago

To fix the problem, we should avoid constructing the shell command dynamically and instead use cp.execFileSync to pass the command and its arguments separately. This approach ensures that the shell does not misinterpret any special characters in the file paths.

  1. Replace the dynamic command string with a static command and an array of arguments.
  2. Use cp.execFileSync instead of cp.execSync to execute the command with the arguments.
Suggested changeset 1
packages/maven-base/index.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/maven-base/index.js b/packages/maven-base/index.js
--- a/packages/maven-base/index.js
+++ b/packages/maven-base/index.js
@@ -39,3 +39,3 @@
 const DEFAULT_LOCAL_REPO = String(
-  cp.execSync(`mvn help:evaluate -Dexpression=settings.localRepository -q -DforceStdout -f ${EMPTY_POM_XML_PATH}`, {
+  cp.execFileSync("mvn", ["help:evaluate", "-Dexpression=settings.localRepository", "-q", "-DforceStdout", "-f", EMPTY_POM_XML_PATH], {
     stdio: "pipe",
EOF
@@ -39,3 +39,3 @@
const DEFAULT_LOCAL_REPO = String(
cp.execSync(`mvn help:evaluate -Dexpression=settings.localRepository -q -DforceStdout -f ${EMPTY_POM_XML_PATH}`, {
cp.execFileSync("mvn", ["help:evaluate", "-Dexpression=settings.localRepository", "-q", "-DforceStdout", "-f", EMPTY_POM_XML_PATH], {
stdio: "pipe",
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
packages/maven-base/index.js Fixed Show fixed Hide fixed
* @param dirname A list of paths representing additional Maven repository directories, to be concatenated the default one (I.e, `maven.repo.local`)
* */
prepareHardLinkedM2ForPackage: (tmpM2Dir, relativePackagePath) => {
const resolvedTmpM2Dir = path.resolve(tmpM2Dir);

Check warning

Code scanning / CodeQL

Unsafe shell command constructed from library input Medium

This path concatenation which depends on
library input
is later used in a
shell command
.
This path concatenation which depends on
library input
is later used in a
shell command
.

Copilot Autofix AI 3 months ago

To fix the problem, we should avoid directly embedding the tmpM2Dir parameter in the shell command. Instead, we can use the child_process.execFile method, which allows us to pass arguments as an array, thus avoiding shell interpretation of the input. This method is safer and prevents command injection vulnerabilities.

  1. Replace the cp.execSync calls with cp.execFileSync and pass the command and arguments separately.
  2. Ensure that all paths and arguments are passed as separate elements in the array to execFileSync.
Suggested changeset 1
packages/maven-base/index.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/maven-base/index.js b/packages/maven-base/index.js
--- a/packages/maven-base/index.js
+++ b/packages/maven-base/index.js
@@ -106,3 +106,3 @@
     // head
-    cp.execSync(`cp -nal ${DEFAULT_LOCAL_REPO}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
+    cp.execFileSync("cp", ["-nal", `${DEFAULT_LOCAL_REPO}/*`, resolvedTmpM2Dir], { stdio: "inherit" });
 
@@ -115,3 +115,3 @@
       if (fs.existsSync(path.resolve(t))) {
-        cp.execSync(`cp -al ${path.resolve(t)}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
+        cp.execFileSync("cp", ["-al", `${path.resolve(t)}/*`, resolvedTmpM2Dir], { stdio: "inherit" });
       }
EOF
@@ -106,3 +106,3 @@
// head
cp.execSync(`cp -nal ${DEFAULT_LOCAL_REPO}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
cp.execFileSync("cp", ["-nal", `${DEFAULT_LOCAL_REPO}/*`, resolvedTmpM2Dir], { stdio: "inherit" });

@@ -115,3 +115,3 @@
if (fs.existsSync(path.resolve(t))) {
cp.execSync(`cp -al ${path.resolve(t)}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
cp.execFileSync("cp", ["-al", `${path.resolve(t)}/*`, resolvedTmpM2Dir], { stdio: "inherit" });
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
fs.mkdirSync(resolvedTmpM2Dir, { recursive: true });

// head
cp.execSync(`cp -nal ${DEFAULT_LOCAL_REPO}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });

Check warning

Code scanning / CodeQL

Unsafe shell command constructed from library input Medium

This string concatenation which depends on
library input
is later used in a
shell command
.

Copilot Autofix AI 3 months ago

To fix the problem, we should avoid directly concatenating user input into shell commands. Instead, we can use the child_process.execFile method, which allows us to pass arguments as an array, thus avoiding shell interpretation of special characters. This method is safer and prevents command injection vulnerabilities.

  1. Replace the cp.execSync call with cp.execFileSync to safely pass the command and its arguments.
  2. Ensure that all paths and arguments are passed as separate elements in the array to execFileSync.
Suggested changeset 1
packages/maven-base/index.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/maven-base/index.js b/packages/maven-base/index.js
--- a/packages/maven-base/index.js
+++ b/packages/maven-base/index.js
@@ -106,3 +106,3 @@
     // head
-    cp.execSync(`cp -nal ${DEFAULT_LOCAL_REPO}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
+    cp.execFileSync("cp", ["-nal", `${DEFAULT_LOCAL_REPO}/*`, resolvedTmpM2Dir], { stdio: "inherit" });
 
@@ -115,3 +115,3 @@
       if (fs.existsSync(path.resolve(t))) {
-        cp.execSync(`cp -al ${path.resolve(t)}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
+        cp.execFileSync("cp", ["-al", `${path.resolve(t)}/*`, resolvedTmpM2Dir], { stdio: "inherit" });
       }
EOF
@@ -106,3 +106,3 @@
// head
cp.execSync(`cp -nal ${DEFAULT_LOCAL_REPO}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
cp.execFileSync("cp", ["-nal", `${DEFAULT_LOCAL_REPO}/*`, resolvedTmpM2Dir], { stdio: "inherit" });

@@ -115,3 +115,3 @@
if (fs.existsSync(path.resolve(t))) {
cp.execSync(`cp -al ${path.resolve(t)}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
cp.execFileSync("cp", ["-al", `${path.resolve(t)}/*`, resolvedTmpM2Dir], { stdio: "inherit" });
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
fs.mkdirSync(resolvedTmpM2Dir, { recursive: true });

// head
cp.execSync(`cp -nal ${DEFAULT_LOCAL_REPO}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium

This shell command depends on an uncontrolled
absolute path
.

Copilot Autofix AI 3 months ago

To fix the problem, we should avoid constructing the shell command as a single string and instead use cp.execFileSync or cp.spawnSync to pass the command and its arguments separately. This approach prevents the shell from interpreting special characters in the arguments.

  1. Replace the cp.execSync call on line 107 with cp.execFileSync to pass the command and arguments separately.
  2. Ensure that the DEFAULT_LOCAL_REPO and resolvedTmpM2Dir paths are passed as arguments to avoid shell interpretation.
Suggested changeset 1
packages/maven-base/index.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/maven-base/index.js b/packages/maven-base/index.js
--- a/packages/maven-base/index.js
+++ b/packages/maven-base/index.js
@@ -106,3 +106,3 @@
     // head
-    cp.execSync(`cp -nal ${DEFAULT_LOCAL_REPO}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
+    cp.execFileSync("cp", ["-nal", `${DEFAULT_LOCAL_REPO}/*`, resolvedTmpM2Dir], { stdio: "inherit" });
 
@@ -115,3 +115,3 @@
       if (fs.existsSync(path.resolve(t))) {
-        cp.execSync(`cp -al ${path.resolve(t)}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
+        cp.execFileSync("cp", ["-al", `${path.resolve(t)}/*`, resolvedTmpM2Dir], { stdio: "inherit" });
       }
EOF
@@ -106,3 +106,3 @@
// head
cp.execSync(`cp -nal ${DEFAULT_LOCAL_REPO}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
cp.execFileSync("cp", ["-nal", `${DEFAULT_LOCAL_REPO}/*`, resolvedTmpM2Dir], { stdio: "inherit" });

@@ -115,3 +115,3 @@
if (fs.existsSync(path.resolve(t))) {
cp.execSync(`cp -al ${path.resolve(t)}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
cp.execFileSync("cp", ["-al", `${path.resolve(t)}/*`, resolvedTmpM2Dir], { stdio: "inherit" });
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
// tail
for (const t of tail) {
if (fs.existsSync(path.resolve(t))) {
cp.execSync(`cp -al ${path.resolve(t)}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });

Check warning

Code scanning / CodeQL

Unsafe shell command constructed from library input Medium

This string concatenation which depends on
library input
is later used in a
shell command
.

Copilot Autofix AI 3 months ago

To fix the problem, we should avoid constructing shell commands using string concatenation with untrusted input. Instead, we can use the child_process.execFile method, which allows us to pass arguments as an array, thereby avoiding shell interpretation of special characters.

  1. Replace the cp.execSync calls with cp.execFileSync to safely pass arguments.
  2. Ensure that all dynamic parts of the command are passed as separate arguments in the array.
Suggested changeset 1
packages/maven-base/index.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/maven-base/index.js b/packages/maven-base/index.js
--- a/packages/maven-base/index.js
+++ b/packages/maven-base/index.js
@@ -39,3 +39,3 @@
 const DEFAULT_LOCAL_REPO = String(
-  cp.execSync(`mvn help:evaluate -Dexpression=settings.localRepository -q -DforceStdout -f ${EMPTY_POM_XML_PATH}`, {
+  cp.execFileSync("mvn", ["help:evaluate", "-Dexpression=settings.localRepository", "-q", "-DforceStdout", "-f", EMPTY_POM_XML_PATH], {
     stdio: "pipe",
@@ -73,5 +73,5 @@
     if (process.platform === "win32") {
-      cp.execSync(cmd.replaceAll(" -", " `-"), { stdio: "inherit", shell: "powershell.exe" });
+      cp.execFileSync("powershell.exe", ["-Command", cmd.replaceAll(" -", " `-")], { stdio: "inherit" });
     } else {
-      cp.execSync(cmd, { stdio: "inherit" });
+      cp.execFileSync("sh", ["-c", cmd], { stdio: "inherit" });
     }
@@ -106,3 +106,3 @@
     // head
-    cp.execSync(`cp -nal ${DEFAULT_LOCAL_REPO}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
+    cp.execFileSync("cp", ["-nal", `${DEFAULT_LOCAL_REPO}/*`, resolvedTmpM2Dir], { stdio: "inherit" });
 
@@ -115,3 +115,3 @@
       if (fs.existsSync(path.resolve(t))) {
-        cp.execSync(`cp -al ${path.resolve(t)}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
+        cp.execFileSync("cp", ["-al", `${path.resolve(t)}/*`, resolvedTmpM2Dir], { stdio: "inherit" });
       }
EOF
@@ -39,3 +39,3 @@
const DEFAULT_LOCAL_REPO = String(
cp.execSync(`mvn help:evaluate -Dexpression=settings.localRepository -q -DforceStdout -f ${EMPTY_POM_XML_PATH}`, {
cp.execFileSync("mvn", ["help:evaluate", "-Dexpression=settings.localRepository", "-q", "-DforceStdout", "-f", EMPTY_POM_XML_PATH], {
stdio: "pipe",
@@ -73,5 +73,5 @@
if (process.platform === "win32") {
cp.execSync(cmd.replaceAll(" -", " `-"), { stdio: "inherit", shell: "powershell.exe" });
cp.execFileSync("powershell.exe", ["-Command", cmd.replaceAll(" -", " `-")], { stdio: "inherit" });
} else {
cp.execSync(cmd, { stdio: "inherit" });
cp.execFileSync("sh", ["-c", cmd], { stdio: "inherit" });
}
@@ -106,3 +106,3 @@
// head
cp.execSync(`cp -nal ${DEFAULT_LOCAL_REPO}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
cp.execFileSync("cp", ["-nal", `${DEFAULT_LOCAL_REPO}/*`, resolvedTmpM2Dir], { stdio: "inherit" });

@@ -115,3 +115,3 @@
if (fs.existsSync(path.resolve(t))) {
cp.execSync(`cp -al ${path.resolve(t)}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
cp.execFileSync("cp", ["-al", `${path.resolve(t)}/*`, resolvedTmpM2Dir], { stdio: "inherit" });
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
// tail
for (const t of tail) {
if (fs.existsSync(path.resolve(t))) {
cp.execSync(`cp -al ${path.resolve(t)}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium

This shell command depends on an uncontrolled
absolute path
.
This shell command depends on an uncontrolled
absolute path
.
This shell command depends on an uncontrolled
absolute path
.
This shell command depends on an uncontrolled
file name
.
This shell command depends on an uncontrolled
absolute path
.

Copilot Autofix AI 3 months ago

To fix the problem, we should avoid constructing the shell command as a single string and instead use cp.execFileSync or cp.spawnSync to pass the command and its arguments separately. This approach ensures that the shell does not interpret any special characters in the arguments.

  1. Replace the cp.execSync call on line 116 with cp.execFileSync to pass the command and arguments separately.
  2. Ensure that the paths are passed as separate arguments to avoid shell interpretation issues.
Suggested changeset 1
packages/maven-base/index.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/maven-base/index.js b/packages/maven-base/index.js
--- a/packages/maven-base/index.js
+++ b/packages/maven-base/index.js
@@ -106,3 +106,3 @@
     // head
-    cp.execSync(`cp -nal ${DEFAULT_LOCAL_REPO}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
+    cp.execFileSync("cp", ["-nal", `${DEFAULT_LOCAL_REPO}/*`, resolvedTmpM2Dir], { stdio: "inherit" });
 
@@ -115,3 +115,3 @@
       if (fs.existsSync(path.resolve(t))) {
-        cp.execSync(`cp -al ${path.resolve(t)}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
+        cp.execFileSync("cp", ["-al", `${path.resolve(t)}/*`, resolvedTmpM2Dir], { stdio: "inherit" });
       }
EOF
@@ -106,3 +106,3 @@
// head
cp.execSync(`cp -nal ${DEFAULT_LOCAL_REPO}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
cp.execFileSync("cp", ["-nal", `${DEFAULT_LOCAL_REPO}/*`, resolvedTmpM2Dir], { stdio: "inherit" });

@@ -115,3 +115,3 @@
if (fs.existsSync(path.resolve(t))) {
cp.execSync(`cp -al ${path.resolve(t)}/* ${resolvedTmpM2Dir}`, { stdio: "inherit" });
cp.execFileSync("cp", ["-al", `${path.resolve(t)}/*`, resolvedTmpM2Dir], { stdio: "inherit" });
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
console.info(`[maven-base] Setting property '${key}' with value '${value}'...`);
console.time(`[maven-base] Setting property '${key}' with value '${value}'...`);

const cmd = `mvn versions:set-property -Dproperty=${key} -DnewVersion=${value} -DgenerateBackupPoms=false ${BOOTSTRAP_CLI_ARGS}`;

Check warning

Code scanning / CodeQL

Unsafe shell command constructed from library input Medium

This string concatenation which depends on
library input
is later used in a
shell command
.
This string concatenation which depends on
library input
is later used in a
shell command
.

Copilot Autofix AI 3 months ago

To fix the problem, we should avoid using string concatenation to construct the shell command. Instead, we can use child_process.execFile to safely pass the arguments to the mvn command. This approach ensures that the inputs are not interpreted by the shell, preventing command injection.

  1. Replace the string concatenation with an array of arguments.
  2. Use cp.execFile instead of cp.execSync to execute the command with the arguments array.
Suggested changeset 1
packages/maven-base/index.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/maven-base/index.js b/packages/maven-base/index.js
--- a/packages/maven-base/index.js
+++ b/packages/maven-base/index.js
@@ -134,8 +134,14 @@
 
-    const cmd = `mvn versions:set-property -Dproperty=${key} -DnewVersion=${value} -DgenerateBackupPoms=false ${BOOTSTRAP_CLI_ARGS}`;
+    const args = [
+      "versions:set-property",
+      `-Dproperty=${key}`,
+      `-DnewVersion=${value}`,
+      "-DgenerateBackupPoms=false",
+      ...BOOTSTRAP_CLI_ARGS.split(" ")
+    ];
 
     if (process.platform === "win32") {
-      cp.execSync(cmd.replaceAll(" -", " `-"), { stdio: "inherit", shell: "powershell.exe" });
+      cp.execFileSync("mvn", args, { stdio: "inherit", shell: "powershell.exe" });
     } else {
-      cp.execSync(cmd, { stdio: "inherit" });
+      cp.execFileSync("mvn", args, { stdio: "inherit" });
     }
EOF
@@ -134,8 +134,14 @@

const cmd = `mvn versions:set-property -Dproperty=${key} -DnewVersion=${value} -DgenerateBackupPoms=false ${BOOTSTRAP_CLI_ARGS}`;
const args = [
"versions:set-property",
`-Dproperty=${key}`,
`-DnewVersion=${value}`,
"-DgenerateBackupPoms=false",
...BOOTSTRAP_CLI_ARGS.split(" ")
];

if (process.platform === "win32") {
cp.execSync(cmd.replaceAll(" -", " `-"), { stdio: "inherit", shell: "powershell.exe" });
cp.execFileSync("mvn", args, { stdio: "inherit", shell: "powershell.exe" });
} else {
cp.execSync(cmd, { stdio: "inherit" });
cp.execFileSync("mvn", args, { stdio: "inherit" });
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
const cmd = `mvn versions:set-property -Dproperty=${key} -DnewVersion=${value} -DgenerateBackupPoms=false ${BOOTSTRAP_CLI_ARGS}`;

if (process.platform === "win32") {
cp.execSync(cmd.replaceAll(" -", " `-"), { stdio: "inherit", shell: "powershell.exe" });

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium

This shell command depends on an uncontrolled
absolute path
.

Copilot Autofix AI 3 months ago

To fix the problem, we should avoid constructing the shell command as a single string and instead use cp.execFileSync to separate the command and its arguments. This approach prevents the shell from interpreting special characters in the arguments, thus mitigating the risk of command injection.

  1. Replace the dynamic command construction with a command and arguments array.
  2. Use cp.execFileSync to execute the command with the arguments array.
Suggested changeset 1
packages/maven-base/index.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/maven-base/index.js b/packages/maven-base/index.js
--- a/packages/maven-base/index.js
+++ b/packages/maven-base/index.js
@@ -70,8 +70,13 @@
 
-    const cmd = `mvn -e org.apache.maven.plugins:maven-wrapper-plugin:${env.mvnw.version}:wrapper ${BOOTSTRAP_CLI_ARGS}`;
+    const cmd = "mvn";
+    const args = [
+      "-e",
+      `org.apache.maven.plugins:maven-wrapper-plugin:${env.mvnw.version}:wrapper`,
+      ...BOOTSTRAP_CLI_ARGS.split(" ")
+    ];
 
     if (process.platform === "win32") {
-      cp.execSync(cmd.replaceAll(" -", " `-"), { stdio: "inherit", shell: "powershell.exe" });
+      cp.execFileSync(cmd, args, { stdio: "inherit", shell: "powershell.exe" });
     } else {
-      cp.execSync(cmd, { stdio: "inherit" });
+      cp.execFileSync(cmd, args, { stdio: "inherit" });
     }
EOF
@@ -70,8 +70,13 @@

const cmd = `mvn -e org.apache.maven.plugins:maven-wrapper-plugin:${env.mvnw.version}:wrapper ${BOOTSTRAP_CLI_ARGS}`;
const cmd = "mvn";
const args = [
"-e",
`org.apache.maven.plugins:maven-wrapper-plugin:${env.mvnw.version}:wrapper`,
...BOOTSTRAP_CLI_ARGS.split(" ")
];

if (process.platform === "win32") {
cp.execSync(cmd.replaceAll(" -", " `-"), { stdio: "inherit", shell: "powershell.exe" });
cp.execFileSync(cmd, args, { stdio: "inherit", shell: "powershell.exe" });
} else {
cp.execSync(cmd, { stdio: "inherit" });
cp.execFileSync(cmd, args, { stdio: "inherit" });
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
if (process.platform === "win32") {
cp.execSync(cmd.replaceAll(" -", " `-"), { stdio: "inherit", shell: "powershell.exe" });
} else {
cp.execSync(cmd, { stdio: "inherit" });

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium

This shell command depends on an uncontrolled
absolute path
.

Copilot Autofix AI 3 months ago

To fix the problem, we should avoid constructing the shell command as a single string that includes potentially unsafe environment values. Instead, we should use cp.execFileSync to pass the command and its arguments separately. This approach ensures that the shell does not misinterpret any special characters or spaces in the paths.

  1. Replace the construction of the cmd variable with an array of arguments.
  2. Use cp.execFileSync instead of cp.execSync to execute the command with the arguments array.
Suggested changeset 1
packages/maven-base/index.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/maven-base/index.js b/packages/maven-base/index.js
--- a/packages/maven-base/index.js
+++ b/packages/maven-base/index.js
@@ -134,8 +134,14 @@
 
-    const cmd = `mvn versions:set-property -Dproperty=${key} -DnewVersion=${value} -DgenerateBackupPoms=false ${BOOTSTRAP_CLI_ARGS}`;
+    const args = [
+      "versions:set-property",
+      `-Dproperty=${key}`,
+      `-DnewVersion=${value}`,
+      "-DgenerateBackupPoms=false",
+      ...BOOTSTRAP_CLI_ARGS.split(" ")
+    ];
 
     if (process.platform === "win32") {
-      cp.execSync(cmd.replaceAll(" -", " `-"), { stdio: "inherit", shell: "powershell.exe" });
+      cp.execFileSync("mvn", args, { stdio: "inherit", shell: "powershell.exe" });
     } else {
-      cp.execSync(cmd, { stdio: "inherit" });
+      cp.execFileSync("mvn", args, { stdio: "inherit" });
     }
EOF
@@ -134,8 +134,14 @@

const cmd = `mvn versions:set-property -Dproperty=${key} -DnewVersion=${value} -DgenerateBackupPoms=false ${BOOTSTRAP_CLI_ARGS}`;
const args = [
"versions:set-property",
`-Dproperty=${key}`,
`-DnewVersion=${value}`,
"-DgenerateBackupPoms=false",
...BOOTSTRAP_CLI_ARGS.split(" ")
];

if (process.platform === "win32") {
cp.execSync(cmd.replaceAll(" -", " `-"), { stdio: "inherit", shell: "powershell.exe" });
cp.execFileSync("mvn", args, { stdio: "inherit", shell: "powershell.exe" });
} else {
cp.execSync(cmd, { stdio: "inherit" });
cp.execFileSync("mvn", args, { stdio: "inherit" });
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
if (process.platform === "win32") {
cp.execSync(cmd.replaceAll(" -", " `-"), { stdio: "inherit", shell: "powershell.exe" });
} else {
cp.execSync(cmd, { stdio: "inherit" });

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium

This shell command depends on an uncontrolled
absolute path
.

Copilot Autofix AI 3 months ago

To fix the problem, we should avoid constructing the shell command as a single string that includes potentially unsafe environment values. Instead, we should use cp.execFileSync to pass the command and its arguments separately. This approach ensures that the shell does not misinterpret any special characters in the paths.

  1. Replace the construction of the cmd variable with separate command and arguments.
  2. Use cp.execFileSync instead of cp.execSync to execute the command with the arguments passed as an array.
Suggested changeset 1
packages/maven-base/index.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/maven-base/index.js b/packages/maven-base/index.js
--- a/packages/maven-base/index.js
+++ b/packages/maven-base/index.js
@@ -70,8 +70,13 @@
 
-    const cmd = `mvn -e org.apache.maven.plugins:maven-wrapper-plugin:${env.mvnw.version}:wrapper ${BOOTSTRAP_CLI_ARGS}`;
+    const cmd = "mvn";
+    const args = [
+      "-e",
+      `org.apache.maven.plugins:maven-wrapper-plugin:${env.mvnw.version}:wrapper`,
+      ...BOOTSTRAP_CLI_ARGS.split(" ")
+    ];
 
     if (process.platform === "win32") {
-      cp.execSync(cmd.replaceAll(" -", " `-"), { stdio: "inherit", shell: "powershell.exe" });
+      cp.execFileSync(cmd, args, { stdio: "inherit", shell: "powershell.exe" });
     } else {
-      cp.execSync(cmd, { stdio: "inherit" });
+      cp.execFileSync(cmd, args, { stdio: "inherit" });
     }
EOF
@@ -70,8 +70,13 @@

const cmd = `mvn -e org.apache.maven.plugins:maven-wrapper-plugin:${env.mvnw.version}:wrapper ${BOOTSTRAP_CLI_ARGS}`;
const cmd = "mvn";
const args = [
"-e",
`org.apache.maven.plugins:maven-wrapper-plugin:${env.mvnw.version}:wrapper`,
...BOOTSTRAP_CLI_ARGS.split(" ")
];

if (process.platform === "win32") {
cp.execSync(cmd.replaceAll(" -", " `-"), { stdio: "inherit", shell: "powershell.exe" });
cp.execFileSync(cmd, args, { stdio: "inherit", shell: "powershell.exe" });
} else {
cp.execSync(cmd, { stdio: "inherit" });
cp.execFileSync(cmd, args, { stdio: "inherit" });
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
const cmd = `mvn versions:set-property -Dproperty=${key} -DnewVersion=${value} -DgenerateBackupPoms=false ${BOOTSTRAP_CLI_ARGS}`;

if (process.platform === "win32") {
cp.execSync(cmd.replaceAll(" -", " `-"), { stdio: "inherit", shell: "powershell.exe" });

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium

This shell command depends on an uncontrolled
absolute path
.

Copilot Autofix AI 3 months ago

To fix the problem, we should avoid constructing the shell command as a single string that includes environment-derived paths. Instead, we should use cp.execFileSync to pass the command and its arguments separately. This approach ensures that the shell does not misinterpret special characters in the paths.

  1. Replace the construction of the cmd variable with an array of arguments.
  2. Use cp.execFileSync to execute the command with the arguments array.
  3. Ensure the fix is applied consistently across different platforms (Windows and non-Windows).
Suggested changeset 1
packages/maven-base/index.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/maven-base/index.js b/packages/maven-base/index.js
--- a/packages/maven-base/index.js
+++ b/packages/maven-base/index.js
@@ -134,8 +134,14 @@
 
-    const cmd = `mvn versions:set-property -Dproperty=${key} -DnewVersion=${value} -DgenerateBackupPoms=false ${BOOTSTRAP_CLI_ARGS}`;
+    const args = [
+      "versions:set-property",
+      `-Dproperty=${key}`,
+      `-DnewVersion=${value}`,
+      "-DgenerateBackupPoms=false",
+      ...BOOTSTRAP_CLI_ARGS.split(" ")
+    ];
 
     if (process.platform === "win32") {
-      cp.execSync(cmd.replaceAll(" -", " `-"), { stdio: "inherit", shell: "powershell.exe" });
+      cp.execFileSync("mvn", args, { stdio: "inherit", shell: "powershell.exe" });
     } else {
-      cp.execSync(cmd, { stdio: "inherit" });
+      cp.execFileSync("mvn", args, { stdio: "inherit" });
     }
EOF
@@ -134,8 +134,14 @@

const cmd = `mvn versions:set-property -Dproperty=${key} -DnewVersion=${value} -DgenerateBackupPoms=false ${BOOTSTRAP_CLI_ARGS}`;
const args = [
"versions:set-property",
`-Dproperty=${key}`,
`-DnewVersion=${value}`,
"-DgenerateBackupPoms=false",
...BOOTSTRAP_CLI_ARGS.split(" ")
];

if (process.platform === "win32") {
cp.execSync(cmd.replaceAll(" -", " `-"), { stdio: "inherit", shell: "powershell.exe" });
cp.execFileSync("mvn", args, { stdio: "inherit", shell: "powershell.exe" });
} else {
cp.execSync(cmd, { stdio: "inherit" });
cp.execFileSync("mvn", args, { stdio: "inherit" });
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@tiagobento tiagobento closed this Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.