LESSON 5

SAST and DAST

Use static and dynamic analysis effectively: what each finds and misses, secrets and infrastructure scanning, placing scans in the pipeline, tuning for signal, triaging results, and using AI to interpret findings.

Introduction

Reviewing every line of code by hand does not scale, and testing a running system by hand does not scale either. Automated analysis tools check the same patterns on every commit and never get tired. They also produce false alarms, miss whole categories of problems, and, if configured carelessly, produce so much noise that developers stop reading them.

This lesson covers the main kinds of automated security analysis, what each is good for, and how to place them in the Production Deployment Pipeline so that they improve security instead of slowing delivery.

Learning Objectives

  • Explain static (SAST), dynamic (DAST), and interactive (IAST) analysis, and what each finds and misses.
  • Add secrets scanning and infrastructure-as-code scanning.
  • Place security checks in the pipeline with sensible gates and time budgets.
  • Configure tools to reduce noise, and triage and suppress findings responsibly.
  • Combine tools with manual review and testing.
  • Use AI to interpret and prioritize tool output.

1. The Landscape

Approach What it does Needs Good at Weak at
SAST (static application security testing) Analyzes source code without running it Source code Injection patterns, unsafe functions, hard-coded secrets, early feedback in the editor and pull request Business logic, authorization flaws, configuration and runtime behavior; many false positives
DAST (dynamic application security testing) Attacks a running application from outside, as a user would A running, test-safe deployment Misconfiguration, missing headers, exposed endpoints, some injection and authentication issues, what is actually reachable Code coverage; locating the cause in code; authenticated and complex flows without setup
IAST (interactive) Instruments the running application while tests exercise it Instrumented app and tests Precise findings with code location, fewer false positives Needs good test coverage; setup and language support
SCA (software composition analysis) Checks dependencies for known vulnerabilities Dependency manifests Known flaws in libraries (lesson 6) Unknown flaws; whether the code is reachable
Secrets scanning Searches code and history for credentials Repository Leaked keys and tokens Secrets that look like ordinary strings
IaC and container scanning Checks infrastructure definitions and images Definitions, images Open ports, public storage, root containers, missing encryption Runtime drift; application flaws

No single tool covers everything. The weaknesses are different, which is why they are used together. Most importantly, none of them reliably finds broken access control or flawed business logic, which are among the most damaging problems. Those need design review, code review, and targeted tests (lessons 7 and 8).

2. Static Analysis in Practice

SAST tools model how data flows through code, from sources (user input) to sinks (database calls, command execution, output). Use them:

  • In the editor and the pull request, where feedback is fastest and the author remembers the code.
  • On a small, high-confidence ruleset first, then widen. Ten rules the team trusts beat a thousand it ignores.
  • With rules for your frameworks and your own patterns. Write custom rules for recurring local mistakes, such as “database access must go through the data access layer” or “never log request bodies.”
  • As differences, not totals: block on new findings in changed code, and track the existing backlog separately so the team is not frozen by history.

Expect false positives (a flagged flow that is actually sanitized) and false negatives (a vulnerable flow the tool cannot follow through frameworks, reflection, or asynchronous calls). A clean report is not a clean bill of health.

3. Dynamic Analysis in Practice

DAST tools crawl and probe a running application. Use them against a dedicated, non-production environment with test data, and only with authorization. Dynamic scans send many unusual requests: they can create records, trigger emails, fill logs, and in unlucky cases take a service down.

Good practice:

  • Scan staging, never production, and never a system you do not own or have permission to test.
  • Provide authentication, with test accounts for each role and at least two tenants, so the scanner can reach protected pages and you can test isolation.
  • Describe the API. Give the tool the API specification so it knows the endpoints and parameters.
  • Start passive, then active. Passive scans observe traffic and are safe; active scans attack and need more care.
  • Schedule it. A full scan can take hours; run it nightly or per release, and a short baseline scan per change.
  • Watch for side effects: rate limiting, email and model provider costs, and queue floods. Turn off or stub external calls in the test environment.
  • Compare with the expected surface. Endpoints the scanner finds that are not in your API specification are findings in themselves.

4. Secrets Scanning

Leaked credentials are among the most common and most easily exploited problems. Scan:

  • Every commit and pull request, before merge, with a hook or pipeline job.
  • The full history, once and periodically: a secret removed from the latest file still lives in earlier commits.
  • Build outputs and images, since secrets sometimes end up in layers and logs.

When a secret is found, the response is not to delete the line. Treat the secret as compromised: revoke or rotate it, check access logs for misuse, then remove it and add a preventive control. Rewriting history is secondary and does not undo exposure, especially if the repository was ever shared or cloned.

5. Infrastructure and Container Scanning

Policy checks on infrastructure code (from the delivery course) catch dangerous settings before they exist:

  • Storage open to the public, databases reachable from the internet, wide-open network rules.
  • Missing encryption, logging, or backup settings.
  • Administrator-level permissions for workloads.
  • Containers running as root, mutable base image tags, missing resource limits.

Run these on every infrastructure change, and run image scans on every build and on a schedule, since new vulnerabilities in old images appear daily. Treat the cloud account’s configuration as a target, too: periodically compare what is actually deployed to what the code says, and report differences.

6. Placing Checks in the Pipeline

Different checks belong at different points, balancing speed and depth:

Stage Checks Gate behavior (illustrative)
Editor and pre-commit Lint rules for security, secrets scan Advisory; fast
Pull request SAST on changed code, secrets scan, dependency check, IaC scan Block on new high-confidence critical or high findings and on any secret
Build Image scan, SBOM generation, signing Block on critical exploitable vulnerabilities without an accepted exception
Deploy to staging Baseline DAST, authenticated API checks, security smoke tests Block on high findings in the baseline
Nightly or per release Full DAST, deeper SAST, full-history secrets scan, drift report Report and open findings; release gate for unresolved criticals
Production Continuous monitoring, scheduled scans Alert and ticket

Keep the pull request stage under a time budget (for example, a few minutes) or developers will route around it. Slow, deep checks run in parallel or on a schedule. Make failure messages actionable: what is wrong, where, why it matters, and how to fix or request an exception.

Remember the lesson about gates from the delivery course: a gate that is routinely overridden is worse than none, because it teaches the team that security signals do not matter.

7. Reduce Noise and Triage Responsibly

Noise kills security programs. Manage it deliberately:

  • Tune rules: disable those that never produce true findings in your codebase, with a written reason.
  • Prioritize by confidence and severity, and show developers only what they should act on.
  • Suppress with discipline. A suppression records the reason, the person, and a review date, and lives in version control next to the code, where it can be reviewed.
  • Deduplicate across tools and over time.
  • Track tool quality: what share of reported findings turned out to be real? If it is low, fix the configuration.
  • Measure outcomes, not tool output: time to fix, findings that escaped to later stages, the number of accepted exceptions.

Give findings to the developer who can fix them, in the tool they already use (the pull request or issue tracker), not in a separate report nobody opens.

8. Using AI With Analysis Tools

AI is useful for reading tool output; it is not a replacement for the tools.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Act as an application security engineer interpreting scan results.

Inputs:
- Results from [SAST, DAST, secrets, IaC, image scans], redacted:
  [paste]
- Relevant code snippets for the top findings: [paste]
- Architecture summary and exposure per component: [paste]
- Current suppressions and exceptions: [paste]

Tasks:
1. Deduplicate and group findings by root cause.
2. For each group, say whether it looks like a true or false
   positive, with a reason that refers to the code or request shown.
3. Propose an adjusted priority using exposure and data sensitivity.
4. For true positives, suggest a fix that removes the cause.
5. Identify rules or settings that are producing noise.
6. List important weakness classes that these tools are unlikely to
   have found in this system, and how they could be checked.

Do not claim exploitability without stating the conditions. Do not
write exploit code. Mark uncertainty.

Then verify. Open the code for each claimed true positive. AI can also write custom rules or explain how to configure a tool; check any rule against positive and negative examples before relying on it, and check tool options against its documentation.

Be careful about what leaves your environment. Scan results and code snippets can reveal vulnerabilities and secrets; use approved tools and redact.

9. Practical Exercise

For SignalDesk (or your project):

  1. Choose a SAST tool, a secrets scanner, a dependency and image scanner, and an IaC scanner (or note equivalents you already have), and a DAST approach for staging.
  2. Define the pipeline stages for each check, the gate behavior, and a time budget for the pull request stage.
  3. Create test accounts for at least two roles and two tenants for dynamic testing, and describe the scan scope and rules of engagement.
  4. Run the tools on the codebase and staging environment (authorized), and record the raw results.
  5. Triage the top twenty findings: true or false positive, adjusted priority, owner.
  6. Record suppressions with reasons and review dates, and tune at least two noisy rules.
  7. Run the AI interpretation prompt and compare with your triage.
  8. List the weakness classes your tools are unlikely to find, and decide how each will be covered.
  9. Add the confirmed findings to the findings register.

Verification

You are ready to continue when:

  • Each tool has a purpose, a place in the pipeline, a gate rule, and an owner.
  • Dynamic scans run only in an authorized test environment with test data and accounts for multiple roles and tenants.
  • A leaked secret has a defined response: revoke, rotate, investigate, then remove.
  • Suppressions are recorded with reasons and review dates.
  • You can name what the tools cannot find and how those weaknesses will be covered.

Key Takeaways

  • SAST, DAST, SCA, secrets, and infrastructure scanning find different things; use them together.
  • None finds broken access control or business logic flaws reliably; those need review and tests.
  • Put fast, high-confidence checks early and deep checks on a schedule, with actionable failures.
  • Noise is the main risk to a security pipeline; tune, deduplicate, and suppress with discipline.
  • AI helps interpret and prioritize results; people verify them and decide.

What’s Next?

Most of the code in a modern application is not written by your team. The next lesson turns to dependencies and the software supply chain: how to know what you ship, keep it current, and trust what you build.