# jacobdavidalcock/firescan architecture

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

- Interactive diagram: https://gitdiagram.com/jacobdavidalcock/firescan
- Repository: https://github.com/jacobdavidalcock/firescan

## Overview

1. FireScan is a Go-based CLI security auditor for Firebase projects. The repo is centered around one main binary, `cmd/firescan`, plus an `cmd/e2e` entrypoint for end-to-end testing against the included Firebase fixture project.

2. The top-level execution path is: user commands in the console → command parsing/dispatch in `internal/ui` → shared configuration/session state in `internal/config` → service-specific actions in the scanner/auth packages → results back to status/output. The tool is designed for both interactive use and scripted/non-interactive scans.

3. `internal/ui` is the presentation layer. It handles the console, command definitions, history, prompts, and formatting of results/status messages. `internal/status` and `internal/logger` provide the output plumbing for progress, warnings, and structured logs.

4. `internal/config` and `internal/auth` form the session/control plane. They store project settings such as `projectID`, `apiKey`, referer, and persisted auth/session data, and they handle Firebase sign-in, JWT refresh, account creation, provider enumeration, and logout. `internal/unauth` covers the unauthenticated scan path.

5. The central scanning workflow lives under `internal/scanner`. It fans out into service adapters for Realtime Database, Firestore, Storage, Cloud Functions, and Hosting. Each adapter is responsible for discovering endpoints/resources and probing access or exposure in its service domain.

6. The scanner is driven by candidate generation and workload control. `internal/wordlist` supplies built-in and custom wordlists, `internal/validation` checks user input and scan parameters, and `internal/ratelimit` plus worker concurrency settings control request pressure during enumeration.

7. Safety is an explicit architectural boundary. `internal/safety` and the `rules`/`write_access` packages separate read-only probing from safe write tests and deeper audit behavior. The README’s probe/test/audit modes are implemented as a policy layer that gates which operations the scanners are allowed to perform.

8. Firebase API access is abstracted through shared HTTP/service helpers in `internal/httpclient`, `internal/services`, and related support packages such as `internal/management`, `internal/appcheck`, and `internal/fcm`. These packages isolate the external service interactions from the CLI and scanning logic.

9. Data extraction and findings reporting are separate from discovery. The `extract` flow reuses the same authenticated service clients to pull data from Firestore or RTDB and write it out, while scan results are formatted either as human-readable console output or JSON for automation.

10. The repository includes integration fixtures under `test-fixture` that mimic a Firebase project: rules files, hosting/functions assets, storage config, and a wordlist. These fixtures support unit tests and the `cmd/e2e` path, while GitHub Actions (`build.yml`, `test.yml`, `release.yml`) handles CI, validation, and release packaging.

Main entry points: [`internal/scanner`](https://github.com/jacobdavidalcock/firescan/tree/main/internal/scanner) (Scanner), [`internal/services`](https://github.com/jacobdavidalcock/firescan/tree/main/internal/services) (Services), [`internal/ui`](https://github.com/jacobdavidalcock/firescan/tree/main/internal/ui) (UI), [`internal/auth`](https://github.com/jacobdavidalcock/firescan/tree/main/internal/auth) (Auth)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_cmd["Entry points"]
  node_node_cmd_firescan["firescan<br/>main CLI<br/>[main.go]"]
  node_node_cmd_e2e["e2e<br/>test runner<br/>[main.go]"]
end

subgraph group_group_core["CLI core"]
  node_node_ui["UI<br/>console layer"]
  node_node_config[("Config<br/>session state")]
  node_node_auth["Auth"]
  node_node_unauth["Unauth<br/>anonymous scan"]
  node_node_status["Status<br/>progress output"]
  node_node_logger["Logger<br/>structured logs"]
end

subgraph group_group_scan["Scanning pipeline"]
  node_node_scanner["Scanner<br/>scan orchestrator"]
  node_node_wordlist["Wordlists<br/>candidate source"]
  node_node_validation["Validation<br/>input checks"]
  node_node_ratelimit["Rate limit<br/>workload control"]
  node_node_safety{{"Safety<br/>policy gate"}}
end

subgraph group_group_services["Firebase access"]
  node_node_services["Services<br/>api helpers"]
  node_node_httpclient["HTTP client<br/>transport"]
  node_node_storage["Storage"]
  node_node_rtdb["RTDB<br/>database probing"]
  node_node_scanner_firestore["Firestore<br/>collection probe<br/>[firestore.go]"]
  node_node_scanner_rtdb["RTDB scan<br/>database scan<br/>[rtdb.go]"]
  node_node_scanner_storage["Storage scan<br/>bucket scan<br/>[storage.go]"]
  node_node_scanner_functions["Functions scan<br/>endpoint scan<br/>[functions.go]"]
  node_node_scanner_hosting["Hosting scan<br/>site probe<br/>[hosting.go]"]
  node_node_appcheck["App Check<br/>firebase helper"]
  node_node_fcm["FCM<br/>messaging helper"]
  node_node_management["Management<br/>admin helper"]
end

subgraph group_group_fixture["Fixture assets"]
  node_node_fixture[("Fixture<br/>firebase project")]
end

node_node_cmd_firescan -->|"starts"| node_node_ui
node_node_cmd_e2e -->|"uses"| node_node_fixture
node_node_ui -->|"loads"| node_node_config
node_node_ui -->|"reports"| node_node_status
node_node_ui -->|"logs"| node_node_logger
node_node_ui -->|"dispatches"| node_node_scanner
node_node_ui -->|"auth flows"| node_node_auth
node_node_ui -->|"anonymous mode"| node_node_unauth
node_node_scanner -->|"validates"| node_node_validation
node_node_scanner -->|"throttles"| node_node_ratelimit
node_node_scanner -->|"gates"| node_node_safety
node_node_scanner -->|"candidates"| node_node_wordlist
node_node_scanner -->|"runs"| node_node_scanner_rtdb
node_node_scanner -->|"runs"| node_node_scanner_firestore
node_node_scanner -->|"runs"| node_node_scanner_storage
node_node_scanner -->|"runs"| node_node_scanner_functions
node_node_scanner -->|"runs"| node_node_scanner_hosting
node_node_scanner_rtdb -->|"probes"| node_node_rtdb
node_node_scanner_storage -->|"probes"| node_node_storage
node_node_scanner_firestore -->|"calls"| node_node_services
node_node_scanner_functions -->|"calls"| node_node_services
node_node_scanner_hosting -->|"calls"| node_node_services
node_node_scanner -->|"transport"| node_node_httpclient
node_node_auth -->|"auth requests"| node_node_httpclient
node_node_auth -->|"persists"| node_node_config
node_node_unauth -->|"uses"| node_node_services
node_node_services -->|"wraps"| node_node_httpclient
node_node_services -->|"integrates"| node_node_appcheck
node_node_services -->|"integrates"| node_node_fcm
node_node_services -->|"integrates"| node_node_management
node_node_fixture -->|"drives"| node_node_scanner

click node_node_cmd_firescan "https://github.com/jacobdavidalcock/firescan/blob/main/cmd/firescan/main.go"
click node_node_cmd_e2e "https://github.com/jacobdavidalcock/firescan/blob/main/cmd/e2e/main.go"
click node_node_ui "https://github.com/jacobdavidalcock/firescan/tree/main/internal/ui"
click node_node_config "https://github.com/jacobdavidalcock/firescan/tree/main/internal/config"
click node_node_auth "https://github.com/jacobdavidalcock/firescan/tree/main/internal/auth"
click node_node_unauth "https://github.com/jacobdavidalcock/firescan/tree/main/internal/unauth"
click node_node_status "https://github.com/jacobdavidalcock/firescan/tree/main/internal/status"
click node_node_logger "https://github.com/jacobdavidalcock/firescan/tree/main/internal/logger"
click node_node_scanner "https://github.com/jacobdavidalcock/firescan/tree/main/internal/scanner"
click node_node_wordlist "https://github.com/jacobdavidalcock/firescan/tree/main/internal/wordlist"
click node_node_validation "https://github.com/jacobdavidalcock/firescan/tree/main/internal/validation"
click node_node_ratelimit "https://github.com/jacobdavidalcock/firescan/tree/main/internal/ratelimit"
click node_node_safety "https://github.com/jacobdavidalcock/firescan/tree/main/internal/safety"
click node_node_services "https://github.com/jacobdavidalcock/firescan/tree/main/internal/services"
click node_node_httpclient "https://github.com/jacobdavidalcock/firescan/tree/main/internal/httpclient"
click node_node_storage "https://github.com/jacobdavidalcock/firescan/tree/main/internal/storage"
click node_node_rtdb "https://github.com/jacobdavidalcock/firescan/tree/main/internal/rtdb"
click node_node_scanner_firestore "https://github.com/jacobdavidalcock/firescan/blob/main/internal/scanner/firestore.go"
click node_node_scanner_rtdb "https://github.com/jacobdavidalcock/firescan/blob/main/internal/scanner/rtdb.go"
click node_node_scanner_storage "https://github.com/jacobdavidalcock/firescan/blob/main/internal/scanner/storage.go"
click node_node_scanner_functions "https://github.com/jacobdavidalcock/firescan/blob/main/internal/scanner/functions.go"
click node_node_scanner_hosting "https://github.com/jacobdavidalcock/firescan/blob/main/internal/scanner/hosting.go"
click node_node_appcheck "https://github.com/jacobdavidalcock/firescan/tree/main/internal/appcheck"
click node_node_fcm "https://github.com/jacobdavidalcock/firescan/tree/main/internal/fcm"
click node_node_management "https://github.com/jacobdavidalcock/firescan/tree/main/internal/management"
click node_node_fixture "https://github.com/jacobdavidalcock/firescan/tree/main/test-fixture"

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_node_cmd_firescan,node_node_cmd_e2e toneBlue
class node_node_ui,node_node_config,node_node_auth,node_node_unauth,node_node_status,node_node_logger toneAmber
class node_node_scanner,node_node_wordlist,node_node_validation,node_node_ratelimit,node_node_safety toneMint
class node_node_services,node_node_httpclient,node_node_storage,node_node_rtdb,node_node_scanner_firestore,node_node_scanner_rtdb,node_node_scanner_storage,node_node_scanner_functions,node_node_scanner_hosting,node_node_appcheck,node_node_fcm,node_node_management toneRose
class node_node_fixture toneIndigo
```

## Components

### Entry points

Main binaries for the CLI and end-to-end fixture-driven run.

- [firescan](https://github.com/jacobdavidalcock/firescan/blob/main/cmd/firescan/main.go): main CLI · Primary Go binary for interactive and scripted scanning. · `cmd/firescan/main.go`
- [e2e](https://github.com/jacobdavidalcock/firescan/blob/main/cmd/e2e/main.go): test runner · End-to-end entrypoint that runs against the bundled Firebase fixture. · `cmd/e2e/main.go`

### CLI core

User interaction, config, logging, and runtime control plane.

- [UI](https://github.com/jacobdavidalcock/firescan/tree/main/internal/ui): console layer · Command parsing, prompts, history, formatting, and status presentation. · `internal/ui`
- [Config](https://github.com/jacobdavidalcock/firescan/tree/main/internal/config): session state · Project settings and persisted session/auth state. · `internal/config`
- [Auth](https://github.com/jacobdavidalcock/firescan/tree/main/internal/auth): firebase auth · Firebase sign-in, JWT refresh, account creation, provider enumeration, and logout. · `internal/auth`
- [Unauth](https://github.com/jacobdavidalcock/firescan/tree/main/internal/unauth): anonymous scan · Unauthenticated scan path and control flow. · `internal/unauth`
- [Status](https://github.com/jacobdavidalcock/firescan/tree/main/internal/status): progress output · Progress and warning display plumbing for scan execution. · `internal/status`
- [Logger](https://github.com/jacobdavidalcock/firescan/tree/main/internal/logger): structured logs · Structured logging and diagnostic output. · `internal/logger`

### Scanning pipeline

Candidate generation, policy checks, and service-specific enumeration.

- [Scanner](https://github.com/jacobdavidalcock/firescan/tree/main/internal/scanner): scan orchestrator · Coordinates the main enumeration workflow across Firebase services. · `internal/scanner`
- [Wordlists](https://github.com/jacobdavidalcock/firescan/tree/main/internal/wordlist): candidate source · Built-in and custom wordlists used for discovery. · `internal/wordlist`
- [Validation](https://github.com/jacobdavidalcock/firescan/tree/main/internal/validation): input checks · Validates user input and scan parameters. · `internal/validation`
- [Rate limit](https://github.com/jacobdavidalcock/firescan/tree/main/internal/ratelimit): workload control · Controls request pressure and scan pacing. · `internal/ratelimit`
- [Safety](https://github.com/jacobdavidalcock/firescan/tree/main/internal/safety): policy gate · Separates read-only probing from safe writes and deeper audit behavior. · `internal/safety`

### Firebase access

Shared clients and service-specific adapters for Firebase APIs.

- [Services](https://github.com/jacobdavidalcock/firescan/tree/main/internal/services): api helpers · Shared Firebase service helpers and HTTP abstraction. · `internal/services`
- [HTTP client](https://github.com/jacobdavidalcock/firescan/tree/main/internal/httpclient): transport · Shared HTTP client and request plumbing for Firebase API calls. · `internal/httpclient`
- [Storage](https://github.com/jacobdavidalcock/firescan/tree/main/internal/storage): storage security · Storage-specific security checks and exposure probing. · `internal/storage`
- [RTDB](https://github.com/jacobdavidalcock/firescan/tree/main/internal/rtdb): database probing · Realtime Database discovery and access probing. · `internal/rtdb`
- [Firestore](https://github.com/jacobdavidalcock/firescan/blob/main/internal/scanner/firestore.go): collection probe · Firestore enumeration and access probing. · `internal/scanner/firestore.go`
- [RTDB scan](https://github.com/jacobdavidalcock/firescan/blob/main/internal/scanner/rtdb.go): database scan · RTDB scanning workflow used by the orchestrator. · `internal/scanner/rtdb.go`
- [Storage scan](https://github.com/jacobdavidalcock/firescan/blob/main/internal/scanner/storage.go): bucket scan · Storage scanning workflow used by the orchestrator. · `internal/scanner/storage.go`
- [Functions scan](https://github.com/jacobdavidalcock/firescan/blob/main/internal/scanner/functions.go): endpoint scan · Cloud Functions discovery and probing workflow. · `internal/scanner/functions.go`
- [Hosting scan](https://github.com/jacobdavidalcock/firescan/blob/main/internal/scanner/hosting.go): site probe · Hosting discovery and probing workflow. · `internal/scanner/hosting.go`
- [App Check](https://github.com/jacobdavidalcock/firescan/tree/main/internal/appcheck): firebase helper · Firebase App Check related helper interactions. · `internal/appcheck`
- [FCM](https://github.com/jacobdavidalcock/firescan/tree/main/internal/fcm): messaging helper · Firebase Cloud Messaging helper interactions. · `internal/fcm`
- [Management](https://github.com/jacobdavidalcock/firescan/tree/main/internal/management): admin helper · Firebase management API helper interactions. · `internal/management`

### Fixture assets

Repository fixture project used by tests and end-to-end execution.

- [Fixture](https://github.com/jacobdavidalcock/firescan/tree/main/test-fixture): firebase project · Bundled Firebase project used for integration and end-to-end validation. · `test-fixture`

## Connections

- firescan → UI: starts · Main CLI enters the console command layer.
- e2e → Fixture: uses · End-to-end runner targets the bundled Firebase fixture.
- UI → Config: loads · UI reads and updates session/config state.
- UI → Status: reports · UI sends progress and status messages.
- UI → Logger: logs · UI emits structured diagnostics.
- UI → Scanner: dispatches · Commands are routed into the scanner orchestration layer.
- UI → Auth: auth flows · Interactive commands manage sign-in and logout.
- UI → Unauth: anonymous mode · UI can trigger unauthenticated scan paths.
- Scanner → Validation: validates · Scanner checks inputs and scan parameters.
- Scanner → Rate limit: throttles · Scanner applies workload and request pacing control.
- Scanner → Safety: gates · Safety policy decides which operations are allowed.
- Scanner → Wordlists: candidates · Scanner consumes built-in or custom candidate lists.
- Scanner → RTDB scan: runs · Orchestrator invokes the RTDB workflow.
- Scanner → Firestore: runs · Orchestrator invokes the Firestore workflow.
- Scanner → Storage scan: runs · Orchestrator invokes the Storage workflow.
- Scanner → Functions scan: runs · Orchestrator invokes the Functions workflow.
- Scanner → Hosting scan: runs · Orchestrator invokes the Hosting workflow.
- RTDB scan → RTDB: probes · RTDB scan uses the RTDB adapter.
- Storage scan → Storage: probes · Storage scan uses storage security helpers.
- Firestore → Services: calls · Firestore workflow uses shared Firebase service helpers.
- Functions scan → Services: calls · Functions workflow uses shared Firebase service helpers.
- Hosting scan → Services: calls · Hosting workflow uses shared Firebase service helpers.
- Scanner → HTTP client: transport · Scanner depends on shared HTTP transport for API access.
- Auth → HTTP client: auth requests · Auth operations use the shared HTTP client.
- Auth → Config: persists · Auth updates session and project settings.
- Unauth → Services: uses · Unauthenticated scans still rely on shared service helpers.
- Services → HTTP client: wraps · Shared service layer sits on top of HTTP transport.
- Services → App Check: integrates · Service helpers include App Check interactions.
- Services → FCM: integrates · Service helpers include messaging interactions.
- Services → Management: integrates · Service helpers include management API interactions.
- Fixture → Scanner: drives · Fixture project supports end-to-end scan execution.
