Policy support #17
RealHarshThakur
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Overview
This RFC proposes a unified, declarative policy configuration model for Nuon applications, along with an execution strategy for evaluating OPA-based policies across Kubernetes manifests, Terraform modules, and Helm charts. The goal is to make policy authoring, distribution, evaluation, and auditability consistent and predictable across all types of components, while keeping the system flexible and scalable.
The core idea:
A single policies.toml defines all policies (1 → N mapping), and workflows—not runners—own plan evaluation and policy enforcement.
Problem Statement
Describe the problem that needs to be solved.
Policy Definition
Policies need to be tied to specific components. This makes global, cross-component rules easy to enforce.
Example problem:
Directory-Based Grouping
Nuon heavily relies on directory structure for semantic grouping (e.g., components, actions)
Policies should follow a similar pattern.
Goals
policies.toml.Solution
Key characteristics:
contentscan point to a file or be in-lined.sandbox_only).Policies are resource constraints, not process steps.
Consider a vendor who wants to prevent insecure RDS configurations, such as:
These constraints are properties of the RDS resource itself, not properties of a workflow like “sandbox provision” or “sandbox update.”
The same RDS misconfiguration is unsafe regardless of the workflow step that produced it. A vendor’s intent is not:
The vendor’s actual intent is:
Why we shouldn’t have process level policies.
If policy binding is done using workflow-based types (e.g.,
policy_sandbox_provision,policy_sandbox_update,policy_deploy, etc.), then the vendor must manually attach the same rule to every workflow path that might affect the resource. This creates an immediate correctness hazard:This design forces policy authors to reason about the internal state machine of the platform rather than the security posture of the resource. As workflows evolve over time, policy bindings must be updated continuously, even though the security requirement (“RDS must be encrypted”) has not changed. This is brittle & error-prone.
In contrast, binding policies to resource roles—such as
terraform_module,kubernetes_manifest, orhelm_chart—aligns the enforcement model with how vendors actually think about risk:These constraints are properties of the resource domain, not of the execution flow.
With a role-based model:
Policies attach to resource types and resource semantics, not to lifecycle events.
Implementation
For correct evaluation of policies, runner job output needs to contain:
We’ve the necessary data for terraform. However, we should have also have the Runner job output include details for Kubernetes Manifest and Helm. For MVP, we could consider doing it on a non-dry run output for Kubernetes Manifest.
Opa Integration
OPA allows for policies to be evaluated in this manner using "github.com/open-policy-agent/opa/rego" Go module-
Enforcement Architecture
Where Enforcement Runs
Enforcement runs in workflows / ctl-api, not in the runner.
Reasons:
-
-
- Full helm template output
- K8s dry-run manifest
- Terraform plan JSON
-
-
- Relying on runner availability
- Log shipping
- Build pipelines
-
- No-op approvals
- plan object (terraform or helm or kube)
- policy set filtered by:
- type
- component match
- sandbox_only
- Load policies from DB.
- Evaluate each policy against its plan.
- Store the violations as a workflow property
- Embed plain Rego text into DB.
- Simple to implement.
- No build pipeline required.
# OverviewWorkflows already process plans (Terraform plans, manifests, diffs).
DB is the correct long-term storage for:
Avoid round-trips to runner jobs.
Avoid complications of:
Temporal workflows already handle:
Workflow Integration
New Child Workflow:
CheckPoliciesInput:
Steps:
Go-getter embedding in component config
This RFC proposes a unified, declarative policy configuration model for Nuon applications, along with an execution strategy for evaluating OPA-based policies across Kubernetes manifests, Terraform modules, and Helm charts. The goal is to make policy authoring, distribution, evaluation, and auditability consistent and predictable across all types of components, while keeping the system flexible and scalable.
The core idea:
A single policies.toml defines all policies (1 → N mapping), and workflows—not runners—own plan evaluation and policy enforcement.
Problem Statement
Describe the problem that needs to be solved.
Policy Definition
Policies need to be tied to specific components. This makes global, cross-component rules easy to enforce.
Example problem:
Directory-Based Grouping
Nuon heavily relies on directory structure for semantic grouping (e.g., components, actions)
Policies should follow a similar pattern.
Goals
policies.toml.Solution
Key characteristics:
contentscan point to a file or be in-lined.sandbox_only).Policies are resource constraints, not process steps.
Consider a vendor who wants to prevent insecure RDS configurations, such as:
These constraints are properties of the RDS resource itself, not properties of a workflow like “sandbox provision” or “sandbox update.”
The same RDS misconfiguration is unsafe regardless of the workflow step that produced it. A vendor’s intent is not:
The vendor’s actual intent is:
Why we shouldn’t have process level policies.
If policy binding is done using workflow-based types (e.g.,
policy_sandbox_provision,policy_sandbox_update,policy_deploy, etc.), then the vendor must manually attach the same rule to every workflow path that might affect the resource. This creates an immediate correctness hazard:This design forces policy authors to reason about the internal state machine of the platform rather than the security posture of the resource. As workflows evolve over time, policy bindings must be updated continuously, even though the security requirement (“RDS must be encrypted”) has not changed. This is brittle & error-prone.
In contrast, binding policies to resource roles—such as
terraform_module,kubernetes_manifest, orhelm_chart—aligns the enforcement model with how vendors actually think about risk:These constraints are properties of the resource domain, not of the execution flow.
With a role-based model:
Policies attach to resource types and resource semantics, not to lifecycle events.
Implementation
For correct evaluation of policies, runner job output needs to contain:
We’ve the necessary data for terraform. However, we should have also have the Runner job output include details for Kubernetes Manifest and Helm. For MVP, we could consider doing it on a non-dry run output for Kubernetes Manifest.
Opa Integration
OPA allows for policies to be evaluated in this manner using "[github.com/open-policy-agent/opa/rego](http://github.com/open-policy-agent/opa/rego)" Go module-
Enforcement Architecture
Where Enforcement Runs
Enforcement runs in workflows / ctl-api, not in the runner.
Reasons:
Workflows already process plans (Terraform plans, manifests, diffs).
DB is the correct long-term storage for:
Avoid round-trips to runner jobs.
Avoid complications of:
Temporal workflows already handle:
Workflow Integration
New Child Workflow:
CheckPoliciesInput:
Steps:
Go-getter embedding in component config
All reactions