Security as Code
Security as Code is an approach where security policies, controls, and procedures are written and managed as code rather than applied manually after software is built. This means security checks and requirements are embedded directly into the development process and automated tooling. The goal is to make security a consistent, repeatable part of how software is built and delivered.
Security as Code (SaC) is a software development discipline in which security policies, controls, procedures, and compliance requirements are codified and version-controlled alongside application and infrastructure code, enabling automated enforcement throughout the software development lifecycle. SaC integrates security protocols directly into DevOps tools, pipelines, and workflows, typically through automated scanning, policy-as-code enforcement, and infrastructure security configuration, so that security measures are applied consistently at each stage of development rather than as a manual, post-development activity. SaC is a foundational building block of DevSecOps, mapping security requirements to code and infrastructure changes to ensure that key practices are enforced programmatically across all components of the software delivery process.
Why it matters
Manual security reviews applied after software is built create predictable gaps: controls are inconsistently applied, findings arrive too late to be fixed cheaply, and the same classes of vulnerability recur across releases because there is no programmatic enforcement preventing them. As development cycles have accelerated through CI/CD adoption, the window available for manual security gates has narrowed to the point where post-deployment remediation has become the norm rather than the exception for many teams. Security as Code addresses this by making security enforcement a structural property of the pipeline rather than a scheduled activity.
The consistency benefit is significant beyond speed. When security controls are written as code and version-controlled alongside application and infrastructure code, every change to those controls is auditable, reviewable, and testable. Teams can trace when a policy was introduced, who approved it, and whether it was enforced during a given build. This auditability is particularly relevant for compliance requirements, where demonstrating continuous enforcement is typically more defensible than point-in-time audit evidence.
Securing the software supply chain has raised the stakes for pipeline integrity specifically. Automated, codified controls that govern how dependencies are ingested, how builds are executed, and how artifacts are promoted through environments reduce the surface area available to attackers who target the build and delivery process itself. Without codified enforcement at these stages, individual human reviewers become the primary control, and human controls do not scale consistently across large engineering organizations.
Who it's relevant to
Inside SaC
Common questions
Answers to the questions practitioners most commonly ask about SaC.