← Back to Articles
Focus: Enterprise Security Architecture | Angle: blueprint

“As-Code” definitions

How many “as-code” approaches are there?

After the 2017 Equifax breach, we learned that one-click Policy as Code “solutions” from security vendors barely covered half of our actual requirements.

The problem wasn’t just the tooling—it was that the industry keeps slapping ‘as-Code’ onto different disciplines. Some define target states, some enforce SDLC workflows, and some just run generic compliance checklists. If you don’t separate them, you’ll spend a year automating someone else’s rules instead of your own.

I’m creating some detailed project documentation for my Policy as Code experience over the past decade, and I felt it was important to examine and define the relevant ones. I won’t get deep into the benefits and drawbacks of each, but I may point out one or two.

Infrastructure as Code (IaC)

Infrastructure as code is the practice of storing the definition of infrastructure as one or more files. This replaces the traditional model where infrastructure as a service is provisioned manually, usually through shell scripts or other configuration tools.

—https://glossary.cncf.io/infrastructure-as-code/

The purpose of IaC is not only to define a target state using some domain-specific language (e.g., HCL, Chef recipes), but also to process them with an engine of some sort (e.g., OpenTofu or Terraform for HCL) to move the infrastructure to that target state. Less often, idempotent scripts or imperative engines will be used.

Because the target state is defined, drift is detectable, auditable, and correctable, down to the instance ID in some cases. IaC is the only sane way to handle infrastructure at scale, and so it has become synonymous with the DevOps approach to infrastructure.

Security as Code (SaC)

The practice of embedding security checks into development workflows. Some ways this is implemented may include running SAST against new code, blocks in the CI/CD pipelines for code with ‘critical’ findings, the required use of a central CI/CD pipeline, secret scanning, vulnerability scanning, etc.

This hasn’t become a buzzword yet, but it deserves a mention. I wouldn’t consider this an “as-Code” approach, myself, because these pieces and parts enforce a process, not a target state. The term “Security as Code” seems like it was not created by a security practitioner, because it does not encompass all security nor is it declarative. I would call this “Code Security in SDLC” or “AppSec in CI/CD”.

Compliance as Code (CaC)

Code that automates compliance checks against relevant security frameworks, like CIS Controls, NIST SP 800-53, CJIS, etc. It may or may not enforce those requirements.

One of the newer buzzwords, but no strong definition has coalseced, despite the desire for automated compliance, the history of computer-aided auditing, and the existence of the Compliance Engineering fad. There is a lot of overlap with Policy as Code, and if the program is managed properly, this is a tiny use case inside of a comprehensive PaC program.

Policy as Code (PaC)

Policy as Code is the practice of storing the definition of policies as one or more files in machine-readable and processable form. This replaces the traditional model where policies are documented in human-readable form in separate documents.

—https://glossary.cncf.io/policy-as-code/

The benefits being both enforcement and monitoring.

While researching this, the definitions of PaC from security vendors often say that their tool will implement this in one click. However, the vast majority of them are actually compliance checks against common security frameworks like CIS Controls, NIST SP 800-53, CJIS, etc. Sound familiar from CaC above? But those aren’t your policies. And some of those frameworks require you to define certain things yourself, so there is no personalization, and thus little connection to your actual human-readable policies and standards.

In Equifax after the 2017 breach, we had a real problem—federal consent orders, a multi-state attorneys general settlement, and thousands of lawsuits settled as one. Each imposed special security requirements onto us over and above the security requirements of any single framework. On top of that, we had certain internal requirements added due to our own lessons learned from the breach.

Less than half of the vendor-provided checks against common security frameworks would work for us. Add on the very specific architectural decisions we had made for separation of concerns, and the vendor-provided remediations for half of the checks that worked, wouldn’t apply to us.

For example, if the remediation required changing the VPC Network or VPC Subnet, that was impossible for a dev team to do directly. We required them to open a ticket for the networking team who owned the host VPC Project, to prevent a dev team from accidentally allowing Internet access to their Project.

So we created our own Policy as Code program. A generic version of which I will be posting about in the coming weeks.

You can buy a tool to check generic regulatory boxes, but you cannot outsource ownership of your own policies. Until leadership, compliance, and engineering agree on what is actually being automated—target state, SDLC workflow, generic compliance, or corporate policy—you will keep paying for tools that generate alerts your teams aren’t even permitted to fix.

Over the coming five part series, I’ll walk through the Policy as Code architecture we built to solve that—starting with why written policies break down in practice and the missing architectural layer most teams skip.