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] volatileConfig exclude statements cannot tolerate multiple references to the same rule #423

Open
ralphbean opened this issue Oct 31, 2024 · 3 comments · May be fixed by #428
Open
Assignees
Labels
bug Something isn't working

Comments

@ralphbean
Copy link

Describe the Bug

If you specify more than one exclude entry with an imageRef for the same rule (but with different imageRefs), then EC fails, calling it invalid when I try to apply it to my cluster.

Steps to Reproduce

Construct an policy with the following volatileConfig:

volatileConfig:
  exclude:
    - value: cve.cve_blockers
      imageRef: sha256:d363597a0a7d555e16bec72095cd1a928d081ddd6f3764883f128525fd4fe226
    - value: cve.cve_blockers
      imageRef: sha256:b993ec75adad17dcccf49b67d985bdc23b70e1a6a2c4858241fec2a49b8b5902
    - value: cve.cve_blockers
      imageRef: sha256:5cfc89651593af9a84f9a852aae9775884a6ee0551f0e84f03d5c11f93ef30b5

Expected Behavior

You can successfully apply that policy to the cluster and ec cli will process it and it will ignore cve.cve_blockers for those three refs.

Actual Behavior

Applying the resource to the cluster fails with:

The EnterpriseContractPolicy "..." is invalid: spec.sources[0].volatileConfig.exclude[1]: Duplicate value: map[string]interface {}{"value":"cve.cve_blockers"}
``
@ralphbean ralphbean added the bug Something isn't working label Oct 31, 2024
@lcarva lcarva transferred this issue from enterprise-contract/ec-cli Oct 31, 2024
@simonbaird
Copy link
Member

IIUC the schema is generated from the CRD, which might be this?

@simonbaird
Copy link
Member

From @joejstuart in slack:

// +listType:=map
// +listMapKey:=value

It appears that, even though it's a list, the x-kubernetes-list-type: map means the value is used as a map key, therefore it is required to be unique.

@simonbaird
Copy link
Member

listType:=atomic might be the solution.

@zregvart zregvart self-assigned this Nov 14, 2024
zregvart added a commit to zregvart/enterprise-contract-controller that referenced this issue Nov 15, 2024
To fix the `Duplicate value` issue this declares the `volatileConfig`
not to be a map-like type with `value` as (unique) key, but rather a
slice.

Resolves: enterprise-contract#423
@zregvart zregvart linked a pull request Nov 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants