zscaler / zscaler-terraformer

CLI tool to generate terraform files from existing ZPA and ZIA
https://github.com/zscaler/zscaler-terraformer
MIT License
13 stars 0 forks source link

DLP Templates that have a variable in them like ${NAME} need to be properly escaped in the TF Files #208

Closed eReyesZscaler closed 3 months ago

eReyesZscaler commented 4 months ago

Confirmation

zscaler-terraformer version

zscaler-terraformer v1.2.2 Terraform version: Terraform v1.5.7

Expected outcome

Running terraform plan when there's variables as text in the notification templates errors, since they aren't escaped.

Actual outcome

Terraform commands fail:
 on zia_dlp_notification_templates.tf line 4, in resource "zia_dlp_notification_templates" "resource_zia_dlp_notification_templates_3671":
│    4:   html_message       = "<!DOCTYPE html>\n<html>\n\t<head>\n\t\t<style>\n\t\t\t.user {color: rgb(1, 81, 152);}\n\t\t\t.url {color: rgb(1, 81, 152);}\n\t\t\t.postingtype {color: rgb(1, 81, 152);}\n\t\t\t.engines {color: rgb(1, 81, 152);}\n\t\t\t.dictionaries {color: rgb(1, 81, 152);}\n\t\t</style>\n\t</head>\n\t<body>\n\t\tThe attached content triggered a Web DLP rule for your organization.\n\t\t<br/><br/>\n\t\tTransaction ID: <span class=\"transaction_id\">${TRANSACTION_ID}</span>\n\t\t<br/>\n\t\tUser Accessing the URL: <span class=\"user\">${USER}</span>\n\t\t<br/>\n\t\tURL Accessed: <span class=\"url\">${URL}</span>\n\t\t<br/>\n\t\tPosting Type: <span class=\"postingtype\">${TYPE}</span>\n\t\t<br/>\n\t\tDLP MD5: <span class=\"dlpmd5\">${DLPMD5}</span>\n\t\t<br/>\n\t\tTriggered DLP Violation Engines (assigned to the hit rule): <span class=\"engines\">${ENGINES_IN_RULE}</span>\n\t\t<br/>\n\t\tTriggered DLP Violation Dictionaries (assigned to the hit rule): <span class=\"dictionaries\">${DICTIONARIES}</span>\n\t\t<br/><br/>\n\t\tNo action is required on your part.\n\t\t<br/><br/>\n\t</body>\n</html>"
│
│ A reference to a resource type must be followed by at least one attribute access, specifying the resource name.
╵
╷
│ Error: Invalid reference

Steps to reproduce

TF Files like this:


# __generated__ by Zscaler Terraformer from Default DLP
resource "zia_dlp_notification_templates" "resource_zia_dlp_notification_templates_3671" {
  attach_content     = true
  html_message       = "<!DOCTYPE html>\n<html>\n\t<head>\n\t\t<style>\n\t\t\t.user {color: rgb(1, 81, 152);}\n\t\t\t.url {color: rgb(1, 81, 152);}\n\t\t\t.postingtype {color: rgb(1, 81, 152);}\n\t\t\t.engines {color: rgb(1, 81, 152);}\n\t\t\t.dictionaries {color: rgb(1, 81, 152);}\n\t\t</style>\n\t</head>\n\t<body>\n\t\tThe attached content triggered a Web DLP rule for your organization.\n\t\t<br/><br/>\n\t\tTransaction ID: <span class=\"transaction_id\">$${TRANSACTION_ID}</span>\n\t\t<br/>\n\t\tUser Accessing the URL: <span class=\"user\">$${USER}</span>\n\t\t<br/>\n\t\tURL Accessed: <span class=\"url\">$${URL}</span>\n\t\t<br/>\n\t\tPosting Type: <span class=\"postingtype\">$${TYPE}</span>\n\t\t<br/>\n\t\tDLP MD5: <span class=\"dlpmd5\">$${DLPMD5}</span>\n\t\t<br/>\n\t\tTriggered DLP Violation Engines (assigned to the hit rule): <span class=\"engines\">${ENGINES_IN_RULE}</span>\n\t\t<br/>\n\t\tTriggered DLP Violation Dictionaries (assigned to the hit rule): <span class=\"dictionaries\">${DICTIONARIES}</span>\n\t\t<br/><br/>\n\t\tNo action is required on your part.\n\t\t<br/><br/>\n\t</body>\n</html>"
  name               = "Default DLP"
  plain_text_message = "The attached content triggered a Web DLP rule for your organization.\n\nTransaction ID: $${TRANSACTION_ID}\nUser Accessing the URL: $${USER}\nURL Accessed: $${URL}\nPosting Type: $${TYPE}\nDLP MD5: $${DLPMD5}\nTriggered DLP Violation Engines (assigned to the hit rule): $${ENGINES_IN_RULE}\nTriggered DLP Violation Dictionaries (assigned to the hit rule): $${DICTIONARIES}\n\nNo action is required on your part."
  subject            = "DLP Violation: $${TRANSACTION_ID} $${RULENAME}"
  tls_enabled        = true
}

Fail, the ${VARIABLES} need to be escaped $${VARIABLES} or terraform errors on them.

References

No response

willguibr commented 3 months ago

Issue has been address in the latest version v1.3.0. Zscaler DevRel