Skip to content

Core API

policyshield.core.models

Core data models for PolicyShield.

RuleSet

Bases: BaseModel

A set of rules loaded from YAML files.

Source code in policyshield/core/models.py
class RuleSet(BaseModel):
    """A set of rules loaded from YAML files."""

    model_config = ConfigDict(frozen=True)

    shield_name: str
    version: int
    rules: list[RuleConfig]
    default_verdict: Verdict = Verdict.ALLOW
    taint_chain: TaintChainConfig = TaintChainConfig()
    honeypots: list[dict[str, Any]] | None = None
    output_rules: list[OutputRule] = []

    def enabled_rules(self) -> list[RuleConfig]:
        """Return only rules with enabled=True."""
        return [rule for rule in self.rules if rule.enabled]

enabled_rules()

Return only rules with enabled=True.

Source code in policyshield/core/models.py
def enabled_rules(self) -> list[RuleConfig]:
    """Return only rules with enabled=True."""
    return [rule for rule in self.rules if rule.enabled]

Verdict

Bases: str, Enum

Verdict for a tool call check.

Source code in policyshield/core/models.py
class Verdict(str, Enum):
    """Verdict for a tool call check."""

    ALLOW = "ALLOW"
    BLOCK = "BLOCK"
    APPROVE = "APPROVE"
    REDACT = "REDACT"