# praetorian-inc/titus architecture

> Architecture diagram of the GitHub repository praetorian-inc/titus, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/praetorian-inc/titus
- Repository: https://github.com/praetorian-inc/titus

## Overview

#### Purpose and entry points
Titus is a Go-based secrets scanner for source trees, Git history, repositories, container images, and extracted binary content. It is exposed as:
- CLI commands rooted at `cmd/titus/main.go` and `cmd/titus/root.go`, including scan, report, serve, rules, explore, and enumeration commands.
- An embeddable Go API in `titus.go`.
- A WASM scanner used by the Chrome extension: `wasm/main.go`, `wasm/scanner.go`.
- A Burp Suite Java extension: `burp/src/main/java/com/praetorian/titus/burp/TitusExtension.java`.

#### Scan orchestration and input acquisition
The CLI scan path coordinates inputs, rule selection, persistence, validation, scoring, and output in `cmd/titus/scan.go`. Enumeration adapters acquire scan material from local filesystems, Git repositories/history, GitHub/GitLab, OCI/Docker images, and SaaS sources; their shared boundary is `pkg/enum/enum.go`, with representative implementations in `pkg/enum/git.go`, `pkg/enum/docker.go`, and `pkg/enum/github.go`.

Acquired content is modeled with locations, provenance, snippets, matches, findings, and scores under `pkg/types/finding.go`, `pkg/types/provenance.go`, and `pkg/types/match.go`. This keeps source-specific acquisition separate from detection and reporting.

#### Rule loading and detection engine
Detection rules are embedded YAML assets, loaded and validated by `pkg/rule/loader.go` and `pkg/rule/validate.go`, with the default ruleset at `pkg/rule/rulesets/default.yml` and individual definitions under `pkg/rule/rules/`. Rules provide patterns, captures, metadata, filtering, noise behavior, and base risk inputs.

`pkg/scanner/core.go` drives scanning over content. `pkg/matcher/matcher.go` and `pkg/matcher/extended.go` implement matching, capture extraction, context, deduplication, and post-filtering. The matching backend is a material runtime boundary: `pkg/matcher/matcher_vectorscan.go` uses CGO-backed Vectorscan/Hyperscan when built with the relevant tag, while `pkg/matcher/matcher_default.go` provides the portable Go fallback.

#### Finding lifecycle: validation and scoring
Raw detections can be validated against provider APIs by the concurrent validation engine in `pkg/validator/engine.go`; provider-specific validators and declarative validator definitions live in `pkg/validator/` and `pkg/validator/validators/`. This is an outbound-network boundary and can contact credential-provider APIs.

Risk scoring is a separate stage in `pkg/scoring/engine.go`, using YAML and Go scorers from `pkg/scoring/scorers/` and provider clients such as `pkg/scoring/aws_client.go`. It combines rule metadata, accessibility context, and optionally live permission/blast-radius checks into typed scores.

#### Storage, reporting, and service protocol
Findings are persisted behind a store abstraction in `pkg/store/store.go`, with SQLite and memory implementations in `pkg/store/sqlite.go` and `pkg/store/memory.go`. CLI reporting rereads this datastore via `cmd/titus/report.go`; SARIF conversion is isolated in `pkg/sarif/sarif.go`.

`cmd/titus/serve.go` hosts the scanner behind an NDJSON stdin/stdout protocol implemented in `pkg/serve/server.go`. This process boundary permits non-Go clients to load rules once and submit scan requests without embedding Go.

#### Extension clients and infrastructure
The Burp extension launches and manages the CLI service process through `ProcessManager.java` and scans HTTP traffic through `TitusProcessScanner.java`; queueing, deduplication, persistence, and Burp issue reporting are handled by `ScanQueue.java`, `DedupCache.java`, and `IssueReporter.java`.

The Chrome extension packages the Go WASM artifact (`extension/lib/titus.wasm`) with service-worker, content, popup, dashboard, and IndexedDB layers at `extension/background/service-worker.js`, `extension/content/content.js`, and `extension/storage/db.js`. It scans browser-accessible page resources and stores findings locally.

Build infrastructure includes Go modules (`go.mod`), Gradle for the Burp JAR (`burp/build.gradle.kts`), and GitHub Actions CI/release workflows under `.github/workflows/`.

Main entry points: [`cmd/titus/scan.go`](https://github.com/praetorian-inc/titus/blob/main/cmd/titus/scan.go) (Scan orchestration), [`pkg/scanner/core.go`](https://github.com/praetorian-inc/titus/blob/main/pkg/scanner/core.go) (Scanner core), [`pkg/enum/enum.go`](https://github.com/praetorian-inc/titus/blob/main/pkg/enum/enum.go) (Enumeration adapters), [`pkg/types/finding.go`](https://github.com/praetorian-inc/titus/blob/main/pkg/types/finding.go) (Finding model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_cli["CLI commands<br/>Go CLI<br/>[main.go]"]
  node_scan_command["Scan orchestration<br/>CLI workflow<br/>[scan.go]"]
  node_go_api["Embeddable API<br/>Go API<br/>[titus.go]"]
end

subgraph group_acquisition["Acquisition"]
  node_enum_boundary{{"Enumeration adapters<br/>input boundary<br/>[enum.go]"}}
  node_git_enum["Git acquisition<br/>enumerator<br/>[git.go]"]
  node_image_enum["Container image acquisition<br/>enumerator<br/>[docker.go]"]
  node_github_enum["GitHub acquisition<br/>enumerator<br/>[github.go]"]
  node_finding_types["Finding model<br/>typed domain model<br/>[finding.go]"]
end

subgraph group_engine["Detection lifecycle"]
  node_rules["Rule loader &amp; validation<br/>rule registry<br/>[loader.go]"]
  node_scanner{{"Scanner core<br/>scan engine<br/>[core.go]"}}
  node_matcher{{"Matcher pipeline<br/>detection engine<br/>[matcher.go]"}}
  node_vectorscan["Vectorscan backend<br/>CGO backend"]
  node_go_matcher["Portable matcher backend<br/>Go fallback<br/>[matcher_default.go]"]
  node_validator{{"Validation engine<br/>network validation<br/>[engine.go]"}}
  node_scoring{{"Scoring engine<br/>risk scoring<br/>[engine.go]"}}
end

subgraph group_delivery["Storage &amp; delivery"]
  node_store[("Finding store<br/>storage abstraction<br/>[store.go]")]
  node_report["CLI reporting &amp; SARIF<br/>[report.go]"]
  node_serve{{"NDJSON scanner service<br/>process protocol<br/>[server.go]"}}
end

subgraph group_clients["Extension clients"]
  node_wasm_scanner["WASM scanner<br/>browser runtime<br/>[scanner.go]"]
  node_chrome_extension["Chrome extension<br/>browser client<br/>[service-worker.js]"]
  node_burp_extension["Burp Suite extension<br/>Java client"]
end

node_cli -->|"runs"| node_scan_command
node_scan_command -->|"acquires input"| node_enum_boundary
node_go_api -->|"invokes"| node_scanner
node_git_enum -->|"implements"| node_enum_boundary
node_image_enum -->|"implements"| node_enum_boundary
node_github_enum -->|"implements"| node_enum_boundary
node_enum_boundary -->|"produces content context"| node_finding_types
node_scan_command -->|"loads rules"| node_rules
node_scan_command -->|"orchestrates"| node_scanner
node_finding_types -->|"scan material"| node_scanner
node_rules -->|"scan rules"| node_scanner
node_scanner -->|"detects with"| node_matcher
node_matcher -.->|"CGO build"| node_vectorscan
node_matcher -.->|"default build"| node_go_matcher
node_matcher -->|"raw findings"| node_finding_types
node_scan_command -->|"optionally validates"| node_validator
node_validator -->|"validation state"| node_finding_types
node_scan_command -->|"scores"| node_scoring
node_scoring -->|"typed scores"| node_finding_types
node_scan_command -->|"persists"| node_store
node_report -->|"reads findings"| node_store
node_cli -->|"runs"| node_report
node_cli -->|"hosts"| node_serve
node_serve -->|"submits requests"| node_scanner
node_wasm_scanner -.->|"browser build variant"| node_scanner
node_chrome_extension -->|"packages"| node_wasm_scanner
node_burp_extension -->|"manages CLI process"| node_serve

click node_cli "https://github.com/praetorian-inc/titus/blob/main/cmd/titus/main.go"
click node_scan_command "https://github.com/praetorian-inc/titus/blob/main/cmd/titus/scan.go"
click node_go_api "https://github.com/praetorian-inc/titus/blob/main/titus.go"
click node_enum_boundary "https://github.com/praetorian-inc/titus/blob/main/pkg/enum/enum.go"
click node_git_enum "https://github.com/praetorian-inc/titus/blob/main/pkg/enum/git.go"
click node_image_enum "https://github.com/praetorian-inc/titus/blob/main/pkg/enum/docker.go"
click node_github_enum "https://github.com/praetorian-inc/titus/blob/main/pkg/enum/github.go"
click node_finding_types "https://github.com/praetorian-inc/titus/blob/main/pkg/types/finding.go"
click node_rules "https://github.com/praetorian-inc/titus/blob/main/pkg/rule/loader.go"
click node_scanner "https://github.com/praetorian-inc/titus/blob/main/pkg/scanner/core.go"
click node_matcher "https://github.com/praetorian-inc/titus/blob/main/pkg/matcher/matcher.go"
click node_vectorscan "https://github.com/praetorian-inc/titus/blob/main/pkg/matcher/matcher_vectorscan.go"
click node_go_matcher "https://github.com/praetorian-inc/titus/blob/main/pkg/matcher/matcher_default.go"
click node_validator "https://github.com/praetorian-inc/titus/blob/main/pkg/validator/engine.go"
click node_scoring "https://github.com/praetorian-inc/titus/blob/main/pkg/scoring/engine.go"
click node_store "https://github.com/praetorian-inc/titus/blob/main/pkg/store/store.go"
click node_report "https://github.com/praetorian-inc/titus/blob/main/cmd/titus/report.go"
click node_serve "https://github.com/praetorian-inc/titus/blob/main/pkg/serve/server.go"
click node_wasm_scanner "https://github.com/praetorian-inc/titus/blob/main/wasm/scanner.go"
click node_chrome_extension "https://github.com/praetorian-inc/titus/blob/main/extension/background/service-worker.js"
click node_burp_extension "https://github.com/praetorian-inc/titus/blob/main/burp/src/main/java/com/praetorian/titus/burp/TitusExtension.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_scan_command,node_go_api toneBlue
class node_enum_boundary,node_git_enum,node_image_enum,node_github_enum,node_finding_types toneAmber
class node_rules,node_scanner,node_matcher,node_vectorscan,node_go_matcher,node_validator,node_scoring toneMint
class node_store,node_report,node_serve toneRose
class node_wasm_scanner,node_chrome_extension,node_burp_extension toneIndigo
```

## Components

### Entry points

- [CLI commands](https://github.com/praetorian-inc/titus/blob/main/cmd/titus/main.go): Go CLI · Scan, report, serve, rules, explore, and enumeration commands. · `cmd/titus/main.go`
- [Scan orchestration](https://github.com/praetorian-inc/titus/blob/main/cmd/titus/scan.go): CLI workflow · Coordinates input, rules, persistence, validation, scoring, and output. · `cmd/titus/scan.go`
- [Embeddable API](https://github.com/praetorian-inc/titus/blob/main/titus.go): Go API · `titus.go`

### Acquisition

- [Enumeration adapters](https://github.com/praetorian-inc/titus/blob/main/pkg/enum/enum.go): input boundary · Acquires files, Git history, repositories, images, and SaaS content. · `pkg/enum/enum.go`
- [Git acquisition](https://github.com/praetorian-inc/titus/blob/main/pkg/enum/git.go): enumerator · `pkg/enum/git.go`
- [Container image acquisition](https://github.com/praetorian-inc/titus/blob/main/pkg/enum/docker.go): enumerator · `pkg/enum/docker.go`
- [GitHub acquisition](https://github.com/praetorian-inc/titus/blob/main/pkg/enum/github.go): enumerator · `pkg/enum/github.go`
- [Finding model](https://github.com/praetorian-inc/titus/blob/main/pkg/types/finding.go): typed domain model · Locations, provenance, snippets, matches, findings, and scores. · `pkg/types/finding.go`

### Detection lifecycle

- [Rule loader & validation](https://github.com/praetorian-inc/titus/blob/main/pkg/rule/loader.go): rule registry · Loads embedded YAML rules and validates rule definitions. · `pkg/rule/loader.go`
- [Scanner core](https://github.com/praetorian-inc/titus/blob/main/pkg/scanner/core.go): scan engine · Drives rule scanning over acquired content. · `pkg/scanner/core.go`
- [Matcher pipeline](https://github.com/praetorian-inc/titus/blob/main/pkg/matcher/matcher.go): detection engine · Matches patterns, extracts captures, applies context, deduplication, and filters. · `pkg/matcher/matcher.go`
- [Vectorscan backend](https://github.com/praetorian-inc/titus/blob/main/pkg/matcher/matcher_vectorscan.go): CGO backend · Tagged Vectorscan/Hyperscan matcher runtime. · `pkg/matcher/matcher_vectorscan.go`
- [Portable matcher backend](https://github.com/praetorian-inc/titus/blob/main/pkg/matcher/matcher_default.go): Go fallback · `pkg/matcher/matcher_default.go`
- [Validation engine](https://github.com/praetorian-inc/titus/blob/main/pkg/validator/engine.go): network validation · Concurrently checks raw detections against provider APIs. · `pkg/validator/engine.go`
- [Scoring engine](https://github.com/praetorian-inc/titus/blob/main/pkg/scoring/engine.go): risk scoring · Combines rule metadata, context, and optional live permission checks. · `pkg/scoring/engine.go`

### Storage & delivery

- [Finding store](https://github.com/praetorian-inc/titus/blob/main/pkg/store/store.go): storage abstraction · SQLite and memory-backed finding persistence. · `pkg/store/store.go`
- [CLI reporting & SARIF](https://github.com/praetorian-inc/titus/blob/main/cmd/titus/report.go): reporting · Rereads stored findings and converts them to SARIF. · `cmd/titus/report.go`
- [NDJSON scanner service](https://github.com/praetorian-inc/titus/blob/main/pkg/serve/server.go): process protocol · Long-lived stdin/stdout service for non-Go clients. · `pkg/serve/server.go`

### Extension clients

- [WASM scanner](https://github.com/praetorian-inc/titus/blob/main/wasm/scanner.go): browser runtime · Go scanner compiled for the Chrome extension. · `wasm/scanner.go`
- [Chrome extension](https://github.com/praetorian-inc/titus/blob/main/extension/background/service-worker.js): browser client · Scans page resources and persists findings in IndexedDB. · `extension/background/service-worker.js`
- [Burp Suite extension](https://github.com/praetorian-inc/titus/blob/main/burp/src/main/java/com/praetorian/titus/burp/TitusExtension.java): Java client · Launches the CLI service and scans HTTP traffic. · `burp/src/main/java/com/praetorian/titus/burp/TitusExtension.java`

## Connections

- CLI commands → Scan orchestration: runs
- Scan orchestration → Enumeration adapters: acquires input
- Embeddable API → Scanner core: invokes
- Git acquisition → Enumeration adapters: implements
- Container image acquisition → Enumeration adapters: implements
- GitHub acquisition → Enumeration adapters: implements
- Enumeration adapters → Finding model: produces content context
- Scan orchestration → Rule loader & validation: loads rules
- Scan orchestration → Scanner core: orchestrates
- Finding model → Scanner core: scan material
- Rule loader & validation → Scanner core: scan rules
- Scanner core → Matcher pipeline: detects with
- Matcher pipeline → Vectorscan backend: CGO build
- Matcher pipeline → Portable matcher backend: default build
- Matcher pipeline → Finding model: raw findings
- Scan orchestration → Validation engine: optionally validates
- Validation engine → Finding model: validation state
- Scan orchestration → Scoring engine: scores
- Scoring engine → Finding model: typed scores
- Scan orchestration → Finding store: persists
- CLI reporting & SARIF → Finding store: reads findings
- CLI commands → CLI reporting & SARIF: runs
- CLI commands → NDJSON scanner service: hosts
- NDJSON scanner service → Scanner core: submits requests
- WASM scanner → Scanner core: browser build variant
- Chrome extension → WASM scanner: packages
- Burp Suite extension → NDJSON scanner service: manages CLI process
