Skip to content

[Bug]: Missing quotes in opt/hoop/bin/kubectl #1234

@LucVidal360

Description

@LucVidal360

Bug Description

When I execute a kubectl command from a runbook, with spaces in its arguments, it fails with errors.

This comes from the the /opt/hoop/bin/kubectl shell wrapper, which calls the kubectl binary with $@ instead of "$@"

Steps to Reproduce

  • connect to a connection configured to start a shell on the hoop-agent
  • execute kubectl get pods -n namespace --selector "app.kubernetes.io/name=podname" --field-selector status.phase=Running --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}'

Note that there's a space the in the template value.

Expected Behavior

The kubectl command should return with a pod name.

Actual Behavior

The kubectl command fails with the error
error: name cannot be provided when a selector is specified

Version

1.47.2

Browser(s)

Other

Operating System

Ubuntu 24.04

Screenshots

No response

Additional Context

In

if [[ -z "$HEADER_AUTHORIZATION" ]]; then
/usr/local/bin/kubectl $@
exit $?
fi

  • The line /usr/local/bin/kubectl $@
  • should rather be: /usr/local/bin/kubectl "$@"

Likewise,

/usr/local/bin/kubectl --server="$REMOTE_URL" --insecure-skip-tls-verify=$INSECURE --token="$HEADER_AUTHORIZATION" $@

should be
/usr/local/bin/kubectl --server="$REMOTE_URL" --insecure-skip-tls-verify=$INSECURE --token="$HEADER_AUTHORIZATION" "$@"

Relevant Log Output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions