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>
80 lines
2.1 KiB
YAML
80 lines
2.1 KiB
YAML
# Copyright (c) Microsoft Corporation.
|
|
# Licensed under the MIT License.
|
|
|
|
cases:
|
|
- note: basic string formatting with spaces
|
|
data: {}
|
|
modules:
|
|
- |
|
|
package test
|
|
|
|
test1 := sprintf("User %s from %s has access", ["alice", "engineering"])
|
|
test2 := sprintf("A %s B %s C", ["X", "Y"])
|
|
test3 := sprintf("No spaces%s%s", ["A", "B"])
|
|
test4 := sprintf("Single %s", ["word"])
|
|
test5 := sprintf("Start %s end", ["middle"])
|
|
query: data.test
|
|
want_result:
|
|
test1: "User alice from engineering has access"
|
|
test2: "A X B Y C"
|
|
test3: "No spacesAB"
|
|
test4: "Single word"
|
|
test5: "Start middle end"
|
|
|
|
- note: numeric formatting
|
|
data: {}
|
|
modules:
|
|
- |
|
|
package test
|
|
|
|
decimal := sprintf("Number: %d", [42])
|
|
float := sprintf("Float: %f", [3.14])
|
|
hex := sprintf("Hex: %x", [255])
|
|
octal := sprintf("Octal: %o", [64])
|
|
binary := sprintf("Binary: %b", [15])
|
|
query: data.test
|
|
want_result:
|
|
decimal: "Number: 42"
|
|
float: "Float: 3.14"
|
|
hex: "Hex: ff"
|
|
octal: "Octal: 0O100"
|
|
binary: "Binary: 1111"
|
|
|
|
- note: mixed types and escaping
|
|
data: {}
|
|
modules:
|
|
- |
|
|
package test
|
|
|
|
mixed := sprintf("String: %s, Number: %d, Percent: %%", ["hello", 123])
|
|
verbose := sprintf("Value: %v", [{"key": "value"}])
|
|
query: data.test
|
|
want_result:
|
|
mixed: "String: hello, Number: 123, Percent: %"
|
|
verbose: "Value: {\"key\": \"value\"}"
|
|
|
|
- note: width formatting
|
|
data: {}
|
|
modules:
|
|
- |
|
|
package test
|
|
|
|
padded := sprintf("Padded: %5d", [42])
|
|
zero_padded := sprintf("Zero padded: %05d", [42])
|
|
decimal_places := sprintf("Decimal: %.2f", [3.14159])
|
|
query: data.test
|
|
want_result:
|
|
padded: "Padded: 42"
|
|
zero_padded: "Zero padded: 00042"
|
|
decimal_places: "Decimal: 3.14"
|
|
|
|
- note: error cases
|
|
data: {}
|
|
modules:
|
|
- |
|
|
package test
|
|
|
|
# This should cause an error - missing argument
|
|
error_case := sprintf("Value: %s %d", ["only_one"])
|
|
query: data.test
|
|
error: "no argument specified for format verb 1" |