fix(ruleset): preserve exclude wildcard semantics - #326
Closed
philipsolo wants to merge 1 commit into
Closed
philipsolo wants to merge 1 commit into
philipsolo wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Wildcard detection must handle commented one-element lists without changing their semantics.
Pull request overview
Updates the cloudflare_ruleset v4-to-v5 transformer to preserve exclude-all wildcard semantics.
Changes:
- Converts
exclude = ["*"]toexclude = { all = true }. - Preserves ordinary, mixed, and dynamic expressions.
- Adds transformation coverage.
File summaries
| File | Summary |
|---|---|
internal/resources/ruleset/v4_to_v5.go |
Adds wildcard conversion for query-string attributes; commented wildcard lists still require structural detection. |
internal/resources/ruleset/v4_to_v5_test.go |
Adds coverage for wildcard, mixed-list, and dynamic-expression behavior. |
Review details
Suppressed comments (1)
internal/resources/ruleset/v4_to_v5.go:331
isWildcardListmatches formatted source against three exact strings. HCL permits comments in a literal tuple, for exampleexclude = [\n # all query parameters\n "*",\n];hclwrite.Formatpreserves that comment, so this returns false and emitsexclude = { list = ["*"] }, retaining the v4/v5 semantic bug. Detect a one-element, known string-valued list structurally while leaving unknown/dynamic expressions unchanged.
func isWildcardList(tokens hclwrite.Tokens) bool {
formatted := string(hclwrite.Format(tokens.Bytes()))
return formatted == "[\"*\"]" || formatted == "[\n \"*\",\n]" || formatted == "[\"*\",]"
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
philipsolo
force-pushed
the
fix/ruleset-exclude-wildcard
branch
from
September 16, 2026 12:34
8ce3712 to
c16b16b
Compare
Collaborator
|
Superceded by: #327 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Updates the cloudflare_ruleset v4-to-v5 transformer to migrate:
exclude = ["*"]to:
Ordinary lists, mixed lists, dynamic expressions, and existing include behavior remain unchanged.
Motivation
Provider v4 uses [""] as the exclude-all sentinel. Migrating it to list = [""] changes its meaning in provider v5 instead of preserving exclude-all behavior.
Related issue: cloudflare/terraform-provider-cloudflare#6087
Fixes #
Type of change
Testing
make test-unit)make test-integration)make lint-testdatapassesChecklist
internal/registry/registry.gocftftestprefix# MIGRATION WARNINGcomments are documented inDIAGNOSTICS.md