What is the difference between SAST and SCA, and where does SonarQube fit?

IntermediateConceptSonarQube
Answer

Short answer

SAST (Static Application Security Testing) analyses your own source code for vulnerabilities like SQL injection or XSS. SCA (Software Composition Analysis) checks your third-party dependencies for known vulnerabilities (CVEs) and licence issues. SonarQube is mainly SAST + code quality; SCA is done by tools like Trivy, OWASP Dependency-Check, Snyk or Dependabot (newer SonarQube editions are adding dependency analysis).

Comparison

SAST SCA
Looks at Code you wrote Libraries you use
Finds Injection flaws, insecure crypto use, hard-coded secrets CVE-2021-44228 in log4j 2.14, GPL licence in a closed product
Tools SonarQube, Semgrep, CodeQL, Checkmarx Trivy, Dependency-Check, Snyk, Dependabot, Grype

In a pipeline

Run both: Gitleaks (secrets) → SonarQube (SAST + quality) → Trivy fs (SCA) → build image → Trivy image → deploy → ZAP (DAST).

What to say in the interview

"SAST inspects our code, SCA inspects our dependencies. SonarQube covers SAST and code quality, so we pair it with an SCA tool like Trivy or Dependency-Check — about 80% of a typical app's code is open-source dependencies."

All Security Tools questions Roadmap: SonarQube — code quality & SAST

More on SonarQube