SyntaxPilot
Courses/Cybersecurity Fundamentals/Lesson 60
Video coming soonThis lesson’s video is being made

Start with the notes below; the video appears here as soon as it is on YouTube.

Cybersecurity Fundamentals · Lesson 60 of 90

Secure SDLC and DevSecOps

SDLCsecure SDLCshift leftDevSecOpssecurity requirementssecurity championssecure code reviewSASTDASTIASTRASPSCApenetration testing as authorised assessmentsecurity gates

These are the notes for Cybersecurity Fundamentals (defensive), episode 60. In episodes 56 to 59 we kept adding checks one at a time (Bandit, pip-audit, npm audit, secret scanners), each after something went wrong. This episode puts security into every step of building software: what the steps are, how security moves earlier ("shift left"), the people and tools involved (with toy versions you can run), how checks become automatic gates in a pipeline (DevSecOps), and the frameworks companies use to describe and measure all of it. Every term is defined the first time it appears; the Glossary collects them.

Scope. Defensive and educational only. Every program is a toy; the one "scan" of a running app targets a toy server we start ourselves on 127.0.0.1 (this machine only). Samples were run on 13 Nov 2026 in the SyntaxPilot compiler (Python 3.13).

Step 1: the SDLC and shift left

Real-life example: building a house. You plan and design (where the doors go), build and inspect, then the family moves in. Deciding to add a strong room after they've moved in means breaking walls.

  • SDLC (software development life cycle): the phases every piece of software goes through: plan (what to build), design (how it fits together), build (write code), test, release (deliver to users) and operate (run, monitor, patch). Real teams loop through these phases many times, in small steps.
  • Secure SDLC: an SDLC with a security activity in every phase:
Phase Security activity
Plan security requirements
Design threat modelling (episode 7), security design review
Build secure coding, SAST, secure code review, secret scanning
Test DAST, IAST, SCA, security tests, penetration testing
Release security gate, signed artifacts
Operate monitoring, patching, RASP, incident response
  • Shift left: drawing the phases left to right as a timeline, move security checks earlier (to the left), where fixes are cheap. A requirement costs a sentence; a design flaw caught in review costs a redraw; the same flaw found in production can mean rewriting, redeploying and notifying users.

Step 2: security requirements, written as tests

  • Security requirement: a specific, testable statement of what the software must do to be secure. Not "the app must be secure", but "SR-1: passwords are at least 12 characters", "SR-2: an account locks after 5 wrong guesses".
  • Good sources: the OWASP ASVS (Application Security Verification Standard, a checklist of testable security requirements), laws and contracts about personal data, and your threat model.
  • Writing a requirement as an automated test means it is checked on every build, forever.

Demo 1: requirements as tests

# Security requirements written as TESTS, checked on every build.
FAILS = {}

def login_v1(user, password, real="chai-is-life-2026"):
    return password == real                  # v1: no limit on guesses

def login_v2(user, password, real="chai-is-life-2026"):
    if FAILS.get(user, 0) >= 5:
        return "locked"                      # 5 wrong guesses: locked
    ok = password == real
    FAILS[user] = 0 if ok else FAILS.get(user, 0) + 1
    return ok

def test_lockout(login):                     # requirement SR-2
    for guess in range(6):
        result = login("asha", f"guess{guess}")
    return result == "locked"

def test_min_length(rule):                   # requirement SR-1
    return not rule("short") and rule("chai-is-life-2026")

def show(name, ok):
    print(f"{name:<27}", "PASS" if ok else "FAIL  <- build stops")

show("SR-1 password >= 12 chars", test_min_length(lambda p: len(p) >= 12))
show("SR-2 lockout after 5, v1", test_lockout(login_v1))
show("SR-2 lockout after 5, v2", test_lockout(login_v2))

Real output:

SR-1 password >= 12 chars   PASS
SR-2 lockout after 5, v1    FAIL  <- build stops
SR-2 lockout after 5, v2    PASS

Version 1 allows unlimited guesses, so the requirement test fails and the build stops before the weakness ships. (A real lockout also needs a way to unlock, such as a time delay or a reset, so attackers can't lock out real users forever.)

Step 3: security champions and secure code review

Real-life example: one fire officer can't cover a 30-floor building, so each floor has a trained fire warden, and someone checks the exits with a checklist.

  • Security champion: a developer on each team, trained in security, who spots risks early, answers everyday questions and knows when to call the security team. Champions let a small security team scale to hundreds of developers.
  • Secure code review: a second developer reads every change before it is merged, looking specifically for security mistakes (input handling, authentication and authorisation checks, secrets, injection, error handling, logging). A checklist keeps reviews consistent. Episode 61 goes deeper.

Step 4: SAST (static application security testing)

  • SAST: tools that read source code without running it and flag risky patterns. "Static" = not running.
  • Syntax tree (AST, abstract syntax tree): the structure a language builds from code: calls, arguments, assignments. Python's ast module gives you this tree.

Demo 2: a toy SAST tool

# A toy SAST tool: read the code's syntax tree WITHOUT running it.
import ast

source = """import subprocess, pickle
def report(name):
    subprocess.run("wc -l " + name, shell=True)
def load(blob):
    return pickle.loads(blob)
total = eval(input())
"""
RULES = {"eval": "HIGH   eval(): code injection",
         "loads": "MEDIUM pickle.loads on untrusted data"}
found = []
for node in ast.walk(ast.parse(source)):         # every node of the tree
    if isinstance(node, ast.Call):
        f = node.func
        name = getattr(f, "attr", getattr(f, "id", ""))
        if name in RULES:
            found.append((node.lineno, RULES[name]))
        for kw in node.keywords:
            if kw.arg == "shell" and getattr(kw.value, "value", 0):
                found.append((node.lineno, "HIGH   shell=True: injection"))
for line, msg in sorted(found):
    print(f"line {line}: {msg}")
print("the program was never run: this is STATIC analysis")

Real output:

line 3: HIGH   shell=True: injection
line 5: MEDIUM pickle.loads on untrusted data
line 6: HIGH   eval(): code injection
the program was never run: this is STATIC analysis

Real SAST tools work the same way with thousands of rules and data-flow tracking: Bandit (Python, episode 57), Semgrep, CodeQL, SpotBugs (Java). Strengths: early (in the editor or on each pull request), sees every line, points to the exact line. Weaknesses: false positives (flags safe code), and it can't see runtime behaviour or configuration.

Step 5: DAST, IAST, RASP and SCA

  • DAST (dynamic application security testing): tests the running app from the outside, like a visitor: sends inputs, reads responses, looks for signs of problems. It needs no source code.

Demo 3: a toy DAST probe of our own app on localhost

# A toy DAST scan of OUR OWN app on localhost: test it from the outside.
import threading, html, urllib.request, urllib.parse
from http.server import HTTPServer, BaseHTTPRequestHandler

class Shop(BaseHTTPRequestHandler):            # the app under test
    def do_GET(self):
        q = urllib.parse.urlparse(self.path).query
        name = urllib.parse.parse_qs(q).get("q", [""])[0]
        safe = self.path.startswith("/v2")
        shown = html.escape(name) if safe else name   # v1 forgets
        self.send_response(200); self.end_headers()
        self.wfile.write(f"<p>Results for {shown}</p>".encode())
    def log_message(self, *a): pass

srv = HTTPServer(("127.0.0.1", 8099), Shop)
threading.Thread(target=srv.serve_forever, daemon=True).start()

probe = "<b>probe</b>"                        # a harmless marker tag
for page in ("/v1/search", "/v2/search"):
    url = f"http://127.0.0.1:8099{page}?q=" + urllib.parse.quote(probe)
    body = urllib.request.urlopen(url).read().decode()
    print(f"{page}: {body}")
    print("   ->", "FINDING: unescaped, XSS" if probe in body else "ok")
srv.shutdown()

Real output:

/v1/search: <p>Results for <b>probe</b></p>
   -> FINDING: unescaped, XSS
/v2/search: <p>Results for &lt;b&gt;probe&lt;/b&gt;</p>
   -> ok

Version 1 reflected our harmless marker tag unescaped (a reflected XSS, episode 40); version 2 escaped it. DAST strengths: finds real runtime behaviour and configuration problems, language-independent. Weaknesses: only tests the pages it can reach, finds bugs late, and can't point to the line of code. Real DAST tools (for example OWASP ZAP) must only be pointed at apps you own or have written permission to test.

  • localhost / 127.0.0.1: the address that means "this same computer"; nothing leaves the machine.
  • IAST (interactive application security testing): a sensor (an agent) inside the running app while tests or DAST exercise it. It sees both the input and the exact code path it reached, so it has fewer false positives than SAST and gives line numbers unlike DAST. Like a doctor watching a heart monitor during a treadmill test.
  • RASP (runtime application self-protection): a guard inside the app in production that blocks attacks as they happen (for example refusing a SQL query whose structure an input has changed). It protects; it doesn't replace fixing the code.
  • SCA (software composition analysis): checks your third-party libraries (and their dependencies) against known vulnerabilities, and often licences. npm audit (episode 58), pip-audit (episode 57) and OWASP Dependency-Check (episode 56) are SCA tools.
Tool Looks at When Needs source? Typical weakness
SAST your code build (editor, PR) yes false positives, no runtime view
DAST the running app, from outside test / staging no late, only what it can reach
IAST the running app, from inside test agent in app needs good test coverage
RASP the running app, from inside production agent in app protects, doesn't fix
SCA your libraries build manifests / lockfiles only known vulnerabilities

No single tool sees everything: layer them (defence in depth, episode 3).

Step 6: penetration testing, an authorised assessment

  • Penetration test (pentest): skilled testers try to break into a system the way a real attacker would, to find what tools miss (chains of small issues, logic flaws), and report each finding with its risk and a fix.
  • It is only a test with written permission from the owner, a scope (which systems, which dates, which accounts), and rules of engagement (what is allowed, e.g. no denial of service, no real customer data). Without permission the same actions are a crime (episode 1).
  • Pentests are periodic snapshots; they complement, not replace, the automated checks above.

Step 7: security gates, CI pipelines and DevSecOps

  • CI (continuous integration): every change is automatically built and tested on a server. A CI pipeline is the ordered list of steps (build, test, scan) that runs on every change. CD (continuous delivery/deployment) then releases changes that pass.
  • Security gate: a rule in the pipeline that blocks a release when a security check finds something serious.

Demo 4: a toy pipeline with a security gate

# A toy CI pipeline with a SECURITY GATE: HIGH findings stop a release.
import sys

def unit_tests():   return []                  # all tests passed
def sast():         return [("MEDIUM", "pickle.loads in load()")]
def sca():          return [("HIGH", "lodash 4.17.11: prototype pollution")]
def secrets_scan(): return []

STAGES = [("unit tests", unit_tests), ("SAST", sast),
          ("SCA (dependencies)", sca), ("secret scan", secrets_scan)]
BLOCK = {"HIGH", "CRITICAL"}                # the gate's rule, agreed first

blocked = False
for name, stage in STAGES:
    findings = stage()
    print(f"{name:<19}: {len(findings)} finding(s)")
    for sev, what in findings:
        print(f"    {sev:<6} {what}")
        blocked |= sev in BLOCK
if blocked:
    print("SECURITY GATE: FAILED -> no deploy (fix, or a signed exception)")
    sys.exit(1)
print("SECURITY GATE: passed -> deploy")

Real output (the program exits with code 1, which makes a CI pipeline fail):

unit tests         : 0 finding(s)
SAST               : 1 finding(s)
    MEDIUM pickle.loads in load()
SCA (dependencies) : 1 finding(s)
    HIGH   lodash 4.17.11: prototype pollution
secret scan        : 0 finding(s)
SECURITY GATE: FAILED -> no deploy (fix, or a signed exception)

Good gates: agreed in advance, block only what really matters (e.g. high and critical), and allow a signed, dated exception (a recorded, approved decision to accept a risk until a deadline). A gate that blocks on every low finding gets switched off.

Real-life example for DevSecOps: a kitchen that only cleans before the yearly inspection, versus one where every cook cleans as they go.

  • DevOps: developers and operations working as one team, shipping small changes often, with automation.
  • DevSecOps: DevOps with security built into the same loop: security is everyone's job, and checks (SAST, SCA, secret scanning, DAST, gates) run automatically on every change, instead of one big review before release.

Frameworks that write it down

Framework What it is Key facts (fetched 13 Nov 2026)
Microsoft SDL (Security Development Lifecycle) how Microsoft builds security into its own development "the approach Microsoft uses to integrate security into DevOps processes"; the current version recommends 10 practices: security standards, metrics and governance; proven security features, languages and frameworks; security design review and threat modeling; cryptography standards; securing the software supply chain; securing the engineering environment; security testing; operational platform security; security monitoring and response; security training
NIST SSDF (Secure Software Development Framework), SP 800-218 a US government framework of secure development practices version 1.1; four practice groups: Prepare the Organization (PO), Protect the Software (PS), Produce Well-Secured Software (PW), Respond to Vulnerabilities (RV); referenced in Executive Order 14028 and used for secure-development attestations by software suppliers to US federal agencies
OWASP SAMM (Software Assurance Maturity Model) a prescriptive model to assess and improve your programme 5 business functions (Governance, Design, Implementation, Verification, Operations), 15 security practices, 3 maturity levels (1 initial implementation, 2 structured realization, 3 optimized operation)
BSIMM (Building Security In Maturity Model) a descriptive study of what real organisations actually do "a descriptive model that provides a baseline of observed activities"; BSIMM16, published January 2026, analysed 111 companies and 128 activities in 12 practices and 4 domains (Governance, Intelligence, SSDL Touchpoints, Deployment)
  • NIST: the US National Institute of Standards and Technology. SP = Special Publication.
  • Maturity model: a ladder of levels describing how well-developed a set of practices is, used to score yourself and plan the next step.
  • Prescriptive vs descriptive: SAMM tells you what to do at each level; BSIMM reports what organisations are doing.

The whole chain

  1. Security bolted on at the end → secure SDLC, shift left.
  2. "Make it secure" → testable security requirements, checked on every build.
  3. Too few experts → security champions, secure code review.
  4. Read the code → SAST.
  5. Poke the running app → DAST, IAST, RASP; check libraries → SCA.
  6. Chains tools miss → authorised penetration testing.
  7. Checks in order, on every change → security gates in CI, owned by everyone: DevSecOps, described by Microsoft SDL, NIST SSDF, OWASP SAMM, BSIMM.

Common mistakes (and the fix)

Mistake What you see Why Fix
one pentest just before launch design flaws found when hardest to fix security only at the end shift left: requirements, threat model, SAST in PRs
requirement "the app must be secure" nothing to test, nothing fails not testable "lock after 5 wrong guesses" + an automated test
SR-2 lockout after 5, v1 FAIL ignored weak login ships test not wired to the build failing security tests fail the pipeline
gate blocks every LOW finding teams disable the gate too noisy block HIGH/CRITICAL; signed, dated exceptions
only SAST runtime and dependency bugs missed one tool's blind spots layer SAST, SCA, DAST/IAST
DAST pointed at someone else's site unauthorised testing: illegal no permission only your own apps, or a written scope
security team reviews everything a bottleneck, slow releases doesn't scale champions + automation
SAST findings never triaged thousands of open alerts noise triage, tune rules, fix or suppress with a reason

Mini project: a mini DevSecOps pipeline for a toy repo

Create a small Python project with one intentionally risky function. Add: (1) two security requirements as pytest tests; (2) Bandit as SAST; (3) pip-audit as SCA on a requirements.txt; (4) detect-secrets as a pre-commit hook; (5) a script gate.py that runs them all and exits 1 on any HIGH finding, unless an exceptions.json entry with an owner and an expiry date covers it. Run it locally, then (optionally) as a GitHub Actions workflow on your own repository.

Practice

1. Rewrite "users must be protected from brute force" as two testable requirements.

Solution

SR-A: after 5 consecutive failed logins, the account is locked for 15 minutes. SR-B: the login endpoint accepts at most 10 attempts per minute per IP address and returns HTTP 429 beyond that. Each has a pass/fail test.

2. Add a rule to the toy SAST that flags exec(...) and os.system(...).

Solution
RULES.update({"exec": "HIGH   exec(): code injection",
              "system": "HIGH   os.system: runs a shell"})

os.system is an ast.Attribute whose attr is "system"; exec is an ast.Name with id == "exec"; the getattr(f, "attr", getattr(f, "id", "")) line already handles both.

3. Make the toy gate accept a signed, dated exception.

Solution
import datetime
EXCEPTIONS = {"lodash 4.17.11: prototype pollution":
              {"owner": "asha", "until": datetime.date(2026, 12, 1)}}
def allowed(what):
    e = EXCEPTIONS.get(what)
    return e is not None and datetime.date.today() <= e["until"]
# in the loop:
blocked |= sev in BLOCK and not allowed(what)

4. SAST, DAST, IAST, RASP or SCA? (a) flags log4j-core 2.14.1 in a build file; (b) finds that /admin returns 200 without login on staging; (c) blocks a SQL injection in production; (d) flags eval(input()) in a pull request.

Solution

(a) SCA, (b) DAST, (c) RASP, (d) SAST.

5. Map these to NIST SSDF groups: training developers; protecting the code repository from tampering; threat modelling; handling a reported vulnerability.

Solution

Training: PO (Prepare the Organization). Repository protection: PS (Protect the Software). Threat modelling: PW (Produce Well-Secured Software). Vulnerability handling: RV (Respond to Vulnerabilities).

6. What three things must be agreed before a penetration test starts?

Solution

Written permission from the system owner, the scope (systems, dates, accounts), and the rules of engagement (allowed techniques, things that are off-limits, contacts for emergencies).

Quick quiz

A: SAST   reads the source code
B: SCA    checks the libraries you use
C: DAST   sends inputs to the running app
D: a secret scanner on the git history

Which tool tests the running app from the outside, without the source code?

Answer

C. DAST treats the app as a black box: it sends requests to the running app and inspects the responses. SAST and secret scanners read code without running it; SCA checks dependencies against known vulnerabilities.

Interview questions

  1. What is a secure SDLC? An SDLC with security activities in every phase: requirements, threat modelling, secure coding and review, security testing, release gates, and monitoring and response.
  2. What does "shift left" mean, and why? Moving security earlier in the lifecycle, because flaws found early are cheaper and faster to fix.
  3. SAST vs DAST? SAST analyses source without running it (early, line-level, false positives); DAST tests the running app from outside (realistic, later, no line numbers).
  4. What are IAST and RASP? IAST instruments the app during testing to observe inputs and code paths; RASP instruments it in production to block attacks.
  5. What is SCA? Software composition analysis: inventorying third-party components and matching them against known vulnerabilities and licences.
  6. What makes a good security gate? Clear, agreed criteria (e.g. no high/critical), low noise, fast feedback, and a documented exception process.
  7. What is a security champion? A developer embedded in a team with extra security training who acts as the first point of contact and multiplies the security team's reach.
  8. What is the difference between OWASP SAMM and BSIMM? SAMM is prescriptive (a model to assess and improve); BSIMM is descriptive (observed activities across real organisations).
  9. What is NIST SP 800-218? The Secure Software Development Framework (SSDF) v1.1: practices grouped into PO, PS, PW and RV.
  10. What is DevSecOps? Integrating security into DevOps: shared responsibility and automated security checks on every change.

Glossary

Term Meaning
SDLC software development life cycle: plan, design, build, test, release, operate
secure SDLC an SDLC with a security activity in every phase
shift left moving security checks earlier in the lifecycle
security requirement a specific, testable statement of what the software must do to be secure
OWASP ASVS Application Security Verification Standard: a checklist of testable security requirements
threat modelling finding what can go wrong in a design and how to prevent it (episode 7)
security champion a security-trained developer embedded in each team
secure code review a second developer reviewing each change for security mistakes
SAST static application security testing: analysing source code without running it
static / dynamic not running / running
AST (abstract syntax tree) the tree structure a language builds from code
false positive a finding that is not really a problem
Semgrep / CodeQL / SpotBugs / Bandit SAST tools
DAST dynamic application security testing: testing the running app from outside
localhost / 127.0.0.1 "this same computer"
reflected XSS input sent back unescaped in the response page, where a browser would run it
OWASP ZAP a free DAST tool; use only on apps you are authorised to test
IAST interactive application security testing: an agent inside the app during tests
RASP runtime application self-protection: an agent inside the app in production that blocks attacks
SCA software composition analysis: checking third-party libraries for known vulnerabilities
penetration test (pentest) an authorised, simulated attack by skilled testers
scope the systems, dates and accounts a test may cover
rules of engagement what testers may and may not do
CI (continuous integration) automatically building and testing every change
CI pipeline the ordered automatic steps run on each change
CD (continuous delivery/deployment) automatically releasing changes that pass the pipeline
security gate a pipeline rule that blocks a release on serious findings
exit code the number a program returns when it ends; non-zero means failure
signed, dated exception an approved, recorded risk acceptance with an owner and an expiry date
DevOps development and operations as one team, shipping small changes often with automation
DevSecOps DevOps with security built in and automated on every change
Microsoft SDL Microsoft's Security Development Lifecycle (10 practices in its current version)
NIST US National Institute of Standards and Technology
SP 800-218 / SSDF NIST's Secure Software Development Framework v1.1 (PO, PS, PW, RV)
PO / PS / PW / RV Prepare the Organization / Protect the Software / Produce Well-Secured Software / Respond to Vulnerabilities
maturity model levels describing how well-developed a set of practices is
OWASP SAMM Software Assurance Maturity Model: 5 business functions, 15 practices, 3 levels
BSIMM Building Security In Maturity Model: a descriptive study of real security initiatives
prescriptive / descriptive says what you should do / reports what organisations do

Summary

  • The SDLC is plan, design, build, test, release, operate; a secure SDLC adds security to each phase, and shifting left catches problems when they are cheap.
  • Write security requirements you can test, and run them on every build.
  • Scale people with security champions and secure code review.
  • Layer tools: SAST (code), DAST (running app), IAST/RASP (inside the app), SCA (libraries); add authorised penetration tests for what tools miss.
  • Put the checks in a CI pipeline with a few clear security gates and dated exceptions: that habit, owned by everyone, is DevSecOps.
  • Frameworks: Microsoft SDL, NIST SSDF (SP 800-218), OWASP SAMM (prescriptive), BSIMM (descriptive).
  • Next episode: security testing, code review and vulnerability management.

Sources (fetched 13 Nov 2026)

  • Wikipedia, Microsoft Security Development Lifecycle: https://en.wikipedia.org/wiki/Microsoft_Security_Development_Lifecycle
  • NIST, Software Security in Supply Chains: Software Development (SSDF v1.1, SP 800-218): https://nist.gov/itl/executive-order-14028-improving-nations-cybersecurity/software-security-supply-chains-software
  • Black Duck blog, What is NIST SP 800-218 (SSDF)? (four practice groups, EO 14028): https://blackduck.com/blog/nist-ssdf-secure-software-development.html
  • OWASP SAMM v2 release notes: https://owaspsamm.org/release-notes-v2/
  • Black Duck, What is BSIMM?: https://www.blackduck.com/glossary/what-is-bsimm.html ; BSIMM16 report page: https://www.blackduck.com/resources/analyst-reports/bsimm.html