Policy as Code is the practice of defining decision logic programmatically. With this approach, policies for security, compliance, audits and monitoring are defined using a general purpose, domain-specific or markup programming language. These policies are applied as a function of a CI/CD and continuous testing pipeline.
Ultimately, policy as code allows DevOps teams to automate workflows while managing security, risk and compliance.
Let’s look at how policy as code works. We’ll start with what it looks like without codifying your policies.
Traditionally, developers follow documented procedures that specify a variety of organizational policies, such as those for security, auditing and compliance.
This manual approach of adhering to a vast number and variety of applicable policies has a number of challenges:
In some cases, a user may unintentionally disregard a policy due to lack of awareness, collaboration and information sharing between other users.
Enter policy as code, which aims to remedy these manual issues.
Policy as Code systems typically rely on open source agents or a policy engine. These work like this:
A policy validation engine may be introduced into the CI/CD pipeline that takes the policy inputs from a policy version control system, evaluates the code builds from a version control system before approving the build for a deployment engine. The policies may be either:
A policy management system can extend this framework to introduce automated and continuous documentation and collaboration between cross-functional teams.
The concept of Policy as Code is similar to the Infrastructure as Code (IaC) approach of provisioning and managing infrastructure operations programmatically.
Where IaC is suitable for Infrastructure and Operations (I&O) tasks, Policy as Code follows similar DevOps goals relating to security operations, risk management, data handling and access to sensitive digital workloads, apps and services in various IT environments.
Let’s look at some of the key advantages and use cases of Policy as Code:
Authorization solutions rely on multiple control parameters, environment and resource information to determine the context of a request and handle authorizations. Advanced authorization systems use Policy as Code to integrate policy enforcement within the CI/CD and testing environments instead of the application code or external manual tests.
This is particularly useful for Identity and Access Management (IAM) systems that rely on modern policy-based rules frameworks such as RBAC where the policy can change dynamically and the control parameters can be variably defined.
Policy as Code allows DevOps teams to decouple the policy environment and codify modular components of the policy, which can apply to isolated systems and processes without an overlap. This approach simplifies policy enforcement and governance adoption. Users can:
The practice of security testing early during the software development lifecycle — shifting left — allows DevOps teams to identify and resolve security issues, as well as anticipate changes that may arise at later stages. Policy enforcement depends on these changes, which are often only identified in retrospect.
By codifying policy enforcement, the process becomes automated, passive and applied in real-time with respect to every change — including unforeseeable changes. This helps security testing teams to evaluate policy enforcement for a variety of use cases and environment settings throughout the SDLC pipeline.
Policies tend to change frequently depending on:
To enforce policies consistently and uniformly across all IT and digital assets, codifying policies allows full control over the policy environment. Manual policy enforcement is replaced by real-time systems that can conduct a large number of parallel tests to evaluate the impact of policy changes on system performance.
The Policy of Code approach currently faces some limitations. In order to ensure full coverage with existing IaC policies, any policy-as-code offering must be fully compatible with open source and standardized cloud environments. The available policy engines currently in the market may not support all vendor products deployed in your cloud-based environment.
Furthermore, applying a policy-as-code system may require moving configuration information to third-party cloud servers, potentially exposing to security risks as IAM related configurations may be exposed if the target servers are compromised.
A shift to a general-purpose policy engine such as Open Policy Agent alleviates these concerns and provides a standardized approach to decouple decision-logic from policy enforcement.
See an error or have a suggestion? Please let us know by emailing ssg-blogs@splunk.com.
This posting does not necessarily represent Splunk's position, strategies or opinion.
The Splunk platform removes the barriers between data and action, empowering observability, IT and security teams to ensure their organizations are secure, resilient and innovative.
Founded in 2003, Splunk is a global company — with over 7,500 employees, Splunkers have received over 1,020 patents to date and availability in 21 regions around the world — and offers an open, extensible data platform that supports shared data across any environment so that all teams in an organization can get end-to-end visibility, with context, for every interaction and business process. Build a strong data foundation with Splunk.