# SAST and SCA in CI Pipelines

> Automate static code analysis and dependency scanning in pull requests, then tune them so developers trust the results. Free notes, key concepts, resources and...

Canonical: https://www.internhack.in/roadmaps/tracks/cybersecurity/sast-sca-ci
Last updated: 2026-11-28

Automate static code analysis and dependency scanning in pull requests, then tune them so developers trust the results.

Intermediate · about 6 hours · difficulty 3/5

Learn first: [Secure Coding and Input Validation](https://www.internhack.in/roadmaps/tracks/cybersecurity/secure-coding), [Dependency and Supply-Chain Hygiene](https://www.internhack.in/roadmaps/tracks/cybersecurity/supply-chain-security)

Automated checks catch common mistakes on every change, before they reach production. The two most widely used are **SAST** and **SCA**.

### SAST: static application security testing

Analyses your source code without running it, looking for patterns such as untrusted input reaching a database query or a weak crypto call.

- Free options: **Semgrep** (community rules), **CodeQL** (free for public repos on GitHub), language linters like Bandit for Python and ESLint security plugins.
- Strength: finds issues in your own code early. Weakness: false positives and limited understanding of business logic.

### SCA: software composition analysis

Checks your dependencies against known vulnerabilities and licences.

- Tools: **OSV-Scanner**, **Trivy**, Dependabot alerts, `npm audit`, `pip-audit`.
- Trivy also scans container images and infrastructure-as-code for misconfigurations.

### Designing the pipeline

- Run fast scans on every pull request and fuller scans nightly.
- Show results **inline in the PR** so developers see them in context.
- Start in report-only mode, tune rules, then **block only on high-confidence, high-severity** findings.
- Track suppressions with a reason, reviewer and expiry.

### Measuring success

Watch fix rates and time to fix, not just finding counts. A tool nobody trusts will be ignored or disabled.

### Pitfalls

- Enabling every rule and flooding teams with noise.
- Scanning only the default branch, after the risky code is already merged.

Move on when you have a CI workflow that runs Semgrep or CodeQL plus an SCA scanner on pull requests, with at least one tuned rule and a documented suppression.

## Key concepts

- **SAST concepts and limits**
- **Semgrep rules**
- **CodeQL**
- **SCA and dependency scanning**
- **Trivy for images and IaC**
- **PR-inline results and gating**
- **Tuning and suppressions**
- **DAST overview**: Scanning your own running app in a test environment

## Mini project

Create a GitHub Actions workflow that runs Semgrep and OSV-Scanner on pull requests, reports results inline, and fails the build only on high-severity findings; document your tuning decisions in the README.

## Check yourself

Why should a new security scanner usually start in report-only mode before it blocks merges?

## Free resources

- [Semgrep documentation](https://semgrep.dev/docs/) (Semgrep)
- [CodeQL documentation](https://codeql.github.com/docs/) (GitHub)
- [OSV-Scanner](https://google.github.io/osv-scanner/) (Google / OSV)
- [Trivy documentation](https://trivy.dev/latest/docs/) (Aqua Security)

Previous: [Secrets Management](https://www.internhack.in/roadmaps/tracks/cybersecurity/secrets-management) · Next: [Shared Responsibility in the Cloud](https://www.internhack.in/roadmaps/tracks/cybersecurity/shared-responsibility)

## More in Secure Software Development

- [Secure SDLC](https://www.internhack.in/roadmaps/tracks/cybersecurity/secure-sdlc)
- [Threat Modelling with STRIDE](https://www.internhack.in/roadmaps/tracks/cybersecurity/threat-modeling-stride)
- [Secure Coding and Input Validation](https://www.internhack.in/roadmaps/tracks/cybersecurity/secure-coding)
- [Dependency and Supply-Chain Hygiene](https://www.internhack.in/roadmaps/tracks/cybersecurity/supply-chain-security)
- [Secrets Management](https://www.internhack.in/roadmaps/tracks/cybersecurity/secrets-management)
- [SAST and SCA in CI Pipelines](https://www.internhack.in/roadmaps/tracks/cybersecurity/sast-sca-ci)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Cybersecurity Roadmap](https://www.internhack.in/roadmaps/tracks/cybersecurity)
