-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Use devspaces-dashboard.openshift-devspaces.svc to get devfile yaml #23366
Conversation
Signed-off-by: Dmytro Nochevnov <dnochevn@redhat.com>
Signed-off-by: Dmytro Nochevnov <dnochevn@redhat.com>
Signed-off-by: Dmytro Nochevnov <dnochevn@redhat.com>
); | ||
return `http://${serviceClusterIp}:${servicePort}${devfileSampleURIPrefix}`; | ||
|
||
return `http://devspaces-dashboard.openshift-devspaces.svc:8080${devfileSampleURIPrefix}`; |
Check warning
Code scanning / CodeQL
Unsafe shell command constructed from library input Medium test
library input
shell command
This string concatenation which depends on
library input
shell command
This string concatenation which depends on
library input
shell command
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 6 days ago
To fix the problem, we should avoid passing untrusted input directly to the shell. Instead, we can use the child_process.execFile
method, which takes an array of arguments and does not invoke the shell, thus avoiding interpretation of special characters. If the command must be interpreted by a shell, we can use the shell-quote
library to escape any special characters in the input.
- Replace the use of
child_process.exec
withchild_process.execFile
where possible. - For commands that require shell interpretation, use the
shell-quote
library to escape the input.
-
Copy modified lines R36-R37 -
Copy modified line R39 -
Copy modified line R43
@@ -35,4 +35,6 @@ | ||
const clusterURL: string = this.getInternalClusterURLToDevFile(devFileName); | ||
const shellQuote = require('shell-quote'); | ||
const escapedClusterURL = shellQuote.quote([clusterURL]); | ||
this.getShellExecutor().executeCommand( | ||
`oc exec -i ${podName} -n ${BASE_TEST_CONSTANTS.TS_PLATFORM}-${BASE_TEST_CONSTANTS.TESTING_APPLICATION_NAME()} -c ${containerName} -- sh -c 'curl -o /tmp/${devFileName}-devfile.yaml ${clusterURL}'` | ||
`oc exec -i ${podName} -n ${BASE_TEST_CONSTANTS.TS_PLATFORM}-${BASE_TEST_CONSTANTS.TESTING_APPLICATION_NAME()} -c ${containerName} -- sh -c 'curl -o /tmp/${devFileName}-devfile.yaml ${escapedClusterURL}'` | ||
); | ||
@@ -40,3 +42,3 @@ | ||
.executeArbitraryShellScript( | ||
`oc exec -i ${podName} -n ${BASE_TEST_CONSTANTS.TS_PLATFORM}-${BASE_TEST_CONSTANTS.TESTING_APPLICATION_NAME()} -c ${containerName} -- cat /tmp/${devFileName}-devfile.yaml` | ||
`oc exec -i ${podName} -n ${BASE_TEST_CONSTANTS.TS_PLATFORM}-${BASE_TEST_CONSTANTS.TESTING_APPLICATION_NAME()} -c ${containerName} -- cat /tmp/${shellQuote.quote([devFileName])}-devfile.yaml` | ||
) |
-
Copy modified lines R69-R70
@@ -68,3 +68,4 @@ | ||
"inversify": "6.0.1", | ||
"reflect-metadata": "0.1.13" | ||
"reflect-metadata": "0.1.13", | ||
"shell-quote": "^1.8.2" | ||
}, |
Package | Version | Security advisories |
shell-quote (npm) | 1.8.2 | None |
What does this PR do?
Fixes devfile API tests on airgap cluster.
Screenshot/screencast of this PR
What issues does this PR fix or reference?
https://issues.redhat.com/browse/CRW-8247
How to test this PR?
PR Checklist
As the author of this Pull Request I made sure that:
What issues does this PR fix or reference
andHow to test this PR
completedReviewers
Reviewers, please comment how you tested the PR when approving it.