What tx0 checks
4 847 rules for Go, Python, JavaScript, TypeScript, Java, C, C++, C#, PHP, Kotlin, Rust, SQL, HTML, CSS and XML, and Dockerfile, Kubernetes YAML and Terraform. Every pack runs on the same syntax tree, control flow graphs and dataflow analyses.
Languages and formats, one parser each
- Go
- Python
- JavaScript
- TypeScript
- Java
- C
- C++
- C#
- PHP
- Kotlin
- Rust
- SQL
- HTML
- CSS
- XML
- Dockerfile
- Terraform
- Kubernetes
- GitHub Actions
- Docker Compose
- YAML
- JSON
- Secrets
| Pack | Rules |
|---|---|
| Go.go files | 310 |
| Python.py and .pyi files | 440 |
| JavaScript and TypeScript.js, .jsx, .mjs, .cjs, .ts, .tsx, .mts and .cts files | 563 |
| Java.java files | 689 |
| C.c and .h files | 373 |
| C++.cpp, .cc, .cxx, .hpp, .hh and .hxx files | 291 |
| C#.cs files | 344 |
| PHP.php and .phtml files | 323 |
| Kotlin.kt and .kts files | 280 |
| Rust.rs files | 233 |
| SQL.sql files | 201 |
| HTML.html and .htm files | 131 |
| CSS.css, .scss and .less files | 83 |
| XML.xml files and XML formats such as .csproj and .xsl | 61 |
| DockerfileDockerfiles | 43 |
| TerraformTerraform .tf files | 90 |
| KubernetesKubernetes manifests | 41 |
| GitHub ActionsGitHub Actions workflows | 21 |
| Docker ComposeDocker Compose files | 15 |
| YAMLYAML files | 1 |
| JSON.json files | 1 |
| Secretsevery file | 313 |
tx0 reads the code itself with its own lexers and parsers instead of calling a compiler. The C and C++ packs include a preprocessor that maps expanded code back to the source, with the standard headers built into the binary. A .h file goes to C or C++ by the files around it.
Packs, depth, tiers and profiles
Packs what a rule is about
securityinjectionpath-traversalssrfxsssecretscryptoiacreliabilitynull-safetyresourcesconcurrencymemory-safetyarithmeticperformancealgorithmicallocationioregexmaintainabilitycomplexityduplicationdead-codestylenamingconventionsaccessibilitywebframeworksreactspringdjango
Some of the packs of each theme. Framework packs run by tier like any other. Every rule is in one pack, and a pack means the same in every language: security/injection holds the injection rules of every language.
Depth how far a rule reads
fastone file, with the flow of values inside its functionsprojectthe declarations of the whole project: types, imports, members across filesdeepvalues followed across functions and files, such as input that reaches a query
Tier how many rules run
defaultbugs and security problems with measured precisionrecommendedadds likely bugs, resource and performance problemsstrictadds code that can be written more plainlyallevery rule
Profiles one name for all three
profile = "agent"- what tx0 hook uses: no performance, maintainability, style or accessibility packs, nothing deeper than project
profile = "ci"- the recommended tier when tx0.toml sets none, at every depth
profile = "audit"- every security pack at tier all and depth deep
tx0.toml
tier = "recommended"
[packs]
"security/injection" = { tier = "all", depth = "deep" }
"reliability/null-safety" = { tier = "recommended", depth = "project" }
"style/*" = "off"
[depth]
default = "project" # nothing deeper, unless a pack says 52 packs in seven themes. The security theme holds 1 065 rules that name 118 CWE weaknesses between them, and the secrets scanner 313 rules for keys, tokens and passwords. tx0 explain RULE FILE says which line of tx0.toml decided whether a rule runs.
Four tiers
- default1 077Bugs and security problems with measured precision. Runs without a
tx0.toml. - recommended+1 774Likely bugs, resource and performance problems.
- strict+1 338Code that can be written more plainly.
- all4 847Every rule. Each tier includes the ones before it.
A bug or security rule enters the default tier when its findings outside test code, on open-source projects it was not written for, were judged by hand: at least 20 of them, or all it has, with a 95 % lower bound of 90 % on its precision, or all of them true. This is the first release; the changelog lists what each version adds.
Under the rules
- In tx0 now
Dataflow in every language
Every pack builds control flow graphs in SSA form and runs the same dataflow analyses on them: constants, liveness, definite assignment, nullness and function summaries.
- In tx0 now
Facts from project files
Rules can read facts from project files such as
go.mod, so a check knows the language version a module is built for. - In tx0 now
Names across files
A view of the whole project that resolves names across files and packages, for rules that need more than one file.
- In tx0 now
Taint tracking
Following untrusted input, such as a request parameter, through functions and across files to the place where it is used: a query, a shell command, a file path, a fetched URL, a redirect, a page. In Go, Java, Python, JavaScript, TypeScript, PHP and C#, each finding with the path the value took.
- In tx0 now
Types across files
Types resolved across files in Java and TypeScript, so a call into another file is checked against what it really is.
- In tx0 now
A scanner for secrets
Keys and service tokens in any file of the tree, beside the rules that already find secrets written into source code.
- In tx0 now
Infrastructure as code
Packs for Dockerfiles, Terraform and Kubernetes YAML.
- In tx0 now
Analyses across calls
At the deep level: null dereferences and division by zero across calls, indexes out of bounds, leaked resources and memory errors in C and C++. A deep rule moves into the default tier only once its precision is calibrated per language; until then it runs in the tier
all. - In tx0 now
C and C++ without a compiler
The compiler's own headers, such as
stdint.handlimits.h, come with the binary, so C and C++ are checked on a machine without a compiler. Library headers come from the system when it has them; a file whose headers are missing is read as written. - In tx0 now
Time in proportion to the input
Every parser is tested to do work in proportion to its input: doubling a file may at most double the parser's steps, with a ten percent margin. A generated or hostile file costs its size and no more.