SAST scans source code for vulnerabilities before the program is built and run. The scanner is built into CI and runs on every build, so the developer sees the weakness in their own branch rather than a tester after release. Alongside it comes DAST — analysis of a running application from the outside.
What it finds and what it misses
The scanner builds a model from the code — a syntax tree, a call graph and data-flow graphs — and looks for paths along which untrusted data reaches dangerous operations without validation.
| Error class | Example |
|---|---|
| Injections | an SQL query assembled by concatenating a user-supplied string |
| XSS | user data ends up in HTML without escaping |
| Secrets in code | API keys and passwords hardcoded into the repository |
| Weak cryptography | password hashing with MD5, outdated encryption modes |
| Missing access checks | a handler writes to the database without checking user permissions |
No execution takes place, so SAST does not find logic errors, environment misconfigurations or vulnerabilities in dependencies — dynamic analysis and SCA cover those.
Semgrep and CodeQL
Semgrep searches using rules that resemble code samples: a rule is written as a fragment of code with placeholders and metavariables, so a team can describe its own rule in minutes without studying the language’s internal representation. CodeQL works differently: it turns the repository into a database with a syntax tree and flow graphs, and finds complex data paths with SQL-like queries. Both tools support many languages and can trace the path of tainted data from source to sink.
rules: - id: sql-injection-concat message: SQL query built by concatenating an unchecked string languages: [python] severity: HIGH patterns: - pattern: $CURSOR.execute("..." + $X)How it is used
SAST is placed in the pipeline alongside tests: a quick run on changed files, a full run on a schedule. Results are often emitted in SARIF format and labelled against the CWE weakness catalogue, while findings are triaged manually: static scanners produce many false positives, and they are tuned gradually, otherwise developers stop reading the reports.
Sources
the term is written from these pagesVerified 9 Nov