Skip to content

Release 0.4.4: Cedar CLI integration, hierarchical S3 authorization, and failure mode testing#27

Merged
drernie merged 27 commits intomainfrom
hygiene
Jan 22, 2026
Merged

Release 0.4.4: Cedar CLI integration, hierarchical S3 authorization, and failure mode testing#27
drernie merged 27 commits intomainfrom
hygiene

Conversation

@drernie
Copy link
Member

@drernie drernie commented Jan 20, 2026

Release 0.4.4

Major release featuring Cedar CLI integration, hierarchical S3 authorization, and comprehensive failure mode testing.

Key Features

Cedar CLI Integration

  • Native Rust-based policy compilation with Python fallback
  • Rust cedar-validate tool for parsing and validation
  • CI support for Cedar CLI, Lua, and LuaRocks (Linux + macOS)

Hierarchical S3 Authorization

  • Bucket-level and object-level scope enforcement
  • Template expansion for exact bucket validation
  • Enhanced prefix-based authorization with wildcards
  • Comprehensive scope validation utilities

Failure Mode Testing

Test Utilities

  • Shared token builder (tests/shared/token_builder.py)
  • S3 client helpers (tests/shared/s3_client.py)
  • Consolidated test utilities to reduce duplication

Security Enhancements

  • Fail-closed enforcement with explicit deny for malformed requests
  • Enhanced JWT validation with issuer and expiration checks
  • Stricter scope format validation and wildcard handling

Documentation

  • Cedar/AVP authorization model and PostgreSQL schema
  • RAJEE manifest and integration architecture
  • Comprehensive failure mode analysis and fixes
  • Schema validation specifications (specs/3-schema/)
  • Cedar integration README

Testing

All tests pass:

./poe check  # Format, lint, typecheck
./poe test   # Unit + Lua tests

Migration Notes

  • CI now requires Cedar CLI, Lua, and LuaRocks installation
  • Compiler supports forbid policies and template expansion
  • Enhanced scope validation may reject previously accepted wildcards
  • Control plane endpoints have improved audit logging

See CHANGELOG.md for complete details.

drernie and others added 27 commits January 16, 2026 17:11
- Move RAJA_INTEGRATION_PROOF.md to specs/2-rajee/15-integration-proof.md
- Remove docs/Makefile
- Consolidate all RAJEE-related documentation in specs/2-rajee/

Co-Authored-By: Claude <noreply@anthropic.com>
Implemented priority areas from issue #22 to significantly improve test
coverage across core modules.

## Coverage Improvements

- Overall: 82% → 90% ✅
- control_plane.py router: 63% → 99%
- enforcer.py: 52% → 67%
- scope.py: 73% → 78%
- token.py: 75% → 84%
- server/app.py: 81% → 87%

## New Tests (47 tests added, 105 → 152 total)

### New Test File
- tests/unit/test_control_plane_router.py (20 tests)
  * Comprehensive router endpoint testing
  * Token issuance (RAJA/RAJEE types)
  * Principals CRUD operations
  * Policy listing with/without statements
  * JWKS endpoint
  * Error handling (invalid types, audit failures, missing IDs)

### Enhanced Test Files
- tests/unit/test_enforcer.py (5 new tests)
  * Expired token handling
  * Wrong signature detection
  * Scope validation errors
  * Authorization logging (allow/deny)

- tests/unit/test_scope.py (5 new tests)
  * Empty string handling
  * Missing parts validation
  * Duplicate scope normalization
  * Special characters in components

- tests/unit/test_token.py (3 new tests)
  * Token creation with grants (various configurations)
  * Issuer/audience claim handling
  * Edge case validation

- tests/unit/test_server_app.py (1 new test)
  * S3Resource model validator (key/prefix exclusivity)

## Test Quality Improvements

- All tests follow comprehensive documentation patterns
- Edge cases and error paths now covered
- Fail-closed semantics validated
- Better coverage of exception handling branches

Closes #22

Co-Authored-By: Claude <noreply@anthropic.com>
Changes:
- Delete unused wildcard policies (admin, data_analyst, data_engineer)
- Update RAJEE test policies to remove internal wildcards
- Add spec: hierarchical S3Object/S3Bucket schema design
- Add spec: implementation tasks for prefix matching
- Document versioned operations (GetObjectVersion, etc.)
- Remove Python authorizer endpoint (Lua enforcer is source of truth)

Specs detail:
- Cedar hierarchical syntax: S3Object::"key" in S3Bucket::"bucket"
- Prefix matching convention: trailing "/" or "-"
- No internal "*" wildcards (security violation)
- Support for multipart upload and versioned operations

Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive failure mode analysis identifying validation gaps across:
- Token security (expired, invalid, malformed JWTs)
- Cedar policy compilation (forbid, templates, complex conditions)
- Scope enforcement (prefix matching, special chars, edge cases)
- Request parsing (injection, path traversal, unknown actions)
- Cross-component validation (traceability, policy updates)
- Operational concerns (logging, performance, concurrency)

Identifies 39 specific failure modes with severity ratings and test
scenarios. Provides prioritized recommendations and test coverage matrix.

Purpose: Documentation only - identifies gaps without proposing solutions.

Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive specification for enhancing the RAJA admin interface to
enable interactive testing of all 62 failure modes documented in
03-failure-modes.md.

Key features:
- Six test categories (token security, Cedar compilation, scope enforcement,
  request parsing, cross-component, operational)
- One-click test execution with visual pass/fail feedback
- Progressive disclosure: simple UI with detailed diagnostics on demand
- Test case structure with setup, execution, and validation phases
- Backend API design for test execution and result persistence
- Four implementation phases from MVP to full integration

The spec provides clear guidance for building a zero-config testing harness
that serves as both a development tool and executable documentation of
authorization boundaries.

Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive failure mode testing infrastructure to the admin UI with 33
cataloged test cases across 6 categories: token security, Cedar compilation,
scope enforcement, request parsing, cross-component, and operational.

Core additions:
- failure_tests router with test catalog, execution API, and batch runner
- 6 functional test runners for token security scenarios (expired, invalid
  signature, malformed JWT, missing scopes, claim validation, revocation)
- Category metadata with priority levels (CRITICAL, HIGH, MEDIUM, LOW)
- JSON export functionality for test run history

UI enhancements:
- Category selector with pill-based navigation
- Test cards displaying priority badges, descriptions, and run status
- Individual test execution and category batch execution
- Real-time status updates (PASS/FAIL/NOT_IMPLEMENTED/ERROR)
- Run summary with pass/fail/error/pending counts

API endpoints:
- GET /api/failure-tests/ - list all tests and categories
- GET /api/failure-tests/{test_id} - get test definition
- POST /api/failure-tests/{test_id}/run - execute single test
- POST /api/failure-tests/categories/{category}/run - run category batch

Next: implement remaining 27 test runners and add export/permalink/storage
for long-term run persistence.

Co-Authored-By: Claude <noreply@anthropic.com>
Summary:
- Net reduction: 56 lines of code (152 deleted, 96 added)
- Eliminated token building duplication across 3 files
- Eliminated S3 client setup duplication across 2 files
- Added comprehensive testing documentation

New Shared Utilities (tests/shared/):
- token_builder.py: Fluent API for JWT construction
  - Replaces _build_token() in test_failure_modes.py
  - Replaces _build_token() in failure_tests.py
  - Replaces generate_token() in generate_test_token.py
  - Supports all test scenarios: expired tokens, missing claims, custom headers

- s3_client.py: Unified S3 client for RAJEE Envoy proxy
  - Replaces _create_s3_client_with_rajee_proxy() in test_rajee_envoy_bucket.py
  - Replaces _create_s3_client_with_rajee_proxy() in test_failure_modes.py
  - Consistent configuration across all tests

Documentation:
- tests/README.md: Comprehensive testing architecture guide
  - Explains defense-in-depth testing strategy
  - Documents when to use each test layer
  - Clarifies intentional multi-layer testing vs. code duplication
  - Provides usage examples for shared utilities

Testing Philosophy:
This refactoring maintains the healthy multi-layer testing architecture:
- Unit tests (157): Fast logic validation
- Integration tests (32): AWS deployment validation
- Demo (5): Polished proof-of-concept
- Admin GUI (6/31): Interactive exploration

Each layer serves a distinct purpose and catches different bug classes.
The only true duplication was in utility code, now consolidated.

Verification:
- All 157 unit tests pass
- Code quality checks pass (ruff format + lint)
- No functionality removed or changed

Co-Authored-By: Claude <noreply@anthropic.com>
Complete the failure mode testing framework by implementing all 34
remaining test runners across 5 categories:

- Cedar Compilation (2.1-2.7): 7 tests for policy validation
- Scope Enforcement (3.1-3.8): 8 tests for security boundaries
- Request Parsing (4.1-4.5): 5 tests for input validation
- Cross-Component (5.1-5.6): 6 tests for integration consistency
- Operational (6.1-6.7): 7 tests for production readiness

Implementation breakdown:
- 17 functional/passing tests (42.5%)
- 23 NOT_IMPLEMENTED with detailed blockers (57.5%)
- All runners registered in RUNNERS dict
- Consistent error handling and reporting

Key functional tests implemented:
- 3.1-3.4: Critical security tests (prefix, substring, case attacks)
- 4.2-4.3: Request validation and path traversal prevention
- 5.5: JWT claims structure validation
- 6.2, 6.4, 6.6: Operational safeguards

NOT_IMPLEMENTED tests include:
- Cedar Rust tooling integration (2.1-2.7)
- Wildcard scope support (3.5, 3.8)
- Cross-component validation (5.3, 5.4, 5.6)
- Token revocation infrastructure (1.6)
- Operational features (6.1, 6.3, 6.5, 6.7)

Add comprehensive remaining work documentation (08-remaining-work.md):
- Complete status overview of all 40 tests
- 7 major work categories with acceptance criteria
- 3-phase priority roadmap (P0: security, P1: enforcement, P2: ops)
- Cross-references to 06-failure-fixes.md

The admin UI now provides complete visibility into RAJA's authorization
security posture with all 40 test definitions and runners available.

Co-Authored-By: Claude <noreply@anthropic.com>
- Test 2.2: Cedar syntax error detection
  - Tests 6 types of invalid policies (missing semicolon, invalid operators, etc.)
  - Validates that Cedar parser properly rejects malformed policies

- Test 3.6: Multi-scope ordering test
  - Tests 4 authorization requests across 3 different scope orderings
  - Validates that scope evaluation order doesn't affect decisions

- Test 4.4: URL encoding edge cases
  - Added 6 URL encoding tests to Lua test suite
  - Tests %2F, %20, plus signs, double-encoding, unicode, special chars
  - Documents current behavior: paths used as-is (Envoy handles decoding)

- Test 3.5: Wildcard boundary checking
  - Tests 4 wildcard boundary scenarios
  - Documents that explicit wildcard syntax (*) not yet supported
  - Current implementation uses trailing slash for prefix matching

- Updated 08-remaining-work.md: marked scope parsing validation as complete

Co-Authored-By: Claude <noreply@anthropic.com>
This commit implements all 5 phases from specs/3-schema/09-cedar-next.md
and testing requirements from specs/3-schema/05-cedar-testing.md.

Phase 1: Basic Cedar CLI Integration
- Replace regex-based parser with Cedar CLI subprocess
- Add feature flag RAJA_USE_CEDAR_CLI for gradual rollout
- Maintain backward compatibility with legacy parser fallback
- Support custom Cedar binary path via CEDAR_PARSE_BIN

Phase 2: Schema Validation
- Load and validate Cedar schemas
- Validate policies against schema constraints
- Check entity types, actions, and principals
- Validate action-resource compatibility

Phase 3: Forbid Policy Support
- Implement forbid policy compilation and enforcement
- Add scope exclusion logic (deny overrides permit)
- Support multi-principal forbid policies
- Update compiler to handle forbid precedence

Phase 4: Advanced Features
- Wildcard pattern matching (*, prefix, suffix)
- Policy template instantiation with variables
- Scope expansion for resource types and actions
- Action hierarchy support

Phase 5: Testing Infrastructure
- Add 50+ comprehensive test cases across 4 new test files
- Test Cedar CLI integration, schema validation, forbid policies
- Test wildcard patterns and template instantiation
- Full coverage for all Cedar compilation features

Core Changes:
- src/raja/cedar/parser.py: Cedar CLI integration with fallback
- src/raja/cedar/schema.py: Schema validation implementation
- src/raja/compiler.py: Forbid handling and template support
- src/raja/scope.py: Wildcard pattern matching and expansion
- src/raja/models.py: Add policy ID field to CedarPolicy

Tests Added:
- tests/unit/test_cedar_schema_validation.py (13 tests)
- tests/unit/test_compiler_forbid.py (8 tests)
- tests/unit/test_compiler_templates.py (11 tests)
- tests/unit/test_scope_wildcards.py (20 tests)

Documentation:
- CEDAR_INTEGRATION_README.md: Quick start guide
- docs/cedar-cli-integration.md: Complete feature reference
- specs/3-schema/09-cedar-next-IMPLEMENTATION.md: Implementation tracking

This unblocks 7 failure mode tests (2.1-2.7) and brings total test
coverage to 24/40 tests (60%). All changes are backward compatible
with automatic fallback to legacy parser when Cedar CLI unavailable.

Co-Authored-By: Claude <noreply@anthropic.com>
- cedar-quilt.md: Comprehensive spec for Cedar as alternative policy engine
  - Positions Cedar alongside IAM for fine-grained, path-level access control
  - Documents RAJA/RAJ/RAJEE issuer/enforcer split architecture
  - Defines Read and Read/Write action bundles for S3 operations
  - Includes admin UX design for bucket-level permission configuration
  - Clarifies Cedar and IAM coexistence with bypass warning

- cedar-admin.html: V1 mock UI for bucket permissions pane
  - Simple card interface for managing Cedar rules
  - Role, Path, and Access mode configuration
  - Intentionally minimal for initial implementation

Co-Authored-By: Claude <noreply@anthropic.com>
- Install Cedar CLI (cedar-policy-cli) in CI/CD workflows
- Implement Cedar schema validation using cedar check-parse
- Implement Cedar policy validation using cedar validate
- Fix test issues:
  - Add missing id field to CedarPolicy test objects
  - Fix entity format from User::alice to User::"alice"
  - Fix Cedar schema syntax (add semicolons to entity declarations)
- Parse Cedar CLI JSON error output correctly (stdout not stderr)
- All 212 unit tests now passing

Co-Authored-By: Claude <noreply@anthropic.com>
- Add 'from e' to FileNotFoundError exception raise
- Remove unused Path import
- Fix grammar: "reliable" → "reliably" (adverb form)
- Update RAJEE description from STS/pre-signed URLs to transparent Envoy proxy
- Rewrite section 4.5 to accurately describe RAJEE's architecture:
  - Add step-by-step flow showing boto3 → RAJEE → S3 interaction
  - Clarify JWT-based authorization with prefix matching
  - Document key characteristics (S3 compatibility, zero policy evaluation, streaming)
- Update component descriptions to mention transparent proxy consistently
- Improve clarity: "RAJEE only does" → "RAJEE performs only"
- Be more specific: "database calls" → "DynamoDB lookups"

Co-Authored-By: Claude <noreply@anthropic.com>
- macOS: Install luarocks separately (not bundled with lua)
- test_all.sh: Always fail if cargo or busted are missing (not just in CI)
- Prevents silently skipping tests locally while they fail in CI
Security validations added to parse_s3_request:
- Reject double-slash paths (//)
- Reject trailing slashes in bucket paths (/bucket/)
- Reject path traversal attempts (../)
- Reject null bytes in paths

Query string parsing improvements:
- Detect and reject duplicate parameters (return as arrays)
- Reject malformed query strings (only ampersands)
- Reject parameters without keys (=value)
- Reject conflicting multipart parameters (uploadId + uploads)

S3 action validation:
- Reject unknown query parameters (like acl)
- Whitelist known S3 query parameters

Authorization error handling:
- Preserve validation errors (malformed scopes, type mismatches)
- Return specific error messages instead of generic 'no matching scope'

All 52 Lua tests now pass.
This commit resolves all failing tests in the integration test suite by
fixing several security and compatibility issues.

**Security Improvements:**

- Add validation for null/non-string values in JWT scope arrays
  - Envoy now rejects tokens with `"scopes": [null]` with 403
  - Prevents authorization bypass via malformed scope claims

**S3 API Compatibility:**

- Add support for GetObjectAttributes S3 action
  - Recognize `attributes` query parameter in S3 requests
  - Make GetObjectAttributes implied by GetObject permission
  - Enables boto3 clients to call get_object_attributes()

**Lambda Runtime Fixes:**

- Make TokenBuilder import conditional in failure_tests router
  - Gracefully handle missing test dependencies in Lambda
  - Return 503 when failure test endpoints called in Lambda
  - Prevents runtime import errors during Lambda cold starts

**Test Improvements:**

- Update test assertions to accept "mismatch" in error messages
  - Makes tests more resilient to Envoy error message variations

**Files Changed:**

- infra/raja_poc/assets/envoy/authorize.lua
  - Add scope type validation loop
- infra/raja_poc/assets/envoy/authorize_lib.lua
  - Add GetObjectAttributes action support
  - Add attributes query parameter to known params
- src/raja/server/routers/failure_tests.py
  - Make TokenBuilder import conditional
  - Add TOKEN_BUILDER_AVAILABLE flag
- tests/integration/test_rajee_envoy_bucket.py
  - Update error message assertion

**Test Results:**
- Unit tests: 212 passed ✅
- Integration tests: 34 passed, 1 skipped ✅

Co-Authored-By: Claude <noreply@anthropic.com>
- Add cedar-avp.md: Three-level materialized hierarchy (Grants → Rules → Policies)
  - Invariants and design principles
  - Enforcement strategies (prefix_envelope vs manifest_enforced)
  - Package Grant expansion algorithm
  - Publishing flow with soft/hard delete semantics
  - Policy hash usage for drift detection and reconciliation
  - Three concrete examples showing real-world scenarios

- Add cedar-avp.sql: Production-ready PostgreSQL schema
  - Three tables: package_grants, path_rules, avp_policies
  - Foreign key constraints enforcing hierarchy
  - Check constraints for business rules
  - Indexes for query performance
  - Helper views and triggers
  - Comprehensive audit fields

- Update cedar-quilt.md: Fix typo in code block language tag

Co-Authored-By: Claude <noreply@anthropic.com>
@drernie drernie changed the title Implement schema failure fixes Release 0.4.4: Cedar CLI integration, hierarchical S3 authorization, and failure mode testing Jan 21, 2026
@drernie drernie merged commit aede0d3 into main Jan 22, 2026
6 checks passed
@drernie drernie deleted the hygiene branch January 22, 2026 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant