feat: support generic entity instance in selectors#6321
feat: support generic entity instance in selectors#6321evankanderson merged 5 commits intomindersec:mainfrom
Conversation
Fixes mindersec#5380 Supports dynamically creating CEL environments and exposing properties for unmapped entities (like Release or Build). This fully unblocks entity evaluators that were previously returning nil for unsupported entity types, utilizing the generic Property structures instead. Signed-off-by: Your Name <your.email@example.com> Signed-off-by: jaydeep869 <jaydeeppokhariya2106@gmail.com>
ad7aa8d to
7f3fec4
Compare
|
(will look tomorrow, it's getting late) |
evankanderson
left a comment
There was a problem hiding this comment.
Does this need some manual integration testing to ensure that the selector actually works in a Profile?
@evankanderson There is an automated integration test in |
Signed-off-by: jaydeep869 <jaydeeppokhariya2106@gmail.com>
a081a13 to
8c76b91
Compare
Generally, for changes that are intended to be user-visible, it's a good idea to run a manual test of the functionality unless there's a non-mocked integration test (I often use |
|
Additionally, doing a manual check can help with getting examples to update documentation. 😁 |
|
@evankanderson I just ran through a manual end to end check using a local Minder instance. I created a profile with a release selector using the CLI, and the API accepted it perfectly. The engine evaluation worked correctly without any plumbing layers or client filters getting in the way. Taking your advice, I've also just pushed a small documentation update to |
Summary
This PR adds complete support for generic entity instances within selectors.
Previously, if a selector was added to an unmapped entity (like
releaseorbuild), the evaluation failed with aNo converter availableerror becausenewConverterinselector_entity.gorelied on a strict switch statement covering onlyrepository,artifact, andpull_request. While PR #5379 introduced the generic environment fallback,newConverterstill returnednilfor unsupported entities.This change introduces a
genericToSelectorEntityfallback in the converter factory, populating a newSelectorGenericprotobuf message that dynamically exposes all the entity properties. This ensures that properties for generalized entities correctly pipe into CEL environments without breaking.Fixes #5380
Testing
SelectorGenerictointernal/proto/internal.protoand regenerated the protobuf definitions usingmake buf."Generic Entity Type"test case ininternal/providers/selectors/selector_entity_test.goto ensure unmapped objects successfully populate their properties map through the generic constructor."Simple true generic release expression"inpkg/engine/selectors/selectors_test.goto verify that CEL expressions correctly evaluate fields on generic entities (e.g.,generic.name == 'testorg/testrelease').make testlocally to confirm all suite assertions pass successfully.make lintandgo fmtto ensure compliance with styling guidelines.