Ravindra BagaleCourses & study guides Track your progress

DevSecOps

Chapter 2: The Three Pillars and Golden Metrics

2.1 The Three Guilds.

Welcome to Chapter 2!

I am Ravindra Bagale. In Chapter 1, we learned about the history of software and why catching bugs early saves millions. In this chapter, we step inside the inner council of Code City to understand the three guilds: Developers (Dev), Security Engineers (Sec), and Operations Engineers (Ops).

Raju and Guru-ji stood in the central courtyard of Code City, where three distinct towers reached into the sky.

"Guru-ji," Raju observed, "The leaders in these three towers seem to be arguing constantly! The Builder in Tower 1 wants to open doors faster, the Guard in Tower 2 wants to lock all doors completely, and the Overseer in Tower 3 wants nobody to move so the city stays quiet!"

Guru-ji nodded knowingly. "Ah, Raju! You have just witnessed the Classic Conflict of Software Engineering. These are the Three Pillars. Until these three work in harmony, Code City will always remain in chaos!"

Chapter 2 Learning Roadmap

  • Breakdown of the 3 Pillars, their distinct mindsets, goals, and fears.
  • Cultural Transformation: Transitioning from blame culture to blameless collaboration.
  • Deep dive into the 4 Golden DORA Metrics + Security Metrics with mathematical formulas.
  • Real-world metrics calculation scenarios and organizational transformation guides.
Deeper notes for 2.1 The Three Guilds. (examples, stacks, worksheet)

Why this lesson matters

Use this lesson to strengthen systems you own: understand the risk, practise safely in a lab, then write and apply the fix.

Apply the fix across stacks

Same class of bug, same idea in every language.

Java / Spring Boot

Parameterise queries, encode output, CSRF tokens, limited Actuator, dependency scanning.

ASP.NET Core

EF Core / parameterised SQL, Razor encoding, HTTPS, Data Protection.

Node.js / Express

helmet, parameterised SQL, npm audit, avoid eval and shell concat.

Python / Django / Flask / FastAPI

ORM, autoescape, pip-audit, Bandit; never shell=True with user input.

PHP / Laravel

PDO/Eloquent, Blade escaping, composer audit.

Go / Ruby

database/sql placeholders / ActiveRecord; html/template / ERB escaping; govulncheck / Brakeman.

nginx / Apache / Tomcat

Hide versions, TLS, security headers, least-open ports.

MySQL / PostgreSQL / MongoDB / Redis

Private networks, auth on, least-privilege users, no 0.0.0.0/0.

AWS / Azure / GCP

Roles not long-lived keys, private data stores, cloud audit logs on.

Mini case study

Suppose we are on a purple-team exercise for an Indian mid-size company (sample data). Red notes a technique from this lesson against a lab clone. Blue must show the control that stops it, the log that would have fired, and the ticket that hardens production. That is the standard this course trains you for.

Defender's worksheet (do this today)

  1. Write the lesson title, date and the exact lab target you are allowed to use.
  2. List three owned systems (VMs, apps, or cloud accounts) where this lesson applies.
  3. Run one safe check from the lesson on a lab system only. Paste the command and output.
  4. Write a two-sentence fix you would give a teammate.
  5. Name one related public advisory (CERT-In, CISA, NVD, or a vendor bulletin) with its date.

Indian workplace (sample data)

Suppose we are a junior analyst at Infosys, TCS, Wipro or a fintech SOC in Bengaluru/Pune. Turn this lesson into one checklist item with an owner, a due date and a place to store evidence (ticket + screenshot).

Global practice

Compare your notes with OWASP, CIS Benchmarks, NIST CSF/IR guidance or a cloud Well-Architected security question. Write five lines on what overlaps.

Everyday analogy

Explain the risk and the fix to a family member without jargon. If they can repeat the warning, you understand it well enough to teach juniors.

Key terms

  • Control: a safeguard (patch, config, process, detection).
  • Finding: a weakness backed by evidence.
  • Remediation: the fix plus how you verified it.
  • Scope: systems you have written permission to touch.
  • Least privilege: only the access the task needs.
  • Defence in depth: several layers so one failure does not end the story.

Common mistakes

  • Skipping written permission "just for a quick scan".
  • Practising on hostel, office or public targets without authorisation.
  • Collecting tool output without writing the fix.
  • Copying attack steps onto production to "verify". Defenders verify with versions, configs and patches.
  • Publishing screenshots that contain secrets, cookies or internal hostnames.

Recap

  • Evidence, fix, owner, date.
  • Own lab only.
  • Fix > spectacle.

2.2 Pillar 1 Dev. Tower 1: The Developer Guild.

The Developer Mindset: Velocity and Innovation. Developers are the creators and artists of Code City. They turn business requirements into functional digital features that users interact with.

Primary Objective: High Velocity. Developers are measured by business stakeholders on how fast they deliver features (e.g., adding UPI payment buttons, social logins, or dark mode toggle).

KPI: Feature Delivery Rate. Success for a developer is shipping completed user stories per sprint. Their focus is inherently forward-looking: "What cool feature can we build next?"

The Developer's Biggest Blind Spot: Unchecked Speed. Because business management pressures developers for speed, security reviews and edge-case testing are often rushed or skipped. Code is written quickly using copy-pasted libraries from the internet without verifying their security safety!

Quote: "I just want my code to run and pass business QA so we can launch on Friday!" — Typical Developer Focus.

Deeper notes for 2.2 Pillar 1 Dev. Tower 1: The Developer Guild. (examples, stacks, worksheet)

Pillar 1: what the Dev guild owns

In DevSecOps, "Dev" means the people who write and change code. Their job is to ship features. In a DevSecOps team, they also own the first line of security, because the cheapest place to fix a bug is before it is merged.

The Dev guild owns four things:

  1. Code: the application itself, kept in Git.
  2. Pull requests: every change is reviewed by at least one other person before it is merged.
  3. Tests: unit tests that run on every push.
  4. Fast feedback: scanners that run inside the pull request, so developers see problems in minutes, not weeks.
A developer's change goes through pull request checks before merge Laptop Pull request Unit tests ✓ SAST ✓ Secret scan ✓ Merge
A change leaves the laptop, opens a pull request, passes three automatic checks and then merges.

Example 1: an Indian company

Suppose we are a junior developer at Infosys on a banking client project. We add a "download statement" button. What we would see in the pull request (sample output):

✓ unit-tests        124 passed
✗ secret-scan       1 finding: AWS access key in config/dev.yml line 12
✓ sast              0 high, 2 low

The merge button is blocked. We remove the key from the file, ask the cloud admin to deactivate and replace that key (it is already in Git history, so it must be treated as leaked), and push again. Everything turns green. That took 15 minutes. Without the check, the key could have sat in the repository for months.

Example 2: a global app

GitHub's own "branch protection rules" let a repository require reviews and passing checks before merge. Many open-source projects, such as large frameworks on GitHub, use this so that no single person can push straight to the main branch.

Example 3: everyday life

A cook in a restaurant tastes the dal before it goes to the table. He does not wait for the customer to complain. The Dev guild "tastes" its code with tests and scans before it reaches users.

The same checks, one stack at a time

Open your stack. Each one shows the commands for the pull-request checks and the kind of output you would see. The output is shortened sample output, so the exact numbers will differ.

Java / Spring Boot

Maven runs the JUnit tests. OWASP Dependency-Check (a Maven plugin) compares your libraries with known CVEs.

mvn -B test
mvn -B org.owasp:dependency-check-maven:check

What you see:

Tests run: 58, Failures: 0
One or more dependencies were identified with known vulnerabilities
Python / Django, Flask, FastAPI

pytest runs the tests. pip-audit checks requirements.txt. Bandit looks for risky code, such as subprocess with shell=True.

pytest -q
pip-audit -r requirements.txt
bandit -r app/

What you see:

12 passed
Found 1 known vulnerability in 1 package
>> Issue: [B602] subprocess call with shell=True
Node.js / Express, React, Angular

npm test runs Jest. npm audit reads package-lock.json and reports vulnerable packages.

npm ci
npm test
npm audit --audit-level=high

What you see:

Tests: 34 passed
2 high severity vulnerabilities
Run `npm audit fix` to fix them
C# / ASP.NET Core

dotnet test runs xUnit. dotnet list package --vulnerable checks NuGet packages.

dotnet test
dotnet list package --vulnerable

What you see:

Passed!  - Failed: 0, Passed: 40
> Newtonsoft.Json  12.0.1  High
Go

go test runs the tests. govulncheck, from the Go team, reports only vulnerabilities your code actually calls.

go test ./...
govulncheck ./...

What you see:

ok   example.com/api  0.41s
Vulnerability #1: GO-XXXX-XXXX ... Found in: golang.org/x/net
PHP / Laravel

PHPUnit (or php artisan test) runs the tests. composer audit checks composer.lock.

php artisan test
composer audit

What you see:

Tests: 22 passed
Found 1 security vulnerability advisory affecting 1 package
Ruby / Rails

RSpec runs the tests. bundle audit checks Gemfile.lock. Brakeman scans Rails code for issues such as SQL injection.

bundle exec rspec
bundle exec bundle-audit check --update
brakeman -q

What you see:

30 examples, 0 failures
Vulnerabilities found!
SQL Injection ... app/models/user.rb

Summary: tools by stack

Every stack has its own tools for the Dev guild's checks. The idea stays the same: tests, a dependency check and a code scan in every pull request.

StackUnit testsDependency file to scanTypical SAST option
Java / Spring BootJUnit (mvn test)pom.xml / build.gradleCodeQL, SpotBugs
Python / Django, Flask, FastAPIpytestrequirements.txtBandit, CodeQL
Node.js / Express, React, AngularJest (npm test)package-lock.jsonCodeQL, ESLint security plugins
C# / ASP.NET CorexUnit (dotnet test)*.csprojCodeQL, .NET analyzers
Gogo test ./...go.modgosec, govulncheck
PHP / LaravelPHPUnitcomposer.lockPsalm, PHPStan
Ruby / RailsRSpecGemfile.lockBrakeman

Dependabot reads all of these dependency files. Gitleaks or GitHub secret scanning cover secrets in any language.

What the Dev guild should NOT carry alone

  • Choosing which scanners to use and tuning their rules. The Sec guild helps here (lesson 2.3).
  • Keeping servers patched. The Ops guild owns this (lesson 2.4).

Shared ownership does not mean "everyone does everything". It means each guild knows its part and the hand-offs are clear.

Try it yourself

  1. In one of your GitHub repos, open Settings → Branches and add a rule for main.
  2. Tick "Require a pull request before merging".
  3. Add a simple GitHub Actions workflow that runs your tests.
  4. Tick "Require status checks to pass" and select that workflow.
  5. Open a test PR and watch the merge button stay grey until the checks pass.

Common mistakes

  • Letting admins bypass branch protection "just this once".
  • Deleting a leaked key from the file but not rotating it. Git history still has it.
  • Huge pull requests that nobody can really review. Keep them small.
  • Turning off a noisy scanner instead of tuning it with the Sec guild.

More real examples

Global example. Since 2022 GitHub has offered secret scanning push protection. When it is turned on, a git push containing a known token type is blocked, and you see a message naming the secret type and the file. The Dev guild learns about the mistake in seconds, before anyone else can see the key.

Indian company example (sample data). Suppose we are on a TCS team maintaining a Spring Boot claims portal and a React front end. After adding PR checks, the team found 14 outdated npm packages and 3 outdated Maven libraries in the first week. Upgrades were done in small PRs, one library each, so each could be reviewed and rolled back separately.

Everyday analogy. A spell-checker underlines a mistake as you type. You fix it immediately, not after printing 500 copies. PR checks are the spell-checker for code.

Recap

  • The Dev guild owns code, reviews, tests and fast feedback.
  • Security checks inside the pull request catch problems when they are cheapest to fix.
  • Rotate any secret that reaches Git, even if you delete it later.

2.3 Pillar 2 Sec. Tower 2: The Security Guild.

The Security Mindset: Risk Prevention and Defense. Security engineers act as the guardians and intelligence agents of Code City. They constantly look for weaknesses that malicious attackers might exploit.

Primary Objective: Zero Risk and Compliance. Security professionals are held accountable if a data breach, ransomware attack, or compliance audit failure occurs.

KPI: Vulnerability Rate and Audit Compliance. Success for Security is measured by zero open Critical/High vulnerabilities and 100% adherence to regulatory policies (ISO 27001, PCI-DSS, SOC2).

Blind spot: The "Department of NO". In traditional setups, Security operates at the very end of development. They block releases right before launch, causing frustration for business teams without providing clear code remediation guidance.

Quote: "Stop the launch! This application fails compliance check #402!" — Traditional Security Stance.

Deeper notes for 2.3 Pillar 2 Sec. Tower 2: The Security Guild. (examples, stacks, worksheet)

Pillar 2: what the Sec guild owns

The Sec guild is the security team. In old companies, security worked like a gate at the end: "Send us the app two weeks before launch and we will test it." In DevSecOps, security becomes a helper and a rule-writer. It is no longer a gate.

The Sec guild owns:

  1. Policies: simple written rules, such as "no secrets in code", "critical vulnerabilities fixed within 7 days" or "all S3 buckets private by default".
  2. Guardrails: tools that enforce those rules automatically in the pipeline and the cloud account.
  3. Threat modelling: sitting with developers early to ask "what could go wrong here?"
  4. Training: short, practical sessions, like "how to use parameterised queries".
  5. Incident response: leading the team when something does go wrong.
Old model: security gate at the end. New model: guardrails along the road. Old: gate at the end STOP DevSecOps: guardrails all along secretsSASTSCAIaC scancloud rules
Instead of one big stop at the end, small automatic checks guide every step.

Example 1: an Indian company

Suppose we are a junior security engineer at Swiggy. Developers keep creating test S3 buckets that are public by mistake. These are sample numbers. In one week the cloud scanner shows:

Public S3 buckets found: 6
Owner tags missing: 4

The old way: send six angry emails. The guild way:

  1. Turn on S3 Block Public Access at the AWS account level. This is a real AWS setting.
  2. Add a pipeline check that fails any Terraform plan that creates a public bucket.
  3. Write a one-page guide: "How to share a file safely using a presigned URL."

Next week the dashboard shows 0 new public buckets, and nobody had to be shouted at.

Example 2: a global company

Many large tech firms publish "paved road" or "golden path" ideas. The security team provides a ready-made, secure template, and developers are free to build on it. Using the safe way becomes the easy way.

Example 3: everyday life

Highway crash barriers do not stop you from driving. They quietly stop you from going off the edge. A traffic policeman stopping every car at the end of the highway would be slow, and he would still miss things. Guardrails beat gates.

Try it yourself

  1. Write three security rules for a small project in plain words, one line each.
  2. For each rule, name one tool or setting that could enforce it automatically. For example, "no secrets in code" → GitHub secret scanning.
  3. Turn on one of them today.

Common mistakes

  • Security writing 40-page policies nobody reads.
  • Blocking builds on low-severity findings, so developers learn to ignore every alert.
  • Security learning about a new service only after it is live.
  • Saying "no" without offering a safe "yes, like this".

Guardrails, one stack at a time

A guardrail is a rule that a tool checks automatically. Here is one useful guardrail for each common stack, with what a developer sees when it fires.

Java / Spring Boot

Spring Boot Actuator can expose sensitive endpoints such as /actuator/env. The guardrail: expose only health and info in production.

management.endpoints.web.exposure.include=health,info

What you see:

GET /actuator/env -> 404 Not Found
Python / Django

Django must never run with DEBUG = True in production. manage.py check --deploy warns about this and other unsafe settings.

python manage.py check --deploy

What you see:

(security.W018) You should not have DEBUG set to True in deployment.
Node.js / Express

Express does not set security headers by default. The helmet package adds them. A CI check can fail the build if helmet is missing.

const helmet = require('helmet');
app.use(helmet());

What you see:

Response headers now include: Content-Security-Policy, X-Content-Type-Options: nosniff
C# / ASP.NET Core

Force HTTPS and HSTS in production with two lines in Program.cs.

app.UseHsts();
app.UseHttpsRedirection();

What you see:

http://... -> 307 redirect to https://...
Go

gosec flags risky patterns, such as an HTTP server started with no timeouts.

gosec ./...

What you see:

G114: Use of net/http serve function that has no support for setting timeouts
PHP / Laravel

APP_DEBUG=true shows stack traces and settings to visitors. The guardrail: a deploy script refuses to ship if .env has debug on.

grep -q "^APP_DEBUG=true" .env && echo "BLOCK: debug on" && exit 1

What you see:

BLOCK: debug on
nginx / Apache / Tomcat

Hide version numbers so attackers cannot quickly match your server to known bugs: server_tokens off; in nginx, ServerTokens Prod in Apache, and remove the default sample apps from Tomcat.

server_tokens off;

What you see:

Server: nginx   (no version shown)
MySQL / PostgreSQL / MongoDB / Redis

Never expose a database port to the internet. The cloud guardrail: a security-group rule check that blocks 0.0.0.0/0 on 3306, 5432, 27017 and 6379.

What you see:

Policy violation: sg-0abc allows 0.0.0.0/0 on port 6379
AWS / Azure / GCP

Each cloud has an account-wide guardrail service: AWS Config rules and Service Control Policies, Azure Policy, GCP Organization Policy. Use them to block public storage buckets.

What you see:

Deny: s3:PutBucketPolicy would make bucket public

Summary

StackGuardrailChecked by
Spring BootLimit Actuator endpointsConfig review / CI test
DjangoDEBUG offcheck --deploy
Expresshelmet headersCI lint / test
ASP.NET CoreHTTPS + HSTSCode review
GoServer timeoutsgosec
LaravelAPP_DEBUG=falseDeploy script
Web serversHide versionsConfig scan
DatabasesNo public portsCloud policy
CloudNo public bucketsAWS Config / Azure Policy / GCP Org Policy

Two more real examples

Indian bank app (sample data). Suppose we are a junior security engineer at HDFC Bank's digital team. Twice a quarter someone opens a database port for "a quick test". With an account-level policy, the request now fails with "Deny" in seconds, and the developer gets a link to the approved way to reach the database (a bastion host or SSM Session Manager).

Everyday example. A modern lift will not move while the door is open. Nobody has to remember the rule, because the machine enforces it. Good guardrails feel like that.

Recap

  • The Sec guild writes simple rules and automates them as guardrails.
  • It helps early with threat modelling and short training.
  • Make the secure way the easiest way.

2.4 Pillar 3 Ops. Tower 3: The Operations Guild.

The Operations Mindset: Stability and High Availability. Operations and SysAdmins keep the physical and cloud infrastructure running smoothly 24/7/365.

Primary Objective: System Uptime (99.99%). Ops teams manage cloud servers, networks, load balancers, and databases. They want systems to remain rock-solid and stable.

KPI: SLA Uptime and Incident Mean-Time-To-Resolution. Ops is woken up at 3:00 AM if a server crashes. Thus, their natural instinct is to resist frequent software changes because "change causes instability!"

GUILD CORE GOAL MAIN FEAR TRADITIONAL MOTTO
Developer (Dev) Ship features fast Missing deadlines "Move fast, build cool things!"
Security (Sec) Prevent breaches Data leak / Audit fine "Lock everything down!"
Operations (Ops) 100% System uptime Outages and 3 AM alerts "If it works, don't touch it!"
Deeper notes for 2.4 Pillar 3 Ops. Tower 3: The Operations Guild. (examples, stacks, worksheet)

Pillar 3: what the Ops guild owns

Ops means operations: the people who keep systems running after code is deployed. In DevSecOps, Ops owns the ground everything stands on.

  1. Infrastructure: servers, containers, networks and cloud accounts, ideally written as code (Terraform, CloudFormation).
  2. Patching: keeping operating systems and base images up to date.
  3. Monitoring and logs: knowing when something is slow, broken or suspicious.
  4. Backups and recovery: being able to restore data and service quickly.
  5. Access: who can log in to what, with least privilege and MFA.
Ops loop: build, run, watch, patch, repeat Build (IaC) Run Watch (logs) Patch
Ops is a loop that never stops: build it as code, run it, watch it, patch it, and repeat.

Example 1: an Indian company

Suppose we are a junior cloud engineer at Flipkart during a sale-season preparation. These are sample numbers. A weekly patch report shows:

EC2 instances: 120
Missing critical OS patches: 9
Oldest unpatched: 21 days
Instances without CloudWatch agent: 5

What we do:

  1. Use AWS Systems Manager Patch Manager to patch the 9 instances in a maintenance window. Do one group at a time, so the site stays up.
  2. Install the CloudWatch agent on the 5 silent instances, so we can see their logs.
  3. Update the base AMI (machine image) so new servers start out patched.

Example 2: a global platform

AWS, Azure and Google Cloud all publish a "shared responsibility model". The cloud provider patches the physical hosts. You patch your own virtual machines and containers. Many breaches happen because a team assumed "the cloud" patched something that was really theirs.

Example 3: everyday life

A housing society's maintenance team checks the water pump, the lift and the CCTV every week. Nobody notices them when things work, but everyone notices when the lift is stuck. Ops is the maintenance team of the software world, and logs are its CCTV.

What Ops patches, by technology

TechnologyHow it is usually updatedWatch out for
Linux OS (Amazon Linux, Ubuntu)dnf update / apt upgrade, or a new base imageA kernel update needs a reboot
nginx / Apache / TomcatOS package or official image tagTest the config first (nginx -t, apachectl configtest)
MySQL / PostgreSQLManaged: RDS, Azure Database, Cloud SQL maintenance windowsTake a backup or snapshot first, and read the release notes
MongoDB / RedisPackage or managed service (Atlas, ElastiCache)Never expose them to the internet without authentication
Language runtimes (JDK, .NET, Node.js, Python, PHP)Update the runtime in the base image, then rebuildUse a supported LTS version, not an end-of-life one

Try it yourself

  1. Launch a small Amazon Linux EC2 instance in a free-tier account.
  2. Log in and run sudo dnf check-update to see pending updates.
  3. Run sudo dnf update -y, then check again. The list should now be empty or much shorter.
  4. Terminate the instance when you are done, to avoid charges.

Common mistakes

  • Patching by hand on each server instead of updating the base image.
  • Servers with no logs shipped anywhere, so an attack leaves no trace.
  • Backups that were never test-restored.
  • Shared admin passwords instead of individual logins with MFA.

Ops tasks, one stack at a time

Each technology has its own "how do I know it is healthy and patched?" command. Learn the ones for your stack.

nginx

Check the version and test the configuration before every reload.

nginx -v
sudo nginx -t && sudo systemctl reload nginx

What you see:

nginx version: nginx/1.24.0
nginx: configuration file /etc/nginx/nginx.conf test is successful
Apache httpd

Same idea. Test first, then reload gracefully.

sudo apachectl configtest
sudo systemctl reload httpd

What you see:

Syntax OK
Tomcat (Java apps)

Check the running version. Keep catalina.out logs and rotate them.

sudo /opt/tomcat/bin/version.sh

What you see:

Server version: Apache Tomcat/10.1.x
MySQL

Check the version and take a logical backup before patching.

mysql -V
mysqldump --single-transaction shop > shop.sql

What you see:

mysql  Ver 8.0.x for Linux
PostgreSQL

Check the version and back up one database.

psql --version
pg_dump shop > shop.sql

What you see:

psql (PostgreSQL) 16.x
MongoDB

Check that authentication is on. The log should mention access control.

mongosh --eval "db.version()"

What you see:

7.0.x
Redis

Check that it answers only on a private address and needs a password.

redis-cli -h 10.0.2.15 PING

What you see:

(error) NOAUTH Authentication required.
Runtimes: Java, .NET, Node.js, Python, Go, PHP, Ruby

Know which version is running, so you can tell whether it is still supported.

java -version; dotnet --version; node -v; python3 --version; go version; php -v; ruby -v

What you see:

openjdk 21 ... / 8.0.x / v20.x / Python 3.12 ...
AWS / Azure / GCP

Each cloud has a managed patching tool: AWS Systems Manager Patch Manager, Azure Update Manager, and GCP VM Manager OS patch management.

What you see:

Compliance: 118 compliant, 2 non-compliant instances

Summary

TechnologyHealth / version checkBefore patching
nginxnginx -tKeep a copy of the config
Apacheapachectl configtestKeep a copy of the config
Tomcatversion.shBack up webapps/conf
MySQL / PostgreSQLmysql -V / psql --versionBack up or take a snapshot
MongoDB / Redisversion / PINGCheck auth and a private IP
Runtimes-version flagsCheck LTS / end-of-life
Cloud VMsPatch compliance reportUse a maintenance window

One more example

Global example. In December 2021 the Log4Shell bug in the Java logging library Log4j made Ops teams everywhere search every Java app and server for that library in a single weekend. Teams with an up-to-date list of what runs where (an inventory) finished much faster. Keeping that list is an Ops job.

Recap

  • Ops owns infrastructure, patching, monitoring, backups and access.
  • Write infrastructure as code and patch the base image.
  • Logs and tested backups turn a disaster into a short incident.

2.5 Blameless Culture.

Guru-ji showed Raju how DevSecOps dissolves conflict by shifting from a Culture of Blame to a Blameless Culture.

The Old Way: The Finger-Pointing Game. When a production server crashed in the past, management asked: "WHO wrote this bad line of code? Fire them!" Result: Developers hid their mistakes, swept security issues under the rug, and blamed Ops for misconfiguring servers!

The DevSecOps Way: Blameless Post-Mortems. Instead of asking WHO caused the failure, DevSecOps asks: "WHAT process or automated safeguard was missing that allowed this mistake to reach production?"

Building a Security Champions Program. To scale security across large engineering departments, select 1 or 2 developers in every squad to become Security Champions.

They receive extra training in secure coding and threat modeling.

They act as the local security expert inside the development squad.

They bridge communication between the core Sec team and everyday Devs.

Deeper notes for 2.5 Blameless Culture. (examples, stacks, worksheet)

Blameless culture: fix the system, not the person

When something breaks, the easy question is "who did this?" The useful question is "how did our system allow this?" A blameless culture asks the second question.

Blameless does not mean "nobody is responsible". People still own their work. It means we accept that good people make mistakes, and we build systems that catch those mistakes early.

Why this matters for security: if people are punished for mistakes, they hide them. A hidden leaked key is far more dangerous than one reported in five minutes.

Blame leads to hiding; blameless leads to fast reporting and fixes Mistake Blame People hide it Mistake Report fast Fix the system
The same mistake leads to two very different results, depending on how the team reacts.

Example 1: an Indian company

Suppose we are a junior engineer at an Infosys client team. On Friday evening a teammate runs a database script against production instead of test, and 2,000 order rows get a wrong status. This is sample data. They tell the lead within 10 minutes. The team restores the rows from the last backup, and the impact lasts 35 minutes.

The blameless review on Monday asks:

  1. Why did the same login work on both test and production? → Use separate credentials.
  2. Why did the terminal look the same for both? → Add a red "PROD" prompt.
  3. Why was a manual script needed at all? → Move it into a reviewed pipeline job.

Three system fixes. Nobody was named in the report.

Example 2: global practice

Google's public SRE book describes "blameless postmortems" as a core practice. Many cloud providers also publish incident reports on their status pages. These explain the cause and the fixes without blaming individual engineers.

Example 3: everyday life

Aviation is the classic example. Pilots are encouraged to report near-misses, and those reports lead to better checklists. If pilots were punished for every report, nobody would report, and the same problems would keep coming back.

A simple postmortem template

Title: Wrong order status in production
Impact: 2,000 rows, 35 minutes, no money lost
Timeline: 18:02 script run, 18:12 reported, 18:37 restored
Root causes (system): shared credentials, no prod warning, manual script
Actions: separate creds (owner A, 7 days), red prompt (owner B, 2 days),
         pipeline job (owner C, 14 days)

Common mistakes

  • Writing "human error" as the root cause. It is never the end of the analysis.
  • Action items with no owner or no date.
  • Holding the review a month later, when nobody remembers the details.
  • Saying "blameless" but then quietly punishing the person.

Blameless reviews across different stacks

The same blameless questions work whatever the technology. Here are short examples of the "system fix" for common slips.

Common slips and the system fix

Each item: the mistake, then the change that stops it happening again.

MySQL / PostgreSQL

The slip: an UPDATE without a WHERE clause on production. The system fix: separate production credentials, safe-update mode in MySQL (SET SQL_SAFE_UPDATES=1), and changes go through reviewed migration files.

SET SQL_SAFE_UPDATES = 1;
UPDATE orders SET status='X';

What you see:

ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column.
Redis

The slip: FLUSHALL run on the wrong server. The system fix: rename or disable dangerous commands, and give production a different prompt colour.

rename-command FLUSHALL ""

What you see:

(error) ERR unknown command 'FLUSHALL'
nginx

The slip: a typo in a config file takes the site down. The system fix: CI runs nginx -t on every config change before deploy.

nginx -t

What you see:

nginx: [emerg] unexpected "}" in /etc/nginx/conf.d/site.conf:14
Java / Spring Boot, .NET, Node.js, Python, Go, PHP, Ruby

The slip: a password committed in a config file. The system fix is the same in every language: a secret-scanning pre-commit hook plus a CI check, and the key is rotated.

gitleaks protect --staged

What you see:

Finding: password = "..." RuleID: generic-api-key
AWS / Azure / GCP

The slip: a test instance deleted in the wrong account. The system fix: separate accounts or subscriptions for production, and deletion protection on critical resources.

What you see:

DeleteDBInstance failed: deletion protection is enabled

Summary

StackSlipSystem fix
MySQL/PostgreSQLUPDATE without WHERESafe-update mode, migrations
RedisFLUSHALL on prodDisable command
nginxConfig typonginx -t in CI
Any languageSecret in GitPre-commit scan + rotate
CloudWrong-account deleteSeparate accounts, delete protection

Two more real examples

Global example. In 2017 GitLab.com lost several hours of database data after an engineer ran a delete command on the wrong server. GitLab published a detailed, blameless public postmortem. It found that several backup methods had not been working, and the fixes were about systems, not about punishing the engineer.

Everyday example. When a train runs late, a good railway asks "which signal or timetable caused this?" and does not stop at blaming the driver. The fix helps every driver after him.

Recap

  • Ask "how did the system allow this?", not "who did it?"
  • Fast, honest reporting is a security control.
  • Every review ends with system fixes, each with an owner and a date.

2.6 DORA metrics 1 and 2.

Guru-ji opened the Grand Metric Scroll. DORA (DevOps Research and Assessment) identified four key metrics that differentiate top engineering teams.

Metric 1 Deployment Frequency (DF), Velocity. Definition: How often successful code is deployed to production. Formula: Deployment Frequency = (Total Production Deployments) / (Time Period).

Performance Level Deployment Frequency
Elite Multiple deployments per day
High Once per week to once per day
Low Fewer than once per month

Metric 2 Lead Time for Changes (LTC), Efficiency. Definition: Time elapsed from a developer committing code to that code running live in production. Formula: Lead Time = (Time Code Deployed) - (Time First Commit Created).

Performance Level Lead Time for Changes
Elite Less than 1 hour
High Between 1 day and 1 week
Low More than 1 month
Deeper notes for 2.6 DORA metrics 1 and 2. (examples, stacks, worksheet)

DORA metrics 1 and 2 in plain words

The two tables above are short. Let us slow down and make them real.

DORA stands for DevOps Research and Assessment. It is a research group, now part of Google Cloud. Every year it surveys thousands of software teams. It found four numbers that separate fast, safe teams from slow, risky ones. This lesson covers the first two. Both measure speed.

  • Deployment Frequency (DF): how often you put working code into production.
  • Lead Time for Changes (LT): how long one change takes to travel from "commit" to "live".

Lesson 2.7 covers the other two. They measure stability. You need all four together. Speed without stability is just breaking things faster.

A commit travels through build, test and deploy. Lead time is measured from commit to live. Commit Build Test + scan Approve Live Lead time = time the yellow change spends on this road
One change (yellow dot) moving from commit to live. Lead time is the length of the trip. Deployment frequency is how many dots reach "Live" each day.

Metric 1: Deployment Frequency

Count how many times you deployed to production successfully. Divide by the number of days. That is all.

Example 1: an Indian company. Suppose we are a junior engineer at Flipkart, on the team that owns the "My Orders" page. These are sample numbers for practice, not Flipkart's real data. In one week our pipeline log shows:

Mon  deploy #812  success
Mon  deploy #813  success
Tue  deploy #814  FAILED (rolled back)
Wed  deploy #815  success
Thu  deploy #816  success
Fri  deploy #817  success

Five successful deploys in five working days. So DF = 5 / 5 = 1 per day. By the table above, we sit in the "High" band and are close to "Elite".

Notice the failed one. It does not count as a deploy here. It counts in metric 3 (change failure rate) in the next lesson.

Example 2: a global app. Large web companies like Amazon and Netflix have spoken publicly about deploying many times a day. They can do this because each change is small and goes out on its own. Small changes are easy to test. They are also easy to undo.

Example 3: everyday life. Think of a dabbawala in Mumbai. He does not wait to collect every tiffin in the city before setting off. He moves small batches on a fixed schedule, many times. If one tiffin is wrong, only one customer is affected, and it is easy to trace. Frequent small deploys work the same way.

Metric 2: Lead Time for Changes

Pick one change. Note when its first commit was made. Note when it went live. Subtract. Do this for many changes and take the median (the middle value), not the average. One stuck change can pull the average far up.

Example: the Flipkart team again (sample data).

ChangeFirst commitLiveLead time
Fix order date formatMon 10:00Mon 15:005 h
Add "track" buttonMon 11:00Wed 11:0048 h
Update libraryTue 09:00Tue 13:004 h
New filterWed 10:00Fri 10:0048 h
Typo fixThu 12:00Thu 14:002 h

Sort the lead times: 2, 4, 5, 48, 48. The middle one is 5 hours. So the median lead time is 5 hours. The average would be 21.4 hours, which hides the fact that most changes are fast.

Now look at the two 48-hour changes. Both waited two days. When you ask why, you usually find one of three reasons:

  1. The pull request waited for review.
  2. A slow test suite blocked the queue.
  3. A manual approval sat in someone's inbox.

That is the real value of lead time. It shows you where work waits.

Global example. On GitHub, a pull request page shows when it was opened and when it was merged. The Actions tab shows when the deploy job finished. Those timestamps are enough to work out lead time by hand for one change.

Everyday analogy. Ordering on Swiggy: the app shows "order placed 8:02", "picked up 8:20", "delivered 8:31". Total time is 29 minutes. If it took 60 minutes, you would want to know which step was slow: the kitchen or the road. Lead time works the same way.

Where DevSecOps fits

Security checks sit on the same road. A SAST scan, a dependency scan and a secret scan all add minutes. That is fine. The goal is not zero checks. The goal is checks that are fast and automatic, so they do not become the 48-hour wait.

A manual security review that happens once a month is the classic lead-time killer. Moving that check into the pipeline usually improves both security and speed.

Try it yourself (10 minutes)

  1. Open any GitHub repo you own that has GitHub Actions.
  2. Go to the Actions tab and filter by your deploy workflow.
  3. Count the successful runs in the last 14 days. Divide by 14. That is your DF.
  4. Open 5 merged pull requests. For each one, note the first commit time and the deploy run's finish time.
  5. Sort the 5 lead times and take the middle one.

If you see "0 deploys", that is also an answer. It means releases are manual or rare, and that is where to start.

Common mistakes

  • Counting deploys to test or staging. DF counts production only.
  • Counting failed deploys as deploys.
  • Measuring lead time from when the ticket was created. DORA measures from commit to production.
  • Using the average instead of the median.
  • Comparing teams against each other to shame them. These numbers are for a team to improve itself.
  • Chasing a higher DF by splitting one change into ten meaningless deploys. The number goes up, but nothing improves.

Measuring deploys in different stacks and tools

Wherever you deploy, you need two timestamps: the commit time and the time the change went live. Here is where to find them.

GitHub Actions (any language)

Every workflow run has a start and end time. Filter by your deploy workflow and the success status.

gh run list --workflow deploy.yml --status success --limit 20

What you see:

completed success deploy main push 2026-10-14T10:02:11Z
Jenkins (common with Java/Spring Boot and .NET)

The build history of the deploy job shows each successful build with its timestamp.

What you see:

#212  Oct 14, 2026, 3:32 PM  SUCCESS
Kubernetes (any containerised app)

The rollout history of a Deployment counts revisions, one per deploy.

kubectl rollout history deployment/orders-api

What you see:

REVISION  CHANGE-CAUSE
41  image=orders-api:1.8.3
42  image=orders-api:1.8.4
Python / Django, Node.js, PHP, Ruby on a VM

If you deploy with a script, write one log line per deploy with the time and the Git commit.

echo "$(date -Is) deployed $(git rev-parse --short HEAD)" >> /var/log/deploys.log

What you see:

2026-10-14T15:30:02+05:30 deployed 9f2c1ab
AWS / Azure / GCP

AWS CodePipeline, Azure DevOps Pipelines and Google Cloud Deploy each keep a release history with timestamps that you can export.

What you see:

Release-37  Succeeded  14 Oct 2026 15:41

Summary

Where you deployWhere the timestamps are
GitHub ActionsActions run list
JenkinsJob build history
Kubernetesrollout history + Git
VM scriptsYour deploy log
Cloud pipelinesRelease history

More examples

Indian company example (sample data). Suppose we are at Zerodha-style trading software, where releases happen outside market hours. DF might be 1 per trading day by design. That is fine. DORA numbers describe your system, and a business rule like "no deploys during market hours" is a valid reason.

Recap

  • DF means how often you ship to production. LT means how long one change takes to reach production.
  • Use real pipeline timestamps and the median.
  • Long lead times point to waiting: reviews, slow tests, manual approvals.
  • Fast, automatic security checks protect speed instead of hurting it.

2.7 DORA metrics 3 and 4.

Metric 3 Mean Time to Restore (MTTR), Resilience. Definition: The average time required to recover from a production service outage or critical security incident. Formula: MTTR = (Total Downtime Minutes across Incidents) / (Number of Incidents).

Performance Level Mean Time to Restore
Elite Less than 1 hour (automated rollback)
High Less than 1 day
Low More than 1 week

Metric 4 Change Failure Rate (CFR), Quality. Definition: The percentage of deployments that cause a production outage or require an emergency hotfix. Formula: CFR = (Failed Deployments / Total Deployments) × 100%.

Performance Level Change Failure Rate
Elite 0% to 15%
High 16% to 30%
Low Greater than 45%
Deeper notes for 2.7 DORA metrics 3 and 4. (examples, stacks, worksheet)

DORA metrics 3 and 4: are we stable?

Metrics 1 and 2 tell you how fast you ship. Metrics 3 and 4 tell you what happens when shipping goes wrong. Together, the four give you an honest picture.

  • Change Failure Rate (CFR): out of all deploys, what percent caused a problem in production? Here, "a problem" means a rollback, a hotfix, or an incident.
  • Time to Restore Service, often called MTTR: when production breaks, how long until users are fine again? Newer DORA reports call this "failed deployment recovery time". The idea is the same.
Ten deploys, two fail. Recovery time is the red gap until service is green again. 2 red out of 10 deploys → Change Failure Rate = 20% down 40 minTime to restore = length of the red bar
Top: each box is one deploy and red ones caused trouble. Bottom: the red bar is how long users were affected.

Metric 3: Change Failure Rate

Formula: CFR = failed deploys ÷ total deploys × 100.

Example 1: an Indian company. Suppose we are a junior engineer at Paytm on the team that owns the bill-payment screen. These are practice numbers, not Paytm's real data. Last month the team deployed 40 times. Three deploys needed a rollback and one needed a same-day hotfix. That makes 4 failures.

CFR = 4 / 40 × 100 = 10%

On the team dashboard you might see a simple tile like this:

Deploys (30d): 40   Failed: 4   CFR: 10.0%

10% is a healthy number. DORA reports have often placed strong teams roughly in the 0–15% range. The exact bands change from year to year, so read the latest report before quoting a number in an interview.

Example 2: a global app. On GitHub, a failed deploy usually shows as a red cross on the workflow run, followed by a "Revert" pull request a few minutes later. Counting those revert PRs is a quick way to estimate CFR.

Example 3: everyday life. A tea stall makes 100 cups a day, and 3 come back because there is too much sugar. The "return rate" is 3%. The owner does not stop making tea. He fixes the recipe so fewer cups come back. CFR works the same way. You do not stop deploying. You fix why deploys fail.

Metric 4: Time to Restore Service

Start the clock when users are affected, or when your alert fires. Stop it when service is normal again. It does not matter if the fix is a rollback or a code change.

Example: the Paytm team again (sample data). Four incidents last month:

IncidentAlert firedService normalRestore time
Bill page 500 errors10:0510:2015 min
Slow payments API14:0014:4040 min
Wrong currency label11:1011:2515 min
Login loop19:0021:30150 min

Sorted: 15, 15, 40, 150. The median sits between 15 and 40, which is 27.5 minutes. The 150-minute login loop deserves its own review. Ask why it took so long.

Usually the answers are:

  1. No alert fired, so a customer had to report it.
  2. Nobody knew how to roll back.
  3. The rollback needed a database change that could not be undone.

How the two connect to security

A security incident is also a failure. Say a leaked key has to be rotated, or a vulnerable library has to be patched today. A team with a low restore time can ship that fix in minutes. A team that needs a week of manual steps leaves the door open for a week. So good restore times are a security feature too.

Everyday analogy. A building's fire drill is not about stopping every fire. It is about getting everyone out quickly when one happens. Practised rollbacks are your fire drill.

Try it yourself

  1. In your repo, list the last 20 production deploys.
  2. Mark any deploy followed by a revert, rollback, or hotfix within 24 hours as "failed".
  3. Work out CFR = failed ÷ 20 × 100.
  4. For each failed one, note when the problem started and when it was fixed. Take the median.
  5. Write one line for each slow restore: what slowed us down?

Common mistakes

  • Counting a failed build in CI as a failed deploy. It never reached users, so it does not count for CFR.
  • Hiding small rollbacks so the number looks better. Honest numbers are the whole point.
  • Starting the restore clock when an engineer first looks at the problem, instead of when users were first affected.
  • Pushing CFR down by deploying less often. That usually makes each deploy bigger and riskier.
  • Not practising rollback until the day you need it.

Rolling back in different stacks

Fast restore usually means fast rollback. Know the rollback command for your stack before you need it.

Kubernetes

Roll the Deployment back to the previous revision.

kubectl rollout undo deployment/orders-api

What you see:

deployment.apps/orders-api rolled back
Java / Spring Boot on Tomcat

Keep the previous WAR file and swap it back.

cp /opt/releases/app-1.8.3.war /opt/tomcat/webapps/app.war

What you see:

Tomcat redeploys the old version within seconds
Node.js with PM2

Switch the symlink back to the previous release folder and reload.

ln -sfn /srv/app/releases/1.8.3 /srv/app/current && pm2 reload app

What you see:

[PM2] Applying action reloadProcessId on app [app](ids: [ 0 ])
Python (Gunicorn) / PHP-FPM / Ruby (Puma)

The same release-folder pattern works. Point current back, then reload the service.

sudo systemctl reload gunicorn

What you see:

(no output, exit code 0)
.NET on Azure App Service

Use deployment slots. Swap staging and production back.

az webapp deployment slot swap -g rg -n app --slot staging

What you see:

Swap complete
Databases: MySQL / PostgreSQL

Schema changes are the hard part of a rollback. Write a "down" migration for each change, or use expand-and-contract changes that old code can still read.

What you see:

Migration 20261014_add_column reverted
AWS / GCP

AWS CodeDeploy can roll back automatically when alarms fire. Cloud Run and App Engine on GCP can shift traffic back to an earlier revision.

What you see:

Deployment d-ABC rolled back: alarm triggered

Summary

StackRollback
Kubernetesrollout undo
TomcatSwap previous WAR
Node/Python/PHP/RubySymlink + reload
.NET App ServiceSlot swap
DatabasesDown migration
CloudAuto-rollback / traffic shift

Recap

  • CFR is the percent of deploys that hurt production.
  • Time to restore is how long users suffer when something breaks.
  • Use medians, real timestamps and honest counts.
  • Fast, practised rollback helps both reliability and security.

2.8 Security metrics.

Guru-ji emphasized: "DORA metrics measure speed and stability, but DevSecOps requires measuring security risk!"

  1. Mean Time to Remediate (MTTR-Sec). Time elapsed between identifying a security vulnerability (via SAST/SCA/Pentest) and deploying the verified patch. Target: Critical (SLA < 24h), High (SLA < 7 days).
  2. Vulnerability Escape Rate (VER). Percentage of total security bugs that bypassed automated CI/CD security gates and were discovered in live Production. VER = (Prod Security Bugs / Total Security Bugs Found) × 100%.
  3. Dependency Freshness (Software Age). Measures how outdated third-party open-source libraries are relative to their latest upstream secure release.
Deeper notes for 2.8 Security metrics. (examples, stacks, worksheet)

Security metrics that actually help

DORA's four numbers show speed and stability. A DevSecOps team also needs a few numbers that show security health. Pick numbers that lead to an action. If a number goes up and nobody knows what to do, drop it.

These are five useful ones:

  1. Mean Time to Remediate (MTTR-vuln): how many days from "a vulnerability is found" to "it is fixed in production".
  2. Open critical and high findings: how many serious issues are open today, and how old they are.
  3. SLA breach rate: what percent of findings were fixed later than your own target. For example: critical in 7 days, high in 30 days.
  4. Secrets found in code: how many passwords or keys your scanners caught each month, and how fast each was rotated.
  5. Pipeline coverage: what percent of repos actually run SAST, dependency (SCA) and secret scanning on every pull request.
Bar chart of open critical findings falling week by week after scanning was added Week 1Week 2Week 3Week 4Week 5 26201384 Open criticals
Sample data: open critical findings each week after a team started fixing the oldest first.

Example 1: an Indian company

Suppose we are a junior DevSecOps engineer at Zomato, supporting the restaurant-partner app. These are practice numbers, not Zomato's real data. The dependency scanner reports this on Monday:

Repository: partner-app-api
Critical: 3   High: 11   Medium: 40
Oldest critical: 19 days (target 7 days) -- SLA BREACHED

What we do:

  1. Open the 3 critical findings. Two are the same library at an old version.
  2. Upgrade the library in one pull request. The pipeline re-scans it.
  3. The third finding is in test code only, so it never ships. Mark it with a written reason and an expiry date for the exception.
  4. Next Monday the dashboard shows Critical: 0, and the breach rate for the month drops.

Example 2: a global platform

GitHub shows Dependabot alerts under the Security tab of a repository. Each alert names the package, the safe version and the severity. Counting open alerts by severity, and how many days each one has been open, gives you metrics 2 and 3 from the list above without buying any tool.

Example 3: everyday life

Think of a housing society's complaint register. "Lift not working, reported 2 Oct, fixed 4 Oct" means a remediation time of 2 days. If the secretary only counts complaints and never fixes dates, nobody knows whether things are getting better. Security findings are the same. Always record when something was found and when it was fixed.

Where the findings come from, stack by stack

LayerExampleWhat to count
App librariesSpring Boot (Maven), Django (pip), Express (npm), ASP.NET Core (NuGet), Laravel (Composer), Rails (Bundler), Go modulesOpen critical/high per repo, age in days
Web / app serversnginx, Apache httpd, TomcatVersion behind latest patch, days unpatched
DatabasesMySQL, PostgreSQL, MongoDB, RedisExposed to internet? (target: 0), patch age
Container imagesnginx, mysql, eclipse-temurin, mcr.microsoft.com/dotnet/aspnet, node, pythonCritical CVEs per image (Trivy, Grype)
CloudAWS Security Hub, Azure Defender for Cloud, GCP Security Command CenterFailed high-severity controls

Numbers to avoid

  • "Total vulnerabilities found" on its own. More scanning finds more, which looks worse even when you are getting safer.
  • "Number of scans run". Activity is not safety.
  • Medium and low counts as headline numbers. They drown out the few that matter.

Try it yourself

  1. Turn on Dependabot alerts on one of your own GitHub repos.
  2. Write down the critical and high counts, and the age of the oldest alert.
  3. Fix one alert by upgrading the package.
  4. Note the day it was found and the day it was fixed. That is your first remediation time.

Common mistakes

  • Setting a 7-day target for criticals but never measuring it.
  • Closing findings as "won't fix" without a reason or an expiry date.
  • Reporting one number for the whole company, which hides the one team that is in trouble.
  • Treating every scanner result as true. Check for false positives, but write down why you dismissed each one.

Getting the numbers, one stack at a time

Each ecosystem has a free command that lists known vulnerable dependencies. Run it in CI and count the results by severity.

Java / Spring Boot

OWASP Dependency-Check scans Maven and Gradle projects.

mvn org.owasp:dependency-check-maven:check

What you see:

One or more dependencies were identified with known vulnerabilities
Python

pip-audit checks installed packages or requirements files.

pip-audit -r requirements.txt

What you see:

Found 2 known vulnerabilities in 1 package
Node.js

npm audit has a JSON output you can count.

npm audit --json | jq .metadata.vulnerabilities

What you see:

{ "high": 2, "critical": 0 }
.NET

Lists vulnerable NuGet packages.

dotnet list package --vulnerable

What you see:

> System.Text.Json  8.0.0  High
Go

govulncheck reports only vulnerabilities your code actually reaches.

govulncheck ./...

What you see:

Your code is affected by 1 vulnerability
PHP

Composer has a built-in audit.

composer audit

What you see:

Found 1 security vulnerability advisory
Ruby

bundler-audit checks Gemfile.lock.

bundle-audit check --update

What you see:

Vulnerabilities found!
Container images (nginx, mysql, node, python, openjdk...)

Trivy scans an image and can fail on critical findings.

trivy image --severity CRITICAL --exit-code 1 nginx:1.25

What you see:

Total: 0 (CRITICAL: 0)
AWS / Azure / GCP

AWS Inspector, Microsoft Defender for Cloud and GCP Artifact Analysis show findings with ages that you can export to a dashboard.

What you see:

Findings: Critical 1, High 7

Summary

StackCommand
Javadependency-check
Pythonpip-audit
Node.jsnpm audit
.NETdotnet list package --vulnerable
Gogovulncheck
PHPcomposer audit
Rubybundle-audit
Imagestrivy image

Recap

  • Good security metrics lead to actions: remediation time, open critical/high findings, SLA breaches, secrets found, scan coverage.
  • Record the "found" and "fixed" dates for every finding.
  • Fix the oldest critical first, and show the trend falling week by week.

2.9 Calculation workshop.

Guru-ji's Real-World Calculation Challenge for Raju:

A Fintech Startup (PayFast) recorded the following team data over a 30-day month:

  • Total deployments pushed to production: 60 deployments
  • Deployments that caused server crashes / bugs: 6 deployments
  • Outage durations: Incidents took 10, 20, 15, 30, 25, and 20 minutes to fix.
  • Developer code commit to live deployment average time: 45 minutes

Raju's Step-by-Step Solution

  1. Deployment Frequency: 60 / 30 days = 2 deployments/day (High/Elite Performer)
  2. Lead Time for Changes: 45 minutes (Elite Performer < 1 hr)
  3. Change Failure Rate: (6 / 60) × 100% = 10% (Elite Performer < 15%)
  4. MTTR: (10+20+15+30+25+20) / 6 = 120 / 6 = 20 minutes (Elite Performer < 1 hr)

"Guru-ji, PayFast is an Elite DORA Performing Team!" — Raju exclaimed proudly.

Deeper notes for 2.9 Calculation workshop. (examples, stacks, worksheet)

Calculation workshop: all four DORA metrics from one month of data

Let us practise with one realistic dataset. Grab a notebook and calculate along with me before you read the answers.

Scenario. Suppose we are a junior engineer at PhonePe on the team that owns the "split bill" feature. These are practice numbers, not PhonePe's real data. September had 22 working days. The pipeline export looks like this:

Production deploys (successful):  33
Deploys that caused an incident:   3
Lead times of 7 sampled changes (hours): 3, 26, 5, 4, 70, 6, 8
Incident restore times (minutes):  12, 45, 20

Step-by-step answers

  1. Deployment frequency = 33 ÷ 22 = 1.5 deploys per working day.
  2. Lead time: sort the values to get 3, 4, 5, 6, 8, 26, 70. The middle (4th) value is 6 hours, so the median lead time is 6 hours.
  3. Change failure rate = 3 ÷ 33 × 100 ≈ 9.1%.
  4. Time to restore: sort to get 12, 20, 45. The median is 20 minutes.

A team dashboard might summarise it like this:

DF 1.5/day | Lead time 6 h | CFR 9.1% | Restore 20 min
Four metric tiles: deployment frequency, lead time, change failure rate, restore time Deploys/day1.5 Lead time6 h Change fail9.1% Restore20 min
The four DORA numbers for the sample month, as tiles on a team dashboard.

Reading the result

  • Speed is good. Most changes go live the same day.
  • The 70-hour change is an outlier. Find out where it waited.
  • Stability is healthy. Below 10% failures and a quick restore.

Second exercise: an everyday version

A home tiffin service delivers 60 tiffins in a week (that is its "deploys"). 3 come back with the wrong order (change failure rate = 5%). Each wrong order is replaced in 15, 25 and 40 minutes (median restore time = 25 minutes). The same four ideas work for any process that delivers something.

Third exercise: do it yourself

A global SaaS team (sample data) ships 8 deploys in 20 days. 2 fail. The lead times in hours are 30, 50, 46. The restore times in minutes are 90 and 30. Work out all four before reading the answer.

Answer: DF 0.4/day, lead time 46 h, CFR 25%, restore 60 min (the average of 30 and 90, because there is an even number of values). This team ships slowly and fails often. Smaller changes and automated tests would be the first steps.

Common mistakes

  • Forgetting to sort the values before picking the median.
  • Dividing failures by working days instead of by deploys.
  • Mixing calendar days and working days in one report.

Fourth exercise: a multi-stack company (sample data)

Suppose we are a junior DevOps engineer at an Infosys client with four services: a Java Spring Boot payments API, a .NET billing service, a Node.js web front end and a Python data job. In October:

Payments API (Java): 10 deploys, 1 failed, lead times 20, 4, 6 h. Billing (.NET): 4 deploys, 1 failed, lead times 50, 30 h. Web (Node.js): 30 deploys, 2 failed, median lead time 2 h. Data job (Python): 8 deploys, 0 failed, median lead time 5 h.

Answers. Per service CFR: Java 10%, .NET 25%, Node.js 6.7%, Python 0%. The overall CFR is 4 failed ÷ 52 deploys ≈ 7.7%. Notice how the company-wide number hides the .NET service, which fails one deploy in four and has a 40-hour median lead time. Always look per service as well as overall.

Fifth exercise: restore times by database (sample data)

Three incidents: a Redis cache restart (4 min), a MySQL replica failover (12 min) and a PostgreSQL restore from snapshot (95 min). Median = 12 min. The PostgreSQL one shows that restoring a full database from a snapshot is slow. A good action item is to practise point-in-time restore and measure it.

Common mistakes

  • Averaging across services that deploy at very different rates.
  • Leaving out manual hotfixes, which hides failures.
  • Measuring restore time from when a ticket was closed, instead of when service was healthy.

Recap

  • DF = deploys ÷ days. CFR = failed ÷ deploys.
  • Lead time and restore time are medians of sorted values.
  • Outliers tell you where to look next.

2.10 Conclusion.

  • DevSecOps Culture: Aligns Dev (speed), Sec (risk), and Ops (uptime) into a shared responsibility model.
  • Blameless Culture: Focuses on systemic fixes and automated safeguards rather than pointing fingers at individuals.
  • Security Champions: Scaling security expertise into individual development squads.
  • 4 Golden DORA Metrics: Deployment Frequency, Lead Time, MTTR, and Change Failure Rate track delivery speed and stability.
  • Security Metrics: MTTR-Sec and Vulnerability Escape Rate ensure quality is maintained at pace.

Looking Ahead to Chapter 3: Threat Modeling. In Chapter 3, Raju and Guru-ji learn how to become the Mind of the Hacker. We will cover:

  • The STRIDE Threat Modeling Framework.
  • PASTA Framework for Enterprise Risk.
  • Drawing Data Flow Diagrams (DFDs) for a Payment Gateway application.

END OF CHAPTER 2 MASTER CLASS

Deeper notes for 2.10 Conclusion. (examples, stacks, worksheet)

Chapter 2 in one page

This chapter answered two questions. Who does what in DevSecOps? And how do we know if we are getting better?

The three guilds

GuildOwnsOne daily habit
DevCode, reviews, tests, fast feedbackSmall pull requests with scans inside
SecRules, guardrails, threat models, trainingAutomate a rule instead of emailing about it
OpsInfrastructure, patching, logs, backups, accessPatch the base image, not each server

The four DORA numbers plus security health

  1. Deployment frequency: how often you ship.
  2. Lead time for changes: how long one change takes.
  3. Change failure rate: how often shipping hurts users.
  4. Time to restore: how fast you recover.
  5. Security metrics: remediation time, open critical findings, SLA breaches.
Three guild circles overlap; the four metrics sit in the middle DevSecOpsshared metrics
The three guilds overlap. The metrics in the middle belong to everyone.

Three real-life pictures to remember

  • Indian company: a Flipkart-style team (sample data) shipping 1 deploy a day with a 5-hour median lead time, and finding that most waiting happens in code review.
  • Global platform: GitHub branch protection and Dependabot. These are free, built-in ways to apply Dev and Sec guild rules.
  • Everyday life: the Mumbai dabbawalas. Small batches, clear ownership at every hand-off, and very few mistakes.

Self-check (answer without scrolling up)

  1. Name the four DORA metrics.
  2. Why use the median for lead time?
  3. A leaked key was deleted from a file. Is that enough? (No. Rotate it.)
  4. Give one example of a guardrail instead of a gate.
  5. What should a blameless postmortem end with?

Common mistakes to carry forward

  • Measuring only speed or only security. You need both.
  • Using metrics to rank people.
  • Writing rules nobody automates.

Chapter 2 checklist for your stack

Pick your stack and check off the habits from this chapter.

Java / Spring Boot

JUnit tests and Dependency-Check in each PR. Actuator limited to health/info. Rollback by keeping the previous artifact.

Python / Django, Flask, FastAPI

pytest, pip-audit and Bandit in each PR. DEBUG off. Gunicorn or Uvicorn reload for rollback.

Node.js / Express, React, Angular

Jest and npm audit in each PR. helmet headers. PM2 reload or a container rollback.

C# / ASP.NET Core

dotnet test and the vulnerable-package list in each PR. HSTS on. App Service slot swap for rollback.

Go

go test and govulncheck in each PR. Server timeouts set.

PHP / Laravel and Ruby / Rails

PHPUnit or RSpec, composer audit or bundle-audit, Brakeman for Rails. Debug off in production.

nginx, Apache, Tomcat

Config test before reload. Versions hidden. Logs shipped.

MySQL, PostgreSQL, MongoDB, Redis

No public ports. Authentication on. Tested backups. Safe-update habits.

AWS / Azure / GCP

Account-wide guardrails. Patch compliance reports. Release history for DORA numbers.

Two more examples to remember

Global example. The 2021 Log4Shell response showed why inventory, fast patching and fast deploys matter together. Teams with high deploy frequency shipped the fix in hours.

Indian example (sample data). A Swiggy-style team that turned on account-wide public-bucket blocking saw new public buckets drop from 6 a week to 0, without a single extra meeting.

Common questions about the three pillars and golden metrics

Q. Do small teams need DORA metrics?
Yes, even a rough monthly count helps you see if things are improving.

Q. Who owns security in DevSecOps?
Everyone owns a part. Dev, Sec and Ops each have clear responsibilities.

Next

In the following chapters we build these habits in the pipeline itself, starting with web application security and secure code review.