Glossary · Policy, pipelines and supply chain

Policy as code

Policy as code is the practice of expressing security, compliance and operational rules as machine-readable definitions that are versioned, reviewed and evaluated automatically, rather than as prose in a document.

A written policy such as "no critical vulnerabilities in production" depends on people to apply it consistently. Policy as code turns it into something a program evaluates: a rule, stored in version control, that takes facts as input (the findings of a scan, a Kubernetes manifest, a cloud resource, a request) and returns a decision such as allow, warn or deny. Some systems use a general-purpose policy language, such as Rego for Open Policy Agent or CEL in Kubernetes; others use declarative rule structures with a fixed set of conditions. Either way, the policy can be reviewed in a pull request, tested against examples, rolled out gradually and rolled back.

How it is used in practice

Policy as code shows up wherever a decision should be automatic and explainable. CI pipelines ask whether a build's scan results satisfy policy before publishing an artifact. Admission controllers evaluate a workload before a cluster runs it. IaC scanners apply rule catalogs to Terraform and manifests. Access systems evaluate requests against authorization policies. In each case, the useful output is not just the decision but the reasoning: which rule matched which fact. Teams usually introduce a new rule in a non-blocking mode first, observe what it would have refused, and only then enforce it.

Common pitfalls

  • Policy the pipeline can rewrite. If the credential that asks for a decision can also change the rules, the build grades its own homework.
  • Opaque decisions. A bare "fail" with no record of which rule and which finding caused it gets bypassed, not fixed.
  • Non-reproducible results. If evaluating the same inputs twice can give different answers, an audit cannot reconstruct why something shipped.
  • Arbitrary code in policies. A policy language that can make network calls or run customer-supplied code is itself an attack surface.
  • Enforcing on day one. A new rule that blocks immediately breaks pipelines before its authors have read its results.

How TrustIvan relates to it

TrustIvan's AppSec policies are declarative and versioned. A rule is a set of conditions on severity, finding kind, lifecycle status, fixability, advisory identifier, age and match count, with exactly one effect: fail, warn or ignore. A separate signed_by rule refuses a container image not signed by one of the public keys it lists. There is no expression language and no customer code to evaluate. Evaluating a policy against a scan produces a recorded, immutable verdict with its reasoning, and a repeated request replays it rather than recomputing. Policies are written by people in the dashboard or API; policies:manage cannot be granted to an API key, so a pipeline can request verdicts but cannot change the rules it is judged by. A new policy starts disabled. See Policies and verdicts.

Related terms

Guides on Policy as code

On the platform: Policy engine. All glossary terms

See TrustIvan on your own estate.

Book thirty minutes with an engineer and bring an image, a repository or a cloud account, or start free on the hosted service.