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
Rules per language and format
PackRules
Go.go files310
Python.py and .pyi files440
JavaScript and TypeScript.js, .jsx, .mjs, .cjs, .ts, .tsx, .mts and .cts files563
Java.java files689
C.c and .h files373
C++.cpp, .cc, .cxx, .hpp, .hh and .hxx files291
C#.cs files344
PHP.php and .phtml files323
Kotlin.kt and .kts files280
Rust.rs files233
SQL.sql files201
HTML.html and .htm files131
CSS.css, .scss and .less files83
XML.xml files and XML formats such as .csproj and .xsl61
DockerfileDockerfiles43
TerraformTerraform .tf files90
KubernetesKubernetes manifests41
GitHub ActionsGitHub Actions workflows21
Docker ComposeDocker Compose files15
YAMLYAML files1
JSON.json files1
Secretsevery file313

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-traversalssrfxsssecretscryptoiac
  • reliabilitynull-safetyresourcesconcurrencymemory-safetyarithmetic
  • performancealgorithmicallocationioregex
  • maintainabilitycomplexityduplicationdead-code
  • stylenamingconventions
  • accessibilityweb
  • frameworksreactspringdjango

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

  1. fastone file, with the flow of values inside its functions
  2. projectthe declarations of the whole project: types, imports, members across files
  3. deepvalues followed across functions and files, such as input that reaches a query

Tier how many rules run

  1. defaultbugs and security problems with measured precision
  2. recommendedadds likely bugs, resource and performance problems
  3. strictadds code that can be written more plainly
  4. allevery 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

  1. default1 077Bugs and security problems with measured precision. Runs without a tx0.toml.
  2. recommended+1 774Likely bugs, resource and performance problems.
  3. strict+1 338Code that can be written more plainly.
  4. 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.h and limits.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.