// =============================================================================
// Data Pipeline — Security
// =============================================================================
// Strict secrets detection and injection defense for data pipelines.
// RAG inputs are high-risk for injection — lower thresholds than defaults.
//
// Category: security
// Namespace: Guardrails
// =============================================================================

@id("data-secrets-strict")
@name("Strict secrets detection for data pipeline")
@description("Blocks any content containing secrets — even a single match")
@severity("critical")
@tags("profile,data-pipeline,secrets,security")
forbid (
    principal,
    action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
    resource
) when {
    context has contains_secrets && context.contains_secrets == true
};

@id("data-block-output-secrets")
@name("Block secrets in pipeline outputs")
@description("Prevents data pipeline from writing secrets to any output")
@severity("critical")
@tags("profile,data-pipeline,secrets,output")
forbid (
    principal,
    action == Guardrails::Action::"write_file",
    resource
) when {
    (context has contains_secrets && context.contains_secrets == true) ||
    (context has secret_count && context.secret_count > 0)
};

@id("data-injection-defense")
@name("Pipeline injection defense")
@description("Lower injection threshold for data pipelines — RAG inputs are high-risk for injection")
@severity("high")
@tags("profile,data-pipeline,injection,security")
forbid (
    principal,
    action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool"],
    resource
) when {
    context has injection_confidence && context.injection_confidence > 65
};
