Cedar Policy Loader (cedar/_file_loaders.py)

harness-sdk · strands-py/src/strands/vended_interventions/cedar/_file_loaders.py · python · Apache-2.0
ai, security, files, tag:cedar, tag:policy, tag:loader, tag:json

Loads Cedar policies, entities, and schemas from files or inline text.

# Source: https://github.com/strands-agents/harness-sdk | License: Apache-2.0
# Provided via justclaw.it.com; keep this notice with the code.
"""File loading utilities for Cedar policies, entities, and schemas."""

from __future__ import annotations

import json
from pathlib import Path
from typing import Any


def load_policies(source: str) -> str:
    """Load Cedar policies from a .cedar file or return inline text.

    Args:
        source: Path to a .cedar file, or inline Cedar policy text.

    Returns:
        Cedar policy text.

    Raises:
        FileNotFoundError: If a .cedar file path is provided but doesn't exist.
    """
    if source.endswith(".cedar"):
        path = Path(source)
        if not path.exists():
            raise FileNotFoundError(f"Cedar policy file not found:

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key