Extend Condition DSL with Contains and Like operators (with member-access enumeration)#252
Conversation
…ition DSL Co-authored-by: ntt-matthias-fleschuetz <55826276+ntt-matthias-fleschuetz@users.noreply.github.com>
Co-authored-by: ntt-matthias-fleschuetz <55826276+ntt-matthias-fleschuetz@users.noreply.github.com>
… operators Co-authored-by: ntt-matthias-fleschuetz <55826276+ntt-matthias-fleschuetz@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Extends IdLE’s Condition/Precondition DSL to cover common JML gating scenarios by adding list membership (Contains/NotContains) and wildcard matching (Like/NotLike) operators, with accompanying schema validation, tests, and documentation updates.
Changes:
- Added schema validation for
Contains,NotContains,Like, andNotLikeoperator shapes. - Implemented evaluator semantics for list/scalar handling and case-insensitive comparisons/pattern matching.
- Updated documentation and adjusted tooling/provider scripts to satisfy PSSA/CI requirements.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/Generate-IdleStepReference.ps1 | Renames helper to an approved verb and adjusts formatting/indentation. |
| tests/Core/Test-IdleCondition.Tests.ps1 | Adds schema + evaluator tests for the new operators and edge cases. |
| src/IdLE.Provider.EntraID/Private/New-IdleEntraIDAdapter.ps1 | Indentation-only change to satisfy consistent indentation checks. |
| src/IdLE.Core/Private/Test-IdleConditionSchema.ps1 | Extends condition schema validation to recognize and validate new operators. |
| src/IdLE.Core/Private/Test-IdleCondition.ps1 | Adds runtime evaluation logic for Contains/NotContains/Like/NotLike. |
| docs/use/workflows/conditions.md | Documents new operators, semantics table, troubleshooting, and examples. |
Co-authored-by: ntt-matthias-fleschuetz <55826276+ntt-matthias-fleschuetz@users.noreply.github.com>
891e854 to
b80ff9c
Compare
Code Coverage Report
|
ntt-matthias-fleschuetz
left a comment
There was a problem hiding this comment.
@copilot I am not sure if the list handling is really supporting how contextresolver for e.g. for entitlements are writing to Request.Context.Identity.Entitlements
As I understand, Entitlements is a list and each entry has different properties (e.g. Id, DisplayName), depending on the provider used. So Request.Context.Identity.Entitlements never contains something that can be evaluated by some Contains / NotContains
Value = 'CN=BreakGlass-Users,OU=Groups,DC=example,DC=com' or am I mistaken? I assume same for Like / NotLike as the pattern may apply to one field we do not determine? Technically, the path to the fields that may contain this is Request.Context.Identity.Entitlements[].DisplayName` or similar, while [] is hard to resolve.
How is it handling this at the moment and can we achieve the original use case for groups at all with current implementation?
You're absolutely correct. The current implementation has a critical flaw: The Problem:
Current Behavior: Required Fix: Next Steps: |
Co-authored-by: ntt-matthias-fleschuetz <55826276+ntt-matthias-fleschuetz@users.noreply.github.com>
Co-authored-by: ntt-matthias-fleschuetz <55826276+ntt-matthias-fleschuetz@users.noreply.github.com>
ntt-matthias-fleschuetz
left a comment
There was a problem hiding this comment.
@copilot an additional problem is that we cannot check what is exactly written by context resolve when its a list. Template Substitution for EmitEvents do not support any non-scalar values. We need a way that an admin in workflow definition can find out what is exactly written to the context path elements.
You're right - inspecting resolved context data is crucial. Here's how admins can discover the structure: Option 1: Use the plan object in tests/scripts $plan = New-IdlePlan -WorkflowPath ./workflow.psd1 -Request $req -Providers $providers
$plan.Request.Context.Identity.Entitlements | ConvertTo-Json -Depth 3Option 2: Add a debug EmitEvent step @{
Name = 'Debug: Show Entitlements'
Type = 'IdLE.Step.EmitEvent'
With = @{
Message = 'Entitlement count: {{Request.Context.Identity.Entitlements.Count}}'
}
}(Note: Recommended Documentation Enhancement: The member-access enumeration fix (commits 521fdfe, d5c66a7) enables the original use cases once admins know to use |
Co-authored-by: ntt-matthias-fleschuetz <55826276+ntt-matthias-fleschuetz@users.noreply.github.com>
Adds list membership and wildcard pattern matching to the Condition/Precondition DSL. Common enterprise JML scenarios (group membership guards, contractor checks, pattern-based exclusions) previously required host-side workarounds.
Operators
Contains / NotContains
Like / NotLike
Implementation
Test-IdleConditionSchema.ps1- Added operator shape validation (Path+Value / Path+Pattern)Test-IdleCondition.ps1- Implements case-insensitive list/scalar semantics with explicit hashtable rejectionGet-IdlePropertyValue.ps1- Enhanced to support property extraction from array items (e.g.,Entitlements.Idreturns array of all Id values)conditions.md,context-resolver.md, andcapabilities.mdupdated with operator reference, member-access enumeration explanation, semantics table, corrected path syntax, and troubleshooting guidance for inspecting resolved context dataMember-Access Enumeration
A critical enhancement to support real-world provider data: entitlements are objects with
Kind,Id, andDisplayNameproperties, not simple strings.The path resolver now supports PowerShell-style member-access enumeration:
Request.Context.Identity.Entitlements→ array of entitlement objectsRequest.Context.Identity.Entitlements.Id→ array of all Id valuesRequest.Context.Identity.Entitlements.DisplayName→ array of all DisplayName valuesThis enables the documented use cases to work with realistic provider output.
Discoverability and Troubleshooting
Added comprehensive guidance for workflow authors to inspect resolved context data:
context-resolver.mdshowing three methods to inspect context structure:ConvertTo-Json -Depth 5for full structure inspectionFormat-Table -AutoSizefor quick tabular viewGet-Memberfor property discoveryThis addresses the challenge of discovering what data structure is written by context resolvers, enabling admins to determine the correct path syntax for Conditions.
Additional Changes
Fixed PSSA warnings per CI mode requirements:
Ensure-IdleBlankLineBeforeMarkdownLists→Add-IdleBlankLineBeforeMarkdownListsGenerate-IdleStepReference.ps1,New-IdleEntraIDAdapter.ps1Backward Compatibility
Pure additive extension. Existing workflows unchanged. Member-access enumeration is transparent for paths that don't use it.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.