Advanced Software Development

Chapter 9
DevSecOps and Continuous Delivery

Bachelors Program in Computer Science Engineering
Advanced Software Development   •   Bachelor

DevSecOps and Continuous Delivery

Introduction and Context

Modern software systems are delivered through frequent changes to application code, infrastructure, configuration, and third-party dependencies. Traditional separation between development, operations, and security often creates delays, duplicated work, and late discovery of defects. DevSecOps addresses this problem by integrating security practices throughout the software delivery lifecycle, while continuous delivery provides the technical and organizational capability to keep software in a releasable state.

A DevSecOps pipeline is more than a sequence of build commands. It is a governed system that transforms a source-code change into a tested, security-assured, deployable artifact and, where authorized, a production release. Its effectiveness depends on automation, reproducibility, traceability, feedback, and human judgment at appropriate control points.

The central idea is to make quality and security shared responsibilities. Developers contribute secure design and coding practices; operations engineers provide reliable environments and observability; security specialists define controls, threat models, and assurance methods; and product stakeholders determine acceptable risk and release value.

Learning Objectives

By the end of this chapter, students should be able to:

  1. Distinguish continuous integration, continuous delivery, continuous deployment, and DevSecOps.
  2. Design a CI/CD pipeline containing automated testing, security checks, artifact management, and release controls.
  3. Explain infrastructure as code, policy as code, and environment-management strategies.
  4. Compare deployment methods such as blue-green, canary, rolling, and feature-flag releases.
  5. Design rollback and recovery mechanisms based on observable system behavior.
  6. Evaluate governance, compliance, supply-chain, and ethical concerns in automated delivery.

1. Foundations of Continuous Delivery

Continuous integration

Continuous integration (CI) is the practice of frequently merging small changes into a shared repository and automatically validating them. A typical CI process checks out the source, resolves dependencies, compiles or packages the application, executes tests, performs static analysis, and publishes results.

CI reduces integration risk by shortening the interval between introducing and discovering a defect. It is effective only when the main branch remains usable and the pipeline provides rapid, trustworthy feedback. A pipeline that takes several hours, produces flaky results, or permits untested changes is technically automated but operationally weak.

Continuous delivery and continuous deployment

Continuous delivery means that every change that passes the required controls is placed in a releasable state. Deployment to production may still require a deliberate approval, business decision, or scheduled window.

Continuous deployment goes further: every change satisfying automated release criteria is deployed automatically to production. Continuous deployment is therefore a policy choice built on continuous delivery, not a synonym for it.

PracticeMain capabilityTypical production decision
Continuous integrationFrequently validate merged changesNot necessarily involved
Continuous deliveryKeep validated software releasableMay require approval
Continuous deploymentAutomatically release validated softwareAutomated
DevSecOpsIntegrate security into delivery and operationsRisk-based and shared

DevSecOps as a socio-technical system

DevSecOps combines culture, process, architecture, and tools. The following principles are particularly important:

  • Shift left: identify defects and vulnerabilities early, when correction is usually less expensive.
  • Shift right: validate behavior in realistic environments using monitoring, resilience tests, and incident learning.
  • Security by design: address identity, data protection, trust boundaries, and abuse cases before implementation.
  • Automation with accountability: automate repeatable checks while retaining clear ownership for exceptions and risk acceptance.
  • Immutable promotion: build an artifact once and promote the same tested artifact across environments rather than rebuilding it for each stage.
  • Least privilege: limit the permissions of developers, pipeline identities, workloads, and deployment agents.

2. The Architecture of a Secure Delivery Pipeline

A useful pipeline can be viewed as a sequence of increasingly realistic verification stages:

  1. Plan: record requirements, security objectives, acceptance criteria, and change risk.
  2. Code: commit application code, tests, infrastructure definitions, and policy definitions to version control.
  3. Build: compile, package, and generate a uniquely identifiable artifact.
  4. Test: execute unit, component, integration, contract, user-interface, performance, and resilience tests as appropriate.
  5. Secure: conduct static application security testing, software-composition analysis, secrets detection, container scanning, dynamic testing, and infrastructure scanning.
  6. Package and sign: store the artifact in a controlled registry and attach provenance, test results, and signatures.
  7. Deploy to a verification environment: apply infrastructure and configuration through automated, reviewed definitions.
  8. Validate: perform smoke tests, acceptance tests, policy checks, and observability checks.
  9. Release: use an approval, progressive exposure, or automatic deployment rule.
  10. Operate and learn: monitor service-level indicators, security events, errors, cost, and user impact; feed findings back into development.

The stages need not be strictly linear. Fast checks should run early, while expensive tests may run in parallel or after a candidate artifact is created. A pipeline should fail for meaningful reasons, provide actionable diagnostics, and preserve evidence for audit and incident investigation.

Testing strategy

A balanced test portfolio commonly follows a test pyramid: many fast unit tests, fewer component and integration tests, and a smaller number of end-to-end tests. End-to-end tests are valuable but often slower and more fragile because they depend on many services.

Important automated tests include:

  • Unit tests: verify isolated functions or classes.
  • Component tests: verify a service with controlled dependencies.
  • Integration tests: verify interaction with databases, queues, APIs, or identity systems.
  • Contract tests: verify that service providers and consumers agree on interfaces.
  • Acceptance tests: verify behavior against business requirements.
  • Performance tests: measure latency, throughput, and resource behavior under defined conditions.
  • Resilience tests: examine recovery from dependency failure, timeouts, overload, or loss of instances.
  • Security tests: examine misuse cases, authorization boundaries, input validation, and vulnerability indicators.

Test quality matters more than test count. A high coverage percentage does not prove that security-sensitive paths or meaningful business behaviors are tested. Coverage should be treated as evidence, not as a complete quality criterion.

3. Security Controls in the Pipeline

Application and dependency security

Static application security testing (SAST) analyzes source or compiled code without executing the application. It can identify insecure APIs, injection risks, weak cryptography, and suspicious data flows. Dynamic application security testing (DAST) exercises a running application and can reveal observable issues such as authentication failures, injection behavior, and insecure headers.

Software-composition analysis (SCA) inventories open-source dependencies, compares versions with vulnerability databases, and identifies licensing obligations. It should be combined with dependency pinning, controlled update policies, and rapid response to critical advisories. A vulnerable dependency is not automatically exploitable in every context, so teams should assess reachability, exposure, compensating controls, and remediation urgency.

Secrets detection searches repositories, build logs, images, and configuration for credentials, tokens, private keys, and connection strings. Secrets should be supplied through an approved secret-management system, rotated, scoped, and excluded from logs. Removing a secret from the current file is insufficient if it remains in repository history or artifact layers.

Infrastructure and container security

Infrastructure scanning examines cloud resources, network exposure, identity permissions, storage settings, encryption, and configuration drift. Container scanning examines base images, packages, privileges, exposed ports, and unsafe configuration. A secure image should be minimal, reproducibly built, patched, scanned, signed, and executed with a non-root identity where feasible.

Security checks should have severity-based gates. For example, a pipeline may block a release for an exploitable critical vulnerability in a production-exposed component while allowing a documented low-risk finding under a time-limited exception. Exceptions require an owner, justification, compensating control, expiration date, and review; otherwise, they become permanent bypasses.

Software supply-chain assurance

The build system and its dependencies are part of the attack surface. Important controls include protected branches, mandatory review, signed commits where appropriate, isolated build workers, dependency provenance, artifact signing, restricted registry permissions, reproducible builds, and tamper-evident audit logs. Pipeline credentials should be short-lived and scoped to the specific repository, environment, and operation.

4. Infrastructure as Code and Policy as Code

Infrastructure as code

Infrastructure as code (IaC) represents networks, compute resources, databases, permissions, and service configuration in version-controlled declarations. IaC improves repeatability, reviewability, and disaster recovery. It also makes infrastructure changes subject to the same testing and approval practices as application changes.

A robust IaC workflow includes formatting and validation, static analysis, a preview or plan, peer review, controlled application, state protection, drift detection, and post-deployment verification. Secrets should not be embedded in IaC files or state without appropriate encryption and access controls.

Declarative IaC describes the desired state, while an engine determines the actions required to approach that state. This differs from an imperative script, which directly specifies a sequence of commands. Declarative approaches can reduce environmental inconsistency, but they do not eliminate dependency ordering, provider defects, state conflicts, or destructive-change risk.

Policy as code

Policy as code expresses organizational or regulatory rules in machine-evaluable form. Examples include:

  • production storage must use encryption;
  • public network access is prohibited for a database;
  • container images must originate from an approved registry;
  • deployments require a linked change record;
  • workloads may request only approved permissions;
  • personally identifiable information must not be written to application logs.

Policies can be evaluated before deployment, during admission, and continuously after deployment. Preventive controls stop an invalid change; detective controls identify drift or violation; corrective controls restore an approved state or initiate remediation. Policies must be versioned, tested, explainable, and mapped to responsible owners. A policy that blocks legitimate emergency recovery without an exception path may reduce rather than increase resilience.

5. Environment Management and Configuration

Common environments include development, testing, staging, and production. Their purpose is not merely to create multiple copies of a system; each should provide a clear verification function. Development environments optimize feedback, test environments support automated verification, staging approximates production for release validation, and production serves real users.

Environment inconsistency is a major source of deployment failure. Teams should define environments through IaC, standardize runtime versions, manage configuration separately from code, and make differences explicit. Configuration should be injected at deployment or runtime, validated against schemas, and protected according to sensitivity.

A strong promotion model builds one artifact and promotes it through environments. Rebuilding for each environment can introduce untested differences. Environment-specific values—such as endpoints, scaling limits, and credentials—may vary, but the application artifact should remain identical.

Database changes require special care. A release may need an expand-and-contract migration: first add a backward-compatible schema element, then deploy code that can use both old and new forms, migrate data, and finally remove the obsolete element in a later change. This approach reduces downtime and supports rollback of application code.

6. Deployment and Release Strategies

Deployment places software into an environment; release makes functionality available to users. Separating these concepts enables controlled exposure.

Rolling deployment

A rolling deployment replaces instances gradually. It uses existing infrastructure efficiently but can temporarily run different application versions. Compatibility between versions, especially for APIs and database schemas, is therefore essential.

Blue-green deployment

Blue-green deployment maintains two production-like environments. The active environment serves users while the inactive environment receives the new version. Traffic is switched after validation. Rollback can be rapid by switching traffic back, although the approach may require additional capacity and careful treatment of persistent data.

Canary deployment

A canary exposes a small proportion of traffic to the new version. Operators compare error rate, latency, resource use, and business indicators with the stable version. Exposure expands only when predefined criteria are satisfied. Canary analysis is most useful when traffic is representative and observability is reliable.

Feature flags

Feature flags separate code deployment from feature activation. They support gradual rollout, user segmentation, experimentation, and rapid disabling. Flags create operational complexity and should have owners, expiry dates, secure evaluation rules, and removal plans. A flag is not a substitute for testing or access control.

Release controls

Release controls include peer review, segregation of duties, change records, approval gates, maintenance windows, automated policy checks, progressive delivery, and post-release verification. Controls should be risk-based. A low-risk documentation change need not receive the same treatment as a change to authentication or payment processing.

7. Rollback, Recovery, and Observability

Rollback means returning to a previous application or configuration state. It is safest when artifacts are immutable, versions are identifiable, and backward compatibility has been designed. Rollback is not always appropriate: an irreversible database migration, data corruption, or security exposure may require forward repair, restoration from backup, or incident response instead.

A recovery plan should define:

  • the conditions that trigger rollback or halt;
  • who can authorize the action;
  • the exact artifact and configuration to restore;
  • how traffic will be redirected;
  • how data consistency will be checked;
  • how users and stakeholders will be informed;
  • how the incident will be documented and reviewed.

Observability supplies the evidence for release decisions. Logs record events, metrics summarize behavior, and traces connect work across distributed services. Useful indicators include request success rate, latency, saturation, queue depth, deployment failure rate, vulnerability age, and authentication anomalies. Alerts should identify actionable deviations rather than simply increase notification volume.

A practical release gate can compare a canary with the baseline. For example, a team may stop expansion if the canary’s error rate exceeds the baseline by a defined threshold for a sustained observation window. Such a rule is meaningful only when the traffic sample is adequate, the metric is correctly defined, and normal variation is understood.

8. Delivery Metrics and Improvement

The commonly used DORA delivery measures are deployment frequency, lead time for changes, change failure rate, and time to restore service. These measures should be interpreted together. Increasing deployment frequency while increasing incidents may indicate unhealthy optimization.

Teams may also track pipeline duration, flaky-test rate, escaped defects, mean time to remediate vulnerabilities, percentage of infrastructure managed as code, rollback duration, and policy-exception age. Metrics should support learning rather than employee punishment. Local optimization can be harmful: a team that reduces pipeline duration by removing valuable tests may improve one metric while increasing organizational risk.

9. Case Study: Illustrative Online Banking Release

Background

Consider an illustrative bank, Northstar Bank, operating a mobile transfer service. The service consists of an API, an authorization service, a transaction database, and notification workers. The bank must protect customer data, preserve transaction integrity, and meet audit requirements.

Problem

The existing process deploys manually once a month. Security testing occurs near the end of the process, database changes are difficult to reverse, and production configuration differs from staging. Releases are slow and occasionally require emergency fixes.

Analysis

The major risks are late feedback, configuration drift, excessive production change size, weak traceability, and unsafe schema changes. A simple decision to “deploy more often” would not solve these risks. The bank needs an integrated delivery design.

Approach and solution

The team introduces protected source repositories and a pipeline that performs formatting, unit tests, SAST, dependency analysis, secret scanning, and IaC validation on every change. A signed container image is built once and stored in a controlled registry. Integration and contract tests run against an ephemeral environment created from IaC.

Before production, policy as code verifies encryption, network boundaries, approved image sources, identity permissions, and required change records. A staging environment uses the same artifact and a production-like topology. Database changes follow expand-and-contract migration. Production uses a canary deployment, initially exposing a small traffic segment. Error rate, transaction latency, authorization failures, and duplicate-transfer indicators are monitored.

A release automatically pauses when a defined service indicator breaches its threshold. The on-call engineer can switch traffic to the previous application version, but database rollback is avoided unless data safety has been confirmed. Emergency changes use a documented break-glass process with retrospective review.

Outcome

The bank gains smaller changes, earlier security feedback, reproducible environments, and stronger audit evidence. The pipeline does not eliminate risk; rather, it makes risk visible and provides controlled responses. The most important improvement is the combination of technical automation with explicit ownership and release policy.

Learning points

  1. Security controls are most effective when integrated from the first pipeline stages.
  2. Immutable artifacts and compatible schema changes make recovery more realistic.
  3. Progressive delivery requires trustworthy observability.
  4. Compliance evidence can be generated as a normal pipeline output.
  5. Human approval remains valuable for high-impact or ambiguous changes.

10. Governance, Ethics, and Contemporary Developments

Automated delivery can amplify both good and bad decisions. A flawed policy can block access for legitimate users; an incorrect deployment can affect thousands of customers quickly; and excessive monitoring can expose sensitive employee or user data. Teams should apply data minimization, access control, explainable policy decisions, retention limits, and independent review.

Regulated systems may require evidence of authorization, testing, segregation of duties, vulnerability management, change history, and incident response. Evidence should be generated automatically where possible, but automation must not encourage superficial compliance. Auditors and engineers need to understand what a control actually proves.

Contemporary practices include software bills of materials, signed provenance attestations, ephemeral preview environments, confidential computing, automated dependency update systems, and AI-assisted code generation. AI-generated code must undergo the same testing, security review, licensing assessment, and human accountability as other code. Generated suggestions may contain insecure patterns, hallucinated APIs, or unsuitable dependencies. AI should accelerate analysis and implementation, not replace engineering judgment.

Challenges and Limitations

DevSecOps introduces costs and trade-offs. Security tools can produce false positives; tests can become flaky; pipeline infrastructure requires maintenance; policy rules can become inconsistent; and environment replication can be expensive. Excessive gates may encourage bypass behavior, while insufficient gates permit preventable failures.

Organizations also face cultural obstacles. Teams may resist shared ownership, security may be viewed as an external approval function, and operations may inherit poorly designed systems. Effective adoption requires leadership support, training, clear service ownership, incremental improvement, and blameless learning after incidents.

The objective is not maximum automation at any cost. The objective is a delivery system that produces trustworthy changes at an appropriate speed, with evidence, reversibility, and responsible control.

Best-Practice Checklist

  • Keep the main branch buildable and integrate small changes frequently.
  • Build once, identify artifacts uniquely, and promote immutable artifacts.
  • Run fast tests and security checks early; reserve expensive tests for suitable stages.
  • Store infrastructure and policy definitions in version control.
  • Protect secrets and use short-lived, least-privilege pipeline credentials.
  • Make environments reproducible and differences explicit.
  • Design database migrations for compatibility and recovery.
  • Use progressive exposure when the impact of failure is high.
  • Define rollback triggers before deployment and verify recovery regularly.
  • Treat observability, audit evidence, and incident learning as delivery outputs.
  • Review exceptions, feature flags, and policy rules for expiry and ownership.

Chapter Summary

DevSecOps integrates development, operations, and security into a shared delivery system. Continuous integration validates frequent changes; continuous delivery keeps validated software releasable; and continuous deployment automatically releases qualifying changes. A mature pipeline includes automated testing, security analysis, dependency and secret controls, artifact signing, infrastructure as code, policy as code, environment consistency, and traceable release decisions.

Deployment strategies such as rolling, blue-green, canary, and feature-flag releases provide different balances of speed, capacity, exposure, and rollback capability. Recovery depends on immutable artifacts, compatible data changes, observability, and clearly defined authority. Metrics should encourage system-level learning rather than isolated optimization. Finally, automation must operate within ethical, regulatory, and governance boundaries, with human accountability for risk and exceptions.

Key Terms

Continuous integration: Frequent integration of changes with automated validation.

Continuous delivery: Practice of keeping validated software in a releasable state.

Continuous deployment: Automatic production release of changes that satisfy defined criteria.

DevSecOps: Integration of development, operations, and security practices across the delivery lifecycle.

Pipeline: An automated workflow that builds, tests, secures, deploys, and observes software.

Artifact: A versioned build output intended for deployment or distribution.

SAST: Static application security testing performed without executing the application.

DAST: Dynamic application security testing performed against a running application.

Software-composition analysis: Examination of third-party dependencies for vulnerabilities and licensing issues.

Infrastructure as code: Version-controlled declarative or scripted definition of infrastructure.

Policy as code: Machine-evaluable representation of organizational or regulatory rules.

Configuration drift: Divergence between the declared and actual state of an environment.

Blue-green deployment: Release method using two production-like environments and controlled traffic switching.

Canary deployment: Progressive release to a limited portion of users or traffic.

Feature flag: Runtime control that activates or deactivates functionality independently of deployment.

Immutable artifact: Build output that is not modified after creation.

Progressive delivery: Gradual exposure of a change with measurement and control.

Observability: Ability to infer system behavior from logs, metrics, traces, and related evidence.

Break-glass access: Exceptional, tightly controlled access used during urgent incidents.

Software supply chain: The code, dependencies, tools, identities, and processes used to produce software.

Review Questions

Short Answer Questions

  1. What is the difference between continuous delivery and continuous deployment?
  2. Why should a team build an artifact once and promote it across environments?
  3. State two purposes of policy as code.
  4. What is the principal advantage of a canary deployment?
  5. Why are secrets unsuitable for storage in source-code repositories?

Long Answer Questions

  1. Explain the stages of a DevSecOps pipeline and discuss how feedback should flow between them.
  2. Compare rolling, blue-green, and canary deployment strategies, including their operational trade-offs.
  3. Explain how infrastructure as code and policy as code contribute to reliable and auditable delivery.
  4. Discuss the role of automated testing in a secure delivery pipeline and explain why coverage percentage alone is insufficient.
  5. Describe the conditions required for safe rollback and explain why some database changes cannot simply be reversed.

Analytical / Application Questions

  1. Design a pipeline for a healthcare application that processes sensitive patient data. Identify testing, security, policy, environment, and release controls, and justify each control.
  2. A canary release shows lower latency but a higher authorization-failure rate than the baseline. Analyze possible causes and recommend whether traffic expansion should continue.
  3. An organization has frequent production incidents after increasing deployment frequency. Use DevSecOps principles and delivery metrics to diagnose the problem and propose an improvement plan.

Multiple Choice Questions with Answers

Question 1

Which statement best distinguishes continuous delivery from continuous deployment?

A. Continuous delivery eliminates automated testing.

B. Continuous delivery keeps software releasable, while continuous deployment automatically releases qualifying changes.

C. Continuous delivery applies only to infrastructure, while continuous deployment applies only to applications.

D. Continuous delivery always requires production deployment approval.

Correct Answer: B. Continuous delivery keeps software releasable, while continuous deployment automatically releases qualifying changes.

Question 2

Which practice most directly supports artifact immutability?

A. Rebuilding the application separately in every environment

B. Editing the production container after deployment

C. Building once, uniquely identifying the artifact, and promoting it unchanged

D. Storing build outputs only on a developer workstation

Correct Answer: C. Building once, uniquely identifying the artifact, and promoting it unchanged

Question 3

What is the primary purpose of software-composition analysis?

A. Measure user-interface color contrast

B. Inventory dependencies and identify vulnerability or licensing concerns

C. Replace all integration tests

D. Manage production traffic routing

Correct Answer: B. Inventory dependencies and identify vulnerability or licensing concerns

Question 4

Which deployment strategy exposes a new version to a small proportion of traffic before wider release?

A. Canary deployment

B. Big-bang deployment

C. Cold backup deployment

D. Manual compilation

Correct Answer: A. Canary deployment

Question 5

Which example is a policy-as-code rule?

A. A developer prefers short functions

B. A database must not have public network access

C. A service has a descriptive name

D. A team holds a retrospective

Correct Answer: B. A database must not have public network access

Question 6

Why are expand-and-contract database migrations useful?

A. They guarantee that data can never be corrupted.

B. They allow compatible intermediate states during application change.

C. They remove the need for database backups.

D. They require rebuilding every application artifact.

Correct Answer: B. They allow compatible intermediate states during application change.

Question 7

Which control is most appropriate for pipeline credentials?

A. Permanent administrator credentials shared by the team

B. Credentials written to build logs

C. Short-lived credentials with least-privilege permissions

D. Credentials embedded in container source code

Correct Answer: C. Short-lived credentials with least-privilege permissions

Question 8

What is a major limitation of using test coverage percentage as the only quality measure?

A. Coverage cannot be calculated automatically.

B. Coverage proves that every requirement is correct.

C. Coverage does not show whether meaningful behaviors and security paths are tested.

D. Coverage applies only to infrastructure code.

Correct Answer: C. Coverage does not show whether meaningful behaviors and security paths are tested.

Question 9

Which situation most strongly supports switching traffic back during a release?

A. A documented release gate detects a sustained critical error increase.

B. A developer wants to test an unrelated feature.

C. The new version has a different logo.

D. The pipeline has completed successfully.

Correct Answer: A. A documented release gate detects a sustained critical error increase.

Question 10

What is a central purpose of observability during progressive delivery?

A. To remove the need for version control

B. To provide evidence about system behavior and release impact

C. To guarantee that every deployment succeeds

D. To replace access control

Correct Answer: B. To provide evidence about system behavior and release impact

Advanced Software Development
Chapter 9 of 15