-
Notifications
You must be signed in to change notification settings - Fork 34
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
Preventing CLI command injection in a debug mode #194
Merged
openshift-merge-robot
merged 1 commit into
openstack-k8s-operators:main
from
jpodivin:debug-notice
Jul 31, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
tests/kuttl/tests/run_simple_playbook_debug_cmdline/01-assert.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# | ||
# Check for: | ||
# | ||
# - 1 OpenStackAnsibleEE CR | ||
# - 1 Ansibleee-play pod | ||
# - 1 Ansibleee-play job | ||
# - Correct output from ansible play | ||
# | ||
apiVersion: ansibleee.openstack.org/v1alpha1 | ||
kind: OpenStackAnsibleEE | ||
metadata: | ||
name: ansibleee-play-debug | ||
namespace: openstack | ||
spec: | ||
image: quay.io/openstack-k8s-operators/openstack-ansibleee-runner:latest | ||
name: openstackansibleee | ||
play: | | ||
- name: Print hello world | ||
hosts: localhost | ||
tasks: | ||
- name: Using debug statement | ||
ansible.builtin.debug: | ||
msg: "Hello, world this is ansibleee-play-debug.yaml" | ||
debug: true | ||
status: | ||
JobStatus: Running | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
generateName: ansibleee-play-debug- | ||
namespace: openstack | ||
labels: | ||
job-name: ansibleee-play-debug | ||
status: | ||
phase: Running | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
labels: | ||
app: openstackansibleee | ||
job-name: ansibleee-play-debug | ||
name: ansibleee-play-debug | ||
namespace: openstack | ||
--- | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
namespaced: true | ||
commands: | ||
- script: | | ||
pod=$(oc get pods -n openstack -l app=openstackansibleee,job-name=ansibleee-play-debug -o name) | ||
description=$(oc describe -n openstack "$pod") | ||
playbook_present=$(echo "$description" | grep 'Hello, world this is ansibleee-play-debug.yaml') | ||
cmdline_present=$(echo "$description" | grep 'Hello, world this is ansibleee-play-debug.yaml') | ||
echo Pod name: $pod | ||
echo Description: $description | ||
if [ -n "$playbook_present" ]; then | ||
exit 0 | ||
else | ||
exit 1 | ||
fi | ||
if [ -z "$cmdline_present" ]; then | ||
exit 1 | ||
else | ||
exit 0 | ||
fi |
16 changes: 16 additions & 0 deletions
16
tests/kuttl/tests/run_simple_playbook_debug_cmdline/01-run-debug.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: ansibleee.openstack.org/v1alpha1 | ||
kind: OpenStackAnsibleEE | ||
metadata: | ||
name: ansibleee-play-debug | ||
namespace: openstack | ||
spec: | ||
image: quay.io/openstack-k8s-operators/openstack-ansibleee-runner:latest | ||
play: | | ||
- name: Print hello world | ||
hosts: localhost | ||
tasks: | ||
- name: Using debug statement | ||
ansible.builtin.debug: | ||
msg: "Hello, world this is ansibleee-play-debug.yaml" | ||
debug: true | ||
cmdLine: "echo This shouldn't be printed." |
6 changes: 6 additions & 0 deletions
6
tests/kuttl/tests/run_simple_playbook_debug_cmdline/02-cleanup.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
delete: | ||
- apiVersion: ansibleee.openstack.org/v1alpha1 | ||
kind: OpenStackAnsibleEE | ||
name: ansibleee-play-debug |
23 changes: 23 additions & 0 deletions
23
tests/kuttl/tests/run_simple_playbook_debug_cmdline/02-errors.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# | ||
# Check for: | ||
# | ||
# - No Ansibleee-play pod | ||
# - No Ansibleee-play job | ||
# | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
generateName: ansible-play- | ||
labels: | ||
app: openstackansibleee-debug | ||
job-name: ansibleee-play-debug | ||
namespace: openstack | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
labels: | ||
app: openstackansibleee-debug | ||
job-name: ansibleee-play-debug | ||
name: ansibleee-play-debug | ||
namespace: openstack |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nice!