On this page
Key takeaways
- Semgrep matches code against patterns you write yourself and runs fast across many languages.
- CodeQL treats code as data and answers deep security queries, with strong GitHub integration.
- Bandit and Pylint focus on Python, catching security issues and style problems in one pass.
- ESLint brings a huge rule set and a pluggable design to the JavaScript ecosystem.
Static analysis reads source code without running it, looking for patterns that often turn into bugs or security holes. Because the checks run early, problems are caught before they reach a build or a user. For security work, these tools are a cheap first line of defense that fits into an existing pipeline. A check that runs on every change is far less costly than fixing the same bug after it has shipped.
The list below spans several languages and two broad styles: pattern matching tools and deeper analyzers. Some are general purpose, while others focus on a single runtime, so the choice usually starts with the languages a team already uses. In practice, many teams run more than one, layering a fast scanner with a deeper tool for the parts of the code that handle untrusted input.
Quick comparison
| Tool | Best for | Starting price | Free plan |
|---|---|---|---|
| Semgrep | Custom code pattern search | Not included | Not included |
| CodeQL | Security queries on code | Not included | Not included |
| Bandit | Finding Python security issues | Not included | Not included |
| PHPStan | Static analysis for PHP | Not included | Not included |
| Psalm | Type checking for PHP | Not included | Not included |
| ESLint | Finding bugs in JavaScript | Not included | Not included |
| Pylint | Catching Python code issues | Not included | Not included |
The best static analysis tools for code security
1. Semgrep
- Official site: https://semgrep.dev
- Best for: Custom code pattern search
- Starting price: Not included
- Free plan: Not included
- Pros: Write your own rules; fast
- Cons: Learning the syntax; some rules paid
Semgrep is a static analysis tool that matches source code against patterns written in a language that looks like the code being searched. A team can write a rule for a dangerous function call or a misused API and run it across a whole repository quickly. It supports many languages, which makes it useful in mixed codebases.
The main effort is learning the pattern syntax, and some rule sets live behind a paid offering while the core tool remains open. Once the patterns are written, they become reusable checks that can run in CI on every change. That combination of speed and custom rules is what draws security teams to it.
2. CodeQL
- Official site: https://codeql.github.com
- Best for: Security queries on code
- Starting price: Not included
- Free plan: Not included
- Pros: Deep analysis; GitHub native
- Cons: Learning curve; GitHub focus
CodeQL treats code as a database that can be queried, which allows deep analysis that goes beyond simple pattern matching. Queries can follow data from an untrusted source to a dangerous sink, the kind of tracking that finds real injection and deserialization problems. It is integrated tightly with GitHub, where it runs on pull requests and surfaces findings as alerts.
The query language takes time to learn, and the tool is most natural inside the GitHub ecosystem. Outside that environment it still works but with more setup. For teams that want rigorous, query-driven findings on a GitHub repository, it is a strong option.
3. Bandit
- Official site: https://bandit.readthedocs.io
- Best for: Finding Python security issues
- Starting price: Not included
- Free plan: Not included
- Pros: Focused on security; fast
- Cons: Python only; some false positives
Bandit is a security-focused scanner for Python code. It checks for common problems such as unsafe deserialization, hardcoded passwords, and use of risky standard library calls. Because it is purpose-built for Python, it understands the language's idioms and runs quickly on typical projects.
It produces a report of findings with a severity level for each, so developers can triage what matters first. The trade-offs are that it only covers Python, and some of its checks flag code that is actually fine, which means occasional false positives need manual review. For Python projects, it is a fast and easy starting point.
4. PHPStan
- Official site: https://phpstan.org
- Best for: Static analysis for PHP
- Starting price: Not included
- Free plan: Not included
- Pros: Deep checks; fast
- Cons: PHP only; config work
PHPStan examines PHP code without running it and reports type errors, undefined variables, and calls with the wrong arguments. It works up to a configurable level, so a project can start with basic checks and tighten them over time as the codebase improves. This makes it approachable for both new and mature PHP projects.
The tool is limited to PHP, and reaching the strictest levels requires some configuration work and docblock annotations. Even at the default level, though, it catches a large share of mistakes before they hit production. For PHP teams, it is a standard part of a modern quality setup.
5. Psalm
- Official site: https://psalm.dev
- Best for: Type checking for PHP
- Starting price: Not included
- Free plan: Not included
- Pros: Strong types; auto fixes
- Cons: PHP only; learning curve
Psalm is a static analysis tool for PHP that focuses on types and can apply automatic fixes to some of the problems it finds. It reads type annotations and docblocks to spot mistakes that would otherwise appear only at runtime. The auto-fix feature lets a developer correct a class of issues with a single command.
Like other PHP-focused tools, it stays within the PHP ecosystem, and getting the most from its strict mode takes some learning. The benefit is a tighter type model across a codebase, which reduces whole categories of bugs and makes the code easier to reason about.
6. ESLint
- Official site: https://eslint.org
- Best for: Finding bugs in JavaScript
- Starting price: Not included
- Free plan: Not included
- Pros: Huge rule set; pluggable
- Cons: Config time; JS ecosystem only
ESLint is a pluggable linter for JavaScript and TypeScript that ships with a large set of rules and supports thousands of community plugins. Rules catch problematic patterns such as unused variables, unsafe assignments, and code that is likely to behave differently than intended. Because it is configurable, teams can enable only what fits their style.
The cost is the configuration time: a new project has to decide which rules to turn on, which often involves reading through many options. It stays within the JavaScript ecosystem, so other languages need their own tools. Within that ecosystem, though, it is the default first check on nearly every project.
7. Pylint
- Official site: https://pylint.readthedocs.io/en/stable/
- Best for: Catching Python code issues
- Starting price: Not included
- Free plan: Not included
- Pros: Thorough; configurable
- Cons: Can be noisy; slow on big files
Pylint is a long-standing analyzer for Python that checks style, naming, imports, and a range of likely bugs. Its checks are configurable, so a team can silence categories that do not apply and keep the ones that matter. That thoroughness makes it a broad first pass over a Python codebase.
The downside is noise: without tuning, it can flag many issues a team does not care about, and it can be slow on very large files. With a tuned configuration, though, it settles into a dependable guard that runs on every commit and catches mistakes early.
How we chose
These tools were selected to cover the main ways static analysis is applied to security, from fast pattern matching to deeper query-driven analysis. The list spans Python, PHP, and JavaScript, because most teams start the decision from the language they already use. The two styles complement each other, and the entries here show how each can slot into a build without heavy infrastructure.
Selection favored actively maintained tools with clear documentation and a low-friction setup that runs in CI. Preference went to projects with large rule sets or strong type analysis, since those produce the most value for the least ongoing effort. A tool that can run from a single command on a pull request was preferred over one that needs its own server or a manual review step.
FAQ
What is static analysis?
Static analysis reads source code without executing it to find bugs, style issues, and security problems. It runs early in development, before the code reaches a build or a user.
Which tool should I start with for Python security?
Bandit is the quick starting point because it is purpose-built for security and runs fast. Pylint adds broader bug and style checks once a team wants more coverage. Together the two cover both security-specific findings and general code quality in the same language.
Can these tools run in a CI pipeline?
Yes. All of them run from the command line and fit into a continuous integration step, so findings appear on every pull request without manual effort.
Do I need separate tools for PHP and JavaScript?
Generally yes. PHPStan or Psalm handle PHP, and ESLint handles JavaScript, since each tool targets a specific language or ecosystem.
How do I reduce false positives?
Tuning the configuration is the main way. Tools like Pylint and ESLint let teams disable noisy rules, and Semgrep allows custom patterns so checks match exactly what a team cares about.