# SAST overview

What vulnetix sast scans, which rules it runs, what it writes, and how it relates to vulnetix scan and the other Rego-engine commands.

SAST is for developers and reviewers who want flaws in the code they write, such as injection or unsafe calls, found on their own machine or in CI before the change merges. It reads your source, not your dependencies: use [SCA](/sca.md) for vulnerabilities in the packages you depend on, and [Secrets](/secrets.md) for hard-coded credentials.

`vulnetix sast` runs static analysis on the source files in a directory. It evaluates the CLI's built-in Rego rules, plus any rule packs you load with `--rule`, on your machine, using the Open Policy Agent engine compiled into the binary. It does not look up dependencies, licences, secrets, containers or IaC.

```bash
vulnetix sast                       # scan the current directory
vulnetix sast --fail-on high        # exit 1 on any high or critical finding
vulnetix sast -o results.sarif      # also write SARIF where you choose
```

## What runs

The CLI embeds 1,899 rules (see the [rules index](/sast/rules.md)). Each rule declares a `kind` in its metadata, and each command runs one kind:

| Command | Rule kind | Built-in rules |
|---|---|---|
| `vulnetix sast` | `sast` | 793 |
| `vulnetix secrets` | `secrets` | 1,092 |
| `vulnetix containers` | `oci` (and `container` from external packs) | 7 |
| `vulnetix iac` | `iac` | 7 |
| `vulnetix scan` | every kind, plus SCA and licences | all |

The kind lock applies to `--rule` packs too: `vulnetix sast --rule org/pack` runs only the pack's `sast` rules. A rule with no `kind` is `sast`.

Before compiling, the engine drops every rule whose declared languages are all absent from the scanned tree, judged by file extension and well-known file names. A Python-only repository compiles about 370 rules, not 793. Rules that declare no language, `generic`, or a language the filter does not know are always kept. See [Supported languages](/sast/reference/languages.md).

## What is read

| Input | Rule |
|---|---|
| Files | Text files under `--path`, at most `--depth` levels deep (default 3). |
| Size cap | 1 MiB of text per file. Larger, unreadable and binary files are listed in the run's notifications as not content-scanned. |
| Always skipped | `.git`, `node_modules`, `.hg`, `__pycache__`, `.tox` and the other build and cache directories in `internal/sast/input.go`. |
| `.gitignore` | Respected. `--include-ignored` (or `--sast-include-ignored`) reads ignored paths too. |
| `--exclude` | `.gitignore`-syntax pattern, repeatable, relative to `--path`. |

> [!CAREFUL] The default depth skips most of a Java or monorepo tree
> `--depth 3` counts the file itself: `a/b/main.py` is scanned, `a/b/c/main.py` is not, and nothing says so. `src/main/java/App.java` is already depth 4. Pass `--depth 10` (or higher) for any project that nests source more than two directories down.

## What it writes

| Path | When |
|---|---|
| `<path>/.vulnetix/sast.sarif` | SARIF 2.1.0, written when there is at least one finding. A clean run deletes the file. |
| `<path>/.vulnetix/memory.yaml` | Every run: counts, finding history, and suppressions recorded from `nosec` comments. |
| `-o <file>.sarif` | SARIF at a path you choose. |

Signed in, the run also uploads the findings as a SAST snapshot in the Resolve Platform and prints its URL. Without credentials the community fallback is used and nothing is stored for you. See [Output formats](/sast/reference/output-formats.md).

## Sections

| Page | For |
|---|---|
| [Quickstart](/sast/get-started/quickstart.md) | First scan, a CI gate, SARIF upload. |
| [Reading the results](/sast/guides/reading-results.md) | The terminal report, `--explain`, test-code and vendored groups. |
| [Suppressing findings](/sast/guides/suppressing-findings.md) | `nosec` comments, ignore rules, `--suppress-test-code`. |
| [Custom rules](/sast/guides/custom-rules.md) | Write Rego rules and load them with `--rule`. |
| [Flags](/sast/reference/flags.md) | Every flag, environment variable and exit code. |
| [Supported languages](/sast/reference/languages.md) | Language keys, file extensions and rule counts. |
| [Output formats](/sast/reference/output-formats.md) | SARIF fields, JSON report, the upload. |
| [Troubleshooting](/sast/reference/troubleshooting.md) | Problems with a scan and how to fix them. |
| [Rules index](/sast/rules.md) | Every built-in rule, filterable. |

## GitHub Actions

Run it in a workflow with the [sast GitHub Action](/sast/github-actions/sast.md): it uploads `sast.sarif` to code scanning, keeps the files as an artifact and attests them.

## Platform IaC

SAST has no config kind of its own: rule selection and packs are command-line flags. The scan gate can come from the organisation's quality gate, the [`QualityGate`](/platform-iac/kinds/quality-gate.md) kind (see [/quality-gates/](/quality-gates.md)). See the [kind catalogue](/platform-iac/kinds/catalogue.md).
