In brief
SCA checks dependencies, meaning libraries and images, for known vulnerabilities and licenses. SAST analyzes source code without running it. DAST tests the running application from the outside, like a user. In CI, add SCA and a secret scanner first, because they give the most with the least noise, then SAST on changes in pull requests, and run DAST after deployment to the test environment. Block only new high-severity findings.
Three tests, three questions
| Test | What it examines | The question it answers | When in the pipeline |
|---|---|---|---|
| SCA (Software Composition Analysis) | dependencies, container images, licenses | whether we use a component with a known vulnerability | on every build and daily on the main branch |
| SAST (Static Application Security Testing) | source code and configuration | whether our code contains a known flaw pattern | in the pull request, on changed files |
| DAST (Dynamic Application Security Testing) | the running application over HTTP | whether the application behaves safely from the outside | after deployment to the test environment |
These tests complement each other. SAST sees unsafe SQL query concatenation in code, but does not know whether a given endpoint is reachable from the internet at all. DAST sees a missing header or an error in the server's response, but will not point to a line of code. SCA does not look at your code at all, only at what you bring into it.
SCA first: dependencies are most of the code
In a typical Java, .NET, Python, or JavaScript application, the team's own code is the smaller part of what reaches production. The rest is libraries and their transitive dependencies, plus the container base image. That is why a dependency scanner gives a quick result: it points to a specific library, the vulnerable version, and the fixed version.
SCA tools include OWASP Dependency-Check, Trivy, GitHub's Dependabot, and Renovate, as well as modules in commercial platforms. When deploying, settle three things:
- where to scan: the dependency file in the repository and the finished container image, because the base image has its own packages,
- what to do about licenses: a list of licenses allowed in the product, especially when the company sells software,
- how to update: automated pull requests that bump versions and go through the usual regression tests.
An SCA scanner is also a source of data for an SBOM, the component inventory, which we describe in the article Software supply chain.
SAST in change review
SAST works best as a comment in a pull request, not as a report with a thousand items once a month. The developer gets a note on the line they just wrote and fixes it in the same task.
Example tools are Semgrep, CodeQL, and SonarQube. When rolling it out in an existing system, set a baseline: record the current findings as debt to review and block only new ones. Otherwise the first run will stop all deployments, and the team will quickly switch the scanner off.
False positives are unavoidable in SAST. It helps to have a rule set matched to the language and framework, to mark findings as “not applicable” with a short reason visible in review, and to periodically review rules that produce only false positives.
Example: an insurer's policy system
A team develops a policy system with over a decade of history. The first full SAST scan reports several thousand items, mostly in a module nobody changes. The team records them as the baseline, turns on blocking only for new high-severity findings in changed files, and once a sprint reviews one category of old debt, starting with SQL injection in modules reachable from the customer portal. After a few months the old debt shrinks, and new flaws do not reach the code.
DAST in the test environment
DAST needs a running application, so it is run after deployment to a test or pre-production environment. A popular open source tool is ZAP. A sensible setup has two modes:
- A passive scan after every deployment. The tool inspects responses without sending attacks: headers, cookies, information disclosure. It is short and does not damage data.
- An active scan at night. The tool sends crafted requests to all endpoints from the OpenAPI file, logged in with a test account. It takes longer and can change data, so it runs on a separate environment.
DAST will not replace a penetration test, because it does not understand business logic. We describe the difference in the article Penetration testing vs. vulnerability scanning.
Rollout order and blocking thresholds
| Pipeline stage | Test | Blocks? |
|---|---|---|
| pre-commit hook | secret scanner | yes, locally |
| pull request | secret scanner, SAST on changes, SCA | yes, for new high-severity findings |
| image build | image scan, IaC scan | yes, for critical findings with a fix available |
| deployment to test | passive DAST | no, reports findings |
| night | active DAST, full SCA of the main branch | no, creates tasks |
The rule for thresholds is simple: block what the team can fix right away and what has real impact. A critical vulnerability in a library with a fix available blocks the build. A medium-severity finding with no fix goes into the register with a deadline, following the process from the article Vulnerability management.
Two more scanners are worth adding to the pipeline: one for secrets (described in the article Secrets in applications) and one for infrastructure definitions, such as Terraform and Kubernetes manifests, which catch open ports and public data stores before deployment. B2Bnetwork engineers build such pipelines in test automation and DevOps projects.
Questions and answers
Which security test should you add to CI first?
A secret scanner and SCA first. Both are fast, produce few false positives, and point to a specific fix: revoke the key or bump the library version. SAST and DAST need rule and environment tuning, so it is worth adding them once the team already has a habit of responding to findings.
Will SAST slow down pull requests?
It does not have to, if it scans only the changed files and runs in parallel with unit tests. A full scan of the whole repository can run at night on the main branch. Noise matters more than time: if the scanner reports many false positives, developers stop reading its comments.
Can you run DAST in production?
A passive scan is sometimes run in production, because it sends no attacks, but an active scan should not be, because it can create and change data, create accounts, and load the system. Run the active scan in a test environment with test data that matches the production version.
Are these tests enough to meet DORA or CRA requirements?
Scanners alone are not enough, but they are part of the evidence. The regulations require a process: a testing program, vulnerability handling, documentation, and response. SCA, SAST, and DAST results with a history of fixes show that the process works. The details are covered in the articles on testing under DORA and on the Cyber Resilience Act.