writing-rego-rules

Write OPA v1 Rego rules that evaluate evidence against Fianu control policies.

1|Updated Jun 11, 2026
One-click install
npx skills add https://github.com/fianulabs/fianu-skills --skill writing-rego-rules-fianulabs
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: writing-rego-rules
Source: https://github.com/fianulabs/fianu-skills/tree/main/skills/writing-rego-rules
Command: npx skills add https://github.com/fianulabs/fianu-skills --skill writing-rego-rules-fianulabs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Authoring Rego rules for Fianu controls requires knowing the exact v1 syntax, the input.detail.* to data.* mapping convention, and which evaluation pattern fits a given policy requirement; mistakes silently fail at evaluation time. ## Core Features & Use Cases - v1 Syntax Enforcement: Every rule starts with package rule and import rego.v1, using the if keyword and every quantifier. - Five Canonical Patterns: Threshold check, score comparison, presence check, freshness check, and multi-metric rules with full code in references/patterns.md. - Schema Mapping Guidance: Maps evidence plugin fields to input.detail.* paths and policy template keys to data.* paths so the rule and template stay aligned. - Use Case: When building a container-scan control that fails builds with too many critical vulnerabilities, pick the threshold pattern, bind policy maxima from data.vulnerabilities, and count CRITICAL ratings in input.detail.vulnerabilities. ## Quick Start Write a Fianu Rego rule that passes only when a SAST scan is less than 7 days old and critical vulnerabilities are below the policy maximum.

Frequently Asked Questions about writing-rego-rules

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a Rego rule for a Fianu control?▼

Start every rule with package rule and import rego.v1, then define a pass rule using the if keyword. Read evidence from input.detail.* and policy values from data.*, following one of the five canonical patterns such as threshold or freshness checks.

What Rego syntax version do Fianu controls require?▼

Fianu controls require OPA v1 syntax, enabled by the import rego.v1 directive. This mandates the if keyword for every rule body and every for quantifiers; rules written in v0 syntax are not accepted.

How does input.detail map to data in Fianu Rego rules?▼

Evidence from the subscribed plugin arrives under input.detail.*, while policy values from the control's policy template appear under data.*. Every key in the policy template must correspond to a data.* reference in the rule, or evaluation silently fails.

Why does my Rego rule fail even though the syntax is valid?▼

The most common cause is a mismatch between policy template keys and the data.* paths referenced in the rule, which fails silently at evaluation time. Verify schema alignment by running plugin schema discovery and checking every template key against the rule.

When should I use a multi-metric Rego pattern instead of a single check?▼

Use the multi-metric pattern when one control must evaluate several measurements at once, such as critical, high, medium, and low vulnerability counts each staying under its own policy maximum. The rule passes only when all sub-checks pass.