mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
* feat: Add Schema Registry and Validation Framework This commit introduces a comprehensive schema registry and validation framework, providing schema-based validation of resources and policy effects. - Thread-safe, in-memory registry for schema storage and management - Global registry patterns for effects and resources - Concurrent access with proper error handling - Unicode schema names support - JSON Schema-compliant validation for all primitive types - Advanced constraint validation (patterns, ranges, length limits) - Discriminated union support with anyOf schemas - Detailed error reporting with nested validation paths - Discriminated subobject validation for polymorphic schemas - **Registry Tests**: All registry operations - **Effect Tests**: Policy effect validation - **Resource Tests**: Resource validation - **Validation Tests**: Core validation engine - Thread-safety, error handling, integration scenarios, edge cases - **Dependencies**: dashmap, once_cell, regex - **Thread Safety**: Minimal locking with Rc<Schema> sharing - **Error Types**: TypeMismatch, OutOfRange, PatternMismatch, etc. - Complete schema registry and validation subsystem - Comprehensive test coverage - Foundation for policy validation in Regorus Benchmarks: - Criterion benchmarks for basic types, effects and Azure resources - Performance range: 3.22ns (string) to 34.74µs (Azure VM resource schema validation) - String withs patterns validation: 30.2µs. Need to explore whether regex caching helps bring this down. - Azure policy effects: 188ns-1.4µs Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com> * feat: Complete target system with C# bindings and resource inference - Add comprehensive target system with TargetRegistry and target-aware compilation - Implement resource type inference from policy equality expressions - Create modular C# bindings with separate wrapper classes for each concept - Add thread-safe CompiledPolicy with reference counting for safe disposal - Enhance FFI with detailed error propagation and target functionality - Create TargetExampleApp demonstrating Azure Policy integration - Add CI/CD pipeline testing for all C# applications - Support target definitions with schema validation and resource selectors - Implement PolicyModule struct and target-aware compilation methods - Add comprehensive test coverage for target functionality Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com> --------- Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
84 lines
2.2 KiB
YAML
84 lines
2.2 KiB
YAML
cases:
|
|
- note: "Microsoft Graph User Access Control - Allow Active User"
|
|
data: {}
|
|
input:
|
|
"@odata.type": "#microsoft.graph.user"
|
|
id: "12345678-1234-1234-1234-123456789012"
|
|
userPrincipalName: "john.doe@company.com"
|
|
displayName: "John Doe"
|
|
givenName: "John"
|
|
surname: "Doe"
|
|
mail: "john.doe@company.com"
|
|
jobTitle: "Software Engineer"
|
|
department: "Engineering"
|
|
accountEnabled: true
|
|
userType: "Member"
|
|
modules:
|
|
- |
|
|
package msgraph.user.allow
|
|
|
|
import rego.v1
|
|
|
|
__target__ := "target.tests.msgraph"
|
|
|
|
default allow := false
|
|
|
|
allow if {
|
|
input["@odata.type"] == "#microsoft.graph.user"
|
|
input.accountEnabled == true
|
|
input.userType == "Member"
|
|
}
|
|
query: data.msgraph.user.allow.allow
|
|
want_result: true
|
|
|
|
- note: "Microsoft Graph User Access Control - Block Disabled User"
|
|
data: {}
|
|
input:
|
|
"@odata.type": "#microsoft.graph.user"
|
|
id: "87654321-4321-4321-4321-210987654321"
|
|
userPrincipalName: "disabled.user@company.com"
|
|
displayName: "Disabled User"
|
|
accountEnabled: false
|
|
userType: "Member"
|
|
modules:
|
|
- |
|
|
package msgraph.user.block
|
|
|
|
import rego.v1
|
|
|
|
__target__ := "target.tests.msgraph"
|
|
|
|
block := {
|
|
"reason": "User account is disabled",
|
|
"blockType": "signin"
|
|
} if {
|
|
input["@odata.type"] == "#microsoft.graph.user"
|
|
input.accountEnabled == false
|
|
}
|
|
query: data.msgraph.user.block.block
|
|
want_result:
|
|
reason: "User account is disabled"
|
|
blockType: "signin"
|
|
|
|
- note: "Microsoft Graph Invalid Resource Type"
|
|
data: {}
|
|
input:
|
|
"@odata.type": "#microsoft.graph.unknownResource"
|
|
id: "test"
|
|
modules:
|
|
- |
|
|
package msgraph.invalid
|
|
|
|
import rego.v1
|
|
|
|
__target__ := "target.tests.msgraph"
|
|
|
|
default allow := false
|
|
|
|
allow if {
|
|
input["@odata.type"] == "#microsoft.graph.user"
|
|
input.accountEnabled == true
|
|
}
|
|
query: data.msgraph.invalid.allow
|
|
want_result: false
|