F5Networks / terraform-provider-bigip

Terraform resources that can configure F5 BIG-IP products
https://registry.terraform.io/providers/F5Networks/bigip/latest/docs
Mozilla Public License 2.0
105 stars 119 forks source link

Use of single quotes causes unexpected behaviour in bigip_command #1018

Closed alex-harvey-z3q closed 1 month ago

alex-harvey-z3q commented 1 month ago

Environment

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 commented 1 month ago

The root cause appears to be unsafe quoting here https://github.com/F5Networks/terraform-provider-bigip/blob/d1eabd08c61fc53d497f9e39cce82899b026fe88/bigip/resource_bigip_command.go#L64

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

alex-harvey-z3q commented 1 month ago

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 commented 1 month ago

Hi,

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