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

Use of single quotes causes unexpected behaviour in bigip_command #1018

Open
alex-harvey-z3q opened this issue Oct 6, 2024 · 3 comments
Open
Labels
Backlog issue will be tracked by JIRA in backlog bug

Comments

@alex-harvey-z3q
Copy link

Environment

  • TMOS/Bigip Version: n/a
  • Terraform Version: 1.9.3
  • Terraform bigip provider Version: master branch

Summary

Use of single quotes in the bigip_command resource cause unexpected behaviour. For example:

resource "bigip_command" "hello-world" {
  commands = ["bash -c 'echo hello world'"]
}

output "tmsh-test-result" {
  description = "Test"
  value       = bigip_command.hello-world.command_result
}

Steps To Reproduce

resource "bigip_command" "hello-world" {
  commands = ["bash -c 'echo hello world'"]
}

output "tmsh-test-result" {
  description = "Test"
  value       = bigip_command.hello-world.command_result
}

Expected Behavior

The result should contain hello world.

Actual Behavior

The result is an empty string.

@alex-harvey-z3q
Copy link
Author

The root cause appears to be unsafe quoting here

commandList = append(commandList, fmt.Sprintf("-c 'tmsh %s'", cmd.(string)))

The possibility that the string itself contains a single quote does not appear to be handled leading to our issue.

@alex-harvey-z3q
Copy link
Author

I assume that if the input contained only 1 single quote you'd end up with a syntax error but I haven't tested.

@pgouband
Copy link
Collaborator

pgouband commented Oct 7, 2024

Hi,

Thanks for reporting. Added to the backlog and internal tracking ID for this request is: INFRAANO-1675.

@pgouband pgouband added the Backlog issue will be tracked by JIRA in backlog label Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backlog issue will be tracked by JIRA in backlog bug
Projects
None yet
Development

No branches or pull requests

2 participants