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

[tempest] Fix special chars in TEMPESTCONF_OVERRIDES #212

Conversation

ASBishop
Copy link
Contributor

@ASBishop ASBishop commented Sep 18, 2024

Fix a regression introduced in PR #210 in which strings with special bash characters need to be escaped: cubswin:) has to be cubswin:\). The need to escape some characters breaks existing CI jobs.

This patch fixes the regression so it's not necessary to escape special characters.

Fix a regression introduced in PR openstack-k8s-operators#210 in which strings with special
bash characters need to be escaped: cubswin:) has to be cubswin:\).
The need to escape some characters breaks existing CI jobs.

This patch fixes the regression so it's not necessary to escape
special characters.
$*
EOF
}

Copy link
Contributor

@SeanMooney SeanMooney Sep 18, 2024

Choose a reason for hiding this comment

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

this seam to work as indended

~ via 🐹 v1.20.12 via 🐍 v3.11.9 
[00:41:46]❯ ln -s /bin/echo .local/bin/discover-tempest-config
~ via 🐹 v1.20.12 via 🐍 v3.11.9 
00:41:58]➜ function discover_tempest_config {
    cat <<EOF | xargs discover-tempest-config
$*
EOF
 }
~ via 🐹 v1.20.12 via 🐍 v3.11.9 
[00:42:04]➜ discover_tempest_config test
test
~ via 🐹 v1.20.12 via 🐍 v3.11.9 
[00:42:07]➜ discover_tempest_config test:)
bash: syntax error near unexpected token `)'
~ via 🐹 v1.20.12 via 🐍 v3.11.9 
[00:42:10]❯ data="test:)"
~ via 🐹 v1.20.12 via 🐍 v3.11.9 
[00:42:30]➜ discover_tempest_config ${data}
test:)
~ via 🐹 v1.20.12 via 🐍 v3.11.9 
[00:42:39]➜ data="test :)"
~ via 🐹 v1.20.12 via 🐍 v3.11.9 
[00:42:57]➜ discover_tempest_config ${data}
test :)
~ via 🐹 v1.20.12 via 🐍 v3.11.9

at least if the charters that need to be escapes are in a variable
or they are quoted when being passed to the function directly.

[00:42:58]➜ discover_tempest_config '${data}'
${data}
~ via 🐹 v1.20.12 via 🐍 v3.11.9
[00:42:58]➜ discover_tempest_config '${data}'
${data}
~ via 🐹 v1.20.12 via 🐍 v3.11.9 

interpolation or not of variable in string also works

[00:45:31]❯ data="test; echo do bad thing :("
~ via 🐹 v1.20.12 via 🐍 v3.11.9 
00:47:04]➜ discover_tempest_config "${data}"
test; echo do bad thing :(
~ via 🐹 v1.20.12 via 🐍 v3.11.9 
[00:47:08]➜ discover_tempest_config ${data}
test; echo do bad thing :(

it also prevent basic exploites like adding ; shell injection goes here

not that it nessicaly safe but i think this is safer then eval too.

Copy link

@mrkisaolamb mrkisaolamb left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@lpiwowar lpiwowar left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

Copy link
Collaborator

@rabi rabi left a comment

Choose a reason for hiding this comment

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

/lgtm

Copy link
Contributor

openshift-ci bot commented Sep 19, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ASBishop, bshephar, gibizer, lpiwowar, mrkisaolamb, rabi, SeanMooney

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 3a65137 into openstack-k8s-operators:main Sep 19, 2024
5 checks passed
@ASBishop ASBishop deleted the tempestconf-overrides branch September 19, 2024 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants