<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <id>https://openpolicyagent.org/blog</id>
    <title>Open Policy Agent Blog</title>
    <updated>2025-08-20T00:00:00.000Z</updated>
    <generator>https://github.com/jpmonette/feed</generator>
    <link rel="alternate" href="https://openpolicyagent.org/blog"/>
    <subtitle>Open Policy Agent Blog</subtitle>
    <entry>
        <title type="html"><![CDATA[Note from Teemu, Tim, and Torin to the Open Policy Agent community]]></title>
        <id>https://openpolicyagent.org/blog/note-from-teemu-tim-and-torin-to-the-open-policy-agent-community-2dbbfe494371</id>
        <link href="https://openpolicyagent.org/blog/note-from-teemu-tim-and-torin-to-the-open-policy-agent-community-2dbbfe494371"/>
        <updated>2025-08-20T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Banner announcing OPA creators joining Apple]]></summary>
        <content type="html"><![CDATA[<p><img decoding="async" loading="lazy" alt="Banner announcing OPA creators joining Apple" src="https://openpolicyagent.org/assets/images/banner-6f7db1af5a749808cbbd3d201f41b5b8.webp" width="1400" height="336" class="img_ev3q"></p>
<p>Today we're excited to announce that the creators of Open Policy Agent (along with many team members from Styra) have joined Apple to continue our decade-long mission of delivering an open source solution to unifying policy across the cloud-native stack.</p>
<p>Apple is an enthusiastic OPA user, utilizing it as a key component of its authorization infrastructure to manage a vast portfolio of global-scale cloud services. Today's announcement demonstrates Apple's commitment to the OPA project by making a larger investment in the technology and the community.</p>
<p>Open Policy Agent has a rich and vibrant community of end-user organizations, vendors, and individuals each contributing ideas, integrations, docs, and code so anyone in the world can use OPA to enforce the policies they care about. We've been fortunate to see such a community grow over the last decade, and look forward to continuing our contributions to the project as active community members.</p>
<p>We've compiled a set of FAQs below to address questions.</p>
<p><strong>What does this mean for the Open Policy Agent project?</strong>
Open Policy Agent remains a CNCF graduated open source project and there are no changes to the project governance or licensing.</p>
<p><strong>What does this mean for Open Policy Agent maintainers?</strong>
There is no change to the list of maintainers, except for an organization change from Styra to Apple for the maintainers that are joining Apple.</p>
<p><strong>What will happen to the tools I use under the Styra GitHub?</strong>
We've initiated the community process for these repositories to be included in the CNCF OPA GitHub organization with the goal of deeper collaboration with the open source community:</p>
<ul>
<li class="">Styra's commercial distribution of OPA, EOPA: an optimized version of OPA designed for data heavy workloads with data-filtering functionality that was previously only available to enterprise customers.</li>
<li class="">OPA Control Plane: a new control plane for OPA capable of building bundles from git and additional datasources and deploying them to S3 on AWS, GCP, and Azure.</li>
<li class="">SDKs: SDKs for integrating with OPA including TypeScript, React, UCAST-Prisma, C#, ASP.NET, Java, and Springboot.</li>
<li class="">Regal: a linter for OPA's policy language Rego (partly written in Rego itself).</li>
</ul>
<p>Other tools will be evaluated for contribution in the future and remain publicly available for the community.</p>
<p><strong>What will happen to the OPA website and Rego Playground?</strong>
The OPA website continues to remain available and managed by the CNCF and broader OPA community. The Rego Playground continues to be operated by Styra with no changes to current functionality.</p>
<p><strong>What is the planned roadmap for OPA?</strong>
We're excited to continue the development of OPA with the same monthly release schedule. The 2025 OPA roadmap includes the following categories of work:</p>
<ul>
<li class="">Language extensions (and/or/not, keywords in refs, string interpolation, partial-set-functions, ellipsis)</li>
<li class="">Type checking improvements</li>
<li class="">Tooling improvements (streaming OPA test results, debugger attach to trace, rule tracing)</li>
<li class="">Partial evaluation improvements (redundant expression elimination, 'in' handling)</li>
<li class="">Performance (multiple expression indexing, faster loading of dependency-free bundles)</li>
<li class="">Decision API and logging (congestion back-pressure, logging metadata, logging to disk)</li>
</ul>]]></content>
        <author>
            <name>Tim Hinrichs</name>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[Introducing Swift OPA: Native Policy Evaluation for Swift]]></title>
        <id>https://openpolicyagent.org/blog/introducing-swift-opa-native-policy-evaluation-for-swift-d5136c8a662e</id>
        <link href="https://openpolicyagent.org/blog/introducing-swift-opa-native-policy-evaluation-for-swift-d5136c8a662e"/>
        <updated>2025-05-14T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Exciting news — Swift OPA, a new way to integrate OPA natively within Swift applications and services, has now been released.]]></summary>
        <content type="html"><![CDATA[<p>Exciting news — Swift OPA, a new way to integrate OPA natively within Swift applications and services, has now been released.</p>
<p><img decoding="async" loading="lazy" alt="Introducing the Swift OPA project — native policy evaluation for Swift" src="https://openpolicyagent.org/assets/images/1-bd5ee42856951e4cd72077131e83bf8b.png" width="1024" height="538" class="img_ev3q"></p>
<p>Swift OPA builds on the robust foundation of OPA's <a class="" href="https://openpolicyagent.org/blog/i-have-a-plan-exploring-the-opa-intermediate-representation-ir-format-7319cd94b37d">Intermediate Representation</a> (IR) plans. Introduced in 2022, the OPA toolchain gained the ability to compile Rego policy into IR, precisely defining the concrete steps necessary to evaluate the policy. Swift OPA then interprets these IR plans, allowing you to leverage OPA's rich policy natively within Swift applications and services.</p>
<p>Until today, integrating OPA with a Swift application or service required one of the following approaches:</p>
<ul>
<li class="">Inter-process communication to a standalone OPA instance</li>
<li class="">Evaluating Rego policy compiled into a Web Assembly (WASM) binary</li>
</ul>
<p>Each of these approaches represent different ways of using OPA. For most of the OPA project's history, it's been used with a client/server architecture where communication takes place over the network. The embedded approach taken by WASM, on the other hand, avoids this step to enable in-process evaluation.</p>
<p>With its native language support, Swift OPA works more closely to the embedded approach described: evaluation occurs within the process boundary of your service or application. When developing Swift applications, this reduces latency, as well as complexity and operational overhead by simplifying builds and deployments.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="current-status">Current Status<a href="https://openpolicyagent.org/blog/introducing-swift-opa-native-policy-evaluation-for-swift-d5136c8a662e#current-status" class="hash-link" aria-label="Direct link to Current Status" title="Direct link to Current Status" translate="no">​</a></h2>
<p>Swift OPA development is currently focused on expanding support for OPA's built-in functions, starting with over 80 built-ins and a roadmap to add many more in the future. A rigorous conformance test suite has also been published to GitHub. A community discussion has been initiated about how to best publish the transformed data used by the test suite, with the goal of ensuring consistent behavior across different language implementations of OPA including Swift OPA.</p>
<p>It's exciting to add Swift support to the OPA community, and you're invited to start exploring Swift OPA today.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="how-to-get-involved">How to get involved<a href="https://openpolicyagent.org/blog/introducing-swift-opa-native-policy-evaluation-for-swift-d5136c8a662e#how-to-get-involved" class="hash-link" aria-label="Direct link to How to get involved" title="Direct link to How to get involved" translate="no">​</a></h2>
<p>You can explore Swift OPA now at <a href="https://github.com/open-policy-agent/swift-opa" target="_blank" rel="noopener noreferrer" class="">https://github.com/open-policy-agent/swift-opa</a>, and join the community on the Open Policy Agent Slack channel: <a href="https://openpolicyagent.slack.com/archives/C08PCS1KJ48" target="_blank" rel="noopener noreferrer" class="">#swift-opa</a>. Your feedback and ideas are welcome - and there are plenty of opportunities to contribute to the project!</p>]]></content>
        <author>
            <name>Oren Shomron</name>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[Announcing OPA 1.0: A New Standard for Policy as Code]]></title>
        <id>https://openpolicyagent.org/blog/announcing-opa-1-0-a-new-standard-for-policy-as-code-a6d8427ee828</id>
        <link href="https://openpolicyagent.org/blog/announcing-opa-1-0-a-new-standard-for-policy-as-code-a6d8427ee828"/>
        <updated>2024-12-20T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Banner graphic announcing the OPA 1.0 release]]></summary>
        <content type="html"><![CDATA[<p><img decoding="async" loading="lazy" alt="Banner graphic announcing the OPA 1.0 release" src="https://openpolicyagent.org/assets/images/banner-1e952515cea7614741ccacde3a63a705.webp" width="1400" height="560" class="img_ev3q"></p>
<p>We are excited to announce OPA 1.0, a milestone release consolidating an improved developer experience for the future of Policy as Code. After nearly 10 years of innovations and contributions from over 450 developers, OPA 1.0 is finally here. The release makes new functionality designed to simplify policy writing and improve the language's consistency the default. This release marks the beginning of a new era for our project and represents a robust foundation for Policy as Code projects in the years ahead.</p>
<p>Since the project's <a href="https://www.cncf.io/announcements/2021/02/04/cloud-native-computing-foundation-announces-open-policy-agent-graduation/" target="_blank" rel="noopener noreferrer" class="">CNCF graduation</a> at the start of 2021, our work has been focused on Rego's developer experience and consistency. While much of the new functionality has been around for some time, OPA 1.0 will make new features the default — warranting the <a href="https://semver.org/" target="_blank" rel="noopener noreferrer" class="">SemVer</a> bump to <code>v1.0.0</code>. At this time, we would like to take the chance to highlight the following key changes to the defaults in Rego v1:</p>
<ul>
<li class="">Using <code>if</code> for all rule definitions and <code>contains</code> for multi-value rules is now mandatory, not just when using the <code>rego.v1</code> import.</li>
<li class="">Other new keywords (<code>every</code>, <code>in</code>) are available without any imports.</li>
<li class="">Previously requirements that were only run in "strict mode" (like <code>opa check --strict</code>) are now the default. Duplicate imports and imports which shadow each other are no longer allowed.</li>
<li class="">OPA 1.0 comes with a range of backwards compatibility features to aid your migrations, please see the <a href="https://www.openpolicyagent.org/docs/latest/v0-compatibility/" target="_blank" rel="noopener noreferrer" class="">v0 compatibility guide</a> if you must continue to support v0 Rego.</li>
</ul>
<p>Many users have already started using the new syntax (we started adding the new keywords three years ago back in v0.34.0) but for those who haven't; in order to get the best of OPA 1.0; and to remain abreast of follow on updates; users are encouraged to upgrade as soon as possible (using the backwards compatibility functionality if required). Most users will be able to update their Rego quickly as the process can be largely automated using the Rego tools already built into OPA. The process can be summarized as follows:</p>
<ul>
<li class="">Download and install an <a href="https://github.com/open-policy-agent/opa/releases/tag/v1.0.0" target="_blank" rel="noopener noreferrer" class="">OPA 1.0 binary</a> before running the following commands.</li>
<li class=""><code>opa check --v0-v1</code>: Find parser and compiler errors that might be present in old code.</li>
<li class=""><code>opa check --v0-v1 --strict</code>: Find problems in Rego code no longer permitted in OPA 1.0.</li>
<li class=""><code>opa fmt --write --v0-v1</code>: Automatically update code to the OPA 1.0 syntax.</li>
<li class=""><code>regal lint</code>: using Regal, the linter for Rego is also recommended to find bugs and performance issues.</li>
</ul>
<p>For users looking for more detailed information, please see the following resources: <a href="http://openpolicyagent.org/docs/latest/v0-upgrade/" target="_blank" rel="noopener noreferrer" class="">OPA Documentation on upgrading to 1.0</a>; the <a href="https://www.styra.com/blog/renovating-rego/" target="_blank" rel="noopener noreferrer" class="">Renovating Rego</a> post for older projects which digs into the above process in detail; the <a href="https://youtu.be/QuotLxFb2f4?feature=shared&amp;t=800" target="_blank" rel="noopener noreferrer" class="">Maintainer Track presentation</a> from KubeCon NA 2024 for a video overview.</p>
<p>Those <a href="https://www.openpolicyagent.org/docs/latest/integration/" target="_blank" rel="noopener noreferrer" class="">integrating with OPA's Go packages</a> — both via the SDK and the low-level Rego package — are encouraged to update their applications to use the new v1 packages. This is also documented in the <a href="http://openpolicyagent.org/docs/latest/v0-upgrade/" target="_blank" rel="noopener noreferrer" class="">upgrading documentation</a> and is a straightforward process. In some cases, users or integrators will need to support both v0 and v1 Rego simultaneously in the same application. This is generally only applicable to those offering OPA as part of a managed offering where the Rego is controlled by end users. Those who do have this use case, please review the <a href="https://www.openpolicyagent.org/docs/latest/v0-compatibility/" target="_blank" rel="noopener noreferrer" class="">v0 compatibility guide</a> to review the most suitable option for your application.</p>
<p>One last thing, while OPA 1.0 is primarily about consolidating the Rego developer experience, the release also comes with some significant improvements to performance. Check the <a href="https://github.com/open-policy-agent/opa/releases/tag/v1.0.0" target="_blank" rel="noopener noreferrer" class="">release notes</a> to dig into the details.</p>
<p>And that's a wrap! OPA 1.0 is here, it's a milestone release for our project and we're proud of the effort this release represents. We're excited for you to upgrade and experience these improvements firsthand. As you do, please report any issues via <a href="http://slack.openpolicyagent.org/" target="_blank" rel="noopener noreferrer" class="">Slack</a> or <a href="https://github.com/orgs/open-policy-agent/discussions" target="_blank" rel="noopener noreferrer" class="">GitHub Discussions</a>, and feel free to open bug reports or feature requests to help shape future releases. Also, don't forget to use the <a href="https://docs.styra.com/regal/editor-support" target="_blank" rel="noopener noreferrer" class="">Regal language server</a> to ensure your Rego code is efficient &amp; error-free too.</p>
<p>We want to extend our gratitude to our incredible community for always testing the latest versions, reporting bugs, contributing code and supporting fellow community members on their Rego journeys. We're not done yet and look forward to working together for years to come.</p>
<p><em>Happy holidays — the OPA team</em></p>]]></content>
        <author>
            <name>Charlie Egan</name>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[OPA 1.0 is coming. Here's what you need to know.]]></title>
        <id>https://openpolicyagent.org/blog/opa-1-0-is-coming-heres-what-you-need-to-know-c8fb0d258368</id>
        <link href="https://openpolicyagent.org/blog/opa-1-0-is-coming-heres-what-you-need-to-know-c8fb0d258368"/>
        <updated>2024-03-15T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Open Policy Agent Logo with "1.0" written below]]></summary>
        <content type="html"><![CDATA[<p><img decoding="async" loading="lazy" alt="Open Policy Agent Logo with &amp;quot;1.0&amp;quot; written below" src="https://openpolicyagent.org/assets/images/1-4e1e37c1a3f45b7037ec0c0b305b6057.png" width="893" height="577" class="img_ev3q">
<em>Towards Open Policy Agent 1.0</em></p>
<p>December 28th marked the 8th anniversary of the first commit in the Open Policy Agent project. 5000+ commits from more than 400 contributors later, we're starting to prepare for OPA 1.0.</p>
<p>Following the rules of semantic versioning, one would be excused to think of 1.0 as the first "stable" version. That's not really the case for this project. Since the first public releases of OPA, great care has been taken to ensure new changes don't break existing policy. Thousands of organizations have come to rely on OPA for policy enforcement across the whole stack — often for critical production use cases.</p>
<p>While many <strong>features</strong> have been added to OPA and the Rego language since 2015, few have ever been removed. All this means that almost any policy written eight, five or three years ago still evaluates using the very latest version OPA, just as it did when it was written! But to keep adding features without ever being able to remove things that might not have worked out as we imagined — or simply didn't age well — also comes at a price. An increased cost of maintenance for sure, but more importantly, old ideas, language constructs and built-in functions all add to the cost of learning Rego, compared to having policy look and act consistently using only modern equivalent features.</p>
<p>With OPA 1.0, we're aiming to fix this.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="tldr">TL;DR<a href="https://openpolicyagent.org/blog/opa-1-0-is-coming-heres-what-you-need-to-know-c8fb0d258368#tldr" class="hash-link" aria-label="Direct link to TL;DR" title="Direct link to TL;DR" translate="no">​</a></h2>
<p>If you have a busy day ahead and want to get right to something actionable — here's what you can do. From OPA <a href="https://github.com/open-policy-agent/opa/releases/tag/v0.59.0" target="_blank" rel="noopener noreferrer" class="">v0.59.0</a> and onwards, you can start to prepare for the changes in the upcoming 1.0 release following these steps:</p>
<ul>
<li class="">Use import rego.v1 in each of your Rego files. This replaces all future.keywords imports from previous versions, and is all you need to import until OPA 1.0. Use opa fmt --rego-v1 to format your policy with automatic additions of OPA v1.0 constructs, like if, contains and more. This will also replace any future.keywords imports with the rego.v1 import.</li>
<li class="">Use opa check --rego-v1 to ensure your policy is compatible with "Rego 1.0" mode.</li>
</ul>
<p>We'll get back to practical concerns by the end of the blog, but before that, let's see what changes are planned for the first major OPA version.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="changes-to-rego-coming-in-opa-10">Changes to Rego coming in OPA 1.0<a href="https://openpolicyagent.org/blog/opa-1-0-is-coming-heres-what-you-need-to-know-c8fb0d258368#changes-to-rego-coming-in-opa-10" class="hash-link" aria-label="Direct link to Changes to Rego coming in OPA 1.0" title="Direct link to Changes to Rego coming in OPA 1.0" translate="no">​</a></h3>
<p><strong>Note: Below follows a non-comprehensive list subject to change.</strong> While these features are planned — and most of them even implemented already! — updates may be made before the final 1.0 release. I'll do my best to keep this blog post up to date, as we will with the OPA 1.0 documentation.</p>
<h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-future-is-now--no-more-import-futurekeywords">The future is now — no more import future.keywords<a href="https://openpolicyagent.org/blog/opa-1-0-is-coming-heres-what-you-need-to-know-c8fb0d258368#the-future-is-now--no-more-import-futurekeywords" class="hash-link" aria-label="Direct link to The future is now — no more import future.keywords" title="Direct link to The future is now — no more import future.keywords" translate="no">​</a></h4>
<p>Several keywords (in, every, <em>if</em> and contains*)* have been added to OPA since the start. Introducing new keywords means there's always a risk that existing policy might break in case identifiers, like rule names or variables, have been named in a way that clashes with the new keywords. In order to prevent this, access to these keywords have required an import of future.keywords. We now live in that future.</p>
<p><img decoding="async" loading="lazy" alt="That was a problem for future me, and now I am future me." src="https://openpolicyagent.org/assets/images/2-439948e6e8613e0e67deafc8ba8124c3.jpeg" width="320" height="319" class="img_ev3q"></p>
<p>OPA v1.0 makes import future.keywords a no-op, as all keywords are now made available everywhere. In the time before OPA 1.0 is released, the new rego.v1 should be used in place of future.keywords imports.</p>
<h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-if-keyword-made-mandatory">The if keyword made mandatory<a href="https://openpolicyagent.org/blog/opa-1-0-is-coming-heres-what-you-need-to-know-c8fb0d258368#the-if-keyword-made-mandatory" class="hash-link" aria-label="Direct link to The if keyword made mandatory" title="Direct link to The if keyword made mandatory" translate="no">​</a></h4>
<p>The if keyword helps explain the "inverted if … then" nature of Rego rules, and makes rules easier to read. Additionally, any rule body with only a single expression, like:</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token variable" style="color:#36acaa">allow</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token string" style="color:#e3116c">"admin"</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">in</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">roles</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<p>May with the help of if be expressed as a one-liner, with the curly brackets removed:</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token variable" style="color:#36acaa">allow</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">if</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"admin"</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">in</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">roles</span><br></div></code></pre></div></div>
<p>OPA 1.0 makes if a natural — and mandatory — part of every rule's anatomy.</p>
<p><strong>Tip:</strong> Use the opa fmt --rego-v1 utility in OPA v0.59.0+ to automatically rewrite all of your rules with if added to the rule head.</p>
<h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-contains-keyword-made-mandatory">The contains keyword made mandatory<a href="https://openpolicyagent.org/blog/opa-1-0-is-coming-heres-what-you-need-to-know-c8fb0d258368#the-contains-keyword-made-mandatory" class="hash-link" aria-label="Direct link to The contains keyword made mandatory" title="Direct link to The contains keyword made mandatory" translate="no">​</a></h4>
<p>The contains keyword helps express multi-value (or as they're often called, partial) rules — i.e. rules that build a <em>set</em> of values. It also helps avoid ambiguities around certain classes of rules, like the fairly recently introduced "nested" rule type:</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token variable" style="color:#36acaa">users</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">names</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">contains</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">name</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">if</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token comment" style="color:#999988;font-style:italic"># ...</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token variable" style="color:#36acaa">name</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">sprintf</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">"%s, %s"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">first_name</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">last_name</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<p>The contains keyword was already mandatory for nested rules. OPA v1.0 makes the use of this consistent across all multi-value rules by making contains a requirement.</p>
<p><strong>Tip:</strong> Use the opa fmt --rego-v1 utility in OPA v0.59.0+ to automatically rewrite all of your multi-value rules with contains added to the rule head.</p>
<h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="strict-mode-made-mostly-the-default">Strict mode made (mostly) the default<a href="https://openpolicyagent.org/blog/opa-1-0-is-coming-heres-what-you-need-to-know-c8fb0d258368#strict-mode-made-mostly-the-default" class="hash-link" aria-label="Direct link to Strict mode made (mostly) the default" title="Direct link to Strict mode made (mostly) the default" translate="no">​</a></h4>
<p>Most of the rules that have existed in OPA <a href="https://www.openpolicyagent.org/docs/latest/policy-language/#strict-mode" target="_blank" rel="noopener noreferrer" class="">strict mode</a> will be made the default in OPA 1.0. This will help users catch mistakes early, and have them fixed right away. If you have been running opa check --strict as part of your policy build pipeline, you're already in the clear here.</p>
<p>The rules from strict mode that will be made default in OPA 1.0 are:</p>
<h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="no-duplicate-imports">No duplicate imports<a href="https://openpolicyagent.org/blog/opa-1-0-is-coming-heres-what-you-need-to-know-c8fb0d258368#no-duplicate-imports" class="hash-link" aria-label="Direct link to No duplicate imports" title="Direct link to No duplicate imports" translate="no">​</a></h4>
<p>Duplicate imports should realistically not be a problem in any repo, and the fix is simply to have them removed.</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token keyword" style="color:#00009f">package</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">policy</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">data</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">authz</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">data</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">authz</span><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic"># this is now an error</span><br></div></code></pre></div></div>
<h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="no-deprecated-built-in-functions">No deprecated built-in functions<a href="https://openpolicyagent.org/blog/opa-1-0-is-coming-heres-what-you-need-to-know-c8fb0d258368#no-deprecated-built-in-functions" class="hash-link" aria-label="Direct link to No deprecated built-in functions" title="Direct link to No deprecated built-in functions" translate="no">​</a></h4>
<p>Deprecated built-in functions will be removed in OPA 1.0, and most of them are trivial to replace using a single line of Rego, or a different built-in function.</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token keyword" style="color:#00009f">package</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">policy</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># simply change to use `true in {input.foo, input.bar}`</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># using `in` additionally has the benefit that it can be used</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># to check for any type of value, and not just boolean "true"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">a</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">any</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">foo</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">bar</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># change to use `every` keyword, e.g.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># every x in [input.foo, input.bar] {</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic">#     x == true</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># }</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># just like `in` may be used for much more, `every` can be</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># used to evaluate complex expressions</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">e</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">all</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">foo</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">bar</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># simply use the minus (`-`) operator instead, e.g.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># s3 := s1 - s2</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">s3</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">set_diff</span><span class="token punctuation" style="color:#393A34">(</span><span class="token variable" style="color:#36acaa">s1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">s2</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># simply change to use regex.match instead</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">r</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">re_match</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">.</span><span class="token punctuation" style="color:#393A34">.</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># simply change to use net.cidr_intersects</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">n</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token function namespace punctuation" style="color:#393A34;opacity:0.7">net</span><span class="token function punctuation" style="color:#393A34">.</span><span class="token function" style="color:#d73a49">cidr_overlap</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">.</span><span class="token punctuation" style="color:#393A34">.</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># cast_array, cast_set, cast_string, cast_boolean, cast_null, cast_object</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># use the "is_x" equivalent built-in function in their place</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">s</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">is_string</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">"yes"</span><span class="token punctuation" style="color:#393A34">)</span><br></div></code></pre></div></div>
<h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="input-and-data-now-reserved-keywords">input and data now reserved keywords<a href="https://openpolicyagent.org/blog/opa-1-0-is-coming-heres-what-you-need-to-know-c8fb0d258368#input-and-data-now-reserved-keywords" class="hash-link" aria-label="Direct link to input and data now reserved keywords" title="Direct link to input and data now reserved keywords" translate="no">​</a></h4>
<p>OPA 1.0 prohibits the use of input or data as identifiers:</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token comment" style="color:#999988;font-style:italic"># this is not allowed in OPA 1.0</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">input</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"overloaded"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># and neither is this</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">data</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<p>Overloading input has mostly been common in tests. Do note that with input as <code>{..}</code> remains valid. If you're using assignment to input however, (<code>input := {..}</code>), you'll just need to change the name to something like inp instead.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="other-changes-coming-in-opa-10">Other changes coming in OPA 1.0<a href="https://openpolicyagent.org/blog/opa-1-0-is-coming-heres-what-you-need-to-know-c8fb0d258368#other-changes-coming-in-opa-10" class="hash-link" aria-label="Direct link to Other changes coming in OPA 1.0" title="Direct link to Other changes coming in OPA 1.0" translate="no">​</a></h3>
<p>See the <a href="https://github.com/open-policy-agent/opa/issues?q=is%3Aissue+label%3A1.0+" target="_blank" rel="noopener noreferrer" class="">1.0 tag</a> in the OPA backlog for a list of all issues related to OPA 1.0. Do note though that not all issues marked 1.0 might be picked for inclusion, and new issues may pop up before the release!</p>
<p>Other notable changes include:</p>
<h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="import-regov1">import rego.v1<a href="https://openpolicyagent.org/blog/opa-1-0-is-coming-heres-what-you-need-to-know-c8fb0d258368#import-regov1" class="hash-link" aria-label="Direct link to import rego.v1" title="Direct link to import rego.v1" translate="no">​</a></h4>
<p>As previously mentioned — beginning with OPA v0.59.0 a new handy import to help with the 1.0 transition is made available. By adding import rego.v1 to a Rego policy, you can tell OPA to treat the policy just as it will handle it once version 1.0 is released.</p>
<ul>
<li class="">Since rego.v1 implies all the (no longer) future keywords, the importing future.keywords is no longer needed when import rego.v1 is present, and will in fact be an error.</li>
<li class="">Just as in OPA 1.0, the use of if and contains will be enforced</li>
<li class="">The strict mode requirements brought in OPA 1.0 will be checked automatically</li>
</ul>
<h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="bind-server-to-localhost-interface-by-default">Bind server to localhost interface by default<a href="https://openpolicyagent.org/blog/opa-1-0-is-coming-heres-what-you-need-to-know-c8fb0d258368#bind-server-to-localhost-interface-by-default" class="hash-link" aria-label="Direct link to Bind server to localhost interface by default" title="Direct link to Bind server to localhost interface by default" translate="no">​</a></h4>
<p>In OPA 1.0, the server will bind to the localhost interface by default, and not 0.0.0.0 (all interfaces). This change is needed in order to avoid accidentally exposing OPA to the internet, which while uncommon (as OPA normally runs behind firewalls and gateways) still happens, and we should aim to provide a secure default. Should you still want to bind against 0.0.0.0, or some other interface, you can use the --addr flag of the opa run command, like opa run --server --addr 0.0.0.0:8181. The impact of this change is expected to be small, but good to keep in mind.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="documentation">Documentation<a href="https://openpolicyagent.org/blog/opa-1-0-is-coming-heres-what-you-need-to-know-c8fb0d258368#documentation" class="hash-link" aria-label="Direct link to Documentation" title="Direct link to Documentation" translate="no">​</a></h3>
<p>The OPA docs have been updated to cover much of what's mentioned in this blog in greater detail. It also covers more of the technical reasons some of these changes are needed. See the docs on <a href="https://www.openpolicyagent.org/docs/latest/opa-1/" target="_blank" rel="noopener noreferrer" class="">OPA 1.0</a> for more information.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="how-to-prepare">How to prepare<a href="https://openpolicyagent.org/blog/opa-1-0-is-coming-heres-what-you-need-to-know-c8fb0d258368#how-to-prepare" class="hash-link" aria-label="Direct link to How to prepare" title="Direct link to How to prepare" translate="no">​</a></h3>
<p>As we covered in the TL;DR section, we're providing a number of tools to help with the transition starting from OPA v0.59.0 already. These tools will likely be extended and improved in following releases, but starting to use them today will ensure as smooth transition as possible.</p>
<h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="to-summarize">To summarize<a href="https://openpolicyagent.org/blog/opa-1-0-is-coming-heres-what-you-need-to-know-c8fb0d258368#to-summarize" class="hash-link" aria-label="Direct link to To summarize" title="Direct link to To summarize" translate="no">​</a></h4>
<ul>
<li class="">OPA 1.0 planned for release this year, including some backwards incompatible changes</li>
<li class="">Starting now, you should use import rego.v1 in all of your policies (this replaces future.keywords) imports</li>
<li class="">Use opa check --rego-v1 for testing compliance against 1.0</li>
<li class="">Use opa fmt --rego-v1 to have your Rego code updated for 1.0 compliance</li>
<li class="">Run the OPA server with the --v1-compatible flag for OPA 1.0 compliance</li>
</ul>
<p>Also worth pointing out — following guides like the <a href="https://docs.styra.com/opa/rego-style-guide" target="_blank" rel="noopener noreferrer" class="">Rego Style Guide</a>, and using tools like <a href="https://docs.styra.com/regal" target="_blank" rel="noopener noreferrer" class="">Regal</a>, is an excellent way to ensure not just compliance with future changes to Rego, but that your current policy repo is continuously kept in the best possible condition.</p>
<p>If you have any questions, concerns or would like to provide feedback around the upcoming 1.0 release, or the tools made available to help you transition smoothly — don't hesitate to reach out using any of the below channels:</p>
<ul>
<li class="">The OPA community's <a href="https://github.com/open-policy-agent/community/" target="_blank" rel="noopener noreferrer" class="">discussion board</a></li>
<li class="">The <a href="https://slack.openpolicyagent.org/" target="_blank" rel="noopener noreferrer" class="">OPA Slack</a></li>
<li class="">The OPA project's <a href="https://github.com/open-policy-agent/opa/issues" target="_blank" rel="noopener noreferrer" class="">backlog</a> (to file an issue or feature request)</li>
</ul>]]></content>
        <author>
            <name>Anders Eknert</name>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[Open Policy Agent 2023, Year in Review]]></title>
        <id>https://openpolicyagent.org/blog/open-policy-agent-2023-year-in-review-4c12df22e351</id>
        <link href="https://openpolicyagent.org/blog/open-policy-agent-2023-year-in-review-4c12df22e351"/>
        <updated>2023-12-20T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Banner image for Open Policy Agent 2023 year in review post]]></summary>
        <content type="html"><![CDATA[<p><img decoding="async" loading="lazy" alt="Banner image for Open Policy Agent 2023 year in review post" src="https://openpolicyagent.org/assets/images/banner-3aef5a9f6f8712fbc815b94807a6c4f3.webp" width="1400" height="800" class="img_ev3q"></p>
<p>As 2023 draws to a close, the time has come to reflect on another important year for Open Policy Agent (OPA). Now more than two years deep into CNCF Graduated status, OPA continues to see accelerated growth in production deployments — and across a diverse range of use cases. Such use cases demand both performance and stability, while user base growth depends on learning resources and ease of use. This year, the OPA community has worked hard and delivered on all fronts, for new and experienced users alike. This post takes time to share how this was achieved; highlight prominent events and updates; celebrate input from the wider community and set the scene for a historic year of OPA in 2024.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="opa-away-from-keyboard">OPA 'Away From Keyboard'<a href="https://openpolicyagent.org/blog/open-policy-agent-2023-year-in-review-4c12df22e351#opa-away-from-keyboard" class="hash-link" aria-label="Direct link to OPA 'Away From Keyboard'" title="Direct link to OPA 'Away From Keyboard'" translate="no">​</a></h2>
<p>While OPA users and maintainers predominantly collaborate online, there were a good number of occasions where OPA existed very much in the physical realm this year too.</p>
<p>KubeCon EU enabled a few OPA events in Amsterdam early this summer. For the first time ever, an OPA-themed ContribFest session was held, where OPA, <a href="https://www.conftest.dev/" target="_blank" rel="noopener noreferrer" class="">Conftest</a> and <a href="https://github.com/open-policy-agent/gatekeeper" target="_blank" rel="noopener noreferrer" class="">OPA Gatekeeper</a> maintainers worked with new contributors to the different OPA projects. In Amsterdam we also saw an OPA meet-up where speakers from <a href="https://medium.com/miro-engineering/how-miro-leverages-open-policy-agent-to-implement-authorization-as-a-service-763f08469e5" target="_blank" rel="noopener noreferrer" class="">Miro</a>, <a href="https://www.bankdata.dk/" target="_blank" rel="noopener noreferrer" class="">Bankdata</a> and <a href="http://styra.com/" target="_blank" rel="noopener noreferrer" class="">Styra</a> presented. At this KubeCon EU there were four OPA talks:</p>
<ul>
<li class=""><a href="https://www.youtube.com/watch?v=XoWf4QcSbDw" target="_blank" rel="noopener noreferrer" class="">The Compliance Business Case for Kubernetes in the EU: Anders Eknert</a></li>
<li class=""><a href="https://www.youtube.com/watch?v=6RNp3m_THw4" target="_blank" rel="noopener noreferrer" class="">Open Policy Agent. (OPA) Intro &amp; Deep Dive — Charlie Egan, Rita Zhang</a></li>
<li class=""><a href="https://www.youtube.com/watch?v=JSKNch6piyY" target="_blank" rel="noopener noreferrer" class="">Calling OPA from eBPF, Through WASM, in the Kernel? You've Gone Mad! — Nandor Kracser</a></li>
<li class=""><a href="https://www.youtube.com/watch?v=BdeBhukLwt4" target="_blank" rel="noopener noreferrer" class="">Scratching an Itch: Running Policy in Hard to Reach Places with WASM &amp; OPA — Charlie Egan</a></li>
</ul>
<p><img decoding="async" loading="lazy" alt="Contribfest session at KubeCon EU in Amsterdam" src="https://openpolicyagent.org/assets/images/2-a6cff581d70f84e973887e3740a57cd0.webp" width="1400" height="1051" class="img_ev3q"></p>
<p><img decoding="async" loading="lazy" alt="OPA Meetup in Amsterdam hosted by Miro" src="https://openpolicyagent.org/assets/images/3-02bfff9e02eb50a6cb90a77948a8a420.webp" width="1400" height="1051" class="img_ev3q"></p>
<p>Rolling forward a few months, OPA also had a strong presence in Chicago at KubeCon NA. KubeCon is a huge event and it was great to get so many eyes on OPA as part of the graduated projects update in the keynote session. On top of that, the OPA kiosk in the project pavilion was an important meeting place for maintainers and users at the event. Discussions covered all sorts of use cases from authorization of applications, Kubernetes admission, IAC policy and beyond. Don't forget to check out the <a href="https://www.youtube.com/watch?v=wJkjsvVpj_Q" target="_blank" rel="noopener noreferrer" class="">OPA project update</a> from the conference's maintainer track.</p>
<p><img decoding="async" loading="lazy" alt="OPA Update on the big stage" src="https://openpolicyagent.org/assets/images/4-c712245c32f5b27dc7c35062c7c02c91.webp" width="1290" height="641" class="img_ev3q"></p>
<p><img decoding="async" loading="lazy" alt="Open Policy Agent kiosk in the project pavilion" src="https://openpolicyagent.org/assets/images/5-f20658f0ef54809dd759f3d3fa1f02ef.webp" width="1400" height="1051" class="img_ev3q"></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="from-strength-to-strength">From Strength to Strength<a href="https://openpolicyagent.org/blog/open-policy-agent-2023-year-in-review-4c12df22e351#from-strength-to-strength" class="hash-link" aria-label="Direct link to From Strength to Strength" title="Direct link to From Strength to Strength" translate="no">​</a></h2>
<p>OPA grows in so many different ways each year it's sometimes hard to know how to quantify it. Here are some highlighted figures which illustrate OPA's trajectory as we enter 2024.</p>
<p><strong>2700 Contributors</strong>. <a href="https://opa.devstats.cncf.io/" target="_blank" rel="noopener noreferrer" class="">Nearly 3000</a> people have helped make OPA into the project it is today. Contributors help make OPA better by making changes to docs and code; by participating in GitHub discussions and by filing bugs. What's equally impressive is how these contributors are from over 450 different companies. OPA is a general purpose, domain agnostic policy engine so it's vital the project is guided by such a varied contributor base.</p>
<p><strong>9 years</strong> spent by users reading the documentation on the OPA website. This year OPA contributors worked hard and made over <a href="https://gist.github.com/charlieegan3/533ca9795787265c8b536b32fd8e2c8b" target="_blank" rel="noopener noreferrer" class="">160</a> updates to the docs; and so it's reassuring to look back at the end of the year and see just how many users benefited from the hard work.</p>
<p><strong>2000 Go repositories build on OPA</strong>. <a href="https://www.openpolicyagent.org/docs/latest/integration/" target="_blank" rel="noopener noreferrer" class="">Integrating with OPA</a> has always been a priority so it's fantastic to see that just so many different projects are adding policy functionality in this way. With the <a href="https://pkg.go.dev/github.com/open-policy-agent/opa/sdk" target="_blank" rel="noopener noreferrer" class="">OPA SDK</a>, it's possible to bring all the best parts of OPA right into your Go application making it a powerful tool when standardizing your policy as code stack.</p>
<p><strong>1.5 million Playground Runs.</strong> The <a href="https://play.openpolicyagent.org/" target="_blank" rel="noopener noreferrer" class="">Rego Playground</a> is for every OPA user, it's there as a learning tool, as a collaborative scratch pad and now also integrates the output from <a href="https://docs.styra.com/regal" target="_blank" rel="noopener noreferrer" class="">Regal</a>, the new linter for Rego. On average, every 20s someone clicks the 'Evaluate' button on the playground, all day long, all year long. One of the major uses of the playground is for users and maintainers collaborating on support in the OPA Slack, if you're interested in getting help within your team or on the Slack, creating a minimal example on the playground is a place to start.</p>
<p>It's not just OPA's community that's moving forward in leaps and bounds, OPA itself has been keeping pace and has received loads of great updates this year too. Let's dig into that now.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="new-features">New Features<a href="https://openpolicyagent.org/blog/open-policy-agent-2023-year-in-review-4c12df22e351#new-features" class="hash-link" aria-label="Direct link to New Features" title="Direct link to New Features" translate="no">​</a></h2>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="general-references-in-rule-heads">General references in rule heads<a href="https://openpolicyagent.org/blog/open-policy-agent-2023-year-in-review-4c12df22e351#general-references-in-rule-heads" class="hash-link" aria-label="Direct link to General references in rule heads" title="Direct link to General references in rule heads" translate="no">​</a></h3>
<p>The single most important addition to Rego this year was arguably general references in rule heads. Simply put, it is now possible to include variables in rule names (or "references"), making it possible to build complex, nested map structures which would previously require multiple rules distributed over several packages.</p>
<p>Example using dynamic policy composition to collect informative notices from all "rules" policies, and have them organized by category and title.</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token variable" style="color:#36acaa">grouped_notices</span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">category</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">title</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">contains</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">notice</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">if</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token keyword" style="color:#00009f">some</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">category</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">title</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token variable" style="color:#36acaa">rules_to_run</span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">category</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">title</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token keyword" style="color:#00009f">some</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">notice</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">in</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">data</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">rules</span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">category</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">title</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">notices</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<p>Output would be a nested structure, as expected:</p>
<div class="language-json codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-json codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token property" style="color:#36acaa">"grouped_notices"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token property" style="color:#36acaa">"testing"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">      </span><span class="token property" style="color:#36acaa">"file-missing-test-suffix"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">"ignored"</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token property" style="color:#36acaa">"custom"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">      </span><span class="token property" style="color:#36acaa">"naming-convention"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">"ignored"</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">      </span><span class="token property" style="color:#36acaa">"one-liner-rule"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">"obsolete"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"ignored"</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<p>For more examples and information, see the <a href="https://www.openpolicyagent.org/docs/latest/policy-language/#rule-heads-containing-references" target="_blank" rel="noopener noreferrer" class="">OPA docs</a> on the topic.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="default-keyword-on-functions">Default keyword on functions<a href="https://openpolicyagent.org/blog/open-policy-agent-2023-year-in-review-4c12df22e351#default-keyword-on-functions" class="hash-link" aria-label="Direct link to Default keyword on functions" title="Direct link to Default keyword on functions" translate="no">​</a></h3>
<p>The default keyword has been around since forever, and is considered idiomatic for scenarios where a "fallback" value is needed, should rule evaluation fail in other rules sharing the same name. A long requested feature has been to extend support for default to cover custom functions, and 2023 was the year it <a href="https://www.openpolicyagent.org/docs/latest/policy-language/#default-keyword" target="_blank" rel="noopener noreferrer" class="">happened</a>.</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token keyword" style="color:#00009f">package</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">functions</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">default</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">first_name</span><span class="token punctuation" style="color:#393A34">(</span><span class="token variable" style="color:#36acaa">_</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"unknown"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#d73a49">first_name</span><span class="token punctuation" style="color:#393A34">(</span><span class="token variable" style="color:#36acaa">full_name</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">split</span><span class="token punctuation" style="color:#393A34">(</span><span class="token variable" style="color:#36acaa">full_name</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">" "</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">[</span><span class="token number" style="color:#36acaa">0</span><span class="token punctuation" style="color:#393A34">]</span><br></div></code></pre></div></div>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="new-built-in-functions">New built-in functions<a href="https://openpolicyagent.org/blog/open-policy-agent-2023-year-in-review-4c12df22e351#new-built-in-functions" class="hash-link" aria-label="Direct link to New built-in functions" title="Direct link to New built-in functions" translate="no">​</a></h3>
<p>Seven new built-in functions were added to Rego this year. The <a href="https://www.openpolicyagent.org/docs/latest/policy-reference/#builtin-object-jsonverify_schema" target="_blank" rel="noopener noreferrer" class="">json.verify_schema</a> and <a href="https://www.openpolicyagent.org/docs/latest/policy-reference/#builtin-object-jsonmatch_schema" target="_blank" rel="noopener noreferrer" class="">json.match_schema</a> functions are both recent additions for evaluating policy against JSON schemas — a use case that's been increasingly common in recent times. The <a href="https://www.openpolicyagent.org/docs/latest/policy-reference/#builtin-time-timeformat" target="_blank" rel="noopener noreferrer" class="">time.format</a> function will help policy authors present dates and time using either a custom format, or one of the supported constants for <a href="https://www.openpolicyagent.org/docs/latest/policy-reference/#timestamp-parsing" target="_blank" rel="noopener noreferrer" class="">datetime formats</a> that were also added this year. Three new crypto functions were added: <a href="https://www.openpolicyagent.org/docs/latest/policy-reference/#builtin-crypto-cryptohmacequal" target="_blank" rel="noopener noreferrer" class="">crypto.hmac.equal</a>, <a href="https://www.openpolicyagent.org/docs/latest/policy-reference/#builtin-crypto-cryptox509parse_keypair" target="_blank" rel="noopener noreferrer" class="">crypto.x509.parse_keypair</a>, and <a href="https://www.openpolicyagent.org/docs/latest/policy-reference/#builtin-crypto-cryptoparse_private_keys" target="_blank" rel="noopener noreferrer" class="">crypto.parse_private_keys</a>. Finally, the new <a href="https://www.openpolicyagent.org/docs/latest/policy-reference/#builtin-numbers-numbersrange_step" target="_blank" rel="noopener noreferrer" class="">numbers.range_step</a> function, which works just as numbers.range, but with a configurable step value.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="package-scoped-annotations">Package scoped annotations<a href="https://openpolicyagent.org/blog/open-policy-agent-2023-year-in-review-4c12df22e351#package-scoped-annotations" class="hash-link" aria-label="Direct link to Package scoped annotations" title="Direct link to Package scoped annotations" translate="no">​</a></h3>
<p>A metadata annotation using the scope of package is now truly <a href="https://github.com/open-policy-agent/opa/releases/tag/v0.50.0" target="_blank" rel="noopener noreferrer" class="">scoped to the package</a>, and not just the file in which it is declared. This allows for some interesting opportunities to separate metadata declarations from "implementing" packages, and build things like lightweight frameworks leveraging Rego's metadata annotations. Additionally, it'll allow defining package scoped annotations for "packages" created via general references in rule heads, where the package scope isn't directly allowed on the rule itself.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="debugging">Debugging<a href="https://openpolicyagent.org/blog/open-policy-agent-2023-year-in-review-4c12df22e351#debugging" class="hash-link" aria-label="Direct link to Debugging" title="Direct link to Debugging" translate="no">​</a></h3>
<p>The Swiss army knife of OPA also known as "opa eval" got a new flag to help debugging policy this year. Using the <code>--show-builtin-errors</code> flag, policy authors may now get a list of all errors produced by built-in functions as part of evaluation, making it much faster to identify certain types of problems.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="performance">Performance<a href="https://openpolicyagent.org/blog/open-policy-agent-2023-year-in-review-4c12df22e351#performance" class="hash-link" aria-label="Direct link to Performance" title="Direct link to Performance" translate="no">​</a></h3>
<p>OPA keeps getting faster, and in 2023 we saw some great improvements in this area. The <a href="https://www.openpolicyagent.org/docs/latest/policy-reference/#builtin-object-jsonpatch" target="_blank" rel="noopener noreferrer" class="">json.patch</a> built-in function was remodeled entirely and now performs extremely well even when provided with a huge list of changes. Performance isn't entirely in the hands of OPA though. Some <a href="https://www.openpolicyagent.org/docs/latest/policy-performance/" target="_blank" rel="noopener noreferrer" class="">optimizations</a> can only be performed at the level of an actual Rego policy, and OPA provides several tools to help policy authors with this. The <a href="https://www.openpolicyagent.org/docs/latest/policy-performance/#profiling" target="_blank" rel="noopener noreferrer" class="">profiler</a> (<code>opa eval --profile</code>) is one such tool, and from this year it'll now also include the number of generated expressions in evaluation. This helps policy authors better understand why some expressions are evaluated more times than what one might expect.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="server">Server<a href="https://openpolicyagent.org/blog/open-policy-agent-2023-year-in-review-4c12df22e351#server" class="hash-link" aria-label="Direct link to Server" title="Direct link to Server" translate="no">​</a></h3>
<p>Several improvements to the server (and by extension, the <a href="https://www.openpolicyagent.org/docs/latest/integration/#integrating-with-the-go-sdk" target="_blank" rel="noopener noreferrer" class="">OPA SDK</a>) landed in OPA this year. Bundle fetching now works with <a href="https://www.openpolicyagent.org/docs/latest/configuration/#aws-signature" target="_blank" rel="noopener noreferrer" class="">AWS Signing Version 4A</a>, allowing bundles hosted on AWS to be distributed across different geographical regions. Also, a new shorthand format for quickly running the server pointed at a remote bundle was <a href="https://github.com/open-policy-agent/opa/releases/tag/v0.50.0" target="_blank" rel="noopener noreferrer" class="">introduced</a>. The OCI downloader saw several <a href="https://www.openpolicyagent.org/docs/v0.52.0/configuration/#using-private-image-from-oci-repositories" target="_blank" rel="noopener noreferrer" class="">new authentication methods</a> added. Finally, instance <a href="https://www.openpolicyagent.org/docs/v0.52.0/management-discovery/#limitations" target="_blank" rel="noopener noreferrer" class="">labels</a> may now be added via discovery allowing for greater flexibility in runtime re-configuration of long running OPAs.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="monitoring">Monitoring<a href="https://openpolicyagent.org/blog/open-policy-agent-2023-year-in-review-4c12df22e351#monitoring" class="hash-link" aria-label="Direct link to Monitoring" title="Direct link to Monitoring" translate="no">​</a></h3>
<p>Given the large number of OPA instances running in production, having a good story around monitoring is essential. The <a href="https://www.openpolicyagent.org/docs/latest/management-status/#status-service-api" target="_blank" rel="noopener noreferrer" class="">status API</a> provides a way for any OPA deployed to report its current status to a centralized control plane or monitoring system. In 2023, several new metrics got added to the status reports, including most notably the request count for unauthorized calls to the OPA REST API when an <a href="https://www.openpolicyagent.org/docs/latest/security/#authentication-and-authorization" target="_blank" rel="noopener noreferrer" class="">authentication/authorization policy</a> is in use, as well as errors that might have happened in <a href="https://www.openpolicyagent.org/docs/latest/management-decision-logs/" target="_blank" rel="noopener noreferrer" class="">decision logging</a>.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="security">Security<a href="https://openpolicyagent.org/blog/open-policy-agent-2023-year-in-review-4c12df22e351#security" class="hash-link" aria-label="Direct link to Security" title="Direct link to Security" translate="no">​</a></h3>
<p>2023 was the year the OPA docker images finally made rootless the default, and the special "-rootless" images that previously existed for this purpose are now obsolete. If you're still using them, make sure to remove the suffix from the image on your next version upgrade!</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="ecosystem">Ecosystem<a href="https://openpolicyagent.org/blog/open-policy-agent-2023-year-in-review-4c12df22e351#ecosystem" class="hash-link" aria-label="Direct link to Ecosystem" title="Direct link to Ecosystem" translate="no">​</a></h2>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="gatekeeper">Gatekeeper<a href="https://openpolicyagent.org/blog/open-policy-agent-2023-year-in-review-4c12df22e351#gatekeeper" class="hash-link" aria-label="Direct link to Gatekeeper" title="Direct link to Gatekeeper" translate="no">​</a></h3>
<p>The OPA Gatekeeper project had a busy 2023, with many improvements landing this year. The external data feature allows users to connect with external data sources as part of policy evaluation. This year it gained support for caching of responses from external data providers for both audit and admission. A new AssignImage mutator which enables mutation of image registry or tag was also made available. The new PubSub feature (currently in alpha) enables users to subscribe to pubsub services to consume a large number of audit violations. Additionally, observability statistics for admission, audit and gator CLI are now available!</p>
<p>Speaking of the Gator CLI — the tool now prints violating object names on test output, and additionally supports trace and image flags. It may now also be provided an AdmissionReview object for verification.</p>
<p>Using the new (experimental) Kubernetes Native Validation feature, users can now write CEL (Common Expression Language) based rules in addition to Rego rules in constraint templates, similar to Kubernetes ValidatingAdmissionPolicy. Finally, the ExpansionTemplate feature, which enables validation of workload resources, has graduated to beta.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="conftest">Conftest<a href="https://openpolicyagent.org/blog/open-policy-agent-2023-year-in-review-4c12df22e351#conftest" class="hash-link" aria-label="Direct link to Conftest" title="Direct link to Conftest" translate="no">​</a></h3>
<p>The Conftest project saw many improvements around tooling this year. A new <code>--strict</code> flag was added to the verify and test commands, which will enforce additional safety checks on the policies such as unused arguments, duplicate imports, <a href="https://www.openpolicyagent.org/docs/latest/policy-language/#strict-mode" target="_blank" rel="noopener noreferrer" class="">and more</a>. Two more flags got added: the <code>--quiet</code> flag to the verify command which will silence success notifications and only show errors, and a <code>--config</code> flag which allows users to specify where the config file to be tested lives. Test results may now also be emitted in a format compatible with Azure DevOps. On the topic of formats, a new input format was added to the already long list of supported ones, and <a href="https://protobuf.dev/reference/protobuf/textformat-spec/" target="_blank" rel="noopener noreferrer" class="">textproto</a> files may now be targeted for policy evaluation too. Finally, the Confest Docker images now also support both the <code>linux/amd64</code> and <code>linux/arm64</code> platforms.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="opa-ecosystem">OPA Ecosystem<a href="https://openpolicyagent.org/blog/open-policy-agent-2023-year-in-review-4c12df22e351#opa-ecosystem" class="hash-link" aria-label="Direct link to OPA Ecosystem" title="Direct link to OPA Ecosystem" translate="no">​</a></h3>
<p>One goal of the OPA project is to build a domain agnostic policy engine. Being domain agnostic is achieved by simultaneously building generic core policy functionality, while also supporting a range of out-of-the-box integrations for different use cases. This year, the wider OPA community has wholeheartedly delivered on the latter and listed 22 new integrations on the website. The OPA Ecosystem also has a new home as a top level page, where integrations can be browsed by category, <a href="http://openpolicyagent.org/ecosystem/" target="_blank" rel="noopener noreferrer" class="">check it out</a>!</p>
<p><img decoding="async" loading="lazy" alt="New OPA Ecosystem Showcase" src="https://openpolicyagent.org/assets/images/6-7fdde80ad41cb48c7568f7203040b47a.webp" width="1400" height="1064" class="img_ev3q"></p>
<p>Most new ecosystem additions this year have been with other open source tools, generally adding policy functionality to a larger tool or leaning on Rego to provide a solid foundation for a domain-specific policy tool. Some notable examples include:</p>
<ul>
<li class="">Source Code Management: <a href="https://www.openpolicyagent.org/integrations/reposaur/" target="_blank" rel="noopener noreferrer" class="">Reposaur</a>, a repository compliance tool; and <a href="https://www.openpolicyagent.org/integrations/legitify/" target="_blank" rel="noopener noreferrer" class="">Legitify</a>, a repository security configuration scanner.</li>
<li class="">Supply Chain Security: <a href="https://www.openpolicyagent.org/integrations/dependency-management-data/" target="_blank" rel="noopener noreferrer" class="">dependency-management-data</a>, helps understand software dependency posture; and <a href="https://www.openpolicyagent.org/integrations/enterprise-contract/" target="_blank" rel="noopener noreferrer" class="">Enterprise Contract</a> verifies supply chain security artifacts with Rego policy.</li>
<li class="">Infrastructure CD checks: <a href="https://www.openpolicyagent.org/integrations/torque/" target="_blank" rel="noopener noreferrer" class="">Torque</a>, <a href="https://www.openpolicyagent.org/integrations/spinnaker-pipeline/" target="_blank" rel="noopener noreferrer" class="">Spinnaker</a> integrate Rego-based checks for continuous deployment while <a href="https://www.openpolicyagent.org/integrations/wirelesssecuritylab/" target="_blank" rel="noopener noreferrer" class="">ccbr</a> and <a href="https://www.openpolicyagent.org/integrations/carbonetes/" target="_blank" rel="noopener noreferrer" class="">​​BrainIAC</a> support a range of checks on existing IAC codebases.</li>
<li class="">Extending Authorization with OPA: The data orchestration tool <a href="https://www.openpolicyagent.org/integrations/alluxio/" target="_blank" rel="noopener noreferrer" class="">Alluxio</a> now also supports delegation of permissions to OPA.</li>
</ul>
<p><a href="https://www.openpolicyagent.org/integrations/digger/" target="_blank" rel="noopener noreferrer" class="">Digger</a>, an open source CI/CD orchestrator for Terraform both integrates OPA for user RBAC and leaning into existing tooling by leveraging OPA project <a href="http://conftest.dev/" target="_blank" rel="noopener noreferrer" class="">conftest</a> for IAC policy.</p>
<p>Meanwhile, other integrations went deeper and applied Rego in previously unexplored ways. <a href="https://www.openpolicyagent.org/integrations/regocpp/" target="_blank" rel="noopener noreferrer" class="">regocpp</a> is a cutting-edge project from collaborators at Microsoft that aims to bring Rego to other environments, natively. Based on C++, regocpp supports a number of Rego built-ins and the grammar as of v0.55.0.</p>
<p>The aforementioned linter, <a href="https://www.openpolicyagent.org/integrations/regal/" target="_blank" rel="noopener noreferrer" class="">Regal</a> also pushes the boundaries of where Rego can be used to write policies. Using the JSON representation of the Rego abstract syntax tree, this project implements a range of <a href="https://docs.styra.com/regal/category/rules" target="_blank" rel="noopener noreferrer" class="">linting rules</a>… in Rego! Regal has already been deployed by a number of open source Rego policy libraries and now supports over 60 rules. Integrated with the <a href="https://play.openpolicyagent.org/" target="_blank" rel="noopener noreferrer" class="">Rego Playground</a> the linter is already available to everyone. There's no doubt that this will be a great tool for OPA learners and long-timers alike while continuing to help <a href="https://thenewstack.io/scaling-open-source-community-by-getting-closer-to-users/" target="_blank" rel="noopener noreferrer" class="">scale</a> the OPA community.</p>
<p>If you're interested in listing your OPA integration or project, please see <a href="https://github.com/open-policy-agent/opa/tree/main/docs#opa-ecosystem" target="_blank" rel="noopener noreferrer" class="">the instructions</a> or stop by the #ecosystem channel in the <a href="https://communityinviter.com/apps/openpolicyagent/signup" target="_blank" rel="noopener noreferrer" class="">OPA slack</a> if you have any questions.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="thanks">Thanks<a href="https://openpolicyagent.org/blog/open-policy-agent-2023-year-in-review-4c12df22e351#thanks" class="hash-link" aria-label="Direct link to Thanks" title="Direct link to Thanks" translate="no">​</a></h2>
<p>2023 was an exciting year for OPA and its community. With so many projects using, integrating or extending OPA for all sorts of use cases — and so many users helping to contribute in all sorts of ways — this community is truly a great place to be. Thank you all who helped make it so! Your efforts are seen and appreciated.</p>
<p>There's a lot of great stuff lined up for next year already, so buckle up, and let's <code>import future.2024</code>!</p>
<p>Special thanks to Charlie Egan, Rita Zhang and John Reese for having helped contribute to this blog.</p>]]></content>
        <author>
            <name>Anders Eknert</name>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[Open Policy Agent 2022, Year in Review]]></title>
        <id>https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535</id>
        <link href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535"/>
        <updated>2023-01-26T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Banner image for OPA 2022 year in review blog post]]></summary>
        <content type="html"><![CDATA[<p><img decoding="async" loading="lazy" alt="Banner image for OPA 2022 year in review blog post" src="https://openpolicyagent.org/assets/images/banner-fcb0ffaf1ef2b6e0249ff05f54423e9a.webp" width="1400" height="1400" class="img_ev3q"></p>
<p>It's a new year, and once again it's time to look back and reflect on the year that passed in the world of Open Policy Agent! 2022 was OPA's first full year as a CNCF graduated project, and while it would be easy to think that things would slow down after reaching that point of maturity and recognition, things have rather sped up. In community growth as well as pace of development — both of which we'll take a closer look at here.</p>
<p>This year, tech communities like ours enjoyed finally getting to meet in person again, and major conferences in our space, like KubeCon / CloudNativeCon, saw thousands of attendees in both Europe and North America. We also saw meetups, hackathons and other smaller gatherings move back from virtual to in-person events. On the topic of events — let's start our review of the year 2022 for Open Policy Agent there.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="notable-events">Notable Events<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#notable-events" class="hash-link" aria-label="Direct link to Notable Events" title="Direct link to Notable Events" translate="no">​</a></h2>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="2022-user-survey">2022 User Survey<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#2022-user-survey" class="hash-link" aria-label="Direct link to 2022 User Survey" title="Direct link to 2022 User Survey" translate="no">​</a></h3>
<p>While we queried our nearest OPA instance for policy decisions, we also queried the OPA community to learn about their experience of interacting with the project, documentation and tooling. The <a class="" href="https://openpolicyagent.org/blog/open-policy-agent-2022-user-survey-summary-370cf0243bb7">survey results</a> provided us valuable insights into where we might want to spend some extra time and effort in 2023 — richer documentation with more examples was requested by many. We're also seeing a need to better highlight the benefits of the various management capabilities in OPA, like decision logging and monitoring. An interesting trend which continues from 2022 is the increasing number of OPA use cases inside organizations. While infrastructure policies (including Kubernetes) still come out on top, we're seeing more organizations embrace OPA for policy across their whole stack. A standardized way of working with policy was always a goal of the project, so it's really exciting to see more organizations seeing the benefits of this approach!</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="open-policy-day-with-opa">Open Policy Day with OPA<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#open-policy-day-with-opa" class="hash-link" aria-label="Direct link to Open Policy Day with OPA" title="Direct link to Open Policy Day with OPA" translate="no">​</a></h3>
<p>This year we were excited to see an entire event dedicated to OPA — the Open Policy Day with OPA co-located with KubeCon North America. During the course of the day, attendees got to hear end-user stories on using OPA in production, with speakers from organizations like Nvidia, T-Mobile. Capital One, Chime and Snowflake. If you couldn't attend in person, all the talks are up on <a href="https://www.youtube.com/@styra6251/videos" target="_blank" rel="noopener noreferrer" class="">YouTube</a>!</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="conferences-and-meetups">Conferences and Meetups<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#conferences-and-meetups" class="hash-link" aria-label="Direct link to Conferences and Meetups" title="Direct link to Conferences and Meetups" translate="no">​</a></h3>
<p>In the cloud-native space, OPA was represented in talks at both KubeCon / CloudNativeCon <a href="https://www.youtube.com/watch?v=MhyQxIp1H58&amp;t=4s" target="_blank" rel="noopener noreferrer" class="">Europe</a> as well as <a href="https://www.youtube.com/watch?v=RMiovzGGCfI" target="_blank" rel="noopener noreferrer" class="">North America</a>. As the interest in policy as code grew over the year, we saw a number of talks, workshops and events focused on the topic, and many discovered the benefits of unified policy management across tech stacks and organizations.</p>
<p>Additionally — while OPA has been, and continues to be, a popular topic at cloud-native, security and DevOps themed meetups, it's great to see new meetup groups dedicated entirely to the topic of OPA. Several OPA meetups took place in 2022, and we'd love to see that trend continue in the new year! If you'd like to host your own, <a href="https://www.openpolicyagent.org/community" target="_blank" rel="noopener noreferrer" class="">let us know</a>.</p>
<p>It was great to see so much buzz around OPA at these events, and much of that is thanks to the amazing work going on within the OPA projects — let's look into what's been going on there next!</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="new-features">New Features<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#new-features" class="hash-link" aria-label="Direct link to New Features" title="Direct link to New Features" translate="no">​</a></h2>
<p>OPA and Rego saw a record number of new features added in 2022.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="new-keywords">New Keywords<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#new-keywords" class="hash-link" aria-label="Direct link to New Keywords" title="Direct link to New Keywords" translate="no">​</a></h3>
<p>A few new keywords made a big difference both to the aesthetics of Rego, as well as its functionality. First off, the new <a href="https://www.openpolicyagent.org/docs/v0.38.1/policy-language/#every-keyword" target="_blank" rel="noopener noreferrer" class=""><code>every</code> keyword</a> elegantly helps solve the problem of expressing "<a href="https://www.openpolicyagent.org/docs/latest/#for-some-and-for-all" target="_blank" rel="noopener noreferrer" class="">for all</a>" type of queries:</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">future</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">keywords</span><span class="token punctuation" style="color:#393A34">.</span><span class="token keyword" style="color:#00009f">every</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">only_dev_servers</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token keyword" style="color:#00009f">some</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">site</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">in</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">sites</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token variable" style="color:#36acaa">site</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">name</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">==</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"dev"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token keyword" style="color:#00009f">every</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">server</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">in</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">site</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">servers</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">        </span><span class="token function" style="color:#d73a49">endswith</span><span class="token punctuation" style="color:#393A34">(</span><span class="token variable" style="color:#36acaa">server</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">name</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"-dev"</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<p>Next, the new <code>if</code> keyword helps policy authors express their rules in the same way as they normally should be read — as conditional assignments: "allow is true if conditions x, y and z are true". As an added bonus, the <code>if</code> keyword allows skipping the braces around single-line rule bodies, leading to rule constructs that read more like plain English:</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token variable" style="color:#36acaa">allow</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token string" style="color:#e3116c">"admin"</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">in</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">roles</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<p>May now be written as:</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token variable" style="color:#36acaa">allow</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">if</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"admin"</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">in</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">roles</span><br></div></code></pre></div></div>
<p>Similarly, the new <code>contains</code> keyword allows set-building partial rules to be expressed as "the set <strong>contains</strong> x if conditions x, y and z are true":</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token variable" style="color:#36acaa">deny</span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">message</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">security_clearance_level</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">&lt;</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">2</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token variable" style="color:#36acaa">message</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"Security clearance level 2 or higher required"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<p>May now be written as:</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token variable" style="color:#36acaa">deny</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">contains</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">message</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">if</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">security_clearance_level</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">&lt;</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">2</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token variable" style="color:#36acaa">message</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"Security clearance level 2 or higher required"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="refs-in-rule-heads">Refs in Rule Heads<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#refs-in-rule-heads" class="hash-link" aria-label="Direct link to Refs in Rule Heads" title="Direct link to Refs in Rule Heads" translate="no">​</a></h3>
<p>It is said that one of the hardest things in computer science is naming things… "<a href="https://github.com/open-policy-agent/opa/releases/tag/v0.46.1" target="_blank" rel="noopener noreferrer" class="">refs in rule heads</a>" seems to support that claim! Don't let the name intimidate you though, this is a great addition to Rego! Dynamically creating deeply nested objects would previously often require the use of nested packages, with each package provided in its own file. This is no longer the case, as nesting can now be expressed in one place:</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token keyword" style="color:#00009f">package</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">policy</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">claims</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">name</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">concat</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">" "</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">first_name</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">last_name</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">request</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">method</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">request</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">method</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">request</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">valid</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">validate</span><span class="token punctuation" style="color:#393A34">(</span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">request</span><span class="token punctuation" style="color:#393A34">)</span><br></div></code></pre></div></div>
<p>Evaluating the policy package will now provide something like the below result:</p>
<div class="language-json codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-json codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token property" style="color:#36acaa">"claims"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token property" style="color:#36acaa">"user"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">      </span><span class="token property" style="color:#36acaa">"name"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"John Doe"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token property" style="color:#36acaa">"request"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token property" style="color:#36acaa">"method"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"PUT"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token property" style="color:#36acaa">"valid"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="built-in-function-metadata-and-metadata-introspection">Built-in Function Metadata and Metadata Introspection<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#built-in-function-metadata-and-metadata-introspection" class="hash-link" aria-label="Direct link to Built-in Function Metadata and Metadata Introspection" title="Direct link to Built-in Function Metadata and Metadata Introspection" translate="no">​</a></h3>
<p>Another exciting addition to Rego this year was the introduction of <a href="https://www.openpolicyagent.org/docs/latest/annotations/" target="_blank" rel="noopener noreferrer" class="">metadata annotations</a>. Previously, policy authors would have to devise custom methods and formats for annotating their policies, packages and rules with metadata in the form of comments. Native support for annotations now provides a unified way not only for authoring structured annotations, but also for parsing them using either the "opa inspect" command, programmatically from Go, or even from Rego policies themselves via the new built-in rego.metadata functions. Having a standardized way of annotating packages and rules with metadata should benefit both human consumers as well as tooling.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="testing">Testing<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#testing" class="hash-link" aria-label="Direct link to Testing" title="Direct link to Testing" translate="no">​</a></h3>
<p>A major advantage of treating policy as code is that code is testable. Unit testing provides effective guardrails around policies and rules, and allows frequent updates without the risk of breaking things. While test-driven development has been considered a best practice for Rego since the start, one feature that many found missing was the ability to mock functions. <a href="https://www.openpolicyagent.org/docs/latest/policy-testing/#data-and-function-mocking" target="_blank" rel="noopener noreferrer" class="">Function mocking</a> allows replacing built-in functions, like http.send, or custom functions, with different implementations, commonly free of side-effects, all using the same <code>with</code> keyword familiar to test authors.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="policy-and-data-distribution">Policy and Data Distribution<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#policy-and-data-distribution" class="hash-link" aria-label="Direct link to Policy and Data Distribution" title="Direct link to Policy and Data Distribution" translate="no">​</a></h3>
<p>Policy is commonly only half of the equation when OPA makes decisions — having access to up-to-date <em>data</em> related to users, endpoints or resources is often just as important. Data tends to be more dynamic in nature than policy, and certain types of deployments require a <strong>lot</strong> of data. The combination of huge datasets and frequently changing data would previously require continuous transfer of all required data in a bundle — even when only a few attributes had been updated. The introduction of <a href="https://www.openpolicyagent.org/docs/latest/management-bundles/#delta-bundles" target="_blank" rel="noopener noreferrer" class="">delta bundles</a> solves this by providing a new bundle type containing only the changes to data made since the last fetch, i.e. the <em>delta</em>. A much-awaited feature, and one that will help ensure OPA covers even the most complex of use cases going forward.</p>
<p>Another introduction this year was support for <a href="https://opencontainers.org/" target="_blank" rel="noopener noreferrer" class="">OCI</a> <a href="https://www.openpolicyagent.org/docs/latest/management-bundles/#oci-registry" target="_blank" rel="noopener noreferrer" class="">bundle registries</a>. In an increasingly containerized world, distribution of applications is no longer the only use case for containers, and providing policy and data using the same channels as you would for e.g. Docker images, simplify things considerably in many environments.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="disk-storage">Disk Storage<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#disk-storage" class="hash-link" aria-label="Direct link to Disk Storage" title="Direct link to Disk Storage" translate="no">​</a></h3>
<p>While delta bundles may solve the problem of <em>distributing</em> large volumes of data, that data must eventually still be stored somewhere for OPA to make use of it. Up until this year, only a single option for storage was provided: in-memory. While this is normally the best place to store it for fast access, large datasets distributed in-memory across a large number of running instances quickly adds up, and many are those who learnt the hard way that the old slogan of "memory is cheap" isn't always true at scale. The <a href="https://www.openpolicyagent.org/docs/latest/configuration/#disk-storage" target="_blank" rel="noopener noreferrer" class="">disk based storage</a> option now provides a balance between performance and costs, and is a welcome addition to OPA in many types of integrations.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="compiler-strict-mode">Compiler Strict mode<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#compiler-strict-mode" class="hash-link" aria-label="Direct link to Compiler Strict mode" title="Direct link to Compiler Strict mode" translate="no">​</a></h3>
<p>The Topdown compiler in OPA was enhanced with a new <a href="https://www.openpolicyagent.org/docs/latest/strict/" target="_blank" rel="noopener noreferrer" class="">strict mode</a> option, allowing policy authors to catch common mistakes before deploying their policy to production. Unused imports and variables, or use of deprecated built-in functions — now all flagged by the compiler with strict mode turned on. Together with JSON schema-based <a href="https://www.openpolicyagent.org/docs/latest/schemas/" target="_blank" rel="noopener noreferrer" class="">type checking</a>, developers are provided some powerful tools to ensure the robustness of their policy. Guard rails around the guard rails!</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="intermediate-representation-ir">Intermediate Representation (IR)<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#intermediate-representation-ir" class="hash-link" aria-label="Direct link to Intermediate Representation (IR)" title="Direct link to Intermediate Representation (IR)" translate="no">​</a></h3>
<p>The OPA project has the ambitious goal of standardizing policy across the full stack, because of this it's sometimes necessary to consider alternative deployment models to the traditional standalone service. This year we saw OPA provide a new <a class="" href="https://openpolicyagent.org/blog/i-have-a-plan-exploring-the-opa-intermediate-representation-ir-format-7319cd94b37d">intermediate representation</a> format, allowing custom implementations to parse and execute evaluation plans. An implementation for the JVM and Javascript has already been made available with the <a href="https://github.com/borgeby/jarl" target="_blank" rel="noopener noreferrer" class="">Jarl</a> project, and hopefully we'll see more to follow in 2023!</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="built-in-functions">Built-in functions<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#built-in-functions" class="hash-link" aria-label="Direct link to Built-in functions" title="Direct link to Built-in functions" translate="no">​</a></h2>
<p>20 new <a href="https://www.openpolicyagent.org/docs/latest/policy-reference/#built-in-functions" target="_blank" rel="noopener noreferrer" class="">built-in functions</a> got added in 2022 — more than any year before! We saw new functions in almost every existing category, and OPA's exciting new <a href="https://www.openpolicyagent.org/docs/latest/graphql-api-authorization/" target="_blank" rel="noopener noreferrer" class="">GraphQL</a> capabilities create a category of their own.</p>
<p><strong>GraphQL</strong>: <code>graphql.is_valid</code>, <code>graphql.parse</code>, <code>graphql.parse_and_verify</code>, <code>graphql.parse_query</code>, <code>graphql.parse_schema</code>, <code>graphql.schema_is_valid</code></p>
<p><strong>Strings</strong>: <code>indexof_n</code>, <code>regex.replace</code>, <code>strings.any_prefix_match</code>, <code>strings.any_suffix_match</code></p>
<p><strong>Objects</strong>: <code>object.subset</code>, <code>object.union_n</code>, <code>object.keys</code></p>
<p><strong>Crypto</strong>: <code>crypto.hmac.md5</code>, <code>crypto.hmac.sha1</code>, <code>crypto.hmac.sha256</code>, <code>crypto.hmac.sha512</code></p>
<p><strong>Misc</strong>: <code>providers.aws.sign_req</code>, <code>net.cidr_is_valid</code>, <code>graph.reachable_paths</code></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="performance-improvements">Performance Improvements<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#performance-improvements" class="hash-link" aria-label="Direct link to Performance Improvements" title="Direct link to Performance Improvements" translate="no">​</a></h2>
<p>Some improvements are more understated, though no less noteworthy. As a mature software project, deployed in production in thousands of organizations across the world, OPA needs to be both robust and performant. This year saw the following exciting improvements in OPA performance:</p>
<ul>
<li class="">The — optimize flag now works for more commands (previously only available for <code>opa build</code>)</li>
<li class="">Lazy objects optimization allows delaying evaluation of attributes until needed</li>
<li class="">Built-in function optimizations for <code>object.get</code>, <code>in</code>, <code>object.union_n</code>, and others</li>
<li class="">Two new highly optimized built-in functions for doing prefix and suffix matching <em>en masse</em>: <code>strings.any_prefix_match</code> and <code>strings.any_suffix_match</code></li>
<li class="">Internal optimizations to set element addition, object insertion and set union.</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="ecosystem-and-integrations">Ecosystem and integrations<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#ecosystem-and-integrations" class="hash-link" aria-label="Direct link to Ecosystem and integrations" title="Direct link to Ecosystem and integrations" translate="no">​</a></h2>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="gatekeeper">Gatekeeper<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#gatekeeper" class="hash-link" aria-label="Direct link to Gatekeeper" title="Direct link to Gatekeeper" translate="no">​</a></h3>
<p>A whole lot of great things landed in the Gatekeeper project this year! Following recent developments, Gatekeeper was made compatible with the Kubernetes v1.25 shift from Pod Security Policies to Pod Security Admission. On the topic of Kubernetes workloads, the new <a href="https://open-policy-agent.github.io/gatekeeper/website/docs/expansion" target="_blank" rel="noopener noreferrer" class="">Validation of Workload Resources</a> feature allows writing rules that apply to any Pod spec, whether deployed as a standalone pod or embedded in a parent resource, like a Deployment. Similarly, Gatekeeper now also allows validating subresources. The <a href="https://open-policy-agent.github.io/gatekeeper/website/docs/externaldata" target="_blank" rel="noopener noreferrer" class="">external data feature</a>, which, as the name implies, allows Gatekeeper to interface with various external data sources for validation and mutation, moved to beta this year, and the next feature to do so is <a href="https://open-policy-agent.github.io/gatekeeper/website/docs/gator" target="_blank" rel="noopener noreferrer" class="">Gator</a>, which allows testing of Gatekeeper ConstraintTemplates and Constraints in a local environment. Finally, the mutation feature is now considered stable.</p>
<p>In addition to all the features listed above, Gatekeeper is now faster than ever before! Some of the most notable improvements include reduced time for template compilation, adding and evaluating constraints, a whopping ~20X reduction in persistent audit memory usage, reduced request duration for policies with replicated data and reduced CPU time when adding data to OPA storage.</p>
<p>The ecosystem around Gatekeeper also saw improvements this year, where the most notable ones were the new Gatekeeper Policies <a href="https://open-policy-agent.github.io/gatekeeper-library/website" target="_blank" rel="noopener noreferrer" class="">website</a>, and the inclusion of Gatekeeper policies on <a href="https://artifacthub.io/packages/search?repo=gatekeeper-policies" target="_blank" rel="noopener noreferrer" class="">ArtifactHub</a>.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="conftest">Conftest<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#conftest" class="hash-link" aria-label="Direct link to Conftest" title="Direct link to Conftest" translate="no">​</a></h3>
<p>Conftest saw a rapid pace of development this year, with 12 releases pushed — from version 0.29.0, and ending in version 0.37.0! The project added support for policy authoring using a number of additional file types — like env, hcl, jsonc, CycloneDX, and SPDX — as input. Possibly even more exciting is the addition of several new built-in functions exclusive to Conftest, like parse_config, parse_config_file, and parse_combined_config. These functions all allow policy authors to pull in configuration to test from inside of a policy, allowing a greater deal of flexibility in how config tests are executed.</p>
<p>The tooling around Conftest improved as well: when using the <code>--version</code> flag, the version of OPA used by Conftest will now also be displayed. Additionally, the new <code>--quiet</code> flag allows excluding anything but errors in the output, which should help in quickly identifying issues.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="integrations">Integrations<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#integrations" class="hash-link" aria-label="Direct link to Integrations" title="Direct link to Integrations" translate="no">​</a></h3>
<p>OPA would not be what it is without its massive ecosystem of tools, integrations and useful and fun projects. The year started out with some great news in the infrastructure space, with AWS opening up for the possibility of externalizing compliance checks of CloudFormation templates via hooks, and it did not take long for the <a href="https://github.com/StyraInc/opa-aws-cloudformation-hook" target="_blank" rel="noopener noreferrer" class="">AWS CloudFormation hook for OPA</a> to arrive on the scene. Later this year, Hashicorp announced <a href="https://developer.hashicorp.com/terraform/cloud-docs/policy-enforcement" target="_blank" rel="noopener noreferrer" class="">support for OPA</a> in their Terraform Cloud offering. A <a href="https://github.com/pulumi/pulumi-policy-opa" target="_blank" rel="noopener noreferrer" class="">Pulumi</a> integration was also added to the <a href="https://www.openpolicyagent.org/docs/latest/ecosystem/" target="_blank" rel="noopener noreferrer" class="">ecosystem</a>. The message seems clear — the tool to use for infrastructure as code (IaC) compliance is OPA, and the language to define IaC policies is Rego!</p>
<p>Outside of the infrastructure space, we saw a number of interesting integrations being built by the community, like <a href="https://github.com/dolevf/Open-Policy-Agent-Alfred" target="_blank" rel="noopener noreferrer" class="">Alfred</a>, a Rego Playground you can self host, a <a href="https://circleci.com/docs/config-policy-management-overview/" target="_blank" rel="noopener noreferrer" class="">CircleCI</a> integration for CI/CD pipeline policies, <a href="https://github.com/open-policy-agent/contrib/tree/main/opa_fig_autocomplete" target="_blank" rel="noopener noreferrer" class="">fig</a> support for command line auto-completion goodness, <a href="https://docs.walt.id/v/ssikit/ssi-kit/open-policy-agent" target="_blank" rel="noopener noreferrer" class="">self-sovereign identity</a> (SSI) integrations, and even policy-driven access to remote systems via <a href="https://github.com/Snowflake-Labs/sansshell" target="_blank" rel="noopener noreferrer" class="">SansShell</a>. OPA-powered policy enforcement even made it to the desktop this year, with the CISA-developed <a href="https://github.com/cisagov/ScubaGear/" target="_blank" rel="noopener noreferrer" class="">ScubaGear</a> project using Rego for validating M365 tenant configurations!</p>
<p>Finally, a much awaited addition to the OPA ecosystem — the <a href="https://github.com/StyraInc/rego-style-guide" target="_blank" rel="noopener noreferrer" class="">Rego Style Guide</a> now offers policy authors a comprehensive set of rules and best practices for authoring Rego.</p>
<p>For a more comprehensive list of OPA integrations, check out the OPA <a href="https://www.openpolicyagent.org/docs/latest/ecosystem/" target="_blank" rel="noopener noreferrer" class="">ecosystem page</a>, and the <a href="https://github.com/anderseknert/awesome-opa" target="_blank" rel="noopener noreferrer" class="">Awesome OPA</a> list.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="credits">Credits<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-year-in-review-79324ad54535#credits" class="hash-link" aria-label="Direct link to Credits" title="Direct link to Credits" translate="no">​</a></h2>
<p>None of the above would have been made possible without the amazing community around OPA. In 2022, we saw an incredible number of people contribute to the project in all imaginable ways — code, documentation, bug reports, support discussions, integrations and tools. OPA is being used more and more widely around the world, and in different domains. With this growth, it'd be easy to overlook the huge effort in growing a community to support the project. We know how hard the community has worked to get to where we are and for that we are immensely grateful. Thank you all for getting us to where we are today and laying the foundation for another fantastic year with Open Policy Agent.</p>]]></content>
        <author>
            <name>Anders Eknert</name>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[OPA Newsletter: November 2022]]></title>
        <id>https://openpolicyagent.org/blog/november-newsletter-9f3bbcb29405</id>
        <link href="https://openpolicyagent.org/blog/november-newsletter-9f3bbcb29405"/>
        <updated>2023-01-25T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[November Edition!]]></summary>
        <content type="html"><![CDATA[<p><em>November Edition!</em></p>
<p>November has arrived and we are looking forward to the holiday season!</p>
<p>Thanks to all of the community members that stopped by the booth at Kubecon, it was a pleasure meeting you!</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="user-survey">User Survey<a href="https://openpolicyagent.org/blog/november-newsletter-9f3bbcb29405#user-survey" class="hash-link" aria-label="Direct link to User Survey" title="Direct link to User Survey" translate="no">​</a></h2>
<p>We are looking for input from the community to see how everyone is using OPA. Take 5 minutes to fill out this 7 question survey to help out the community!</p>
<p><a href="https://bit.ly/3UaIhWa" target="_blank" rel="noopener noreferrer" class="">Take the Survey</a></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="ecosystem-updates">Ecosystem Updates<a href="https://openpolicyagent.org/blog/november-newsletter-9f3bbcb29405#ecosystem-updates" class="hash-link" aria-label="Direct link to Ecosystem Updates" title="Direct link to Ecosystem Updates" translate="no">​</a></h2>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="open-policy-agent-v0461"><a href="https://github.com/open-policy-agent/opa/releases/tag/v0.46.1" target="_blank" rel="noopener noreferrer" class="">Open Policy Agent v0.46.1</a><a href="https://openpolicyagent.org/blog/november-newsletter-9f3bbcb29405#open-policy-agent-v0461" class="hash-link" aria-label="Direct link to open-policy-agent-v0461" title="Direct link to open-policy-agent-v0461" translate="no">​</a></h3>
<ul>
<li class="">New language feature: refs in rule heads</li>
<li class="">Entrypoint annotations in rule metadata</li>
<li class="">New Built-in Function: graphql.schema_is_valid</li>
<li class="">New Built-in Function: net.cidr_is_valid</li>
</ul>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="gatekeeper-3100"><a href="https://github.com/open-policy-agent/gatekeeper/releases/tag/v3.10.0" target="_blank" rel="noopener noreferrer" class="">Gatekeeper 3.10.0</a><a href="https://openpolicyagent.org/blog/november-newsletter-9f3bbcb29405#gatekeeper-3100" class="hash-link" aria-label="Direct link to gatekeeper-3100" title="Direct link to gatekeeper-3100" translate="no">​</a></h3>
<ul>
<li class="">Kubernetes v1.25+, removal of Pod Security Policies and migration to Pod Security Admission 🔐</li>
<li class="">Mutation is promoted to stable 🦠</li>
<li class="">Introducing Validation of Workload Resources as alpha 🚀</li>
<li class="">Performance improvements 🏃</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="contributor-shout-outs">Contributor Shout Outs<a href="https://openpolicyagent.org/blog/november-newsletter-9f3bbcb29405#contributor-shout-outs" class="hash-link" aria-label="Direct link to Contributor Shout Outs" title="Direct link to Contributor Shout Outs" translate="no">​</a></h2>
<p>Thanks to all of the contributors that participated in these releases, the OPA community wouldn't be here without you!</p>
<ul>
<li class="">@mattfarina</li>
<li class="">@jaspervdj</li>
<li class="">@ricardomaraschini</li>
<li class="">@byronic</li>
<li class="">@philipaconrad</li>
<li class="">@pjbgf</li>
<li class="">@caldwecr</li>
<li class="">@hzliangbin</li>
<li class="">@peterchenadded</li>
<li class="">@phantlantis</li>
<li class="">@ericjkao</li>
<li class="">@TheLunaticScripter</li>
<li class="">@humbertoc-silva</li>
<li class="">@Juneezee</li>
<li class="">@vinhph0906</li>
<li class="">@aholmis</li>
<li class="">@Joffref</li>
<li class="">@olegroom</li>
<li class="">@iamatwork</li>
<li class="">@fredallen-wk</li>
<li class="">@bartandacc</li>
<li class="">@max0ne</li>
<li class="">@OpenSourceZombie</li>
<li class="">@JAORMX</li>
<li class="">@Boojapho</li>
<li class="">@ethanrange</li>
<li class="">@stp-bsh</li>
<li class="">@qa-ship-it</li>
<li class="">@salaxander</li>
<li class="">@boatmisser</li>
<li class="">@gracedo</li>
<li class="">@meons</li>
<li class="">@mariusblarsen</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="community-tools">Community Tools<a href="https://openpolicyagent.org/blog/november-newsletter-9f3bbcb29405#community-tools" class="hash-link" aria-label="Direct link to Community Tools" title="Direct link to Community Tools" translate="no">​</a></h2>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="circle-policy-agent">circle-policy-agent<a href="https://openpolicyagent.org/blog/november-newsletter-9f3bbcb29405#circle-policy-agent" class="hash-link" aria-label="Direct link to circle-policy-agent" title="Direct link to circle-policy-agent" translate="no">​</a></h3>
<p>The policy-agent is essentially a CircleCI-flavored wrapper library around the Open Policy Agent (OPA), which will allow the users to write the policy documents in CircleCI terminology.</p>
<p><a href="https://github.com/CircleCI-Public/circle-policy-agent" target="_blank" rel="noopener noreferrer" class="">Star on GitHub</a></p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="custom-opa-spicedb">custom-opa-spicedb<a href="https://openpolicyagent.org/blog/november-newsletter-9f3bbcb29405#custom-opa-spicedb" class="hash-link" aria-label="Direct link to custom-opa-spicedb" title="Direct link to custom-opa-spicedb" translate="no">​</a></h3>
<p>This experiment adds support for querying relations from Authzed / SpiceDB via GRPC to check resource level permissions as custom builtin commands for Open Policy Agent.</p>
<p><a href="https://github.com/thomasdarimont/custom-opa-spicedb" target="_blank" rel="noopener noreferrer" class="">Star on GitHub</a></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="videos-">Videos 🎥<a href="https://openpolicyagent.org/blog/november-newsletter-9f3bbcb29405#videos-" class="hash-link" aria-label="Direct link to Videos 🎥" title="Direct link to Videos 🎥" translate="no">​</a></h2>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="policy-as-code-with-open-policy-agent--anders-eknert-styra">Policy as Code with Open Policy Agent — Anders Eknert, Styra<a href="https://openpolicyagent.org/blog/november-newsletter-9f3bbcb29405#policy-as-code-with-open-policy-agent--anders-eknert-styra" class="hash-link" aria-label="Direct link to Policy as Code with Open Policy Agent — Anders Eknert, Styra" title="Direct link to Policy as Code with Open Policy Agent — Anders Eknert, Styra" translate="no">​</a></h3>
<p>Should user Alice be allowed to read credit reports? Should a cloud instance be deployable without basic security configuration in place? Should service X be allowed to query the database? Policy defines the rules of our systems, but how do we ensure our policies are enforced consistently in increasingly distributed and diverse tech stacks? In this talk we'll explore the benefits of decoupling policy from our applications, deployment pipelines and platforms, and how Open Policy Agent (OPA) can help unify the way we work with policy across the stack.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="securing-kubernetes-with-opa-and-gatekeeper">Securing kubernetes with opa and gatekeeper<a href="https://openpolicyagent.org/blog/november-newsletter-9f3bbcb29405#securing-kubernetes-with-opa-and-gatekeeper" class="hash-link" aria-label="Direct link to Securing kubernetes with opa and gatekeeper" title="Direct link to Securing kubernetes with opa and gatekeeper" translate="no">​</a></h3>
<p>Starts at 3:23:20 as part of the Kubehuddle Edinburgh event.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="blogs">Blogs<a href="https://openpolicyagent.org/blog/november-newsletter-9f3bbcb29405#blogs" class="hash-link" aria-label="Direct link to Blogs" title="Direct link to Blogs" translate="no">​</a></h2>
<ul>
<li class=""><a class="" href="https://openpolicyagent.org/blog/i-have-a-plan-exploring-the-opa-intermediate-representation-ir-format-7319cd94b37d">I have a plan! Exploring the OPA Intermediate Representation (IR) format</a></li>
<li class=""><a href="https://thenewstack.io/5-application-authorization-best-practices-for-better-cybersecurity/" target="_blank" rel="noopener noreferrer" class="">5 Application Authorization Best Practices for Better Cybersecurity</a></li>
<li class=""><a href="https://qjuanp.dev/post/introduction-sets-rego-open-policy-agent" target="_blank" rel="noopener noreferrer" class="">Intro to sets in Rego</a></li>
<li class=""><a href="https://inspektor.cloud/blog/evaluating-open-policy-agent-in-rust-using-wasm/" target="_blank" rel="noopener noreferrer" class="">OPA into WASM</a></li>
<li class=""><a href="https://dev.to/thenjdevopsguy/open-policy-agent-opa-for-kubernetes-5895" target="_blank" rel="noopener noreferrer" class="">Opa for k8s</a></li>
<li class=""><a href="https://www.baeldung.com/spring-security-authorization-opa" target="_blank" rel="noopener noreferrer" class="">Spring Security Authorization with OPA</a></li>
<li class=""><a href="https://www.infoq.com/news/2022/10/programming-policy-code/" target="_blank" rel="noopener noreferrer" class="">Programming Your Policies: Justin Cormack at QCon San Francisco 2022</a></li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="let-us-know-how-we-did">Let us know how we did<a href="https://openpolicyagent.org/blog/november-newsletter-9f3bbcb29405#let-us-know-how-we-did" class="hash-link" aria-label="Direct link to Let us know how we did" title="Direct link to Let us know how we did" translate="no">​</a></h2>
<p>The OPA monthly newsletter is built for the OPA community, let us know what you liked or what you wanted to see more of. Reach out using one of the links below.</p>]]></content>
        <author>
            <name>Peter O'Neill</name>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[OPA Newsletter: October 2022]]></title>
        <id>https://openpolicyagent.org/blog/october-newsletter-6b90cab2dcdb</id>
        <link href="https://openpolicyagent.org/blog/october-newsletter-6b90cab2dcdb"/>
        <updated>2023-01-25T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[October Edition!]]></summary>
        <content type="html"><![CDATA[<p><em>October Edition!</em></p>
<p>October is here, the leaves are changing colors, and weather is starting to become cool.</p>
<p>The OPA community will be at KubeCon NA, so don't forget to register for Cloud Native Policy Day with OPA!</p>
<p><a href="https://www.styra.com/cloud-native-policy-day-with-opa-2022/" target="_blank" rel="noopener noreferrer" class="">Register Today!</a></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="community-updates">Community Updates<a href="https://openpolicyagent.org/blog/october-newsletter-6b90cab2dcdb#community-updates" class="hash-link" aria-label="Direct link to Community Updates" title="Direct link to Community Updates" translate="no">​</a></h2>
<p>The OPA community now has over 300 GitHub contributors!</p>
<p>Our friends over at Postman connected with us to setup an OPA webpage to help our community members explore the OPA API.</p>
<p><a href="https://www.postman.com/openpolicyagent" target="_blank" rel="noopener noreferrer" class="">The OPA API on Postman</a></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="ecosystem-updates">Ecosystem Updates<a href="https://openpolicyagent.org/blog/october-newsletter-6b90cab2dcdb#ecosystem-updates" class="hash-link" aria-label="Direct link to Ecosystem Updates" title="Direct link to Ecosystem Updates" translate="no">​</a></h2>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="open-policy-agent-v0450"><a href="https://github.com/open-policy-agent/opa/releases/tag/v0.45.0" target="_blank" rel="noopener noreferrer" class="">Open Policy Agent v0.45.0</a><a href="https://openpolicyagent.org/blog/october-newsletter-6b90cab2dcdb#open-policy-agent-v0450" class="hash-link" aria-label="Direct link to open-policy-agent-v0450" title="Direct link to open-policy-agent-v0450" translate="no">​</a></h3>
<ul>
<li class=""><strong>Feature</strong>: Improved Decision Logging with <a href="https://www.openpolicyagent.org/docs/v0.45.0/management-decision-logs/#masking-sensitive-data" target="_blank" rel="noopener noreferrer" class="">nd_builtin_cache</a></li>
<li class=""><strong>New builtin</strong>: <a href="https://www.openpolicyagent.org/docs/v0.45.0/policy-reference/#builtin-regex-regexreplace" target="_blank" rel="noopener noreferrer" class="">regex.replace</a> for regex-based search/replace on strings</li>
<li class=""><strong>Optimization</strong>: <a href="https://github.com/open-policy-agent/opa/issues/4985" target="_blank" rel="noopener noreferrer" class="">object.union_n</a> builtin implementation to use a more efficient merge algorithm</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="community-tools">Community Tools<a href="https://openpolicyagent.org/blog/october-newsletter-6b90cab2dcdb#community-tools" class="hash-link" aria-label="Direct link to Community Tools" title="Direct link to Community Tools" translate="no">​</a></h2>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="capua">Capua<a href="https://openpolicyagent.org/blog/october-newsletter-6b90cab2dcdb#capua" class="hash-link" aria-label="Direct link to Capua" title="Direct link to Capua" translate="no">​</a></h2>
<p>A Kafka Policy engine that will help you validate your resources and artefact creations with style.</p>
<p><a href="https://github.com/kafka-ops/capua" target="_blank" rel="noopener noreferrer" class="">Like on GitHub</a></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="videos-">Videos 🎥<a href="https://openpolicyagent.org/blog/october-newsletter-6b90cab2dcdb#videos-" class="hash-link" aria-label="Direct link to Videos 🎥" title="Direct link to Videos 🎥" translate="no">​</a></h2>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="rq-datalog-for-your-shell-pipelines">rq: Datalog for your shell pipelines<a href="https://openpolicyagent.org/blog/october-newsletter-6b90cab2dcdb#rq-datalog-for-your-shell-pipelines" class="hash-link" aria-label="Direct link to rq: Datalog for your shell pipelines" title="Direct link to rq: Datalog for your shell pipelines" translate="no">​</a></h3>
<p>rq brings the full power of Rego, a Datalog dialect created for Open Policy Agent (OPA) to your shell pipelines. It allows you to easily transform and query data in a variety of commonly used formats using Rego expressions.</p>
<p>Speaker: Charles Daniels, Backend Software Engineer, Styra Inc.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="blogs">Blogs<a href="https://openpolicyagent.org/blog/october-newsletter-6b90cab2dcdb#blogs" class="hash-link" aria-label="Direct link to Blogs" title="Direct link to Blogs" translate="no">​</a></h2>
<ul>
<li class=""><a href="https://doordash.engineering/2022/09/20/how-doordash-ensures-velocity-and-reliability-through-policy-automation/" target="_blank" rel="noopener noreferrer" class="">How DoorDash Ensures Velocity and Reliability through Policy Automation</a></li>
<li class=""><a href="https://medium.com/google-cloud/deploying-gatekeeper-policies-as-oci-artifacts-the-gitops-way-e1233429ae2" target="_blank" rel="noopener noreferrer" class="">Deploying Gatekeeper policies as OCI artifacts, the GitOps way</a></li>
<li class=""><a href="https://amazic.com/rego-the-unified-policy-language-for-better-policy-management/" target="_blank" rel="noopener noreferrer" class="">Rego — The unified policy language for better policy management</a></li>
<li class=""><a href="https://jfarrell.net/2022/09/16/creating-custom-opa-policies-with-azure-policy/" target="_blank" rel="noopener noreferrer" class="">Creating Custom OPA Policies with Azure Policy</a></li>
<li class=""><a href="https://qiita.com/ipppppei/items/07cb80329bd3a9d1732a" target="_blank" rel="noopener noreferrer" class="">Use OPA Gatekeeper to prohibit specific IAM users from creating resources in a specific Namespace</a></li>
<li class=""><a href="http://kakedashi-xx.com:25214/index.php/2021/08/15/post-3024/" target="_blank" rel="noopener noreferrer" class="">[Copy and paste OK] Procedure for linking Open Policy Agent with Python</a></li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="events-">Events 📆<a href="https://openpolicyagent.org/blog/october-newsletter-6b90cab2dcdb#events-" class="hash-link" aria-label="Direct link to Events 📆" title="Direct link to Events 📆" translate="no">​</a></h2>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="cloud-native-policy-day-with-opa-oct-25th">Cloud Native Policy Day with OPA, Oct 25th<a href="https://openpolicyagent.org/blog/october-newsletter-6b90cab2dcdb#cloud-native-policy-day-with-opa-oct-25th" class="hash-link" aria-label="Direct link to Cloud Native Policy Day with OPA, Oct 25th" title="Direct link to Cloud Native Policy Day with OPA, Oct 25th" translate="no">​</a></h3>
<p>Cloud Native Policy Day with OPA hosted by Styra, the creators of Open Policy Agent, will bring together the OPA community for a day of sharing and discussing policy-as-code best practices, key learnings and creative use cases for OPA. Project maintainers will be on hand to field 1:1 questions and provide live-coding demos — and you'll see proven real-world implementations from various OPA adopters during each of the sessions.</p>
<p>Whether you're looking to start down your policy journey, or are an OPA adopter with Rego skills to share, join the community for sharing, learning and socializing.</p>
<p>Attendees are invited to come for the full day with lunch provided or to stop by just for the sessions that interest them most. To register for the event, add Cloud Native Policy Day with OPA from the co-located event list selections when registering for KubeCon + CloudNativeCon NA 2022 or add it to your existing registration by selecting "modify" on your confirmation page or clicking the "modify" link in your confirmation email.</p>
<p><a href="https://events.linuxfoundation.org/kubecon-cloudnativecon-north-america/register/" target="_blank" rel="noopener noreferrer" class="">👉 Register Today! 👈</a></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="let-us-know-how-we-did">Let us know how we did<a href="https://openpolicyagent.org/blog/october-newsletter-6b90cab2dcdb#let-us-know-how-we-did" class="hash-link" aria-label="Direct link to Let us know how we did" title="Direct link to Let us know how we did" translate="no">​</a></h2>
<p>The OPA monthly newsletter is built for the OPA community, let us know what you liked or what you wanted to see more of.</p>]]></content>
        <author>
            <name>Peter O'Neill</name>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[OPA Newsletter: September 2022]]></title>
        <id>https://openpolicyagent.org/blog/september-newsletter-3266b098c5f5</id>
        <link href="https://openpolicyagent.org/blog/september-newsletter-3266b098c5f5"/>
        <updated>2023-01-25T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[September Edition!]]></summary>
        <content type="html"><![CDATA[<p><em>September Edition!</em></p>
<p>Happy September Everyone! This month's edition is coming in a little late, but don't worry, it's still packed with great information.</p>
<p>Don't forget to register for Cloud Native Policy Day with OPA! More info at bottom.</p>
<p><a href="https://www.styra.com/cloud-native-policy-day-with-opa-2022/" target="_blank" rel="noopener noreferrer" class="">Register Today!</a></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="community-updates">Community Updates<a href="https://openpolicyagent.org/blog/september-newsletter-3266b098c5f5#community-updates" class="hash-link" aria-label="Direct link to Community Updates" title="Direct link to Community Updates" translate="no">​</a></h2>
<p>The Rego Playground now has a "Format" button! 🎉</p>
<p>This button auto-formats your policy code in the editor, as well as your input/data JSON documents.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="ecosystem-updates">Ecosystem Updates<a href="https://openpolicyagent.org/blog/september-newsletter-3266b098c5f5#ecosystem-updates" class="hash-link" aria-label="Direct link to Ecosystem Updates" title="Direct link to Ecosystem Updates" translate="no">​</a></h2>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="open-policy-agent-v0440"><a href="https://github.com/open-policy-agent/opa/releases/tag/v0.44.0" target="_blank" rel="noopener noreferrer" class="">Open Policy Agent v0.44.0</a><a href="https://openpolicyagent.org/blog/september-newsletter-3266b098c5f5#open-policy-agent-v0440" class="hash-link" aria-label="Direct link to open-policy-agent-v0440" title="Direct link to open-policy-agent-v0440" translate="no">​</a></h3>
<ul>
<li class="">security fixes, which mitigate CVE-2022-36085 in OPA itself, and CVE-2022-27664 and CVE-2022-32190 in our Go build tooling.</li>
<li class=""><a href="https://github.com/open-policy-agent/opa/pull/4999" target="_blank" rel="noopener noreferrer" class="">Linear performance scaling for sets up into the 500k key range and beyond</a></li>
<li class=""><a href="https://github.com/open-policy-agent/opa/issues/4979" target="_blank" rel="noopener noreferrer" class="">The union builtin is now about 15-30% faster than the equivalent operation in pure Rego.</a></li>
<li class=""><a href="https://www.openpolicyagent.org/docs/v0.42.0/policy-reference/#builtin-strings-stringsany_prefix_match" target="_blank" rel="noopener noreferrer" class="">This release introduces two new builtins: strings.any_prefix_match, and strings.any_suffix_match.</a></li>
</ul>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="npm-opa-wasm-v180"><a href="https://github.com/open-policy-agent/npm-opa-wasm/releases/tag/1.8.0" target="_blank" rel="noopener noreferrer" class="">NPM-OPA-WASM v1.8.0</a><a href="https://openpolicyagent.org/blog/september-newsletter-3266b098c5f5#npm-opa-wasm-v180" class="hash-link" aria-label="Direct link to npm-opa-wasm-v180" title="Direct link to npm-opa-wasm-v180" translate="no">​</a></h3>
<ul>
<li class=""><a href="https://github.com/open-policy-agent/npm-opa-wasm/pull/255" target="_blank" rel="noopener noreferrer" class="">New Feature: add loadPolicySync by @elliots in #255</a></li>
</ul>
<p>We will discuss these new features in the September 20th Office Hours. Sign up today and send in your questions.</p>
<p><a href="https://calendly.com/peter-styra/opa-office-hours" target="_blank" rel="noopener noreferrer" class="">Join OPA Office Hours</a></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="community-tools">Community Tools<a href="https://openpolicyagent.org/blog/september-newsletter-3266b098c5f5#community-tools" class="hash-link" aria-label="Direct link to Community Tools" title="Direct link to Community Tools" translate="no">​</a></h2>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="goast">Goast<a href="https://openpolicyagent.org/blog/september-newsletter-3266b098c5f5#goast" class="hash-link" aria-label="Direct link to Goast" title="Direct link to Goast" translate="no">​</a></h2>
<p>Go AST (Abstract Syntax Tree) based static analysis tool with Rego.</p>
<p><a href="https://github.com/m-mizutani/goast" target="_blank" rel="noopener noreferrer" class="">Like on GitHub</a></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="java-app-with-opa-policies">Java App with OPA Policies<a href="https://openpolicyagent.org/blog/september-newsletter-3266b098c5f5#java-app-with-opa-policies" class="hash-link" aria-label="Direct link to Java App with OPA Policies" title="Direct link to Java App with OPA Policies" translate="no">​</a></h2>
<p>Motivation for this code and application was to try to understand and implement the Hexagonal Architecture — also called Port and Adapter Architecture.</p>
<p><a href="https://github.com/uwegeercken/artikel" target="_blank" rel="noopener noreferrer" class="">Test it out</a></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="opa-support-for-go-fiber">OPA Support for Go Fiber<a href="https://openpolicyagent.org/blog/september-newsletter-3266b098c5f5#opa-support-for-go-fiber" class="hash-link" aria-label="Direct link to OPA Support for Go Fiber" title="Direct link to OPA Support for Go Fiber" translate="no">​</a></h2>
<p>Open Policy Agent support for Fiber.</p>
<p>Note: Requires Go 1.16 and above</p>
<p><a href="https://github.com/gofiber/contrib/tree/main/opafiber" target="_blank" rel="noopener noreferrer" class="">Try it</a></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="blogs">Blogs<a href="https://openpolicyagent.org/blog/september-newsletter-3266b098c5f5#blogs" class="hash-link" aria-label="Direct link to Blogs" title="Direct link to Blogs" translate="no">​</a></h2>
<p>Read up on how the OPA community is using OPA.</p>
<ul>
<li class=""><a href="https://medium.com/@nikman/control-user-access-and-permissions-in-cvat-with-open-policy-agent-a2abbd09774d" target="_blank" rel="noopener noreferrer" class="">Control User Access and Permissions in CVAT with Open Policy Agent</a></li>
<li class=""><a href="https://www.trendmicro.com/en_us/research/22/h/what-exposed-opa-servers-can-tell-you-about-your-applications-.html" target="_blank" rel="noopener noreferrer" class="">What Exposed OPA Servers Can Tell You About Your Applications</a></li>
<li class=""><a href="https://www.styra.com/blog/using-xacml-with-opa-and-rego-the-best-of-both-worlds/" target="_blank" rel="noopener noreferrer" class="">Using XACML with OPA and Rego: The Best of Both Worlds</a></li>
<li class=""><a href="https://christina04.hatenablog.com/entry/opa-rest-api-authorization" target="_blank" rel="noopener noreferrer" class="">Authorize REST API with OPA (Japanese)</a></li>
<li class=""><a href="https://opencredo.com/blogs/controlling-kafka-data-flows-using-open-policy-agent/" target="_blank" rel="noopener noreferrer" class="">Controlling Kafka Data Flows using Open Policy Agent</a></li>
<li class=""><a href="https://tech.isid.co.jp/entry/2021/12/05/Policy_as_Code%E3%82%92%E5%AE%9F%E7%8F%BE%E3%81%99%E3%82%8B_Open_Policy_Agent_/_Rego_%E3%81%AE%E7%B4%B9%E4%BB%8B" target="_blank" rel="noopener noreferrer" class="">Introduction of Open Policy Agent / Rego to realize Policy as Code</a> (Japanese)</li>
<li class=""><a href="https://zendesk.engineering/collaborating-on-access-control-policies-with-open-policy-agent-fddbc3058359" target="_blank" rel="noopener noreferrer" class="">Collaborating on Access Control Policies with Open Policy Agent</a></li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="events-">Events 📆<a href="https://openpolicyagent.org/blog/september-newsletter-3266b098c5f5#events-" class="hash-link" aria-label="Direct link to Events 📆" title="Direct link to Events 📆" translate="no">​</a></h2>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="cloud-native-policy-day-with-opa-oct-25th">Cloud Native Policy Day with OPA, Oct 25th<a href="https://openpolicyagent.org/blog/september-newsletter-3266b098c5f5#cloud-native-policy-day-with-opa-oct-25th" class="hash-link" aria-label="Direct link to Cloud Native Policy Day with OPA, Oct 25th" title="Direct link to Cloud Native Policy Day with OPA, Oct 25th" translate="no">​</a></h3>
<p>Cloud Native Policy Day with OPA hosted by Styra, the creators of Open Policy Agent, will bring together the OPA community for a day of sharing and discussing policy-as-code best practices, key learnings and creative use cases for OPA. Project maintainers will be on hand to field 1:1 questions and provide live-coding demos — and you'll see proven real-world implementations from various OPA adopters during each of the sessions.</p>
<p>Whether you're looking to start down your policy journey, or are an OPA adopter with Rego skills to share, join the community for sharing, learning and socializing.</p>
<p>Attendees are invited to come for the full day with lunch provided or to stop by just for the sessions that interest them most. To register for the event, add Cloud Native Policy Day with OPA from the co-located event list selections when registering for KubeCon + CloudNativeCon NA 2022 or add it to your existing registration by selecting "modify" on your confirmation page or clicking the "modify" link in your confirmation email.</p>
<p><a href="https://events.linuxfoundation.org/kubecon-cloudnativecon-north-america/register/" target="_blank" rel="noopener noreferrer" class="">Register Today!</a></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="let-us-know-how-we-did">Let us know how we did<a href="https://openpolicyagent.org/blog/september-newsletter-3266b098c5f5#let-us-know-how-we-did" class="hash-link" aria-label="Direct link to Let us know how we did" title="Direct link to Let us know how we did" translate="no">​</a></h2>
<p>The OPA monthly newsletter is built for the OPA community, let us know what you liked or what you wanted to see more of.</p>]]></content>
        <author>
            <name>Peter O'Neill</name>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[I have a plan! Exploring the OPA Intermediate Representation (IR) format]]></title>
        <id>https://openpolicyagent.org/blog/i-have-a-plan-exploring-the-opa-intermediate-representation-ir-format-7319cd94b37d</id>
        <link href="https://openpolicyagent.org/blog/i-have-a-plan-exploring-the-opa-intermediate-representation-ir-format-7319cd94b37d"/>
        <updated>2022-10-20T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Diagram illustrating the OPA intermediate representation format]]></summary>
        <content type="html"><![CDATA[<p><img decoding="async" loading="lazy" alt="Diagram illustrating the OPA intermediate representation format" src="https://openpolicyagent.org/assets/images/banner-6ab7344a27e906d495218476abb2202a.webp" width="675" height="714" class="img_ev3q"></p>
<p>It isn't an overstatement to say that the versatility of Open Policy Agent (OPA) is a key factor in its success. As a general purpose policy engine, OPA needs to handle inputs from a disparate set of systems — Terraform, Kubernetes, CI/CD pipelines or custom applications, to name a few — and deliver decisions in a format understood by that particular system. Providing an agnostic approach to input and output data — anything that is or can be modeled hierarchically in a JSON or YAML document is potentially subject to policy — allows <a href="https://www.openpolicyagent.org/docs/latest/ecosystem/" target="_blank" rel="noopener noreferrer" class="">integrating</a> OPA with all kinds of systems, applications and tech stacks.</p>
<p>But how does the data get passed between client application and OPA? Running OPA as a standalone service, and querying OPA for decisions over its <a href="https://www.openpolicyagent.org/docs/latest/rest-api/" target="_blank" rel="noopener noreferrer" class="">REST API</a>, is by far the most common way to integrate OPA, and for good reasons! Running OPA as a separate component provides a nice, unified interface for communication, which commonly involves writing only a few lines of code in most modern programming languages. Additionally, many technologies allow extending the built-in functionality for e.g. authorization by utilizing <em>webhooks</em>, which are commonly REST requests with a JSON-encoded payload. Perfect integration point for OPA!</p>
<p>There are however some scenarios where the standalone REST model proves to be challenging:</p>
<ul>
<li class="">Resource-constrained environments like embedded systems. While OPA is fairly light-weight, some environments simply don't have the resources required to run a standalone OPA service, or networking capabilities for querying.</li>
<li class="">Distributed deployments with tight latency budgets, where every millisecond counts.</li>
<li class="">Environments constrained by other limitations on what type of software can be run, like web browsers.</li>
</ul>
<p>To accommodate these requirements, OPA provides a few <a href="https://www.openpolicyagent.org/docs/latest/integration/" target="_blank" rel="noopener noreferrer" class="">alternatives</a> to the standalone service model:</p>
<ul>
<li class="">Applications written in Go may integrate directly with the OPA Go API, or through the high-level Go SDK, alleviating the need for OPA to run as a separate service.</li>
<li class="">Policy may be compiled into Wasm modules, which can then be evaluated in any Wasm runtime. While the most famous Wasm runtime may be that included in web browsers, most programming languages today offer integrations with a Wasm runtime, allowing (at least the policy evaluation parts of) OPA to run "inside" of the application rather than outside of it. Additionally, OPA itself ships with a Wasm runtime, which makes it possible to have OPA pull down bundles including Wasm compiled policy for faster evaluation, and potentially other benefits.</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="wasm">Wasm<a href="https://openpolicyagent.org/blog/i-have-a-plan-exploring-the-opa-intermediate-representation-ir-format-7319cd94b37d#wasm" class="hash-link" aria-label="Direct link to Wasm" title="Direct link to Wasm" translate="no">​</a></h2>
<p>Rego policies compiled to Wasm modules offers a flexible, highly performant alternative to "regular" policy evaluation, with runtimes available for a <a href="https://github.com/appcypher/awesome-wasm-runtimes" target="_blank" rel="noopener noreferrer" class="">wide array</a> of languages, frameworks and platforms. As such, it should be considered an option for any OPA integration where the standalone server model falls short of the requirements. However, as ubiquitous as Wasm runtimes may be, they are not available <em>everywhere</em>. Embedded environments, exotic architectures or specialized hardware all constitute examples of environments where we're unlikely to encounter a Wasm runtime. But even with one available, Wasm <em>itself</em> is not without limitations, even by design!</p>
<p>With the goals of providing a safe, <em>sandboxed</em> environment, originally targeting web browsers, Wasm has several restrictions on what can and can't be done in the confines of the runtime. Interacting with the host system, or for that matter, other host systems — whether through system calls, network requests, or file system operations, is generally prohibited. While the WebAssembly System Interface (WASI) aims to offer an API for this exact purpose, and could potentially be used for certain features of Rego (like the http.send built-in function) in the future, relying on WASI means that a policy evaluated in one runtime might not work in another, as currently only a certain subset of the WASI API is implemented in any given runtime, and Wasm runtimes like those provided by web browsers likely have no interest in supporting interactions with the host system <em>at all</em>. Last, while some great progress has been made around WASI recently, it is still nowhere near the maturity of Wasm.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="intermediate-representation-ir">Intermediate Representation (IR)<a href="https://openpolicyagent.org/blog/i-have-a-plan-exploring-the-opa-intermediate-representation-ir-format-7319cd94b37d#intermediate-representation-ir" class="hash-link" aria-label="Direct link to Intermediate Representation (IR)" title="Direct link to Intermediate Representation (IR)" translate="no">​</a></h2>
<p>OPA v0.37.0, released early 2022, brought two major enhancements to OPA: <a href="https://www.openpolicyagent.org/docs/latest/strict/" target="_blank" rel="noopener noreferrer" class="">compiler strict mode</a> and <a href="https://www.openpolicyagent.org/docs/latest/management-bundles/#delta-bundles" target="_blank" rel="noopener noreferrer" class="">delta bundles</a>. While those two features might have stolen the show of the release, the <a href="https://github.com/open-policy-agent/opa/releases/tag/v0.37.0" target="_blank" rel="noopener noreferrer" class="">changelog</a> additionally provides us with this:</p>
<blockquote>
<p>The compile package and the opa build command support a new output format: "plan". It represents a <em>query plan</em>, steps needed to take to evaluate a query (with policies). The plan format is a JSON encoding of the intermediate representation (IR) used for compiling queries and policies into Wasm.</p>
</blockquote>
<p>Interesting! Now, what does it mean? As alluded to in the last sentence, the low-level building blocks, or the <em>evaluation plan</em>, that eventually becomes Wasm, is now made available for consumption by other implementations. What would another implementation look like? That's up to you! While OPA may provide us with the low-level, step-by-step plan, for the evaluation of a query, it'll be on us to parse and evaluate that plan. Ever wanted to have your policy decisions served right inside of your Python app? Doable. Can't run the OPA server on your tiny microcontroller? You no longer need to. No runtime, no restrictions. What's the catch?</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="bring-your-own-opa">Bring Your Own OPA<a href="https://openpolicyagent.org/blog/i-have-a-plan-exploring-the-opa-intermediate-representation-ir-format-7319cd94b37d#bring-your-own-opa" class="hash-link" aria-label="Direct link to Bring Your Own OPA" title="Direct link to Bring Your Own OPA" translate="no">​</a></h2>
<p>Using your programming language of choice to implement the full set of <a href="https://www.openpolicyagent.org/docs/latest/ir/" target="_blank" rel="noopener noreferrer" class="">instructions</a> included in the intermediate representation format isn't something you'd pull off in just a few hours. A robust implementation is likely going to necessitate quite some effort, and even if you decide to invest the days — or possibly, weeks — required for a greenfield implementation, implementing the IR instructions is only half of the story. OPA provides an impressive number of <a href="https://www.openpolicyagent.org/docs/latest/policy-reference/#built-in-functions" target="_blank" rel="noopener noreferrer" class="">built-in functions</a>, requiring corresponding implementations in the platform you choose to target. You probably won't need every single built-in to accommodate your use case though, so starting with the ones known to be relevant for you is likely a smart idea. Rego modules compiled to Wasm, on the other hand, ship with <a href="https://github.com/open-policy-agent/opa/tree/main/wasm" target="_blank" rel="noopener noreferrer" class="">native implementations</a> of many of the built-ins. If you plan to build an IR compiler or evaluator in C or C++, leveraging those would give you a head start!</p>
<p>Another aspect to consider is the management features provided by OPA. Similarly to Wasm, the scope of the IR format is limited to policy <em>evaluation</em>. Fetching bundles from remote endpoints, sending decision logs, or providing metrics and status reports is left as an exercise to the implementation. However, just like with the built-in functions, you likely won't need to support the full set of management capabilities shipped with OPA, but can pick and choose the parts that make sense to you. More interestingly, you're free to implement your <em>own</em> management features. Rather than pulling bundles from an S3 bucket, why not stream your permissions data from a Kafka topic? Or build a direct integration against that tool your organization uses for health checks, and so on. As laborious as a custom implementation may be, it opens up for some very interesting opportunities!</p>
<p>We're getting ahead of ourselves though. Before we dash off to write our own, next generation, OPA implementation in whatever the hottest programming language is these days, we should probably start by getting familiar with the IR format, and how to make sense of evaluation <em>plans</em>.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="making-plans">Making Plans<a href="https://openpolicyagent.org/blog/i-have-a-plan-exploring-the-opa-intermediate-representation-ir-format-7319cd94b37d#making-plans" class="hash-link" aria-label="Direct link to Making Plans" title="Direct link to Making Plans" translate="no">​</a></h2>
<p>Let's create a simple policy, and build a plan from that. The below policy contains two rules — <code>is_admin</code> to check if the "admin" role is included in the list of roles provided in the <strong>input</strong> for a user, and <code>allow</code>, which in this case simply is true if <code>is_admin</code> is true, but presumably would be extended to include more checks in future iterations of our policy.</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token keyword" style="color:#00009f">package</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">policy</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">future</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">keywords</span><span class="token punctuation" style="color:#393A34">.</span><span class="token keyword" style="color:#00009f">if</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">future</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">keywords</span><span class="token punctuation" style="color:#393A34">.</span><span class="token keyword" style="color:#00009f">in</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">allow</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">if</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">is_admin</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">is_admin</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">if</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"admin"</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">in</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">roles</span><br></div></code></pre></div></div>
<p>Simple enough, right? Let's see what a plan might look like! In order to build one, we'll use the aptly named <code>opa build</code> command. This command is used to build <a href="https://www.openpolicyagent.org/docs/latest/management-bundles/" target="_blank" rel="noopener noreferrer" class="">bundles</a>, and the <code>--target</code> flag allows us to say that rather than just copying Rego and data files into the bundle, we want OPA to compile either a <code>plan</code>, or a <code>wasm</code> and put that in the bundle for us too. When building a plan, we'll additionally need to provide an <em>entrypoint</em> — this would be the path to either a package or a rule, from which the plan should be built. The path to the entry points (more than one is allowed) will later be used to query an implementation capable of parsing and evaluating our plan. Let's build a bundle with the plan target, and the entrypoint set to that of our <code>allow</code> rule:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token plain">opa build --target plan --entrypoint policy/allow .</span><br></div></code></pre></div></div>
<p>This will create a <code>bundle.tar.gz</code> file in the current directory, with our plan inside of it. Since we're only interested in the plan for now, let's extract it from the bundle:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token plain">tar -zxvf bundle.tar.gz /plan.json</span><br></div></code></pre></div></div>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-planjson-file">The plan.json file<a href="https://openpolicyagent.org/blog/i-have-a-plan-exploring-the-opa-intermediate-representation-ir-format-7319cd94b37d#the-planjson-file" class="hash-link" aria-label="Direct link to The plan.json file" title="Direct link to The plan.json file" translate="no">​</a></h2>
<p>We now have a plan to work with! Let's see what's in that plan.json file. The first thing you'll notice is that the plan file contains three top level attributes — <code>static</code>, <code>plans</code> and <code>funcs</code>. The <code>static</code> object is fairly straightforward:</p>
<div class="language-json codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-json codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token property" style="color:#36acaa">"static"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token property" style="color:#36acaa">"strings"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"value"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"result"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"value"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"user"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"value"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"roles"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"value"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"admin"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token property" style="color:#36acaa">"builtin_funcs"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">      </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">        </span><span class="token property" style="color:#36acaa">"name"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"internal.member_2"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">        </span><span class="token property" style="color:#36acaa">"decl"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">          </span><span class="token property" style="color:#36acaa">"args"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"type"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"any"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"type"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"any"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">          </span><span class="token property" style="color:#36acaa">"result"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"type"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"boolean"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">          </span><span class="token property" style="color:#36acaa">"type"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"function"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">        </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">      </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token property" style="color:#36acaa">"files"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"value"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"policy.rego"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<p>The <code>strings</code> array contains references to all strings included in the plan, and will be referenced whenever needed in evaluation. We'll recognize the "user", "roles" and "admin" strings from our policy, while the "result" string has been added by the plan builder, to be used as a key in the result set from plan evaluation. Thanks, plan builder! The <code>builtin_funcs</code> array provides a list of all the built-in functions used in our policy, along with the types expected for their arguments and return values. While "internal.member_2" might look unfamiliar, it's the internal name used for the built-in function representing the <code>in</code> operator used in our policy! Finally, the files array contains a list of all files used to build the plan, which in our case is only <code>policy.rego</code>.</p>
<p>The next attribute is the actual <em>plans</em>, and here's where things start to turn a bit cryptic. But don't worry, I'll walk you through it!</p>
<div class="language-json codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-json codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token property" style="color:#36acaa">"plans"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token property" style="color:#36acaa">"plans"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">      </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">        </span><span class="token property" style="color:#36acaa">"name"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"policy/allow"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">        </span><span class="token property" style="color:#36acaa">"blocks"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">          </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">            </span><span class="token property" style="color:#36acaa">"stmts"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">              </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                </span><span class="token property" style="color:#36acaa">"type"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"CallStmt"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                </span><span class="token property" style="color:#36acaa">"stmt"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                  </span><span class="token property" style="color:#36acaa">"func"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"g0.data.policy.allow"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                  </span><span class="token property" style="color:#36acaa">"args"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"type"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"local"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"value"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">0</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"type"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"local"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"value"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                  </span><span class="token property" style="color:#36acaa">"result"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">2</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">              </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">              </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                </span><span class="token property" style="color:#36acaa">"type"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"AssignVarStmt"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                </span><span class="token property" style="color:#36acaa">"stmt"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                  </span><span class="token property" style="color:#36acaa">"source"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"type"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"local"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"value"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">2</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                  </span><span class="token property" style="color:#36acaa">"target"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">3</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">              </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">              </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                </span><span class="token property" style="color:#36acaa">"type"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"MakeObjectStmt"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                </span><span class="token property" style="color:#36acaa">"stmt"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                  </span><span class="token property" style="color:#36acaa">"target"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">4</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">              </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">              </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                </span><span class="token property" style="color:#36acaa">"type"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"ObjectInsertStmt"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                </span><span class="token property" style="color:#36acaa">"stmt"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                  </span><span class="token property" style="color:#36acaa">"key"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"type"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"string_index"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"value"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">0</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                  </span><span class="token property" style="color:#36acaa">"value"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"type"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"local"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"value"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">3</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                  </span><span class="token property" style="color:#36acaa">"object"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">4</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">              </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">              </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                </span><span class="token property" style="color:#36acaa">"type"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"ResultSetAddStmt"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                </span><span class="token property" style="color:#36acaa">"stmt"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                  </span><span class="token property" style="color:#36acaa">"value"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">4</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">              </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">            </span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">          </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">        </span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">      </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="functions-statements-blocks">Functions, statements, blocks<a href="https://openpolicyagent.org/blog/i-have-a-plan-exploring-the-opa-intermediate-representation-ir-format-7319cd94b37d#functions-statements-blocks" class="hash-link" aria-label="Direct link to Functions, statements, blocks" title="Direct link to Functions, statements, blocks" translate="no">​</a></h2>
<p>For each entrypoint provided, we'll find a corresponding <em>plan</em>, which represents the planned evaluation path for that entrypoint. The <code>name</code> of the plan is our entrypoint ("policy/allow") and the <code>blocks</code> attribute contains the statements to be evaluated in order to "run" the plan. Quite literally in order too, as each statement block and statement will be evaluated in an entirely procedural fashion. Quite a contrast to the Rego code that produced it!</p>
<p>The first statement is a <code>CallStmt</code>, which means we'll need to evaluate the function (i.e. <code>func</code>) corresponding to the provided name in the <code>funcs</code> object — in our case this has been named "g0.data.policy.allow" (mapped from our <code>allow</code> rule) — and we'll take a closer look at the <code>funcs</code> part in a minute. The <code>args</code> provided to the function is "local" value 0, and "local" value 1. These represent the global <strong>input</strong> and <strong>data</strong> variables that you're likely familiar with from your Rego policies, and "value" in this case is rather the "name" — or pointer — to the values in the local <em>scope</em>. Who said naming was one of the hardest problems in computer science? Not the OPA plan compiler!</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="where-the-locals-go">Where the Locals Go<a href="https://openpolicyagent.org/blog/i-have-a-plan-exploring-the-opa-intermediate-representation-ir-format-7319cd94b37d#where-the-locals-go" class="hash-link" aria-label="Direct link to Where the Locals Go" title="Direct link to Where the Locals Go" translate="no">​</a></h2>
<p>Since you'll see a lot of references to <code>local</code> throughout compiled plans, learning how it's used is imperative to understanding the steps involved in plan execution. When a function is invoked, like our "g0.data.policy.allow" above, a local object is created to represent the inputs to that function. The <em>statements</em> that comprise the function may in turn both read from the local object, as well as write to it, effectively making it a bearer of local <em>state</em>.</p>
<p>If a statement inside of a function involves calling <em>another</em> function, a new, "inner" <code>local</code> object will be created for the scope of that function, and the result of the function evaluation will be stored in the "outer" <code>local</code>, and so on.</p>
<p>Back to our <code>CallStmt</code>! We now know that it'll be invoked with the input (local 0) and data (local 1) as its arguments. The next attribute in the statement simply says "return": 2, meaning that whatever value is returned by the function should be stored in the next position — i.e. 2 — in the local state. Next up, the <code>AssignVarStmt</code> is used to assign the value at position 2 — that's our return value — to a new local value at position 3 (as defined by the "target" attribute). Moving on, we'll see a <code>MakeObjectStmt</code> used to create an empty object, which is placed at local value 4. In the next step, a key value pair is inserted into the object (<code>ObjectInsertStmt</code>) where the key is the "string_index" at position 0. Remember the <code>strings</code> attribute from the <code>static</code> object from before? This is it. The first item in that array is "result", so it looks like we're building a result set over here! The value associated with the result is good ol' local value 3, which we might recall was the result of invoking the "g0.data.policy.allow" function. Finally <code>ResultSetAddStmt</code> signals that we're done here. We have a result from the plan, and we're now ready to return it.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="following-procedure">Following Procedure<a href="https://openpolicyagent.org/blog/i-have-a-plan-exploring-the-opa-intermediate-representation-ir-format-7319cd94b37d#following-procedure" class="hash-link" aria-label="Direct link to Following Procedure" title="Direct link to Following Procedure" translate="no">​</a></h2>
<p>What about "g0.data.policy.allow" then? I promised we'd get back to the "funcs" object in a minute, and wow, time really flies when describing procedural instructions of an evaluation plan! A quick glance at the <a href="https://gist.github.com/anderseknert/d2aec51b950362e156bb413ad312fca3" target="_blank" rel="noopener noreferrer" class="">funcs</a> object reveals that it contains not just the "allow" function, but also our "is_admin" function, here in the form of "g0.data.policy.is_admin". Since the allow function merely mirrors the result of is_admin, let's zoom in on the latter to learn how an implementation would evaluate the statements step by step, and how the state of the local object is updated in (almost) each step along the way. Rather than describing the steps in words, let's use a table for demonstration. In the left column you'll see a simplified version of each statement called, and in the right you'll see the local state after the statement has been applied. Note how each step procedurally builds up the final state, which is eventually returned to the caller. Beautiful, isn't it?</p>
<p><img decoding="async" loading="lazy" alt="Evaluation plan statements and local state" src="https://openpolicyagent.org/assets/images/1-dcdcd0f253780858d3afd08b0819ca02.png" width="675" height="714" class="img_ev3q"></p>
<p><em>Evaluation plan statements and local state. As Medium does not have embeddable tables, you may find the spreadsheet from the image above in <a href="https://docs.google.com/spreadsheets/d/1pU9J3QkfKwkFOZf7UV_PWPHZspQvHOJxOw_zh4poLoQ/edit?usp=sharing" target="_blank" rel="noopener noreferrer" class="">this Google Sheets document</a>.</em></p>
<p>To learn more about the different statements an evaluator implementation may encounter, consult the <a href="https://www.openpolicyagent.org/docs/latest/ir/" target="_blank" rel="noopener noreferrer" class="">OPA docs</a> on the topic.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="planning-ahead">Planning Ahead<a href="https://openpolicyagent.org/blog/i-have-a-plan-exploring-the-opa-intermediate-representation-ir-format-7319cd94b37d#planning-ahead" class="hash-link" aria-label="Direct link to Planning Ahead" title="Direct link to Planning Ahead" translate="no">​</a></h2>
<p>Every aspect and instruction of the IR format would be too much for a single blog to cover, but the process of untangling an evaluation plan has hopefully been made clearer by now. While creating a full-fledged "OPA" native to your language or platform of choice might be a huge undertaking, even a basic implementation, with only a handful of built-in functions implemented, gets you surprisingly far towards something that actually feels <em>usable</em>. Open source implementations of course would have the benefit of others being able to contribute the parts that make the project usable to them. On the topic of open source implementations, are there any of those out there yet? In fact, there is!</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="introducing-jarl">Introducing Jarl<a href="https://openpolicyagent.org/blog/i-have-a-plan-exploring-the-opa-intermediate-representation-ir-format-7319cd94b37d#introducing-jarl" class="hash-link" aria-label="Direct link to Introducing Jarl" title="Direct link to Introducing Jarl" translate="no">​</a></h2>
<p>For the past few months, fellow OPA maintainer <a href="https://github.com/johanfylling" target="_blank" rel="noopener noreferrer" class="">Johan Fylling</a> and I have spent some of our spare time hacking away on an IR implementation for the Java Virtual Machine (JVM) called <a href="https://github.com/johanfylling/jarl" target="_blank" rel="noopener noreferrer" class="">Jarl</a>. A jarl was a chieftain in the age of vikings, and given the viking theme of OPA itself, we figured it would be a good name for the project. And of course, it has that "J" in there too, which seems almost mandatory for JVM-based software.</p>
<p>We chose to use <a href="https://clojure.org/" target="_blank" rel="noopener noreferrer" class="">Clojure</a> for our implementation, and while we are both rather novice Clojure coders, it's been a lot of fun to work with! Not only that, but using Clojure means getting access to the broader JVM ecosystem, both in terms of libraries available, and that applications written in Java, Kotlin or Scala will be able to use Jarl eventually. As an added bonus, Clojurescript allows the library to be compiled into Javascript as well, allowing us to target deployments in Node, or web browsers. Quite a versatile platform to build on!</p>
<p>While we still have a long way to go before Jarl is anywhere near production readiness, we're already at a point where it's usable for evaluation of many types of common policies. As we wanted to ensure conformance against OPA from the start, we ported the OPA <a href="https://github.com/johanfylling/opa-compliance-test" target="_blank" rel="noopener noreferrer" class="">compliance test suite</a> to the IR format, which has proven to be tremendously useful for testing not just plan evaluation, but also the behavior of built-in function implementations. This code should be useful for anyone building their own implementation, so if that's you, make sure to check it out. As for the built-in functions, we currently have <a href="https://github.com/johanfylling/jarl/blob/main/doc/builtins.md" target="_blank" rel="noopener noreferrer" class="">most of them</a> ported, but some work remains to be done before we're able to have all tests from OPA pass. Then awaits the management features…</p>
<p>If the project sounds interesting to you, we'd love to hear from you! Reach out on the OPA Slack, or just try it out and report back on any issues, feature requests or ideas you might have. Or if you'd rather work on your own implementation, we'd love to help you get started.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="wrapping-up">Wrapping Up<a href="https://openpolicyagent.org/blog/i-have-a-plan-exploring-the-opa-intermediate-representation-ir-format-7319cd94b37d#wrapping-up" class="hash-link" aria-label="Direct link to Wrapping Up" title="Direct link to Wrapping Up" translate="no">​</a></h2>
<p>With the introduction of the intermediate representation format, another integration option for OPA has been made available. While it might be a bit of a niche — and certainly not the first choice to consider for most applications — it opens the door for many new and interesting use cases where an OPA integration using the standalone server model might not have been the best fit, or possible at all. Although perhaps not a well-known option until now, I hope this blog may contribute to changing that, and I'm looking forward to seeing how this alternative is leveraged in the future. Interesting times ahead!</p>]]></content>
        <author>
            <name>Anders Eknert</name>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[OPA Newsletter: August 2022]]></title>
        <id>https://openpolicyagent.org/blog/august-newsletter-4c177ddc4829</id>
        <link href="https://openpolicyagent.org/blog/august-newsletter-4c177ddc4829"/>
        <updated>2022-08-22T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[August Edition!]]></summary>
        <content type="html"><![CDATA[<p><em>August Edition!</em></p>
<p>August is here and we are feeling the heat! Reply back to this email and let the OPA team know how you're beating the heat this year!</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="community-updates">Community Updates<a href="https://openpolicyagent.org/blog/august-newsletter-4c177ddc4829#community-updates" class="hash-link" aria-label="Direct link to Community Updates" title="Direct link to Community Updates" translate="no">​</a></h2>
<p>Office Hours and the Bi-weekly meeting have converged to 1 weekly meeting. Each Office Hours is an open format meeting you can use to ask any questions you'd like.</p>
<p>But now we are reserving the Office Hours Session following a new OPA release to showcase the new features from that release. Join the next session on August 9th to hear about the v0.43.0 release</p>
<p><a href="https://calendly.com/peter-styra/opa-office-hours" target="_blank" rel="noopener noreferrer" class="">Sign Up for Office Hours</a></p>
<p>You can also watch the replays from the OPA Office Hours and the Gatekeeper Weekly meetings on YouTube. Check out the release announcement for v0.42.0 below.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="youtube-videos-">YouTube Videos 🎥<a href="https://openpolicyagent.org/blog/august-newsletter-4c177ddc4829#youtube-videos-" class="hash-link" aria-label="Direct link to YouTube Videos 🎥" title="Direct link to YouTube Videos 🎥" translate="no">​</a></h2>
<p>Our community has posted lots of good stuff on YouTube this month, check out these cool videos.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="feature-release-videos">Feature Release Videos<a href="https://openpolicyagent.org/blog/august-newsletter-4c177ddc4829#feature-release-videos" class="hash-link" aria-label="Direct link to Feature Release Videos" title="Direct link to Feature Release Videos" translate="no">​</a></h2>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="keywords-contains-and-if">Keywords, Contains and If<a href="https://openpolicyagent.org/blog/august-newsletter-4c177ddc4829#keywords-contains-and-if" class="hash-link" aria-label="Direct link to Keywords, Contains and If" title="Direct link to Keywords, Contains and If" translate="no">​</a></h2>
<p>How to incorporate the new keywords <strong>contains</strong> and <strong>if</strong> into your policies.</p>
<p><a href="https://youtu.be/dm-JsDQPCZ0" target="_blank" rel="noopener noreferrer" class="">Watch Now</a></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="builtin-objectsubset">Builtin, Object.subset<a href="https://openpolicyagent.org/blog/august-newsletter-4c177ddc4829#builtin-objectsubset" class="hash-link" aria-label="Direct link to Builtin, Object.subset" title="Direct link to Builtin, Object.subset" translate="no">​</a></h2>
<p>This new builtin allows you to check if a set, array, or object is a subset of another item.</p>
<p><a href="https://www.youtube.com/watch?v=indJqrgOSko" target="_blank" rel="noopener noreferrer" class="">Watch Now</a></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="events-">Events 📆<a href="https://openpolicyagent.org/blog/august-newsletter-4c177ddc4829#events-" class="hash-link" aria-label="Direct link to Events 📆" title="Direct link to Events 📆" translate="no">​</a></h2>
<ul>
<li class=""><a href="https://www.meetup.com/cloud-native-computing-switzerland/events/283522028/?utm_content=215127640&amp;utm_medium=social&amp;utm_source=twitter&amp;hss_channel=tw-2851142013" target="_blank" rel="noopener noreferrer" class="">Cloud Native Computing Meetup | August 25, 2022</a></li>
<li class=""><a href="https://calendly.com/peter-styra/opa-office-hours" target="_blank" rel="noopener noreferrer" class="">OPA Office Hours | August 9th, 2022</a></li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="blogs">Blogs<a href="https://openpolicyagent.org/blog/august-newsletter-4c177ddc4829#blogs" class="hash-link" aria-label="Direct link to Blogs" title="Direct link to Blogs" translate="no">​</a></h2>
<ul>
<li class=""><a href="https://dev.to/thenjdevopsguy/open-policy-agent-opa-for-kubernetes-5895" target="_blank" rel="noopener noreferrer" class="">Open Policy Agent (OPA) For Kubernetes</a></li>
<li class=""><a href="https://dimakorolev.substack.com/p/high-performance-opa" target="_blank" rel="noopener noreferrer" class="">High-Performance OPA</a></li>
<li class=""><a href="https://www.styra.com/blog/how-to-shape-opa-data-for-policy-performance/" target="_blank" rel="noopener noreferrer" class="">How to Shape OPA Data for Policy Performance</a></li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="ecosystem">Ecosystem<a href="https://openpolicyagent.org/blog/august-newsletter-4c177ddc4829#ecosystem" class="hash-link" aria-label="Direct link to Ecosystem" title="Direct link to Ecosystem" translate="no">​</a></h2>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="open-policy-agent-v0430"><a href="https://github.com/open-policy-agent/opa/releases/tag/v0.43.0" target="_blank" rel="noopener noreferrer" class="">Open Policy Agent v0.43.0</a><a href="https://openpolicyagent.org/blog/august-newsletter-4c177ddc4829#open-policy-agent-v0430" class="hash-link" aria-label="Direct link to open-policy-agent-v0430" title="Direct link to open-policy-agent-v0430" translate="no">​</a></h3>
<ul>
<li class=""><a href="https://github.com/open-policy-agent/opa/issues/4625" target="_blank" rel="noopener noreferrer" class="">Large Object Performance Improvements</a></li>
<li class=""><a href="https://www.openpolicyagent.org/docs/latest/graphql-api-authorization/" target="_blank" rel="noopener noreferrer" class="">GraphQL Tutorial</a></li>
</ul>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="gatekeeper-v390"><a href="https://github.com/open-policy-agent/gatekeeper/releases/tag/v3.9.0" target="_blank" rel="noopener noreferrer" class="">Gatekeeper v3.9.0</a><a href="https://openpolicyagent.org/blog/august-newsletter-4c177ddc4829#gatekeeper-v390" class="hash-link" aria-label="Direct link to gatekeeper-v390" title="Direct link to gatekeeper-v390" translate="no">​</a></h3>
<ul>
<li class=""><a href="https://github.com/open-policy-agent/gatekeeper/pull/2092" target="_blank" rel="noopener noreferrer" class="">Constraint schema validation testing</a></li>
<li class=""><a href="https://github.com/open-policy-agent/gatekeeper/pull/2054" target="_blank" rel="noopener noreferrer" class="">Make gatekeeper validate subresources</a></li>
</ul>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="conftest-v0340"><a href="https://github.com/open-policy-agent/conftest/releases/tag/v0.34.0" target="_blank" rel="noopener noreferrer" class="">Conftest v0.34.0</a><a href="https://openpolicyagent.org/blog/august-newsletter-4c177ddc4829#conftest-v0340" class="hash-link" aria-label="Direct link to conftest-v0340" title="Direct link to conftest-v0340" translate="no">​</a></h3>
<ul>
<li class=""><a href="https://www.conftest.dev/#writing-unit-tests" target="_blank" rel="noopener noreferrer" class="">Add parse_config and parse_config_file Rego functions to allow unit testing using config file snippets</a></li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="calling-all-opa-end-users">Calling all OPA End-Users<a href="https://openpolicyagent.org/blog/august-newsletter-4c177ddc4829#calling-all-opa-end-users" class="hash-link" aria-label="Direct link to Calling all OPA End-Users" title="Direct link to Calling all OPA End-Users" translate="no">​</a></h2>
<p>OPA Summit is officially scheduled, are you ready to share your OPA development journey? Let me us know how you're using OPA and we will help you craft a presentation. This event will be colocated at Kubecon in Detroit this October.</p>
<p><a href="mailto:peteroneilljr@styra.com" target="_blank" rel="noopener noreferrer" class="">👉 Speak at OPA Summit 👈</a></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="let-us-know-how-we-did">Let us know how we did<a href="https://openpolicyagent.org/blog/august-newsletter-4c177ddc4829#let-us-know-how-we-did" class="hash-link" aria-label="Direct link to Let us know how we did" title="Direct link to Let us know how we did" translate="no">​</a></h2>
<p>The OPA monthly newsletter is built for the OPA community, let us know what you liked or what you wanted to see more of. Reach out using one of the links below.</p>]]></content>
        <author>
            <name>Peter O'Neill</name>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[Open Policy Agent 2022 User Survey Summary]]></title>
        <id>https://openpolicyagent.org/blog/open-policy-agent-2022-user-survey-summary-370cf0243bb7</id>
        <link href="https://openpolicyagent.org/blog/open-policy-agent-2022-user-survey-summary-370cf0243bb7"/>
        <updated>2022-07-11T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Banner image for the OPA 2022 user survey summary]]></summary>
        <content type="html"><![CDATA[<p><img decoding="async" loading="lazy" alt="Banner image for the OPA 2022 user survey summary" src="https://openpolicyagent.org/assets/images/banner-009148655581163a5b9cd85e1277b934.webp" width="929" height="498" class="img_ev3q"></p>
<p>It's that time of year again! We have polled the Open Policy Agent (OPA) community to learn a bit more about what members are working on, their goals and how we can improve the project in the future. This year we had over 240 respondents, from various industries ranging from Software, Finance, E-commerce, Security, and more. With this new data set, we can learn if OPA usage has changed from the previous year, what features and tools are utilized the most and how to improve the OPA project as a whole for the community. To start, let's compare last year's survey results to this year's to see how things have changed or remained consistent:</p>
<blockquote>
<p><a class="" href="https://openpolicyagent.org/blog/open-policy-agent-2021-survey-summary-e749bbd7b824">Last Year's Survey</a></p>
</blockquote>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="year-over-year-numbers">Year-over-year numbers<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-user-survey-summary-370cf0243bb7#year-over-year-numbers" class="hash-link" aria-label="Direct link to Year-over-year numbers" title="Direct link to Year-over-year numbers" translate="no">​</a></h2>
<p>Within a couple of percentage points, the number of use cases and respondents' implementation goals show similar results to last year. Of the users that responded that they have over four use cases, 70% of those reporting have used OPA for a year or longer. This shows us that as OPA usage matures in an organization, users gain confidence in adding additional use cases, helping them achieve their higher-level goals.</p>
<p><img decoding="async" loading="lazy" alt="Table comparing 2022 vs 2021 use cases and implementation goals percentages" src="https://openpolicyagent.org/assets/images/2-0ecdc4ec4c7c4201005190fc521046cb.webp" width="1400" height="597" class="img_ev3q"></p>
<p>Almost 43% of respondents are in production with their OPA usage. This is a noticeable improvement from last year. With the addition of the Evaluating option, we can assume those users would have chosen experimentation given last year's choices, making the other two possibilities a few percentage points lower than the current year.</p>
<p><img decoding="async" loading="lazy" alt="Table comparing 2022 vs 2021 stage percentages" src="https://openpolicyagent.org/assets/images/3-d303354a36bb5aff284553e958383f44.webp" width="1400" height="301" class="img_ev3q"></p>
<p>The last metric we highlighted in last year's survey is the time to production, showing that 40% of users reach production within six months. This year we are seeing about 27% of users in the production phase by this point. However, 50% of the users in this time frame are in a pre-production phase, which is a substantial amount.</p>
<p><img decoding="async" loading="lazy" alt="Table cross-tabulating how long respondents have used OPA against stage" src="https://openpolicyagent.org/assets/images/4-d8ee1babbbd5e83f5ee7d31020436242.webp" width="1400" height="388" class="img_ev3q"></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="policy-libraries">Policy libraries<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-user-survey-summary-370cf0243bb7#policy-libraries" class="hash-link" aria-label="Direct link to Policy libraries" title="Direct link to Policy libraries" translate="no">​</a></h2>
<p>We've seen a slight increase in usage for the Gatekeeper policy library from 57% to 62%, for the respondents that indicated they're using OPA for Kubernetes Admission Control. However, overall we are seeing 50% of respondents indicating that they are not using any external policy libraries. As policy libraries grow around specific use cases we can expect this number to increase.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="feedback">Feedback<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-user-survey-summary-370cf0243bb7#feedback" class="hash-link" aria-label="Direct link to Feedback" title="Direct link to Feedback" translate="no">​</a></h2>
<p>Last year's request for better debugging tools led to creating two issues, rule-level tracing, and the print function. The Print Function was released in v0.34.0 and happily adopted by the community. Rule-level tracing still needs assistance from the community; perhaps you can help the community and submit a PR?</p>
<p>As we did with the previous year's survey, we asked the community for feedback to see what improvements would improve their OPA experience. The number one request was for more examples; nearly 33% of respondents asked for examples of specific or complex configurations and tutorials/sample data to go with them. About 12% of respondents asked for more integrations with AWS, such as the AWS CloudFormation integration that came out in June. And another 10% of users asked for additional debugging capabilities.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="learning-tools">Learning tools<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-user-survey-summary-370cf0243bb7#learning-tools" class="hash-link" aria-label="Direct link to Learning tools" title="Direct link to Learning tools" translate="no">​</a></h2>
<p>The official OPA documentation is the most used resource by the community, with over 90% of respondents using it, followed by the Rego Playground at 66%. The OPA docs are consistently evolving and receive updates as new features roll out, but as with most open source projects, we need the community's help to keep the docs up to date. As for the Rego playground, we maintain this tool in the hopes that it helps users debug problems and collaborate on new policies. If you see any way that we can improve it, please let us know by creating a feature request.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="monitoring">Monitoring<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-user-survey-summary-370cf0243bb7#monitoring" class="hash-link" aria-label="Direct link to Monitoring" title="Direct link to Monitoring" translate="no">​</a></h2>
<p>One surprising discovery from this year's responses is that 36% of users don't track OPA decisions, and 39% don't monitor their OPA status. While these metrics are accessible via OPA's management APIs, perhaps the docs can be spruced up with some new tutorials on configuring monitoring and logging!</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="wrap-up">Wrap up<a href="https://openpolicyagent.org/blog/open-policy-agent-2022-user-survey-summary-370cf0243bb7#wrap-up" class="hash-link" aria-label="Direct link to Wrap up" title="Direct link to Wrap up" translate="no">​</a></h2>
<p>To sum it up, we saw consistency in the implementation goals and number of use cases for OPA with a slight uptick in the overall number of users in production. The utilization of policy libraries seems to have dropped to half of what it was last year. Debugging remains a high-priority area where users wish to see additional improvements, along with more examples and tutorials for the documentation. The OPA Docs and Rego playground take home the gold for most valuable resources, but they could use a few more examples to help community members configure monitoring and logging.</p>
<p>Thanks for your participation in this year's OPA User Survey. If you've sent us your mailing address, you can expect your t-shirt to arrive in your mailbox soon!</p>
<p><em>photo credit Kayla</em></p>
<p><em>Happy OPA 2022 Survey from Charlie!</em></p>]]></content>
        <author>
            <name>Peter O'Neill</name>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[OPA Newsletter: November 2021]]></title>
        <id>https://openpolicyagent.org/blog/the-opa-monthly-newsletter-448a995a1f5e</id>
        <link href="https://openpolicyagent.org/blog/the-opa-monthly-newsletter-448a995a1f5e"/>
        <updated>2021-12-01T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[November Edition]]></summary>
        <content type="html"><![CDATA[<p><em>November Edition</em></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="intro">Intro<a href="https://openpolicyagent.org/blog/the-opa-monthly-newsletter-448a995a1f5e#intro" class="hash-link" aria-label="Direct link to Intro" title="Direct link to Intro" translate="no">​</a></h2>
<p>Hello everyone and welcome to the very first edition of the OPA Monthly Newsletter! We are excited to bring you all the happenings in the OPA ecosystem. You can expect to find a bit of everything in this newsletter, some community updates, a bit of contributor news, a handful of release notes, and any interesting content we've found on the internet this month.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="slack-updates">Slack Updates<a href="https://openpolicyagent.org/blog/the-opa-monthly-newsletter-448a995a1f5e#slack-updates" class="hash-link" aria-label="Direct link to Slack Updates" title="Direct link to Slack Updates" translate="no">​</a></h2>
<p><img decoding="async" loading="lazy" alt="OPA Slack community member growth screenshot" src="https://openpolicyagent.org/assets/images/2-e79e4c3b1abf9e127abfc20a53d279fc.png" width="800" height="800" class="img_ev3q"></p>
<p>Our Slack Org now hosts over 5,150 OPA community members!! The OPA team has been hard at work revamping the space to make it functional and valuable for all of our members. A little while ago you may remember we announced a <a class="" href="https://openpolicyagent.org/blog/opa-slack-tune-up-b3c52492e2fc">Slack Reorg</a> to consolidate and update channel names and descriptions. This effort was to give everyone a clear understanding of what's going on and where to go.</p>
<p>To continue to improve the Slack experience for our members we've added 2 new channels. For everyone interested in contributing to the OPA project you can now hang out in the <a href="https://openpolicyagent.slack.com/archives/C02L1TLPN59" target="_blank" rel="noopener noreferrer" class="">#development</a> channel to speak directly with other contributors and maintainers.</p>
<p>We've also added a <a href="https://openpolicyagent.slack.com/archives/C02J6LBL6GH" target="_blank" rel="noopener noreferrer" class="">#vendor</a> channel to allow members to reach out directly to our rich ecosystem of vendors that are building products on top of OPA. Jump into the channel today and ask questions about how to improve your OPA management.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="news-highlights">News Highlights<a href="https://openpolicyagent.org/blog/the-opa-monthly-newsletter-448a995a1f5e#news-highlights" class="hash-link" aria-label="Direct link to News Highlights" title="Direct link to News Highlights" translate="no">​</a></h2>
<p>One of our community members @boranx shared with the community that Conftest has made it into the <a href="https://www.thoughtworks.com/radar/tools/conftest" target="_blank" rel="noopener noreferrer" class="">Technology Radar by ThoughtWorks</a></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="github-updates">GitHub Updates<a href="https://openpolicyagent.org/blog/the-opa-monthly-newsletter-448a995a1f5e#github-updates" class="hash-link" aria-label="Direct link to GitHub Updates" title="Direct link to GitHub Updates" translate="no">​</a></h2>
<p>The OPA project wouldn't be the same without all of the contributions from the community. As such we would like to send a big thank you to all of the contributors from the v0.34 release.</p>
<ul>
<li class="">Edward Paget has contributed (<a href="https://github.com/open-policy-agent/opa/issues/3826" target="_blank" rel="noopener noreferrer" class="">#3826</a> SDK Feat) &amp; (<a href="https://github.com/open-policy-agent/opa/issues/3863" target="_blank" rel="noopener noreferrer" class="">#3863</a> Bundles Fix)</li>
<li class="">Kirk Patton a long time contributor added (<a href="https://github.com/open-policy-agent/opa/issues/3773" target="_blank" rel="noopener noreferrer" class="">#3773</a> Fix for exit statuses)</li>
<li class="">GitHub User <a href="https://github.com/0xAP" target="_blank" rel="noopener noreferrer" class="">@0xAP</a> first time contributor added (<a href="https://github.com/open-policy-agent/opa/issues/3860" target="_blank" rel="noopener noreferrer" class="">#3860</a> Bundles improvement)</li>
<li class="">Andreas Brehmer first time contributor added (<a href="https://github.com/open-policy-agent/opa/issues/3836" target="_blank" rel="noopener noreferrer" class="">#3836</a> Fmt fix)</li>
<li class="">Florian Gasc first time contributor added (<a href="https://github.com/open-policy-agent/opa/issues/3879" target="_blank" rel="noopener noreferrer" class="">#3879</a> Storage fix)</li>
<li class="">Omolola Olamide has landed (<a href="https://github.com/open-policy-agent/opa/issues/3910" target="_blank" rel="noopener noreferrer" class="">#3910</a> Tutorial Updates)</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="twitter-highlights">Twitter Highlights<a href="https://openpolicyagent.org/blog/the-opa-monthly-newsletter-448a995a1f5e#twitter-highlights" class="hash-link" aria-label="Direct link to Twitter Highlights" title="Direct link to Twitter Highlights" translate="no">​</a></h2>
<p>For those not active on Twitter, we've collected some of the highlights and OPA shoutouts here:</p>
<p><a href="https://twitter.com/that_tech_tea/status/1451930146835861504" target="_blank" rel="noopener noreferrer" class="">https://twitter.com/that_tech_tea/status/1451930146835861504</a></p>
<p><img decoding="async" loading="lazy" alt="Screenshot of that_tech_tea tweet mentioning OPA" src="https://openpolicyagent.org/assets/images/3-6c5d720c278e48cb8ae16c0e5630a81b.jpeg" width="1284" height="1006" class="img_ev3q"></p>
<p><a href="https://twitter.com/nusairat/status/1458815340985520130" target="_blank" rel="noopener noreferrer" class="">https://twitter.com/nusairat/status/1458815340985520130</a></p>
<p><img decoding="async" loading="lazy" alt="Screenshot of nusairat tweet mentioning OPA" src="https://openpolicyagent.org/assets/images/4-c1126feebaba9416618fc7c91895f349.jpeg" width="1284" height="862" class="img_ev3q"></p>
<p><a href="https://twitter.com/nmeisenzahl/status/1458419364433117184" target="_blank" rel="noopener noreferrer" class="">https://twitter.com/nmeisenzahl/status/1458419364433117184</a></p>
<p><img decoding="async" loading="lazy" alt="Screenshot of nmeisenzahl tweet sharing OPA slides" src="https://openpolicyagent.org/assets/images/5-95453f9eb99358595475f91af849548a.jpeg" width="1284" height="1006" class="img_ev3q"></p>
<p>Check out the slides and demos that <a href="https://twitter.com/nmeisenzahl" target="_blank" rel="noopener noreferrer" class="">Nico Meisenzahl</a> created:</p>
<ul>
<li class=""><a href="https://www.slideshare.net/nmeisenzahl/continuous-lifecycle-enhance-your-compliance-and-governance-with-policybased-cicd" target="_blank" rel="noopener noreferrer" class="">enhance-your-compliance-and-governance-with-policy-based-cicd</a></li>
<li class=""><a href="https://gitlab.com/nico-meisenzahl/demo-opa-terraform-validation" target="_blank" rel="noopener noreferrer" class="">demo-opa-terraform-validation</a></li>
<li class=""><a href="https://github.com/nmeisenzahl/demo-opa-cicd-validation" target="_blank" rel="noopener noreferrer" class="">demo-opa-cicd-validation</a></li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="ecosystem-updates">Ecosystem Updates<a href="https://openpolicyagent.org/blog/the-opa-monthly-newsletter-448a995a1f5e#ecosystem-updates" class="hash-link" aria-label="Direct link to Ecosystem Updates" title="Direct link to Ecosystem Updates" translate="no">​</a></h2>
<p>The OPA Project is always changing, check out the latest updates and features for OPA and some of the sub-projects.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="opa-release-v0350"><a href="https://github.com/open-policy-agent/opa/releases/tag/v0.35.0" target="_blank" rel="noopener noreferrer" class="">OPA Release v0.35.0</a><a href="https://openpolicyagent.org/blog/the-opa-monthly-newsletter-448a995a1f5e#opa-release-v0350" class="hash-link" aria-label="Direct link to opa-release-v0350" title="Direct link to opa-release-v0350" translate="no">​</a></h3>
<ul>
<li class="">Early Exit Optimization improves performance in many policy types</li>
<li class="">New net.lookup_ip_addr built-in function to resolve host IP addresses</li>
<li class="">Massive performance improvement in decision logging compression</li>
</ul>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="opa-release-v0340"><a href="https://github.com/open-policy-agent/opa/releases/tag/v0.34.0" target="_blank" rel="noopener noreferrer" class="">OPA Release v0.34.0</a><a href="https://openpolicyagent.org/blog/the-opa-monthly-newsletter-448a995a1f5e#opa-release-v0340" class="hash-link" aria-label="Direct link to opa-release-v0340" title="Direct link to opa-release-v0340" translate="no">​</a></h3>
<ul>
<li class="">A new in operator for checking membership and for iteration</li>
<li class="">New <a class="" href="https://openpolicyagent.org/blog/introducing-the-opa-print-function-809da6a13aee">print</a> function for debugging</li>
<li class="">New opa inspect command for quickly checking contents of a <a href="https://www.openpolicyagent.org/docs/latest/management-bundles/" target="_blank" rel="noopener noreferrer" class="">bundle</a></li>
</ul>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="gatekeeper-release-v370"><a href="https://github.com/open-policy-agent/gatekeeper/releases/tag/v3.7.0" target="_blank" rel="noopener noreferrer" class="">Gatekeeper Release v3.7.0</a><a href="https://openpolicyagent.org/blog/the-opa-monthly-newsletter-448a995a1f5e#gatekeeper-release-v370" class="hash-link" aria-label="Direct link to gatekeeper-release-v370" title="Direct link to gatekeeper-release-v370" translate="no">​</a></h3>
<ul>
<li class="">Mutation has graduated to Beta! 🎉</li>
<li class="">Added ModifySet mutator 📐</li>
</ul>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="conftest-release-v0283"><a href="https://github.com/open-policy-agent/conftest/releases/tag/v0.28.3" target="_blank" rel="noopener noreferrer" class="">Conftest Release v0.28.3</a><a href="https://openpolicyagent.org/blog/the-opa-monthly-newsletter-448a995a1f5e#conftest-release-v0283" class="hash-link" aria-label="Direct link to conftest-release-v0283" title="Direct link to conftest-release-v0283" translate="no">​</a></h3>
<ul>
<li class="">The OPA <a class="" href="https://openpolicyagent.org/blog/introducing-the-opa-print-function-809da6a13aee">print</a> function is now supported in Conftest!</li>
</ul>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="kube-mgmt-release-v310"><a href="https://github.com/open-policy-agent/kube-mgmt/releases/tag/3.1.0" target="_blank" rel="noopener noreferrer" class="">Kube-mgmt Release v3.1.0</a><a href="https://openpolicyagent.org/blog/the-opa-monthly-newsletter-448a995a1f5e#kube-mgmt-release-v310" class="hash-link" aria-label="Direct link to kube-mgmt-release-v310" title="Direct link to kube-mgmt-release-v310" translate="no">​</a></h3>
<ul>
<li class="">Support extra environment variables in opa and kube-mgmt containers</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="community-spotlights">Community Spotlights<a href="https://openpolicyagent.org/blog/the-opa-monthly-newsletter-448a995a1f5e#community-spotlights" class="hash-link" aria-label="Direct link to Community Spotlights" title="Direct link to Community Spotlights" translate="no">​</a></h2>
<p><img decoding="async" loading="lazy" alt="Developer-Guy community spotlight for Cosign OPA integration" src="https://openpolicyagent.org/assets/images/6-a23ea435aa18ea4a986b9cb6897322b5.png" width="512" height="512" class="img_ev3q"></p>
<ul>
<li class="">The one and only <a href="https://github.com/developer-guy" target="_blank" rel="noopener noreferrer" class="">Developer-Guy</a> has been working tirelessly to add OPA policy functionality to <a href="https://github.com/sigstore/cosign" target="_blank" rel="noopener noreferrer" class="">Cosign</a>, Check out the <a href="https://github.com/sigstore/cosign/pull/641" target="_blank" rel="noopener noreferrer" class="">PR</a> to see the awesome work to connect the two projects.</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="what-happened-this-month">What happened this month?<a href="https://openpolicyagent.org/blog/the-opa-monthly-newsletter-448a995a1f5e#what-happened-this-month" class="hash-link" aria-label="Direct link to What happened this month?" title="Direct link to What happened this month?" translate="no">​</a></h2>
<ul>
<li class="">Meetup: <a href="https://www.meetup.com/london-opa-meetup/events/281522329" target="_blank" rel="noopener noreferrer" class="">OPA London Meetup</a></li>
<li class="">Meetup: <a href="https://www.meetup.com/stockholm-opa-meetup/events/281066231/" target="_blank" rel="noopener noreferrer" class="">OPA Stockholm Meetup</a></li>
<li class="">Talk: <a href="https://www.youtube.com/watch?v=RwsyMLyl8O0" target="_blank" rel="noopener noreferrer" class="">WTF is Cloud Native talk</a></li>
<li class="">Talk: <a href="https://www.infracloud.io/cloud-native-talks/api-authorization-with-open-policy-agent-opa/" target="_blank" rel="noopener noreferrer" class="">API Authorization with Open Policy Agent</a></li>
<li class="">Blog: <a class="" href="https://openpolicyagent.org/blog/serverless-policy-enforcement-connecting-opa-and-aws-lambda-e624f7176a3">Connecting OPA with AWS Lambda</a></li>
<li class="">Blog: <a href="https://medium.com/@ravindursr/automated-manifest-file-validation-using-open-policy-agent-and-github-actions-697fa9fd74f0" target="_blank" rel="noopener noreferrer" class="">Automated Manifest File Validation Using Open Policy Agent and GitHub Actions</a></li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="whats-coming-up-next-month">What's coming up next month?<a href="https://openpolicyagent.org/blog/the-opa-monthly-newsletter-448a995a1f5e#whats-coming-up-next-month" class="hash-link" aria-label="Direct link to What's coming up next month?" title="Direct link to What's coming up next month?" translate="no">​</a></h2>
<p>A list of community meetings, meetups, and conferences.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="opa-bi-weekly"><a href="https://docs.google.com/document/d/1v6l2gmkRKAn5UIg3V2QdeeCcXMElxsNzEzDkVlWDVg8/edit?usp=sharing" target="_blank" rel="noopener noreferrer" class="">OPA Bi-Weekly</a><a href="https://openpolicyagent.org/blog/the-opa-monthly-newsletter-448a995a1f5e#opa-bi-weekly" class="hash-link" aria-label="Direct link to opa-bi-weekly" title="Direct link to opa-bi-weekly" translate="no">​</a></h3>
<ul>
<li class="">Dec 7th at 10 AM PT</li>
<li class="">Dec 21st at 10 AM PT</li>
</ul>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="gatekeeper-weekly"><a href="https://docs.google.com/document/d/1A1-Q-1OMw3QODs1wT6eqfLTagcGmgzAJAjJihiO3T48/edit" target="_blank" rel="noopener noreferrer" class="">Gatekeeper Weekly</a><a href="https://openpolicyagent.org/blog/the-opa-monthly-newsletter-448a995a1f5e#gatekeeper-weekly" class="hash-link" aria-label="Direct link to gatekeeper-weekly" title="Direct link to gatekeeper-weekly" translate="no">​</a></h3>
<ul>
<li class="">Dec 2nd, 2 PM PT</li>
<li class="">Dec 8th, 9 AM PT</li>
<li class="">Dec 15th, 2 PM PT</li>
<li class="">Dec 22nd, 9 AM PT</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="let-us-know-how-we-did">Let us know how we did<a href="https://openpolicyagent.org/blog/the-opa-monthly-newsletter-448a995a1f5e#let-us-know-how-we-did" class="hash-link" aria-label="Direct link to Let us know how we did" title="Direct link to Let us know how we did" translate="no">​</a></h2>
<p>This was our very first edition of the OPA Newsletter, we really hope you enjoyed it! While we tried our best to find all the latest and greatest activities in the community we surely missed a lot as well. Want to share some cool content, have an OPA shoutout to make, want to speak at a conference, or host a meetup? Let us know by sending an email to: <a href="mailto:opa_newsletter@styra.com" target="_blank" rel="noopener noreferrer" class="">opa_newsletter@styra.com</a>.</p>
<p>If you're new to OPA or to the community check out these community resources to get started.</p>
<ul>
<li class="">Chat with the community on <a href="https://slack.openpolicyagent.org/" target="_blank" rel="noopener noreferrer" class="">Slack</a></li>
<li class="">Ask for help and support on <a href="https://github.com/open-policy-agent/feedback/discussions" target="_blank" rel="noopener noreferrer" class="">GitHub Discussions</a></li>
</ul>]]></content>
        <author>
            <name>Peter O'Neill</name>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[Introducing the OPA print function]]></title>
        <id>https://openpolicyagent.org/blog/introducing-the-opa-print-function-809da6a13aee</id>
        <link href="https://openpolicyagent.org/blog/introducing-the-opa-print-function-809da6a13aee"/>
        <updated>2021-10-29T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Banner image for introducing the OPA print function post]]></summary>
        <content type="html"><![CDATA[<p><img decoding="async" loading="lazy" alt="Banner image for introducing the OPA print function post" src="https://openpolicyagent.org/assets/images/banner-aa6dc10cb71d3347d12df779a29b5e77.webp" width="1400" height="577" class="img_ev3q"></p>
<p>One of the key takeaways from the <a class="" href="https://openpolicyagent.org/blog/open-policy-agent-2021-survey-summary-e749bbd7b824">Open Policy Agent 2021 Survey</a>, was the need to improve the OPA debugging experience. Simply put, we need to make it easier to know what's going on when policies and rules are evaluated.</p>
<p>However, whenever someone talks about an "experience," it's rarely a small task and a checkbox to be checked once completed. Rather, it's all the little things that when combined provide a great improvement to the greater goal. If the OPA project used JIRA, it would probably be a safe bet to classify the "improve debugging experience" story as an "epic." With some improvements made, many new ideas and feature requests are likely to emerge along the way, and it would be rather optimistic to think that such a story ever got <em>done</em>, in the sense that no new improvements could be made.</p>
<p>To make things more complicated — and certainly more interesting — the OPA debugging experience isn't isolated to OPA itself. Improving the debugging experience for OPA entails not just looking at where things can be made better in OPA, but just as much in the tools commonly used when authoring Rego policies. These include tools like <a href="https://marketplace.visualstudio.com/items?itemName=tsandall.opa" target="_blank" rel="noopener noreferrer" class="">VS Code</a>, <a href="https://plugins.jetbrains.com/plugin/14865-open-policy-agent" target="_blank" rel="noopener noreferrer" class="">IntelliJ IDEA</a> and all the <a href="https://www.openpolicyagent.org/docs/latest/editor-and-ide-support/" target="_blank" rel="noopener noreferrer" class="">other editors</a> commonly used for policy authoring.</p>
<p>So, where do we start?</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="debugging-with-opa-eval">Debugging with OPA eval<a href="https://openpolicyagent.org/blog/introducing-the-opa-print-function-809da6a13aee#debugging-with-opa-eval" class="hash-link" aria-label="Direct link to Debugging with OPA eval" title="Direct link to Debugging with OPA eval" translate="no">​</a></h2>
<p>Evaluating rules and variables has traditionally been done using the aptly named <strong>opa eval</strong> command. Commonly referred to as the "Swiss army knife of OPA," opa eval allows a policy author to quickly evaluate either standalone expressions like:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token plain">opa eval --format raw 1+1</span><br></div></code></pre></div></div>
<p>Or, more commonly, with policy, data and input provided through command line arguments, and the path to the rule or variable of interest.</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token plain">opa eval --data policy.rego --input input.json data.policy.main</span><br></div></code></pre></div></div>
<p>While truly a versatile tool, debugging with <strong>opa eval</strong> has a couple of drawbacks. Having to create a new file to provide input might feel a little clunky, but hardly a terrible experience. But what if you want to evaluate the value of some variable inside of a rule, a test or a comprehension?</p>
<p>The <a href="https://www.openpolicyagent.org/docs/latest/policy-reference/#debugging" target="_blank" rel="noopener noreferrer" class="">trace</a> built-in has to some extent been used for this purpose, but requires additional parameters passed to OPA to actually print something, and while occasionally useful, it was often perceived as somewhat clunky for the purpose of simply printing something.</p>
<p>Another problem frequently mentioned in the context of debugging is how sometimes <strong>opa eval</strong>, or the <strong>trace</strong> built-in comes back with just… nothing.</p>
<p>This brings us right into another topic often considered tricky with regards to debugging — OPA's handling of undefined. When OPA encounters undefined values, policy evaluation normally halts. Considering how Rego is a declarative <em>query</em> language, there isn't a whole lot more to do when a query comes back with nothing, just like a query language like SQL wouldn't have a whole lot more to do with an empty resultset. Since Rego rules are often compositions of many statements or other rules, it can sometimes be pretty difficult to tell where the undefined value that halted policy evaluation was introduced.</p>
<p>What to do?</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="introducing-the-print-built-in">Introducing the print built-in<a href="https://openpolicyagent.org/blog/introducing-the-opa-print-function-809da6a13aee#introducing-the-print-built-in" class="hash-link" aria-label="Direct link to Introducing the print built-in" title="Direct link to Introducing the print built-in" translate="no">​</a></h2>
<p>To tackle this, OPA v0.34.0 introduces a new <strong>print</strong> function to its ever growing list of <a href="https://www.openpolicyagent.org/docs/latest/policy-reference/#built-in-functions" target="_blank" rel="noopener noreferrer" class="">built-ins</a>. The print function does exactly what you'd expect it to do — prints any provided values to the console. Consider a rule like the one below.</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token variable" style="color:#36acaa">allow</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token function" style="color:#d73a49">print</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">"Entering allow"</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token variable" style="color:#36acaa">role</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">roles</span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">_</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token function" style="color:#d73a49">print</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">"Found role"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">role</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token variable" style="color:#36acaa">role</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">==</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"admin"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<p>Running OPA eval would produce the following result.</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token plain">$ opa eval -f raw -d policy.rego -i input.json 'data.policy.allow'</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">Entering allow</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">Found role developer</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">Found role sysadmin</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">Found role dba</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">Found role admin</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">true</span><br></div></code></pre></div></div>
<p>The <strong>print</strong> function takes any number of arguments (static values, variables, <strong>input</strong>, <strong>data</strong>, etc) and prints each one (separated by whitespace) to the console.</p>
<p>While simple on the surface, a whole lot of <a href="https://github.com/open-policy-agent/opa/issues/3319" target="_blank" rel="noopener noreferrer" class="">thought</a> has been put into its design, and unlike other built-in functions (which are often trivial to add into OPA) the print function required changes to the internal compiler. How come?</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="varargs">Varargs<a href="https://openpolicyagent.org/blog/introducing-the-opa-print-function-809da6a13aee#varargs" class="hash-link" aria-label="Direct link to Varargs" title="Direct link to Varargs" translate="no">​</a></h2>
<p>One of the design goals of the new print function was to allow a variable number of values or variables (i.e. varargs) to be passed as arguments, without resorting to the use of an array for the arguments, as is done by <strong>sprintf</strong> and other built-ins. Simply put we wanted something intuitive like:</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">print</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">"x"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">x</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"y"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">y</span><span class="token punctuation" style="color:#393A34">)</span><br></div></code></pre></div></div>
<p>To work just as expected. Sounds easy, right? Well, not really.</p>
<p>One of the more obscure (and hence, not encouraged) features of Rego can be traced back to its Datalog roots. Any built-in function can have it's return value expressed as the last argument to the function. Meaning that:</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token variable" style="color:#36acaa">x</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">concat</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">"."</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">"a"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"b"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"c"</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">)</span><br></div></code></pre></div></div>
<p>Could alternatively be written as:</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">concat</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">"."</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">"a"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"b"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"c"</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">x</span><span class="token punctuation" style="color:#393A34">)</span><br></div></code></pre></div></div>
<p>With the last argument "reserved" for the return value, how would an implementation of varargs work? The answer was a new type of void function, where there simply is no return value to take into account. Since Rego functions are generally free from side effects, a void type of function hasn't really made sense previously, but with <strong>print</strong> having no purpose other than the desired side effect of printing to the console, adding a void type made sense.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="printing-undefined">Printing undefined<a href="https://openpolicyagent.org/blog/introducing-the-opa-print-function-809da6a13aee#printing-undefined" class="hash-link" aria-label="Direct link to Printing undefined" title="Direct link to Printing undefined" translate="no">​</a></h2>
<p>The next problem to tackle in order for print to work nicely as a debugging tool was how to deal with undefined. Since we can expect print to be used to debug variables from <strong>input</strong> and <strong>data</strong> that might not be defined, it would be kind of a bummer if calling print <em>itself</em> halted policy evaluation! Ideally we'd be able to call the print function and have it print <em>something</em> even if some of the arguments provided pointed at undefined values. That way we could use the function to try and help also with the problem of identifying where in a policy undefined values have been introduced.</p>
<p>This requirement meant some internal assumptions of how Rego is parsed had to change, and the end result is a print function that prints undefined values as <code>&lt;undefined&gt;</code>, without halting policy evaluation.</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token variable" style="color:#36acaa">allow</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token function" style="color:#d73a49">print</span><span class="token punctuation" style="color:#393A34">(</span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">email</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">roles</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">roles</span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">_</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">==</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"admin"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token function" style="color:#d73a49">endswith</span><span class="token punctuation" style="color:#393A34">(</span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">email</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"@acmecorp.com"</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<p>Evaluating the above allow rule with user.email missing from the input would now output something like this to the console:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token plain">$ opa eval -f raw -d policy.rego -i input.json data.policy.allow</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">&lt;undefined&gt; ["developer", "admin"]</span><br></div></code></pre></div></div>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="using-print">Using print<a href="https://openpolicyagent.org/blog/introducing-the-opa-print-function-809da6a13aee#using-print" class="hash-link" aria-label="Direct link to Using print" title="Direct link to Using print" translate="no">​</a></h2>
<p>OPA supports many different modes of operation, from <strong>opa eval</strong> and <strong>opa test</strong>, to the OPA REPL and of course running as a standalone server. Both <strong>opa eval</strong> and the REPL will always print to the console (stderr, specifically) as expected. When running as a server, OPA will print any output from print function calls at the <strong>info</strong> log level. This makes print useful for debugging at the default info level or below. When configured to run with log level <strong>error</strong> (the generally recommended log level for production), OPA erases any calls to print from policies as they are loaded. Print calls left in the policy at that point will thus not impact performance whatsoever.</p>
<p>When running <strong>opa test</strong>, the <strong>print</strong> function by default will print to the console on test failures. Should you want to print output also for successful tests, the — verbose (short form -v) will do the trick. One case I've found particularly useful in tests is to use print in combination with the with … as mocking construct, to quickly see what exactly the result of a rule evaluation returns, like:</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token variable" style="color:#36acaa">test_decison_allowed</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token variable" style="color:#36acaa">result</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">decision</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">with</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">input</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">as</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">        </span><span class="token string" style="color:#e3116c">"user"</span><span class="token plain">: </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">            </span><span class="token string" style="color:#e3116c">"id"</span><span class="token plain">: </span><span class="token string" style="color:#e3116c">"abc123"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">        </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">        </span><span class="token string" style="color:#e3116c">"request"</span><span class="token plain">: </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">            </span><span class="token string" style="color:#e3116c">"method"</span><span class="token plain">: </span><span class="token string" style="color:#e3116c">"POST"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">            </span><span class="token string" style="color:#e3116c">"path"</span><span class="token plain">: </span><span class="token string" style="color:#e3116c">"/users"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">        </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token function" style="color:#d73a49">print</span><span class="token punctuation" style="color:#393A34">(</span><span class="token variable" style="color:#36acaa">result</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token function" style="color:#d73a49">print</span><span class="token punctuation" style="color:#393A34">(</span><span class="token variable" style="color:#36acaa">expectedResult</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token variable" style="color:#36acaa">result</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">==</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">expectedResult</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">decision</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">_</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">payload</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">_</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token function namespace punctuation" style="color:#393A34;opacity:0.7">io</span><span class="token function punctuation" style="color:#393A34">.</span><span class="token function namespace punctuation" style="color:#393A34;opacity:0.7">jwt</span><span class="token function punctuation" style="color:#393A34">.</span><span class="token function" style="color:#d73a49">decode</span><span class="token punctuation" style="color:#393A34">(</span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">token</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token function" style="color:#d73a49">print</span><span class="token punctuation" style="color:#393A34">(</span><span class="token variable" style="color:#36acaa">payload</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">.</span><span class="token punctuation" style="color:#393A34">.</span><span class="token punctuation" style="color:#393A34">.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<p>While printing the outcome of rule evaluation in tests like this is valuable, the decision rule <em>itself</em> might be composed of multiple rules, and being able to add a few print lines in those to understand why our result isn't what we expect can help us quickly pinpoint the problem.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="wrapping-up">Wrapping up<a href="https://openpolicyagent.org/blog/introducing-the-opa-print-function-809da6a13aee#wrapping-up" class="hash-link" aria-label="Direct link to Wrapping up" title="Direct link to Wrapping up" translate="no">​</a></h2>
<p>Rego as a policy language isn't a general purpose programming language, and shouldn't be treated as one. However, making the OPA and Rego debugging experience as smooth as possible means we sometimes might need to adapt concepts familiar from the programming languages policy authors normally work with. That the <strong>print</strong> function <a href="https://github.com/open-policy-agent/opa/pull/3868" target="_blank" rel="noopener noreferrer" class="">pull request</a> added almost 2000 lines of code — half of them however from added test cases! — to the codebase is an interesting case study in how all the "little" details — like backwards compatibility, usability and performance — need to be considered when adding new functionality to a mature open source project like OPA.</p>
<p>I hope that you'll find the print function a useful addition to OPA, and a small improvement to the OPA/Rego debugging experience. Expect a lot more to come out in this space in future releases, and as always, make your voice heard in the <a href="https://slack.openpolicyagent.org/" target="_blank" rel="noopener noreferrer" class="">OPA Slack</a> if you have ideas, questions or feature requests you'd like to see incorporated into OPA!</p>]]></content>
        <author>
            <name>Anders Eknert</name>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[Serverless Policy Enforcement: Connecting OPA and AWS Lambda]]></title>
        <id>https://openpolicyagent.org/blog/serverless-policy-enforcement-connecting-opa-and-aws-lambda-e624f7176a3</id>
        <link href="https://openpolicyagent.org/blog/serverless-policy-enforcement-connecting-opa-and-aws-lambda-e624f7176a3"/>
        <updated>2021-10-05T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[OPA logo connected to AWS Lambda serverless icon]]></summary>
        <content type="html"><![CDATA[<p><img decoding="async" loading="lazy" alt="OPA logo connected to AWS Lambda serverless icon" src="data:image/webp;base64,UklGRgwjAABXRUJQVlA4WAoAAAAMAAAANwQAeQIAVlA4IEghAAAwLwGdASo4BHoCPnU6m0mko6KhIlPI6JAOiWdu/HyZp2Hm8MQ/t9gk7p+af9X6PXq/67/SP9B8dGbV+X5h/Oecj/W+qn9A/rj8AH6H/4Dqgfzr0Cf1P/s+tB6Vf/R6gH9+6mT0APLi9mT92/W76v/pN+rP+l/wPsy8bf2H9y9T9XFefrTfmTPf2N8AL8Z/nX+I3ncAP6V/WvSwmlfhOoB5397fQA8of/d8n/7R6ivSy/c32dxE4iSmlViHTBHkSU0qsQ6YI8iSmlViHTBHkSU0qsQ6YI8iSmlViHTBHkSU0qsQ6YI8iSmlViHTBHkSU0qsQ6YI8iSmlViHTBHkSU0qsQ6YI8iSmlViHTBHkSU0qsQ6YI8iSmlViHTBHkSU0qs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dPtCq+6eMHKAP9hTezMwKt4lqdVI+GDVmGD6OSH4oC4q2CZX9rSeee6PFeX/zgnrZ0ZswShgFhRR76ZmXgb0CVqjwPtEMrAil/wQVTWvi8gggAAAAAEuAFo/Zh4i5qMuG2kwGx9cWnX8uefCHVAf8kHmSml5G9yZ8SuWduuaLhsTWcIA+4AENtq04AAAAAAAAAAAAAAAAAAAAAAAAABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA4BAAAA6AEAAEAAAB6AgAAAAAAAFhNUCDbAAAAPD94cGFja2V0IGJlZ2luPSIiIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iR28gWE1QIFNESyAxLjAiPjxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+PC9yZGY6UkRGPjwveDp4bXBtZXRhPgo8P3hwYWNrZXQgZW5kPSJ3Ij8+AA==" width="1080" height="634" class="img_ev3q"></p>
<p><a href="https://www.openpolicyagent.org/" target="_blank" rel="noopener noreferrer" class="">Open Policy Agent</a> (OPA) provides policy-based control for cloud native environments. It's commonly used alongside massive projects like Kubernetes and Envoy, and has dozens of other integrations and related projects in its <a href="https://www.openpolicyagent.org/docs/latest/ecosystem/" target="_blank" rel="noopener noreferrer" class="">ecosystem</a>. Recent updates to the project aim to better integrate OPA with serverless architectures and other infrastructure with intermittent compute.</p>
<p><a href="https://docs.aws.amazon.com/lambda/latest/dg/welcome.html" target="_blank" rel="noopener noreferrer" class="">AWS Lambda</a> is one such serverless solution. When a Lambda function is invoked, its execution environment only stays up until the function responds, at which point the runtime is frozen and all active processes/threads are paused. They are resumed once the next invocation is received, and the cycle repeats. OPA's plugin architecture wasn't designed to handle this freezing process, which resulted in unexpected behavior for things like bundle retrieval and log shipping.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="why-is-manual-better-than-automatic">Why is Manual Better than Automatic?<a href="https://openpolicyagent.org/blog/serverless-policy-enforcement-connecting-opa-and-aws-lambda-e624f7176a3#why-is-manual-better-than-automatic" class="hash-link" aria-label="Direct link to Why is Manual Better than Automatic?" title="Direct link to Why is Manual Better than Automatic?" translate="no">​</a></h2>
<p>However, thanks to a great new feature released in Open Policy Agent <a href="https://github.com/open-policy-agent/opa/releases/tag/v0.32.0" target="_blank" rel="noopener noreferrer" class="">v0.32.0</a>, plugins can now be triggered manually instead of automatically. Now, you may ask: "Wait, why is manual better than automatic?" Well, in many cases it's not, but for environments like AWS Lambda, it's not only useful, but critical to the stability and functionality of the OPA process.</p>
<p>First, let's briefly review the default behavior of plugins in OPA. Most of the standard plugins — Discovery, Bundles, and Decision Logs — operate by using a <a href="https://github.com/open-policy-agent/opa/blob/v0.32.0/plugins/logs/plugin.go#L671" target="_blank" rel="noopener noreferrer" class="">loop</a> running in a <a href="https://github.com/open-policy-agent/opa/blob/v0.32.0/plugins/logs/plugin.go#L513" target="_blank" rel="noopener noreferrer" class="">goroutine</a> that listens to various signals, one of which is a <a href="https://github.com/open-policy-agent/opa/blob/v0.32.0/plugins/logs/plugin.go#L698" target="_blank" rel="noopener noreferrer" class="">timer</a>. When the timer delay elapses, the plugins will do stuff in the background, e.g. ship logs, check for new bundles to download, etc. OPA calls this a "periodic" trigger.</p>
<p>For most use cases, periodic triggers are exactly what we need. We don't really care precisely when a plugin is doing something in the background, just that it happens roughly within the interval period we've specified. The non-deterministic nature of periodic plugin triggers works well for a majority of applications. But what happens when that non-determinism becomes a problem? What if we need control over exactly when a plugin both starts and finishes a run of its primary task? Well, now we can get that control, thanks to the addition of <a href="https://github.com/open-policy-agent/opa/pull/3668" target="_blank" rel="noopener noreferrer" class="">Manual Trigger Support</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="introducing-manual-trigger-support">Introducing Manual Trigger support<a href="https://openpolicyagent.org/blog/serverless-policy-enforcement-connecting-opa-and-aws-lambda-e624f7176a3#introducing-manual-trigger-support" class="hash-link" aria-label="Direct link to Introducing Manual Trigger support" title="Direct link to Introducing Manual Trigger support" translate="no">​</a></h2>
<p>Plugins now support an optional "manual" trigger mode that can be set directly in a <a href="https://www.openpolicyagent.org/docs/latest/configuration/#bundles" target="_blank" rel="noopener noreferrer" class="">plugin's configuration</a>. Additionally, if manual triggers are set on the Discovery plugin, all other plugins will inherit that setting. When a plugin's trigger is set to manual, the plugin's background loop will either pause until the <a href="https://github.com/open-policy-agent/opa/blob/v0.32.0/plugins/logs/plugin.go#L639" target="_blank" rel="noopener noreferrer" class="">Trigger func</a> is called, or it will never start, depending on the plugin. The Trigger func will run a plugin's primary task and return only when the task is complete, or the provided context ends.</p>
<p>Now that we understand what manual triggers do, let's look at how we can use them in AWS Lambda. Lambda's on-demand compute is excellent for saving on compute costs, but it presents a challenge for code that has indeterminate start and end points, i.e., OPA plugins with periodic triggers. We don't want to interrupt the OPA process by freezing the execution environment when it's in the middle of downloading a bundle or shipping logs. And we don't want to wait around for a background loop to kick off those behaviors. Manual triggers give us the deterministic start and end points we need to properly coordinate OPA plugins in Lambda.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="try-it-for-yourself">Try it for Yourself<a href="https://openpolicyagent.org/blog/serverless-policy-enforcement-connecting-opa-and-aws-lambda-e624f7176a3#try-it-for-yourself" class="hash-link" aria-label="Direct link to Try it for Yourself" title="Direct link to Try it for Yourself" translate="no">​</a></h2>
<p>For those that are interested in running OPA in AWS Lambda, GoDaddy has recently <a href="https://github.com/godaddy/opa-lambda-extension-plugin" target="_blank" rel="noopener noreferrer" class="">open-sourced a small OPA plugin</a> to make this easier, which uses manual triggers to operate OPA as a <a href="https://docs.aws.amazon.com/lambda/latest/dg/runtimes-extensions-api.html" target="_blank" rel="noopener noreferrer" class="">Lambda Extension</a>. Lambda Extensions are deeply integrated into the lifecycle of a Lambda function, allowing you to perform background tasks without impacting the response time of your functions. OPA and Lambda Extensions are a great match, allowing you to plug in OPA's policy enforcement to your serverless infrastructure without complex installation or configuration management.</p>]]></content>
        <author>
            <name>Grant Shively</name>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[Open Policy Agent 2021 Survey Summary]]></title>
        <id>https://openpolicyagent.org/blog/open-policy-agent-2021-survey-summary-e749bbd7b824</id>
        <link href="https://openpolicyagent.org/blog/open-policy-agent-2021-survey-summary-e749bbd7b824"/>
        <updated>2021-08-31T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[OPA 2021 community survey results banner]]></summary>
        <content type="html"><![CDATA[<p><img decoding="async" loading="lazy" alt="OPA 2021 community survey results banner" src="https://openpolicyagent.org/assets/images/banner-62cc22b9793c4233a18a7b23eac448b1.webp" width="508" height="582" class="img_ev3q"></p>
<p><em>…happy OPA 2021 survey from Cal [credit: @eileen_kemp]</em></p>
<p>Last month we surveyed the OPA community to learn more about user adoption and help us plan and improve the project. We received over 300 responses from users across financial services, healthcare, public sector, automotive, cloud technology providers and more. This post highlights some of the survey results.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="use-cases-and-adoption">Use Cases and Adoption<a href="https://openpolicyagent.org/blog/open-policy-agent-2021-survey-summary-e749bbd7b824#use-cases-and-adoption" class="hash-link" aria-label="Direct link to Use Cases and Adoption" title="Direct link to Use Cases and Adoption" translate="no">​</a></h2>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="opa-adoption-driven-by-authorization-use-cases-across-the-stack">OPA adoption driven by authorization use cases across the stack<a href="https://openpolicyagent.org/blog/open-policy-agent-2021-survey-summary-e749bbd7b824#opa-adoption-driven-by-authorization-use-cases-across-the-stack" class="hash-link" aria-label="Direct link to OPA adoption driven by authorization use cases across the stack" title="Direct link to OPA adoption driven by authorization use cases across the stack" translate="no">​</a></h3>
<p>Like last year, we used the survey to gauge use case adoption among respondents. We're interested in understanding where and why companies are deploying OPA because it helps us steer the project's long-term roadmap in the right direction. This year we asked respondents about the high-level goals they're trying to achieve by using OPA. We found that implementation of internal compliance and governance rules was the most common goal, however, nearly 60% of respondents indicated two or more goals being highly relevant.</p>
<table><thead><tr><th>Goal</th><th>% of Respondents</th></tr></thead><tbody><tr><td>Internal compliance/governance</td><td>64%</td></tr><tr><td>Operational excellence</td><td>49%</td></tr><tr><td>Implementing end-user IAM</td><td>44%</td></tr><tr><td>External compliance (e.g., PCI)</td><td>28%</td></tr></tbody></table>
<p>In terms of use cases (e.g., Kubernetes admission control, Microservice authorization, etc.), the results were similar to the previous year with 50% of respondents indicating they use OPA for two or more use cases:</p>
<table><thead><tr><th># of Use Cases</th><th>% of Respondents</th></tr></thead><tbody><tr><td>1</td><td>48%</td></tr><tr><td>2</td><td>34%</td></tr><tr><td>3</td><td>13%</td></tr><tr><td>4+</td><td>3%</td></tr></tbody></table>
<p>Kubernetes admission control continues to be the most common use case for OPA with 54% of respondents indicating they run OPA or OPA Gatekeeper to enforce various policies on their clusters:</p>
<table><thead><tr><th>Use Case</th><th>% of Respondents</th></tr></thead><tbody><tr><td>Kubernetes admission control</td><td>54%</td></tr><tr><td>Application authorization</td><td>39%</td></tr><tr><td>Microservice authorization</td><td>39%</td></tr><tr><td>Terraform validation</td><td>25%</td></tr><tr><td>Other</td><td>5%</td></tr></tbody></table>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="from-experiments-to-production-in-6-months-or-less">From experiments to production in 6 months (or less)<a href="https://openpolicyagent.org/blog/open-policy-agent-2021-survey-summary-e749bbd7b824#from-experiments-to-production-in-6-months-or-less" class="hash-link" aria-label="Direct link to From experiments to production in 6 months (or less)" title="Direct link to From experiments to production in 6 months (or less)" translate="no">​</a></h3>
<p>The survey showed the distribution of respondents OPA usage maturity was roughly equal:</p>
<table><thead><tr><th>Stage</th><th>% of Respondents</th></tr></thead><tbody><tr><td>Experimentation</td><td>33%</td></tr><tr><td>Pre-production &amp; QA</td><td>32%</td></tr><tr><td>Production</td><td>35%</td></tr></tbody></table>
<p>What was more interesting was that about half of respondents indicated they had only been using OPA since January 2021. Of those users, nearly 40% had already reached production. Furthermore, the survey results show that most respondents reached production within 6 months. Beyond that, the percentage of users that are still in experimental stages drops to single digits:</p>
<table><thead><tr><th></th><th>Experimentation</th><th>Pre-prod/QA</th><th>Production</th></tr></thead><tbody><tr><td>&lt; 3 months</td><td>54%</td><td>28%</td><td>14%</td></tr><tr><td>3-6 months</td><td>22%</td><td>54%</td><td>25%</td></tr><tr><td>6-12 months</td><td>4%</td><td>38%</td><td>58%</td></tr><tr><td>Over 12 months</td><td>7%</td><td>15%</td><td>76%</td></tr></tbody></table>
<p>These results are encouraging and also give us high-level metrics to improve on — ideally the time to production with OPA will continue to decrease as we improve the user experience and harden the project.</p>
<p>The survey results also highlighted a range of deployment sizes for production users. The following chart breaks down the deployment size responses by use case:</p>
<table><thead><tr><th>Use Case</th><th>&lt;10</th><th>10-50</th><th>50-200</th><th>&gt;200</th></tr></thead><tbody><tr><td>Kubernetes admission control</td><td>42%</td><td>31%</td><td>13%</td><td>12%</td></tr><tr><td>Terraform validation</td><td>43%</td><td>25%</td><td>18%</td><td>12%</td></tr><tr><td>Microservice authorization</td><td>37%</td><td>37%</td><td>12%</td><td>11%</td></tr><tr><td>Application authorization</td><td>44%</td><td>32%</td><td>10%</td><td>11%</td></tr></tbody></table>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="policy-library-adoption-is-growing">Policy library adoption is growing<a href="https://openpolicyagent.org/blog/open-policy-agent-2021-survey-summary-e749bbd7b824#policy-library-adoption-is-growing" class="hash-link" aria-label="Direct link to Policy library adoption is growing" title="Direct link to Policy library adoption is growing" translate="no">​</a></h3>
<p>The survey asked users about various features in OPA and one of the most encouraging bits of information was that policy library adoption is growing within platform authorization use cases, like Kubernetes admission control and Terraform plan validation. Specifically, we found that nearly 60% of Kubernetes admission control users rely on the official <a href="https://github.com/open-policy-agent/gatekeeper-library" target="_blank" rel="noopener noreferrer" class="">gatekeeper-library</a> policies that implement various best practices as well as PSP. We also found that nearly 30% of users that run OPA to validate Terraform plans rely on various open source policy libraries.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="opa-feedback">OPA Feedback<a href="https://openpolicyagent.org/blog/open-policy-agent-2021-survey-summary-e749bbd7b824#opa-feedback" class="hash-link" aria-label="Direct link to OPA Feedback" title="Direct link to OPA Feedback" translate="no">​</a></h2>
<p>In addition to gauging adoption we also used the survey to solicit feedback about the project.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="debugging-needs-some-love">Debugging needs some love<a href="https://openpolicyagent.org/blog/open-policy-agent-2021-survey-summary-e749bbd7b824#debugging-needs-some-love" class="hash-link" aria-label="Direct link to Debugging needs some love" title="Direct link to Debugging needs some love" translate="no">​</a></h3>
<p>After poring over the feedback comments, we found that the most common area for improvement is <em>debugging</em>. As with all surveys, some comments were non-specific, however multiple respondents requested better <a href="https://github.com/open-policy-agent/opa/issues/2089" target="_blank" rel="noopener noreferrer" class="">tracing modes</a> and explanation presentation formats. Improved <a href="https://github.com/open-policy-agent/opa/issues/3319" target="_blank" rel="noopener noreferrer" class="">debug output</a> support was another common request, and respondents also mentioned a desire for an <a href="https://github.com/open-policy-agent/opa/issues/3191" target="_blank" rel="noopener noreferrer" class="">interactive debugger</a> similar to what you find in typical programming languages.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="sdks-for-various-languages">SDKs for various languages<a href="https://openpolicyagent.org/blog/open-policy-agent-2021-survey-summary-e749bbd7b824#sdks-for-various-languages" class="hash-link" aria-label="Direct link to SDKs for various languages" title="Direct link to SDKs for various languages" translate="no">​</a></h3>
<p>Aside from debugging, the next most common request was better SDK support for OPA in various languages. Several respondents indicated interest in <a href="https://www.openpolicyagent.org/docs/latest/wasm/" target="_blank" rel="noopener noreferrer" class="">Wasm-based SDKs</a> for OPA, and others requested regular SDKs for Java, NodeJS and other languages. One of the reasons we haven't developed SDKs for OPA yet is because the OPA API is <em>extremely simple</em> (e.g., you can query OPA for decisions with a single HTTP POST request). However, with the Wasm compiler in OPA improving with every release, and the Wasm ecosystem growing rapidly, it feels like it's time to invest into language-specific integration libraries.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="wrap-up">Wrap Up<a href="https://openpolicyagent.org/blog/open-policy-agent-2021-survey-summary-e749bbd7b824#wrap-up" class="hash-link" aria-label="Direct link to Wrap Up" title="Direct link to Wrap Up" translate="no">​</a></h2>
<p>Thanks to everyone who completed the survey! The OPA t-shirts for completing the survey will be shipped soon. If you have not filled out the survey but would like to do so, you can still <a href="https://form.typeform.com/to/pL0jDuyT" target="_blank" rel="noopener noreferrer" class="">complete the OPA survey</a>. As always, if you have questions or feedback, we're available on Slack, GitHub, etc.</p>]]></content>
        <author>
            <name>Torin Sandall</name>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[OPA Slack Tune Up]]></title>
        <id>https://openpolicyagent.org/blog/opa-slack-tune-up-b3c52492e2fc</id>
        <link href="https://openpolicyagent.org/blog/opa-slack-tune-up-b3c52492e2fc"/>
        <updated>2021-08-19T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Celebrating the growth of OPA community with a little cleanup.]]></summary>
        <content type="html"><![CDATA[<p><img decoding="async" loading="lazy" alt="Banner illustration for the OPA Slack channel cleanup announcement" src="https://openpolicyagent.org/assets/images/banner-a88012e8a15d522b95f62740b2198979.webp" width="640" height="1600" class="img_ev3q"></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="celebrating-the-growth-of-opa-community-with-a-little-cleanup">Celebrating the growth of OPA community with a little cleanup<a href="https://openpolicyagent.org/blog/opa-slack-tune-up-b3c52492e2fc#celebrating-the-growth-of-opa-community-with-a-little-cleanup" class="hash-link" aria-label="Direct link to Celebrating the growth of OPA community with a little cleanup" title="Direct link to Celebrating the growth of OPA community with a little cleanup" translate="no">​</a></h2>
<p>The OPA community now has over 4,600 members in Slack! This is a tremendous milestone and we are so excited to have all of the new members join us. With this explosion of new members, the total number of Slack channels has crept up on us. The OPA team has noticed having so many channels has created confusion for our new and existing members on where to post about specific topics or themes. To make Slack easier to navigate we are rolling out a new set of channel names and descriptions. We hope this new structure will make Slack a bit easier for everyone. However, if you have a suggestion on how to make it better we would love to know.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="primary--default-channels">Primary / Default Channels<a href="https://openpolicyagent.org/blog/opa-slack-tune-up-b3c52492e2fc#primary--default-channels" class="hash-link" aria-label="Direct link to Primary / Default Channels" title="Direct link to Primary / Default Channels" translate="no">​</a></h2>
<p>Any new members joining the OPA community will want to hang out here to start! Read about the latest announcements, introduce yourself in the community chit-chat and ask questions in the help channel.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="announcements">#announcements<a href="https://openpolicyagent.org/blog/opa-slack-tune-up-b3c52492e2fc#announcements" class="hash-link" aria-label="Direct link to #announcements" title="Direct link to #announcements" translate="no">​</a></h3>
<p>Previous channel name: #general</p>
<p>The general channel is now the announcements channel. General was our busiest channel by far! It is now our announcements channel so that big news like releases and community events can stick around longer. New channels have been created for chit-chat and general help questions. The announcements channel is still open for anyone to post, but now think about posting things you want the entire community to know.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="chit-chat">#chit-chat<a href="https://openpolicyagent.org/blog/opa-slack-tune-up-b3c52492e2fc#chit-chat" class="hash-link" aria-label="Direct link to #chit-chat" title="Direct link to #chit-chat" translate="no">​</a></h3>
<p>Previous channel name: #random</p>
<p>Everyone loves a good random channel and the OPA community is no different. Just because we changed the name you shouldn't feel the need to change what you're posting. Drop in your OPA memes and funny web links just like before. But now we also want to include community introductions and general chatter here as well.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="help">#help<a href="https://openpolicyagent.org/blog/opa-slack-tune-up-b3c52492e2fc#help" class="hash-link" aria-label="Direct link to #help" title="Direct link to #help" translate="no">​</a></h3>
<p>Previous channel names:</p>
<ul>
<li class="">#rego</li>
<li class="">#openpolicyagent</li>
<li class="">#questions_and_answers</li>
<li class="">#feasibility-question</li>
</ul>
<p>We want to make it as easy as possible for you to find help while learning about OPA. So we've combined the channels we noticed new members were looking for help into a single channel. We hope that this will make it easier for everyone to know where to go when they need help and where to go when they feel like helping others.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="integrations">Integrations<a href="https://openpolicyagent.org/blog/opa-slack-tune-up-b3c52492e2fc#integrations" class="hash-link" aria-label="Direct link to Integrations" title="Direct link to Integrations" translate="no">​</a></h2>
<p>For OPA users that have been around for a while you are probably well aware of the Conftest and Gatekeeper projects. These two OPA projects have gained a lot of traction and provide amazing contributions to the OPA community. If you have specific questions about the projects these channels are the best place to go. While the maintainers do hang around these channels, we love seeing community members showing off their OPA knowledge answering questions for each other.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="conftest">#conftest<a href="https://openpolicyagent.org/blog/opa-slack-tune-up-b3c52492e2fc#conftest" class="hash-link" aria-label="Direct link to #conftest" title="Direct link to #conftest" translate="no">​</a></h3>
<p>Conftest is a must have in your policy toolkit. Write tests against structured configuration files including JSON, YAML, XML, Dockerfile, HCL, and more.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="gatekeeper">#gatekeeper<a href="https://openpolicyagent.org/blog/opa-slack-tune-up-b3c52492e2fc#gatekeeper" class="hash-link" aria-label="Direct link to #gatekeeper" title="Direct link to #gatekeeper" translate="no">​</a></h3>
<p>Gatekeeper helps you safeguard your Kubernetes clusters by defining OPA-based admission control policies that are enforced via webhooks. Gatekeeper also helps you audit your Kubernetes clusters to detect policy violations.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="topics">Topics<a href="https://openpolicyagent.org/blog/opa-slack-tune-up-b3c52492e2fc#topics" class="hash-link" aria-label="Direct link to Topics" title="Direct link to Topics" translate="no">​</a></h2>
<p>Trimmed down from the myriad of channels that existed before, the OPA team has chosen 3 channels that contained the most buzz from the community. Terraform, Envoy and WebAssembly are the 3 topics we noticed everyone likes to chat about. We hope that this buzz continues to grow. Also be on the lookout for programs in the future to be recognized as OPA experts in these areas.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="terraform">#terraform<a href="https://openpolicyagent.org/blog/opa-slack-tune-up-b3c52492e2fc#terraform" class="hash-link" aria-label="Direct link to #terraform" title="Direct link to #terraform" translate="no">​</a></h3>
<p><a href="https://www.terraform.io/" target="_blank" rel="noopener noreferrer" class="">Terraform</a> lets you describe the infrastructure you want and automatically creates, deletes, and modifies your existing infrastructure to match. OPA makes it possible to write policies that test the changes Terraform is about to make before it makes them.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="envoy">#envoy<a href="https://openpolicyagent.org/blog/opa-slack-tune-up-b3c52492e2fc#envoy" class="hash-link" aria-label="Direct link to #envoy" title="Direct link to #envoy" translate="no">​</a></h3>
<p><a href="https://github.com/open-policy-agent/opa-envoy-plugin" target="_blank" rel="noopener noreferrer" class="">OPA-Envoy</a> plugin extends OPA with a gRPC server that implements the <a href="https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/security/ext_authz_filter.html" target="_blank" rel="noopener noreferrer" class="">Envoy External Authorization API</a>. You can use this version of OPA to enforce fine-grained, context-aware access control policies with Envoy without modifying your microservices.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="wasm">#wasm<a href="https://openpolicyagent.org/blog/opa-slack-tune-up-b3c52492e2fc#wasm" class="hash-link" aria-label="Direct link to #wasm" title="Direct link to #wasm" translate="no">​</a></h3>
<p>OPA is able to compile Rego policies into executable Wasm modules that can be evaluated with different inputs and external data. This is not running the OPA server in Wasm, nor is this just cross-compiled Golang code. The compiled Wasm module is a planned evaluation path for the source policy and query.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="archived-channels">Archived Channels<a href="https://openpolicyagent.org/blog/opa-slack-tune-up-b3c52492e2fc#archived-channels" class="hash-link" aria-label="Direct link to Archived Channels" title="Direct link to Archived Channels" translate="no">​</a></h2>
<ul>
<li class="">#intros</li>
<li class="">#bosun</li>
<li class="">#feedback</li>
<li class="">#registry</li>
<li class="">#intellij-extension</li>
<li class="">#gsoc19</li>
</ul>
<p>You may notice some of the lesser used channels have been archived, we picked these channels based on a number of factors such as frequency of posts and average rate of responses. Ultimately we feel consolidating these conversations into the primary channel #chit-chat will increase participation and response rates.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="bot-channels">Bot Channels<a href="https://openpolicyagent.org/blog/opa-slack-tune-up-b3c52492e2fc#bot-channels" class="hash-link" aria-label="Direct link to Bot Channels" title="Direct link to Bot Channels" translate="no">​</a></h2>
<ul>
<li class="">#bot-github</li>
<li class="">#bot-rss</li>
</ul>
<p>These are not the bots you're looking for…or maybe they are! Going forward any channels with the <code>bot-</code> prefix will be used for channels that include Slack bots or automated tools. Currently, the OPA team uses these channels to keep up to date with external sources like Stack Overflow, Reddit, and GitHub.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="wrapping-up">Wrapping Up<a href="https://openpolicyagent.org/blog/opa-slack-tune-up-b3c52492e2fc#wrapping-up" class="hash-link" aria-label="Direct link to Wrapping Up" title="Direct link to Wrapping Up" translate="no">​</a></h2>
<p>Whether you're an OPA power user or looking to write your first Rego policy, we want the OPA Slack community to be your home for all things policy related. The OPA team realizes that sometimes new ideas need their own space to flourish. If you're interested in creating a new channel, reach out to @peteroneilljr or @tsandall on Slack and join us in our mission to solve policy enforcement across the stack. In addition to these Slack updates, you should also be on the look out for our new <a href="https://docs.github.com/en/discussions" target="_blank" rel="noopener noreferrer" class="">GitHub Discussions</a> forum that will officially launch in the next couple of weeks. For a sneak peak check out the link at the bottom of this article!</p>
<p><img decoding="async" loading="lazy" alt="Join Open Policy Agent on Slack" src="https://openpolicyagent.org/assets/images/2-6f3f279a42e3e169622d83e1d41df06d.webp" width="1350" height="752" class="img_ev3q"></p>
<p>Join the community on:</p>
<ul>
<li class=""><a href="https://slack.openpolicyagent.org/" target="_blank" rel="noopener noreferrer" class="">Slack</a></li>
<li class=""><a href="https://twitter.com/OpenPolicyAgent" target="_blank" rel="noopener noreferrer" class="">Twitter</a></li>
<li class=""><a href="https://github.com/open-policy-agent" target="_blank" rel="noopener noreferrer" class="">GitHub</a></li>
<li class=""><a href="https://github.com/open-policy-agent/feedback/discussions" target="_blank" rel="noopener noreferrer" class="">Discussions</a> (Launching Soon!!)</li>
</ul>]]></content>
        <author>
            <name>Peter O'Neill</name>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[Community Spotlight — Grant Shively]]></title>
        <id>https://openpolicyagent.org/blog/community-spotlight-grant-shively-12903674c28c</id>
        <link href="https://openpolicyagent.org/blog/community-spotlight-grant-shively-12903674c28c"/>
        <updated>2021-05-05T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Portrait photo of Grant Shively, GoDaddy principal software engineer]]></summary>
        <content type="html"><![CDATA[<p><img decoding="async" loading="lazy" alt="Portrait photo of Grant Shively, GoDaddy principal software engineer" src="https://openpolicyagent.org/assets/images/banner-6375cea888b1c19f7932ae2eadf87830.jpg" width="1280" height="720" class="img_ev3q"></p>
<p>"Community Spotlight" is a new series of blogs where we talk to people in and around the OPA community: users, integrators and contributors. Our first "spotlight" is <a href="https://www.linkedin.com/in/grant-shively/" target="_blank" rel="noopener noreferrer" class="">Grant Shively</a>, principal software engineer at GoDaddy.</p>
<p><strong>Okay, so let's start with an introduction.</strong></p>
<p>Sure! My name is Grant Shively and I've been working at GoDaddy for the last 13 years. For the last six years or so I've been a principal engineer on what we call our Care Platform, which is essentially our CRM system.</p>
<p>On the infrastructure side, we've moved from bare metal legacy servers with big monolithic ASP.NET web applications to a cloud-native, microservice architecture. Meanwhile we've transitioned much of the application platform towards Node.js and .NET Core. Recently, I've been doing a lot of work migrating things from our internal cloud to AWS.</p>
<p>For many years I've been involved in projects where we've needed complex authorization policies. And so we've built all these systems to deal with that, but there's never been a company-wide solution for that kind of thing.</p>
<p>I've been pushing for an authorization platform for the company for a few years, and last year it finally gained traction. We completed two company-wide initiatives with leaders from each of the major organizations where we all got together to talk about how we wanted to solve for authorization holistically at GoDaddy.</p>
<p>During the initiatives, we did a buy vs. build analysis where we evaluated different vendors, and open source projects. And that's when I discovered OPA. I watched the <a href="https://www.youtube.com/watch?v=R6tUNpRpdnY" target="_blank" rel="noopener noreferrer" class="">Netflix talk</a>, which showed how they used OPA to solve many of the issues we are currently experiencing.</p>
<p>And so we did a proof of concept at the end of last year to prove the value and efficacy of the project using OPA, and we got buy-in on it, and now we're here, building out the final multi-tenant solution! We are hoping to have the next team running in production by the end of Q2, and we already have a number of teams lined up to onboard after that.</p>
<p><strong>That was a great introduction! So, OPA adoption starting from a platform team, and growing from there?</strong></p>
<p>I've definitely evangelized OPA within the company, since I'm a big fan of the project. There's someone from another team helping to contribute to this platform we're building so I guess that makes us two teams at the moment. My team is focused on the systems that support our customer service guides, while the other team is working on our domain control center. Initially, they're looking to implement this authorization platform for some of the high risk scenarios we have around domains, such as transfer of ownership and things like that.</p>
<p><strong>You said you were working mainly with .NET and Node.js?</strong></p>
<p>Yep. As a company we work in a number of languages, including Python, Go, Node.js, .NET Core, and Java… I think those are most of the blessed languages, but there are probably some other languages used for one-offs as well.</p>
<p>My team, we were traditionally C#, and then we brought in Node.js during our transition to microservices. With the arrival of .NET Core, we were comfortable with continuing to support C# as well. Personally, after working with both languages for a number of years, I prefer Node.js for implementing our small, single-purpose APIs.</p>
<p><strong>You've made quite a few contributions to OPA, which is written in Go. Did you have experience working with that before?</strong></p>
<p>No, I hadn't touched it before! Go is definitely approachable. And I think the OPA code base is very clean and logical to explore. You don't have to look too much to figure out where something's at, once you get used to it.</p>
<p>Go feels like a language that minimizes syntactic sugar. There's really only a couple of "right" ways to do things, I feel. Sometimes it's frustrating too, like with the lack of map/filter/reduce operations. Coming from more functional paradigms it feels frustrating at times.</p>
<p><strong>Agreed. In this process of finding OPA, what other alternatives did you consider? Building your own? Some commercial options?</strong></p>
<p>We looked at <a href="https://github.com/AthenZ/athenz" target="_blank" rel="noopener noreferrer" class="">Athenz</a>. One of our senior architects had worked on that project and it looked interesting. It did some of the stuff we wanted, but not all. And then we looked at a whole bunch of products from various vendors. We briefly thought about building our own until we ran into OPA. OPA completely negated any reason for us to try and build our own because it did exactly what we needed, and in such an elegant way that it would be very difficult for us to replicate.</p>
<p><strong>Compared to the other options you considered, what was the main appeal of OPA? What was it that won you over?</strong></p>
<p>One of the things we needed was the ability for multiple engineering teams to work with policy, in a self-service manner, while at the same time leveraging globally-managed policy and data, like authentication token expiration rules and identity attributes.</p>
<p>Like everybody else, we have a few home-grown systems, and we definitely needed to be able to integrate with those. Also, we have an extremely distributed architecture. Hundreds of AWS accounts, and whatever solution we found was going to need to run in pretty much all of them.</p>
<p>I knew that there were going to be integration points that would be very difficult for most vendor products. One thing we really didn't want was some sort of centralized authorization API for the whole company. We've been bitten by such architectures in the past. Our apps are highly distributed, and we need our authorization decision points to be highly distributed too, while still being able to manage and distribute policy from a central location. And a lot of the bigger vendors had these products that just felt a little too heavy for large-scale decentralization, you know?.</p>
<p><strong>Right.</strong></p>
<p>And we really liked Rego. We've talked about this before, but a lot of the vendors are based on <a href="https://en.wikipedia.org/wiki/XACML" target="_blank" rel="noopener noreferrer" class="">XACML</a>, which is just really tedious to work with. Compared to that, Rego was a breath of fresh air. Another factor we considered was the buy-in we saw from some of the bigger companies like Netflix, etc. Rapid adoption of a project is usually a great sign.</p>
<p>I'm sure I'll have more opinions on Rego once we try and onboard more teams onto our platform. Certain teams at GoDaddy have more operational experience than others, and we'd really like to build a simplified UI policy builder on top of our platform and Rego. That way, they can just fill out some simple input boxes, hit enter, and it publishes a policy for them. That kind of thing.</p>
<p><strong>Interesting!</strong></p>
<p>Yeah, I'm both looking and not looking forward to tackling that problem, haha!</p>
<p><strong>Maybe you don't remember anymore, but did you have any such moments where you got stuck while learning Rego? I know one thing that felt a little odd to me when starting out was how Rego handled undefined values. How rule evaluation just stops when they are encountered.</strong></p>
<p>Some of the syntax around iteration was a little confusing at first. I think it's one of those things that makes total sense once you understand it, but it wasn't like anything I'd worked with before.</p>
<p>The biggest issue though — and we still kind of have it—is understanding how a decision was made, and how to surface that in logs. We have a couple of <a href="https://github.com/open-policy-agent/opa/issues/2755" target="_blank" rel="noopener noreferrer" class="">open</a> <a href="https://github.com/open-policy-agent/opa/issues/2089" target="_blank" rel="noopener noreferrer" class="">issues</a> about that, and we have been running OPA internally with a few patches we want to upstream that help address some of this.</p>
<p>It's really important to our security and engineering teams that we can look at a somewhat human readable, but hopefully not super verbose, way of saying that "this authorization request was approved or denied because of these reasons".</p>
<p>Another related issue would be how to best propagate obligations up through layers of policy. Some obligations can come from a really low level, like policy checking the claims of a JWT, and if some property doesn't exist, then we want to propagate an obligation up from that lower level rule. Solving some of those problems has felt a little clunky.</p>
<p><strong>On the other side, what did you really like?</strong></p>
<p>I really liked that you could create custom built-in functions and other things to extend OPAs functionality. That has been really useful to us as we've built things around our requirements, like custom key signing, custom decision logging, and so on.</p>
<p>There have been a few cases where we needed to extend portions of the OPA code, only to find that they were hardcoded around a particular implementation, without interfaces for us to leverage. I've been very pleased with the responsiveness of and guidance from the OPA maintainers. We've been able to contribute a number of small changes to make the OPA code more flexible for our extensions.</p>
<p><strong>On the topic of flexibility, one of the things that really appealed to me was the number of <a href="https://www.openpolicyagent.org/docs/latest/ecosystem/" target="_blank" rel="noopener noreferrer" class="">integrations</a> available. Even if you're never going to use all of them, it really shows what the general purpose nature of OPA enables.</strong></p>
<p>Yeah, that brings to mind another consideration. Netflix talked about how they used OPA for authorization across their entire stack—infrastructure, forward facing code, back end. When I saw OPA, I knew our platform could grow to be much more than just, you know, a simple authorization engine—there are many other policy-based scenarios that don't necessarily have to do with authorization. So that may be a far future thing, but that was also very enticing about OPA.</p>
<p><strong>I think some of the flexibility really pays off at scale. Having one unified language to describe policy across the stack, having one place to go for decision logs, and so on.</strong></p>
<p>Yep. We're definitely looking at increasing the number of integrations. So many of the systems deployed today work only with Active Directory, and AD group-based authorization, so it'll be interesting to see how we can integrate with systems like that.</p>
<p><strong>About integrations. Are there any of the existing ones in the <a href="https://www.openpolicyagent.org/docs/latest/ecosystem/" target="_blank" rel="noopener noreferrer" class="">ecosystem</a> you are using or are planning to use?</strong></p>
<p>I'm only familiar with the <a href="https://github.com/open-policy-agent/opa-envoy-plugin" target="_blank" rel="noopener noreferrer" class="">Envoy one</a>. Oh, and Kubernetes. What else is there? We're just starting to use Envoy, so I think there will likely be some places where we use that integration. And, we'll probably want to look into a Kubernetes integration too at some point, if <a href="https://aws.amazon.com/eks/" target="_blank" rel="noopener noreferrer" class="">AWS EKS</a> supports that.</p>
<p>Looking at the list now… Wow, there's really a bunch of them here! I'll need to look into some of these. What we're really doing a lot of is AWS integrations. Kind of in the same vein as the Envoy integration, extending OPA and all that, you know? We're doing the same thing with OPA and AWS, and I hope we'll be able to eventually open source that.</p>
<p>Things like key signing using the <a href="https://aws.amazon.com/kms/" target="_blank" rel="noopener noreferrer" class="">AWS Key Management Service</a> (KMS) or shipping decision logs directly to <a href="https://aws.amazon.com/kinesis/" target="_blank" rel="noopener noreferrer" class="">AWS Kinesis</a> without having to go through HTTP endpoints in between.</p>
<p><strong>I know you've mentioned <a href="https://aws.amazon.com/lambda/" target="_blank" rel="noopener noreferrer" class="">AWS Lambda</a> functions too.</strong></p>
<p>Yeah. A lot of our APIs are lambda-based, and we'll obviously want to use this platform we're building for that too. We're currently trying to figure out how to make OPA work as well for on-demand serverless functions as it does for traditional compute environments.</p>
<p><strong>Definitely a hot topic! I've seen some questions on that on the OPA Slack as well. What are the challenges there?</strong></p>
<p>So, the way OPA currently works is that many of the internal "plugins", like the client downloading bundles, or the one uploading decision logs-they all work on a time-based loop. So you configure them to upload or download or to do whatever they are meant to do at a certain interval, like every thirty seconds or something.</p>
<p>This doesn't really work for serverless functions though as they don't have continuous compute available; functions freeze after serving a response, so nothing can run in the background. What we'd need in this context is rather something based on <a href="https://github.com/open-policy-agent/opa/issues/2899" target="_blank" rel="noopener noreferrer" class="">other types of triggers</a>. We're waiting for a feature called AWS Lambda Extensions, which should reach general availability in May. They should make it possible to use OPA really efficiently even in a lambda context.</p>
<p><strong>Anything you have found missing from OPA or would like to see on the <a href="https://docs.google.com/presentation/u/1/d/16QV6gvLDOV3I0_guPC3_19g6jHkEg3X9xqMYgtoCKrs/edit" target="_blank" rel="noopener noreferrer" class="">roadmap</a>?</strong></p>
<p>I mentioned it before, but yeah, the big thing would be figuring out how to do the tracing in a more efficient way. I have come to understand that the way "full" tracing is done today is apparently pretty expensive. We just need something like <a href="https://github.com/open-policy-agent/opa/issues/2089" target="_blank" rel="noopener noreferrer" class="">rule level tracing</a>, which has been discussed a bit in GitHub issues in the past. With that in OPA proper we wouldn't have a reason to run our own modifications at all, except for plugins.</p>
<p><strong>Awesome! Finally, what are your future plans for OPA at GoDaddy?</strong></p>
<p>What we're starting out with is authorization for internal systems. Once we nail that and it's working well we're looking to expand it to authorization for customer systems, and at some point possibly our infrastructure too.</p>
<p>With what OPA can do, I feel like the sky's the limit in terms of what you want to throw into it. We just have to make sure we fully support the platform we're building as we continue growing. I have high hopes for it!</p>]]></content>
        <author>
            <name>Anders Eknert</name>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[Enhanced Type Checking for OPA with JSON Schema Annotations]]></title>
        <id>https://openpolicyagent.org/blog/enhanced-type-checking-for-opa-with-json-schema-annotations-826acb0f575</id>
        <link href="https://openpolicyagent.org/blog/enhanced-type-checking-for-opa-with-json-schema-annotations-826acb0f575"/>
        <updated>2021-04-27T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Enhanced type checking for OPA with JSON schema]]></summary>
        <content type="html"><![CDATA[<p><img decoding="async" loading="lazy" alt="Enhanced type checking for OPA with JSON schema" src="data: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DZNlaJwoEixCqctoZfApz4oIxIdl15lGKopR2M2YrQAp6K0DE/YI9nKbm+20lnKLIz+6OaTmgTLonvS2iVMmJsLBdK7LgTMmAqV0W3P1xCQR3vTl2RldJDaC/GmqfnoygcMpnWUzYTZzRjYbYUNImMs8o8M33GVn5yR/KF9KbwMdVxe7wHulxuqNGbHsNktuLskcaxcA72AMjbpc0Kj69j+NqFbO2Z3dM6RXYxfcZI/BFtdOPtYzvpdKA5NUgHHsz8PBnB9LpkpcEFJs25GffC032Ou/NKY196ceZnYTc63X1T9jD0wWeBHCvk7TAdB33/9hYq3YHoLGuZUmxFf6mFx4qWAM2SccbMRWECj9FLSYz89RfDLTtwuHYUW+uQEJWgw190g0T5goNs2q4b6tY3E1CCM4MrrO6NWGuoOc78v/73Qx/KiK0fcwuHE7IocMEzNJNSLmfMIEleI4+AeiQ5HjdBZT1mZ9xeK4akKja4yTJxVNGbG8WCeAO5yFtA1dLVPiluGO8YhhLsXPGyKyAJH9015jdkJeQwjts1bXJZ9FlAUq+6XApVDFM03znIfoU6QUBdFLhG9o1mNiQtB+VY4YNI3n4PLaS62c2G7tlsW2LPjRoLvYvQNRFHfX7/ZgMDM2hNOHYHGdj8xBniqqChT1DyVS5MeFAGSOxkUWXd9vULnPdpTGR1LjC6yr0uMBHyOLvjpIkyeSg9MAAAAAAAAAAAAEVYSUa6AAAARXhpZgAASUkqAAgAAAAGABIBAwABAAAAAQAAABoBBQABAAAAVgAAABsBBQABAAAAXgAAACgBAwABAAAAAgAAABMCAwABAAAAAQAAAGmHBAABAAAAZgAAAAAAAABIAAAAAQAAAEgAAAABAAAABgAAkAcABAAAADAyMTABkQcABAAAAAECAwAAoAcABAAAADAxMDABoAMAAQAAAP//AAACoAQAAQAAAFICAAADoAQAAQAAAM0AAAAAAAAA" width="594" height="205" class="img_ev3q"></p>
<p><em><strong>IBM Research &amp; Styra</strong></em></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="whats-happened">What's happened?<a href="https://openpolicyagent.org/blog/enhanced-type-checking-for-opa-with-json-schema-annotations-826acb0f575#whats-happened" class="hash-link" aria-label="Direct link to What's happened?" title="Direct link to What's happened?" translate="no">​</a></h2>
<p>In a <a class="" href="https://openpolicyagent.org/blog/type-checking-your-rego-policies-with-json-schema-in-opa-5f7ac4c8a958">previous Medium blog</a>, a feature released in <a href="https://github.com/open-policy-agent/opa/releases/tag/v0.27.0" target="_blank" rel="noopener noreferrer" class="">OPA v0.27.0</a> was introduced that lets OPA's static type checker take JSON schemas for input documents into account, improving how errors from misused data are caught during policy authoring.</p>
<p>The article explains that <code>opa eval</code> can take a schema for the input document via the <code>--schema(-s)</code> flag, applied globally across the module, allowing OPA's checker to catch issues like undefined objects.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="whats-new">What's new?<a href="https://openpolicyagent.org/blog/enhanced-type-checking-for-opa-with-json-schema-annotations-826acb0f575#whats-new" class="hash-link" aria-label="Direct link to What's new?" title="Direct link to What's new?" translate="no">​</a></h2>
<p>This section covers extending type checking to support <strong>multiple JSON schema files</strong> for both input and data documents.</p>
<p>Example Rego code (based on a Kubernetes admission review input) is shown with a typo bug:</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token keyword" style="color:#00009f">package</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">kubernetes</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">admission</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">deny</span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">msg</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">request</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">kind</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">kinds</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">==</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"Pod"</span><span class="token plain">                       </span><span class="token comment" style="color:#999988;font-style:italic"># This line has a typo, should be input.request.kind.kind</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token variable" style="color:#36acaa">image</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">request</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">object</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">spec</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">containers</span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">_</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">image</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token keyword" style="color:#00009f">not</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">startswith</span><span class="token punctuation" style="color:#393A34">(</span><span class="token variable" style="color:#36acaa">image</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"hooli.com/"</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token variable" style="color:#36acaa">msg</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">sprintf</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">"image '%v' comes from untrusted registry"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">image</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">request</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">kind</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">kinds</span><br></div></code></pre></div></div>
<p>which should be:</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">request</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">kind</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">kind</span><br></div></code></pre></div></div>
<p>Running:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token plain">% opa eval --format pretty -i admission-input.json -d policy.rego -s schemas/admission-input.json</span><br></div></code></pre></div></div>
<p>returns:</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token plain">1 error occurred: policy.rego:4: rego_type_error: undefined ref: input.request.kind.kinds</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  input.request.kind.kinds</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                     ^</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                     have: "kinds"</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                     want (one of): ["kind" "version"]</span><br></div></code></pre></div></div>
<p>The article notes that a similar typo in <code>input.request.object.spec.containers[_].image</code> would go undetected, since the admission review schema leaves <code>input.request.object</code> generically typed.</p>
<p>To solve this, <code>opa eval</code> now supports a <strong>directory of schema files</strong> via the same <code>--schema (-s)</code> flag, while still supporting single schema files. New Rego <strong>Metadata</strong> blocks allow specifying <strong>schema annotations and scope</strong>, improving bug detection for undefined fields.</p>
<p>An <strong>override feature</strong> is also introduced, described as letting users merge existing schemas and subschemas "for more precise type checking."</p>
<p>Additionally, schema loading is enabled for <code>opa eval — bundle</code>, supporting type checking of data documents across a bundle — useful for "batch type analysis of Rego policies as part of any CI/CD pipelines."</p>
<p>These features are available in <a href="https://github.com/open-policy-agent/opa/releases/tag/v0.28.0" target="_blank" rel="noopener noreferrer" class=""><strong>OPA v0.28.0</strong></a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="whats-the-big-deal-you-say">What's the big deal you say?<a href="https://openpolicyagent.org/blog/enhanced-type-checking-for-opa-with-json-schema-annotations-826acb0f575#whats-the-big-deal-you-say" class="hash-link" aria-label="Direct link to What's the big deal you say?" title="Direct link to What's the big deal you say?" translate="no">​</a></h2>
<p>Example policies and schemas are available in the <a href="https://github.com/aavarghese/opa-schema-examples" target="_blank" rel="noopener noreferrer" class="">opa-schema-examples repository</a>.</p>
<p>The Kubernetes Admission Review example is revisited to demonstrate annotations and schema overriding. The <code>object</code> field in an Admission Review can contain any Kubernetes resource, and its <a href="https://github.com/aavarghese/opa-schema-examples/blob/main/kubernetes/schemas/input.json" target="_blank" rel="noopener noreferrer" class="">schema</a> leaves that field generically typed.</p>
<p>Annotations associate a Rego expression with an input or data schema loaded via <code>opa eval -s</code>, within a given scope.</p>
<p>Annotations use <code>METADATA</code> comment blocks in YAML syntax, where "every line in the block must start at Column 1."</p>
<p>Example schema directory structure:</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token plain">mySchemasDir/</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">├── input.json</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">└── kubernetes</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">└──────pod.json</span><br></div></code></pre></div></div>
<p>Loading the schema directory can be done via:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token plain">% opa eval data.kubernetes.admission --format pretty -i opa-schema-examples/kubernetes/input.json -d opa-schema-examples/kubernetes/policy.rego -s opa-schema-examples/kubernetes/mySchemasDir</span><br></div></code></pre></div></div>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token plain">% opa eval data.kubernetes.admission -format pretty -i opa-schema-examples/kubernetes/input.json -b opa-schema-examples/bundle.tar.gz -s opa-schema-examples/kubernetes/mySchemasDir</span><br></div></code></pre></div></div>
<p>In this example, <code>input</code> is associated with the Admission Review schema (<code>input.json</code>), and <code>input.request.object</code> is set to the Kubernetes Pod schema (<code>pod.json</code>), with the second annotation overriding the first. The order of annotations is stated to matter "for overriding to work correctly."</p>
<p>Notes on schema reference syntax:</p>
<ul>
<li class="">Relative paths inside <code>mySchemasDir</code> are used, omitting the <code>.json</code> suffix</li>
<li class="">The global variable <code>schema</code> represents the top level of the directory</li>
<li class=""><code>schema.input</code> is valid; <code>schema.pod-schema</code> is invalid due to the hyphen — the correct syntax is <code>schema["pod-schema"]</code></li>
</ul>
<p>Combining annotations and overriding allows catching type errors in <code>input.request.object.spec.containers[_].image</code>:</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token keyword" style="color:#00009f">package</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">kubernetes</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">admission</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># METADATA</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># scope: rule</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># schemas:</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic">#   - input: schema["input"]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic">#   - input.request.object: schema.kubernetes["pod"]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">deny</span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">msg</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">request</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">kind</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">kinds</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">==</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"Pod"</span><span class="token plain">                       </span><span class="token comment" style="color:#999988;font-style:italic"># This line has a typo, should be input.request.kind.kind</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token variable" style="color:#36acaa">image</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">request</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">object</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">spec</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">containers</span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">_</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">images</span><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic"># This line has a typo, should be input.request.object.spec.containers[_].image</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token keyword" style="color:#00009f">not</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">startswith</span><span class="token punctuation" style="color:#393A34">(</span><span class="token variable" style="color:#36acaa">image</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"hooli.com/"</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token variable" style="color:#36acaa">msg</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">sprintf</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">"image '%v' comes from untrusted registry"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">image</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token plain">2 errors occurred:</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">policy.rego:9: rego_type_error: undefined ref: input.request.kind.kinds</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  input.request.kind.kinds</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                     ^ have: "kinds"</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                     want (one of): ["kind" "version"]</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">policy.rego:10: rego_type_error: undefined ref: input.request.object.spec.containers[_].images</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  input.request.object.spec.containers[_].images</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                                          ^ have: "images"</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                                          want (one of): ["args" "command" "env" "envFrom" "image" "imagePullPolicy" "lifecycle" "livenessProbe" "name" "ports" "readinessProbe" "resources" "securityContext" "stdin" "stdinOnce" "terminationMessagePath" "terminationMessagePolicy" "tty" "volumeDevices" "volumeMounts" "workingDir"]</span><br></div></code></pre></div></div>
<p>A second example checks whether an operation is allowed for a user, given an ACL data document. In the first <code>allow</code> rule, <code>input</code> uses <code>input.json</code> and <code>data.acl</code> uses <code>acl-schema.json</code>; an invalid expression like <code>data.acl.typo</code> would trigger a type error.</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token keyword" style="color:#00009f">package</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">policy</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">data</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">acl</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">default</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">allow</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># METADATA</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># scope: rule</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic"># schemas:</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic">#   - input: schema["input"]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic">#   - data.acl: schema["acl-schema"]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">allow</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">        </span><span class="token variable" style="color:#36acaa">access</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">data</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">acl</span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">"alice"</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">        </span><span class="token variable" style="color:#36acaa">access</span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">_</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">==</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">operation</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">allow</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">        </span><span class="token variable" style="color:#36acaa">access</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">data</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">acl</span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">"bob"</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">        </span><span class="token variable" style="color:#36acaa">access</span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">_</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">==</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">operation</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<p>The article clarifies that this annotation "does not constrain other paths under data" — only the type of <code>data.acl</code> is statically known.</p>
<p>The second <code>allow</code> rule in the same example has no schema annotations, so it isn't type-checked against any loaded schema. Different rules in the same module can use different input schemas.</p>
<p>Annotations can also apply at different scopes via the <code>scope</code> field in Metadata, defaulting to the following statement if omitted. Supported scope values:</p>
<ul>
<li class=""><strong>rule</strong> - applies to the individual rule statement</li>
<li class=""><strong>document</strong> - applies to all of the rules with the same name in the same package</li>
<li class=""><strong>package</strong> - applies to all of the rules in the package</li>
<li class=""><strong>subpackages</strong> - applies to all of the rules in the package and all subpackages (recursively)</li>
</ul>
<p>More details: <a href="https://www.openpolicyagent.org/docs/latest/schemas/#annotation-scopes" target="_blank" rel="noopener noreferrer" class="">Annotation scopes documentation</a></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="whats-next">What's Next?<a href="https://openpolicyagent.org/blog/enhanced-type-checking-for-opa-with-json-schema-annotations-826acb0f575#whats-next" class="hash-link" aria-label="Direct link to What's Next?" title="Direct link to What's Next?" translate="no">​</a></h2>
<p>The article closes by noting future plans to extend schema support to additional JSON Schema features such as <code>additionalProperties</code>, with more updates promised in upcoming OPA releases.</p>
<p>Further reading: <a href="https://www.openpolicyagent.org/docs/latest/schemas/" target="_blank" rel="noopener noreferrer" class="">OPA schemas documentation</a></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="links">Links<a href="https://openpolicyagent.org/blog/enhanced-type-checking-for-opa-with-json-schema-annotations-826acb0f575#links" class="hash-link" aria-label="Direct link to Links" title="Direct link to Links" translate="no">​</a></h2>
<ul>
<li class="">Documentation: <a href="https://www.openpolicyagent.org/docs/latest/schemas/" target="_blank" rel="noopener noreferrer" class="">OPA schemas documentation</a></li>
<li class="">Examples: <a href="https://github.com/aavarghese/opa-schema-examples/" target="_blank" rel="noopener noreferrer" class="">opa-schema-examples repository</a></li>
<li class="">JSON to JSON schema online tool: <a href="https://jsonschema.net/" target="_blank" rel="noopener noreferrer" class="">jsonschema.net</a></li>
<li class="">JSON schema reference: <a href="http://json-schema.org/understanding-json-schema/reference/index.html" target="_blank" rel="noopener noreferrer" class="">Understanding JSON Schema reference</a></li>
<li class="">Related blog: /blog/type-checking-your-rego-policies-with-json-schema-in-opa-5f7ac4c8a958</li>
</ul>]]></content>
        <author>
            <name>Mandana Vaziri</name>
        </author>
        <author>
            <name>Ansu Varghese</name>
        </author>
        <author>
            <name>Torin Sandall</name>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[Type checking your Rego policies with JSON schema in OPA]]></title>
        <id>https://openpolicyagent.org/blog/type-checking-your-rego-policies-with-json-schema-in-opa-5f7ac4c8a958</id>
        <link href="https://openpolicyagent.org/blog/type-checking-your-rego-policies-with-json-schema-in-opa-5f7ac4c8a958"/>
        <updated>2021-03-16T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Diagram illustrating JSON schema type checking for Rego]]></summary>
        <content type="html"><![CDATA[<p><img decoding="async" loading="lazy" alt="Diagram illustrating JSON schema type checking for Rego" src="data:image/webp;base64,UklGRlwkAABXRUJQVlA4WAoAAAAIAAAAdwUAcwIAVlA4IHwjAABQVAGdASp4BXQCPnU4mUokoyIhoFI4sJAOiWlu/Fd5xDCNCB/vyaOHGzyp/ifA3+t/4n+9/jZ7Y+d7zP7b/utz1fTPAn+O/cv9h/ff3S+OX8734/N/yl+AX8k/n/+g/MHgxQA/qP90/3v+B8e76C9YftZ/0fcC/m/95/5HsD39vqfsCf0r+7/sn7tf+F/7P9V/pfVz9Y/+//S/Ab/Pv7r/0PXa9jn7reyT+x4P3Tj5IZx8kM4+SGcfJDOPkhnHyQzj5IZx8kM4+SGcfJDOPkhnHyQzj5IZx8kM4+SGcfJDOPkhnHyQzj5IZx8kM4+SGcfJDOPkhnHyQzj5IZx8kM4+SGcfJDOPkhnHyQzj5IZx8kM4+SGc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AAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAB4BQAAA6AEAAEAAAB0AgAAAAAAAA==" width="1400" height="628" class="img_ev3q"></p>
<p><em><strong>IBM Research &amp; Styra</strong></em></p>
<p>The Open Policy Agent (OPA) is an open-source engine that unifies policy enforcement across the cloud native stack. It provides a query language called Rego that lets the user specify policy as code and an engine that evaluates the queries given input data.</p>
<p>Rego is a powerful declarative language that does not require the user to specify a query strategy. This is achieved by the OPA runtime, leaving users free to reason about policies at a higher level.</p>
<p>Rego has a gradual type system meaning that types can be partially known statically. For example, an object could have certain fields whose types are known and others that are unknown statically. OPA type checks what it knows statically and leaves the unknown parts to be type checked at runtime. However, the input handed to OPA could by design be any JSON value and hence gradual type-checking has no way of catching policy authoring mistakes, even when the policy author knows the intended schema.</p>
<p>In this article, we introduce a new feature that enhances OPA's ability to statically type check Rego code by taking into account schemas for input documents. This improves programmer productivity and helps Rego programmers catch errors earlier.</p>
<p>To achieve this, we enable <code>opa eval</code> to take the schema for the input document, specified in JSON Schema format. The input schema is passed with the flag <code>--schema</code> (<code>-s</code>). Armed with this information, OPA's enhanced type checker can detect bugs stemming from incorrect usage of the input.</p>
<p>This feature is now available in OPA v0.27.0. Let's check it out!</p>
<p><img decoding="async" loading="lazy" alt="Rego type checking demo" src="https://openpolicyagent.org/assets/images/1-494e64e03d84dd90de9ab839cf74bed1.webp" width="780" height="489" class="img_ev3q"></p>
<p><em>Rego type checking demo</em></p>
<p>Consider the following Rego code, which assumes as input a Kubernetes admission review. For resources that are Pods, it checks that the image name starts with a specific prefix.</p>
<div class="language-rego codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-rego codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token keyword" style="color:#00009f">package</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">kubernetes</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">admission</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token variable" style="color:#36acaa">deny</span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">msg</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">request</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">kind</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">kinds</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">==</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"Pod"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token variable" style="color:#36acaa">image</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">input</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">request</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">object</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">spec</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">containers</span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">_</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">.</span><span class="token variable" style="color:#36acaa">image</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token keyword" style="color:#00009f">not</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">startswith</span><span class="token punctuation" style="color:#393A34">(</span><span class="token variable" style="color:#36acaa">image</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"hooli.com/"</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token variable" style="color:#36acaa">msg</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">:=</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">sprintf</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">"image '%v' comes from untrusted registry"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token variable" style="color:#36acaa">image</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<p>Notice that this code has a typo in it: <code>input.request.kind.kinds</code> is undefined and should have been <code>input.request.kind.kind</code>.</p>
<p>Consider the following input document:</p>
<div class="language-json codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-json codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token property" style="color:#36acaa">"kind"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"AdmissionReview"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token property" style="color:#36acaa">"request"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token property" style="color:#36acaa">"kind"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">      </span><span class="token property" style="color:#36acaa">"kind"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"Pod"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">      </span><span class="token property" style="color:#36acaa">"version"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"v1"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token property" style="color:#36acaa">"object"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">      </span><span class="token property" style="color:#36acaa">"metadata"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">        </span><span class="token property" style="color:#36acaa">"name"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"myapp"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">      </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">      </span><span class="token property" style="color:#36acaa">"spec"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">        </span><span class="token property" style="color:#36acaa">"containers"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">          </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"image"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"nginx"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"name"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"nginx-frontend"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">          </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"image"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"mysql"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"name"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"mysql-backend"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">        </span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">      </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></div></code></pre></div></div>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token plain">% opa eval -format pretty -i admission-review.json -d pod.rego</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">[]</span><br></div></code></pre></div></div>
<p>The empty value returned is indistinguishable from a situation where the input did not violate the policy. This error is therefore causing the policy not to catch violating inputs appropriately.</p>
<p>If we fix the Rego code and change <code>input.request.kind.kinds</code> to <code>input.request.kind.kind</code>, then we obtain the expected result:</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token plain">[</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  "image 'nginx' comes from untrusted registry"</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  "image 'mysql' comes from untrusted registry"</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">]</span><br></div></code></pre></div></div>
<p>With this feature, it is possible to pass a schema to <code>opa eval</code>, written in JSON Schema.</p>
<p>Consider the <a href="https://github.com/aavarghese/opa-schema-examples/blob/main/kubernetes/admission-schema.json" target="_blank" rel="noopener noreferrer" class="">Kubernetes admission review input schema</a>. We can pass this schema to the evaluator as follows:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token plain">% opa eval -format pretty -i admission-review.json -d pod.rego -s admission-schema.json</span><br></div></code></pre></div></div>
<p>With the erroneous Rego code, we now obtain the following type error:</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#393A34"><span class="token plain">1 error occurred: pod.rego:5: rego_type_error: undefined ref: input.request.kind.kinds</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">  input.request.kind.kinds</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                     ^</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                     have: "kinds"</span><br></div><div class="token-line" style="color:#393A34"><span class="token plain">                     want (one of): ["kind" "version"]</span><br></div></code></pre></div></div>
<p>This indicates the error to the Rego developer right away, without having the need to observe the results of runs on actual data, thereby improving productivity.</p>
<p>With this new feature, Rego developers will be able to provide JSON Schemas for their input documents and get the most out of static type checking. If you don't have a JSON Schema handy, you can easily obtain one from a sample JSON file using online tools (see links below). In the future, we will add to this feature the support to allow users to specify a directory of schemas and assign schemas to data documents, as well. This will be done via annotations (global, rule-level, rule output) that will indicate what schema is associated with what Rego path expression.</p>
<p>Happy Rego type checking!</p>
<p>For more information and limitations, see <a href="https://www.openpolicyagent.org/docs/policy-language#schema" target="_blank" rel="noopener noreferrer" class="">documentation</a> and <a href="https://github.com/aavarghese/opa-schema-examples/" target="_blank" rel="noopener noreferrer" class="">examples</a>.</p>]]></content>
        <author>
            <name>Ansu Varghese</name>
        </author>
        <author>
            <name>Mandana Vaziri</name>
        </author>
        <author>
            <name>Torin Sandall</name>
        </author>
    </entry>
</feed>