How jacobdavidalcock/firescan works
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: scanner Scanner · services Services · ui UI · auth Auth
Components 26
Entry points
Main binaries for the CLI and end-to-end fixture-driven run.
CLI core
User interaction, config, logging, and runtime control plane.
- UI · Command parsing, prompts, history, formatting, and status presentation.
internal/ui - Config · Project settings and persisted session/auth state.
internal/config - Auth · Firebase sign-in, JWT refresh, account creation, provider enumeration, and logout.
internal/auth - Unauth · Unauthenticated scan path and control flow.
internal/unauth - Status · Progress and warning display plumbing for scan execution.
internal/status - Logger · Structured logging and diagnostic output.
internal/logger
Scanning pipeline
Candidate generation, policy checks, and service-specific enumeration.
- Scanner · Coordinates the main enumeration workflow across Firebase services.
internal/scanner - Wordlists · Built-in and custom wordlists used for discovery.
internal/wordlist - Validation · Validates user input and scan parameters.
internal/validation - Rate limit · Controls request pressure and scan pacing.
internal/ratelimit - Safety · 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 · Shared Firebase service helpers and HTTP abstraction.
internal/services - HTTP client · Shared HTTP client and request plumbing for Firebase API calls.
internal/httpclient - Storage · Storage-specific security checks and exposure probing.
internal/storage - RTDB · Realtime Database discovery and access probing.
internal/rtdb - Firestore · Firestore enumeration and access probing.
internal/scanner/firestore.go - RTDB scan · RTDB scanning workflow used by the orchestrator.
internal/scanner/rtdb.go - Storage scan · Storage scanning workflow used by the orchestrator.
internal/scanner/storage.go - Functions scan · Cloud Functions discovery and probing workflow.
internal/scanner/functions.go - Hosting scan · Hosting discovery and probing workflow.
internal/scanner/hosting.go - App Check · Firebase App Check related helper interactions.
internal/appcheck - FCM · Firebase Cloud Messaging helper interactions.
internal/fcm - Management · Firebase management API helper interactions.
internal/management
Fixture assets
Repository fixture project used by tests and end-to-end execution.
- Fixture · Bundled Firebase project used for integration and end-to-end validation.
test-fixture
Connections 31
- 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.