shisho icon indicating copy to clipboard operation
shisho copied to clipboard

`be-any-of` Pattern Issue

Open y-matsutomo opened this issue 3 years ago • 1 comments

Description of the bug

be-any-of constraint in HCL does not recognize the strings properly.

Steps to Reproduce

target code

resource "google_container_cluster" "bad_example" {
  logging_service = "none"
}

rule

version: '1'
rules:
  - id: 'example'
    title: example
    language: hcl
    patterns:
      - pattern: |
          resource  "google_container_cluster" :[NAME] {
            example_service = :[SETTINGS]
          }
        constraints:
          - target: SETTINGS
            should: be-any-of 
            strings:
              - "none"
              - "example.com"
    rewrite: |
      resource "google_container_cluster" :[NAME] {
        example_service = "example-service"
      }

Expected Behaviour

The pattern should match but it does not.

Additional Materials

N/A

y-matsutomo avatar Oct 25 '21 06:10 y-matsutomo

It works well by writing as follows:

            strings:
              - '"none"'
              - '"example.com"'

marina-ki avatar Jan 18 '22 02:01 marina-ki