OpenCredentials/BIBLE
OpenCredentials — Project Bible
Single source of truth for what OpenCredentials IS, is NOT, and the rules that keep it coherent. README.md says how to build/run; this says how to think about the system.
1. The one sentence
OpenCredentials is a public-service credential-leak pipeline: it watches public GitHub for exposed credentials, fingerprints each match (SHA-256) without ever retaining the secret, optionally discloses it to the leaker's own repo (a private vulnerability report, else a courtesy issue), and tracks whether the leak gets remediated — a CLI scanner and a Blazor Server review UI sharing one SQL Server database (Azure SQL by default).
2. The product promise
- Detection + disclosure + measurement — never exploitation. The system records metadata only. It detects leaks, optionally discloses them to the leaker — privately via GitHub private vulnerability reporting when the repo supports it, otherwise via a public courtesy issue — and measures remediation over time.
- Non-retention at the code level. A raw regex match lives in one local variable, is hashed to SHA-256 + a short scheme prefix, and goes out of scope. It is never written to disk, logged, serialized, or returned from a function. See
§5 LAW-1. - Review precedes disclosure. Every exposure type defaults to
auto_inform = false. The auto-notify pass does nothing until a human flips a category on in the Web UI. See§5 LAW-2. - The research artifact and the operator are the same binary. Aggregate measurements (leak rate per provider, time-to-remediate, notice-to-remediation conversion) fall out of the pipeline for free.
- One database, two front doors, race-safe. The CLI scanner (
opencreds) and the Blazor UI read/write the sameOpenCredentialsdatabase (Azure SQL by default) via EF Core; multiple scanners can run while a human reviews. Pause/resume is coordinated through a singleScannerControlrow. See§5 LAW-5. - Loops forever, never crashes on a 403. Default mode scans on a 60s cadence, paces itself against GitHub's 30 req/min Code Search limit, and absorbs rate-limit headers. See
§5 LAW-3.
3. What it is NOT
- NOT a credential store. It does not retrieve, retain, transmit, log, or return any raw credential — only the SHA-256 fingerprint, the provider's fixed public prefix (never any secret characters), and the public repo/file pointers.
- NOT a validator. It never calls a provider API with a detected credential. Liveness is inferred from the recheck pass (does the hash still appear in the file?), never from authenticated probes.
- NOT an offensive-security tool. No exploitation, no pentest, no use of any found secret.
- NOT a private-repo scanner. Scope is public repositories indexed by GitHub Code Search only — no auth-walled endpoints, no cloning, no execution of repo code, no GitHub Enterprise.
- NOT a rate-limit evader. It does not rotate multiple PATs to multiply the budget (a GitHub AUP violation). For higher legitimate throughput, apply for GitHub Research Access.
- NOT the
v1/Python scraper.v1/is reference only (seev1/DEPRECATED.md); do not run or extend it.
4. Architecture canon
┌──────────────────────────────────────────────────┐
│ │
GitHub ─► 1. Scan ─► 2. Notify (gated) ─► 3. Recheck ───────┘
Code Search (every run)
+ Contents └─ writes Findings └─ writes
RemediationChecks
leaker repo ◄─── private advisory, else issue (only when auto_inform=true)
┌─────────────┐ ┌──────────────────────────────┐ ┌──────────────┐
│ Cli │ │ Shared (library) │ │ Blazor │
│ `opencreds` │──uses──│ Db · Scraper-DTOs · Patterns │──uses──│ Server UI │
│ scan/notify │ │ NoticeService · GitHubClient │ │ Findings/Viz │
│ /recheck │ │ OpenCredentialsContext (EF Core) │ │ /Settings │
└──────┬──────┘ └───────────────┬──────────────┘ └──────┬───────┘
│ │ │
└──────────────► Azure SQL `OpenCredentials` ◄───────┘
(ScannerControl row coordinates pause/resume)
4.1 Projects
OpenCredentials.Shared(v2/Shared/) — library: EF Core entities, DbContext, theDbpersistence facade, detection patterns, notice service, GitHub client, settings. Consumed by both front doors.OpenCredentials.Cli(v2/Cli/) — theopencredsexecutable: arg parsing, interactive + headless modes, the 3-phase pipeline, interactive TUI menu, heartbeat, HTML report.OpenCredentials.Blazor(v2/Blazor/) — Blazor Server review UI: Findings table, Visualizations (KPIs + charts), Settings (pause/resume + per-type auto-inform).
4.2 Domain model (NOUNS)
EF entities are defined in v2/Shared/Entities.cs; mapping in v2/Shared/OpenCredentialsContext.cs.
- Finding — one detected leak, keyed by
(KeySha256, RepoFullName, FilePath). Carries provider, exposure type, model hint, repo/file pointers, key prefix + length, first/last-seen. Never the secret. - ScannedFile — a
(repo, path)claim row; the atomic unit of concurrency-safe work distribution between scanners. - Notice — a disclosure record keyed by
(KeySha256, RepoFullName, FilePath, Channel)with statussent/failed.Channelisgithub_issue(public courtesy issue) orgithub_advisory(private security advisory). - RemediationCheck — a time-stamped recheck result per finding (
present/removed/repo_gone/file_gone/fetch_failed/blocked—blockedis a non-rate-limit 403 and is not rechecked again). - ExposureType — the broad category lookup (
ApiKey,ConnectionString,PrivateKey,PlainTextPassword), each with anAutoInformgate. Canon-as-data: seedocs/data/exposure_types.json. - ScannerControl — single-row cross-process control surface:
RequestedState, heartbeat, current label. - ProviderPattern — one detection rule (provider, exposure type, regex, search needle, model hints) in
v2/Shared/Patterns.cs. Code-owned (regexes), keyed byProvider.
4.3 Key services (VERBS)
Scraper.RunAsync(v2/Cli/Scraper.cs) — the 3-phase pipeline: scan (search → claim → fetch →ScanContent→ upsert),SendPendingNoticesAsync(gated by auto-inform),RecheckRemediationsAsync. Writes the HTML report each pass.Db(v2/Shared/Db.cs) — persistence facade overIDbContextFactory<OpenCredentialsContext>; atomicClaimScan/ReleaseScan,UpsertFinding, notice/recheck reads & writes, exposure-type auto-inform get/set, scanner control + heartbeat.NoticeService.SendVulnerabilityReportAsync(v2/Shared/NoticeService.cs) — the disclosure path both front doors use (the CLI notify pass and the Findings page Send/Retry button). Advisory-first: skips if either channel already has asentnotice; otherwise callsGitHubClient.TryOpenSecurityAdvisoryAsync(POST /repos/{owner}/{repo}/security-advisories/reports, private vulnerability reporting) and records channelgithub_advisory. Only a 404/403/422 (feature unavailable; a 403 carrying rate-limit headers does not count) falls back toSendAsync. Any other advisory failure is recorded as afailedadvisory and is retried privately — it never falls back to a public issue.NoticeService.SendAsync— the public-issue fallback: idempotent issue-open + notice persistence (channelgithub_issue); renders the courtesy template and callsGitHubClient.OpenIssueAsync.GitHubClient(v2/Shared/GitHubClient.cs) —SearchCodeAsync,FetchFileAsync,RefetchAsync,OpenIssueAsync,TryOpenSecurityAdvisoryAsync; all rate-limit handling funnels throughHandleRateLimitAsync. An internal constructor taking anHttpMessageHandleris the test seam for a fake GitHub API.GitHubTokenProvider(v2/Shared/GitHubTokenProvider.cs) — resolves the PAT viaMindAttic.Vault→ User Secrets →GITHUB_TOKEN→ legacy settings.json.
5. The Laws
This project inherits the org-wide MindAttic House Rules. Where a house law applies it is cited inline (
[see HOUSE-LAW-n]) and NOT restated. The laws below are OpenCredentials-specific.
OC-LAW-1 — Non-retention is enforced in code, not policy
The raw credential match exists in exactly one local variable, is reduced to (SHA-256, public prefix, length) by Scraper.Fingerprint — the public prefix is only the provider's fixed, documented token prefix (ghp_, npm_, AKIA, sk-, key-; nothing from the secret part), the URI scheme for a connection string, and empty for a plaintext password (Patterns.PublicPrefix), and is dropped (rawKey = null!) before scope exit. It is never written to disk, logged, serialized, returned from a function, or persisted. This is the project's prime directive and an IRB-defensible property. (Extends org-wide secret hygiene — see HOUSE-LAW-3.)
OC-LAW-2 — Disclosure is opt-in per exposure type; review precedes action
Every ExposureType.AutoInform defaults to false. The auto-notify pass (Scraper.SendPendingNoticesAsync) discloses ONLY for types a human has flipped on in the Web UI. Filing a public issue against an innocent repo is reputational harm, so review-then-act is the safe default. This is a project-specific specialization of HOUSE-LAW-2 (soft-disable / reversible by default).
OC-LAW-3 — The scanner never crashes on a rate limit
All GitHub rate-limit handling funnels through GitHubClient.HandleRateLimitAsync (honors Retry-After, X-RateLimit-Remaining=0/Reset, falls back to a 60s secondary back-off). The --loop mode rides this out indefinitely; an unexpected pass failure is logged and the loop continues. Indefinite, self-pacing operation is the contract.
OC-LAW-4 — No credential validation, ever
The tool never calls a provider API with a detected credential. Remediation liveness is inferred solely by re-fetching the public file and re-hashing (RecheckRemediationsAsync), never by an authenticated probe. Do not rotate multiple PATs to evade rate limits (GitHub AUP).
OC-LAW-5 — One engine, many front doors, one race-safe database
The CLI and Blazor app register the identical Shared engine and read/write the same SQL Server database (Azure SQL by default). Concurrent scanners coordinate through atomic ClaimScan (PK-uniqueness) and the single ScannerControl row; pause/resume works from either surface. (Project realization of HOUSE-LAW-6.)
OC-LAW-6 — Credentials resolve through MindAttic.Vault
The GitHub PAT is resolved by GitHubTokenProvider via the MindAttic.Vault configuration source (then User Secrets, then GITHUB_TOKEN, then a deprecated legacy file). No token is committed; the repo .gitignore defends against a stray settings.json. (Direct application of HOUSE-LAW-3.)
6. Verified state
Build/test evidence recorded 2026-10-03 (dotnet SDK 10.0.400, TFM net9.0, Windows PowerShell 5.1):
- Build: GREEN.
dotnet build OpenCredentials.sln -c Release→ Build succeeded, 0 Warning(s), 0 Error(s) (all four projects:Shared→net9.0/OpenCredentials.Shared.dll,Cli→net9.0/opencreds.dll,Blazor→net9.0/OpenCredentials.Blazor.dll,Tests→net9.0/OpenCredentials.Tests.dll). - Tests: 14 passed, 0 failed.
dotnet test OpenCredentials.slnrunsv2/Tests/OpenCredentials.Tests.csproj(NUnit + bUnit) against a fake GitHub API (in-processHttpMessageHandler) and an in-memory EF Core database — no network, no database server. Coverage is disclosure only: advisory-first routing (NoticeServiceDisclosureTests,NotifyPassTests,FindingsPageTests), the auto-inform gate, and notice idempotency. Detection, non-retention, remediation and concurrency stories remain🟡. - Runtime evidence: the
--headlessone-shot CLI mode is runnable and CI-shaped (exits non-zero on a failed pass). Persistence is SQL Server (theOpenCredentialsdatabase in Azure SQL by default); the root filesfindings.db*(legacy SQLite, untracked and gitignored since OC-T33) andfindings.htmare not read by v2.
tools/codex.ps1 doctorchecks that every file path cited in this bible exists on disk.
7. Active frontier
- Testing gap (highest priority): the test suite covers disclosure only. The non-retention guarantee (LAW-1) and concurrency safety (LAW-5) are asserted by code structure but not proven by tests. See RFC 0001 and the priority backlog in USER_STORIES.md.
- Open epics: see Epics in USER_STORIES.md — Detection, Disclosure, Remediation tracking, Review UI, Operations.
8. Quality bar
A feature is done (✅) only when:
dotnet build OpenCredentials.sln -c Releaseis clean (no new warnings in changed files).- A test or a reproducible run proves the behavior — and the story in USER_STORIES.md names that evidence. (Org-wide: HOUSE-LAW-8.)
- The non-retention invariant (LAW-1) is preserved — no new code path persists, logs, or returns a raw match.
- Anything touching disclosure respects the auto-inform gate (LAW-2).
- Versioning, when bumped, follows whole-number rules (HOUSE-LAW-1).
9. Glossary
- Exposure type — broad category of a leak:
ApiKey,ConnectionString,PrivateKey,PlainTextPassword. Carries theauto_informgate. Canon:docs/data/exposure_types.json. - Provider — the specific source of a credential (
anthropic,aws-access-key,postgres-uri, …); maps to oneProviderPattern. - Finding — a detected leak, identified by SHA-256 fingerprint + repo + file path. Never contains the secret.
- Fingerprint —
(SHA-256 hex, public prefix, length)computed from a raw match; the only thing persisted. The public prefix is the provider's fixed token prefix, the URI scheme, or empty — never a character of the secret. - Notice — a disclosure sent to the leaker's repo: a courtesy GitHub issue (
github_issue) or a private security advisory (github_advisory). - Remediation check — a re-fetch + re-hash that determines whether a previously-found leak is still present.
- auto_inform — per-exposure-type boolean gate; when
false(default) the CLI never auto-discloses findings of that type. - ScannerControl — the single DB row that lets the Web UI pause/resume any running scanner.
- Heartbeat — periodic
LastHeartbeatUtc+CurrentLabelwrite so the UI can show scanner liveness. - Headless / one-shot —
--headlesswith no--loop: a single CI-friendly pass that exits non-zero on failure. - MindAttic.Vault — shared configuration source resolving secrets from
%APPDATA%\MindAttic\....