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

[Bug] kyverno-json documentation seems incorrect re: wildcards and validate property #342

Open
1 task done
menzenski opened this issue Mar 22, 2024 · 2 comments
Open
1 task done
Labels
bug Something isn't working good first issue Good for newcomers triage Default label assigned to all new issues indicating label curation is needed to fully organize.

Comments

@menzenski
Copy link

Kyverno JSON Version

0.1.0

Description

I am on version 0.0.2, which I can't select in the bug issue form version selector (I installed via Homebrew, and the only version available there is 0.0.2)

The kyverno-json documentation includes an example ValidatingPolicy that uses validate with a wildcard ?*:

apiVersion: json.kyverno.io/v1alpha1
kind: ValidatingPolicy
metadata:
  name: required-s3-tags
spec:
  rules:
    - name: require-team-tag
      identifier: address
      match:
        any:
        - type: aws_s3_bucket
      exclude:
        any:
        - name: bypass-me
      validate:
        assert:
          all:
          - values:
              tags:
                Team: ?*

However, this doesn't work. In the Kyverno playground an attempt to use this policy just returns {"results": null}. On the command line there is an error thrown:

$ kyverno-json scan --payload my_payload.yaml --policy required_s3_tags.yaml
Loading policies ...
Error: failed to parse document (spec.rules[0].validate: Invalid value: value provided for unknown field)

Steps to reproduce

  1. Define policy with the YAML example from the documentation:
cat <<EOF > test_policy.yaml
apiVersion: json.kyverno.io/v1alpha1
kind: ValidatingPolicy
metadata:
  name: required-s3-tags
spec:
  rules:
    - name: require-team-tag
      identifier: address
      match:
        any:
        - type: aws_s3_bucket
      exclude:
        any:
        - name: bypass-me
      validate:
        assert:
          all:
          - values:
              tags:
                Team: ?*
EOF
  1. Invoke kyverno-json using that policy:
$ kyverno-json scan --policy test_policy.yaml

This throws an error:

$ kyverno-json scan --policy test_policy.yaml
Loading policies ...
Error: failed to parse document (spec.rules[0].validate: Invalid value: value provided for unknown field)

Expected behavior

I had expected that the examples provided in the documentation would work.

Screenshots

No response

Logs

No response

Slack discussion

No response

Troubleshooting

  • I have searched other issues in this repository and mine is not recorded.
@menzenski menzenski added bug Something isn't working triage Default label assigned to all new issues indicating label curation is needed to fully organize. labels Mar 22, 2024
@menzenski
Copy link
Author

Many of the examples on https://kyverno.github.io/kyverno-json/latest/policies/asserts/#assert also contain the validate property. These seem to exhibit the same error.

For example:

apiVersion: json.kyverno.io/v1alpha1
kind: ValidatingPolicy
metadata:
  name: test
spec:
  rules:
    - name: foo-bar-4
      validate:
        assert:
          all:
          - message: "..."
            check:
              # project field `foo` onto itself, the content of `foo` becomes the current object for descendants
              foo:

                # evaluate expression `(bar > `3`)`, the boolean result becomes the current object for descendants
                # the `true` leaf is compared with the current value `true`
                (bar > `3`): true

                # evaluate expression `(!baz)`, the boolean result becomes the current object for descendants
                # the leaf `false` is compared with the current value `false`
                (!baz): false

                # evaluate expression `(bar + bat)`, the numeric result becomes the current object for descendants
                # the leaf `10` is compared with the current value `10`
                (bar + bat): 10
$ kyverno-json scan --policy test_policy_2.yaml
Loading policies ...
Error: failed to parse document (spec.rules[0].validate: Invalid value: value provided for unknown field)

@menzenski menzenski changed the title [Bug] kyverno-documentation seems incorrect re: wildcards [Bug] kyverno-documentation seems incorrect re: wildcards and validate property Mar 22, 2024
@menzenski menzenski changed the title [Bug] kyverno-documentation seems incorrect re: wildcards and validate property [Bug] kyverno-json documentation seems incorrect re: wildcards and validate property Mar 22, 2024
@eddycharly
Copy link
Member

Hmm, thanks for reporting !

Will check that next week.

@JimBugwadia JimBugwadia added the good first issue Good for newcomers label Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers triage Default label assigned to all new issues indicating label curation is needed to fully organize.
Projects
Status: No status
Development

No branches or pull requests

3 participants