Self-hosted OSINT exposure checker — is your email, username, phone or password leaked? Keyless sources: breaches, infostealer logs, COMB credentials, HIBP k-anonymity, 200-platform username grid. Docker one-command install, no API keys, no AI, Apache-2.0.
PHP breach-checkcredential-exposuredata-breachdigital-footprintemail-osintfree-osinthaveibeenpwnedip-reputationleaked-credentialsleaked-dataosintosint-apiosint-toolsphone-lookupprivacy-toolspublic-datapwned-passwordsself-hostedusername-checkusername-osint
v1.1.0: JSON/CSV export, ec:doctor self-test, username confidence tiers (#1)
Rana Khan8b11ccbdd9e2
diff --git a/.gitignore b/.gitignoreindex 12326ef..db37e4e 100644--- a/.gitignore+++ b/.gitignore@@ -23,3 +23,4 @@ yarn-error.logdatabase/database.sqlite/storage/app/database.sqlite/storage/app/env/+storage/framework/testing/diff --git a/CHANGELOG.md b/CHANGELOG.mdindex cf7d390..978d1db 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -2,6 +2,30 @@All notable changes to Exposure-Check-OSINT are documented here.+## [1.1.0] — 2026-10-21++### Added+- **JSON / CSV export** — every stored check can now be downloaded as a JSON+ document (full per-source detail) or a flat CSV (one row per source verdict)+ from the report page, the history table and right after a live check.+ Exports keep identifiers masked and re-strip credential material+ belt-and-braces, exactly like the stored rows.+- **`php artisan ec:doctor`** — install self-test: PHP version and required+ extensions, app key, admin password, storage writability, maigret site+ database validity, database + migration state, source-registry health, and+ a live reachability probe for all 18 sources (parallel, short timeout).+ Table output by default, structured JSON with `--json`; non-zero exit code+ when anything FAILs. Run it after install and any time results look wrong.+- **Username confidence tiers** — every username hit is now labeled+ `confirmed` (page-content or redirect verified) or `probable`+ (status-code only) — on the dashboard logo grid, in the report table and+ in the JSON/CSV exports. Older stored checks render without badges+ (graceful degradation).++### Fixed+- Reported version: `config/app.version` was still `1.0.0` inside the+ v1.0.1 release — now bumped correctly (report header shows v1.1.0).+## [1.0.1] — 2026-10-21### Fixeddiff --git a/README.md b/README.mdindex 4cade3d..37b484d 100644--- a/README.md+++ b/README.md@@ -66,8 +66,16 @@ That is the whole install: one Docker container (Apache + PHP + SQLite — no MyRedis, no API keys), a generated admin password, and `http://localhost:8080` ready.Details and non-Docker paths: [docs/SELF-HOSTING.md](docs/SELF-HOSTING.md).+Self-test the whole stack any time (18-source reachability, storage, database,+site database — seconds, no real check performed):++```bash+docker compose exec app php artisan ec:doctor # add --json for machine-readable output+```+```Sign in → paste an email → watch 18 sources answer in parallel → open the printable report.+Export any stored check as JSON or CSV — report page, history table, or right after a live check.```## 🔎 The 5 Checks@@ -75,7 +83,7 @@ Sign in → paste an email → watch 18 sources answer in parallel → open the| Check | Input | What it answers ||-------|-------|-----------------|| 📧 Email exposure | any email | Which breaches / stealer logs / COMB corpora contain it · disposable? · Gravatar? · which of ~120 platforms hold an account |-| 👤 Username exposure | one username | Which of 150 platforms have it registered (logo grid) · Bluesky · Hacker News |+| 👤 Username exposure | one username | Which of 150 platforms have it registered (logo grid, confidence tiers: confirmed vs probable) · Bluesky · Hacker News || 📱 Phone exposure | E.164 number | Valid, country, line type, carrier class · COMB leak association || 🔑 Password exposure | a password | How many times it appears in breach corpora — **hashed in your browser, 5-char prefix only** || 🌐 IP exposure | IPv4/IPv6 | Open ports + services · VPN/proxy/hosting classification |diff --git a/app/Console/Commands/EcDoctorCommand.php b/app/Console/Commands/EcDoctorCommand.phpnew file mode 100644index 0000000..b44b591--- /dev/null+++ b/app/Console/Commands/EcDoctorCommand.php@@ -0,0 +1,298 @@+<?php++declare(strict_types=1);++namespace App\Console\Commands;++use App\Modules\Osint\OsintCheckService;+use App\Modules\Osint\Sources\OsintSource;+use Illuminate\Console\Command;+use Illuminate\Support\Facades\DB;+use Illuminate\Support\Facades\Http;+use Illuminate\Support\Facades\Schema;+use Illuminate\Support\Facades\Storage;++/**+ * ec:doctor — install self-test (v1.1).+ *+ * Runs the full health matrix WITHOUT running a real check:+ * 1. environment — PHP version, required extensions, app key, admin password+ * 2. storage — writability, maigret site database validity+ * 3. database — reachable, migrations applied, audit table present+ * 4. source health — all 18 adapter classes instantiate and resolve+ * 5. reachability — ONE lightweight probe per source (the first request+ * spec for a synthetic identifier), fired in parallel with a short+ * timeout, so the whole doctor run finishes in seconds.+ *+ * Honesty rules (same as the product):+ * - a source that answers with ANY HTTP status is reachable (PASS);+ * - transport failure / timeout is WARN (unreachable now, never "broken");+ * - only config-level problems (missing extension, unwritable storage,+ * invalid site DB, dead database) are FAIL.+ *+ * Exit code: 0 = no FAIL (WARN allowed), 1 = at least one FAIL.+ * Output: human table by default, structured JSON with --json.+ */+class EcDoctorCommand extends Command+{+ protected $signature = 'ec:doctor+ {--json : Emit machine-readable JSON instead of the human table}+ {--timeout=8 : Per-source network probe timeout in seconds (2-30)}';++ protected $description = 'Self-test the install: environment, storage, database, source registry and live reachability of every source';++ /** @var array<int, array{status: string, name: string, detail: string}> */+ private array $checks = [];++ /** @var array<int, array{key: string, label: string, status: string, http: ?int, detail: string}> */+ private array $sourceProbes = [];++ public function handle(): int+ {+ $timeout = max(2, min(30, (int) $this->option('timeout')));++ $this->checkEnvironment();+ $this->checkStorage();+ $this->checkDatabase();+ $this->checkSourceRegistry();+ $this->probeSources($timeout);++ $passed = count(array_filter($this->checks, static fn ($c) => $c['status'] === 'PASS'))+ + count(array_filter($this->sourceProbes, static fn ($p) => $p['status'] === 'PASS'));+ $warned = count(array_filter($this->checks, static fn ($c) => $c['status'] === 'WARN'))+ + count(array_filter($this->sourceProbes, static fn ($p) => $p['status'] === 'WARN'));+ $failed = count(array_filter($this->checks, static fn ($c) => $c['status'] === 'FAIL'))+ + count(array_filter($this->sourceProbes, static fn ($p) => $p['status'] === 'FAIL'));++ if ($this->option('json')) {+ $this->line((string) json_encode([+ 'ok' => $failed === 0,+ 'passed' => $passed,+ 'warned' => $warned,+ 'failed' => $failed,+ 'checks' => $this->checks,+ 'sources' => $this->sourceProbes,+ ], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));+ } else {+ $rows = array_map(static fn ($c) => [$c['status'], $c['name'], $c['detail']], $this->checks);+ foreach ($this->sourceProbes as $p) {+ $rows[] = [$p['status'], 'source: ' . $p['key'], $p['detail']];+ }+ $this->table(['Status', 'Check', 'Detail'], $rows);+ $this->newLine();+ $this->info(sprintf('%d passed · %d warned · %d failed', $passed, $warned, $failed));+ if ($failed > 0) {+ $this->error('Install self-test FAILED — fix the FAIL rows above (most are one .env or permission change).');+ } elseif ($warned > 0) {+ $this->warn('Install is functional; WARN rows are transient (a source may be down right now).');+ } else {+ $this->info('Install is healthy — all sources reachable.');+ }+ }++ return $failed > 0 ? self::FAILURE : self::SUCCESS;+ }++ private function add(string $status, string $name, string $detail): void+ {+ $this->checks[] = ['status' => $status, 'name' => $name, 'detail' => $detail];+ }++ private function checkEnvironment(): void+ {+ $this->add(PHP_VERSION_ID >= 80200 ? 'PASS' : 'FAIL', 'PHP version', PHP_VERSION . (PHP_VERSION_ID >= 80200 ? '' : ' — PHP 8.2+ required'));++ $required = ['curl', 'dom', 'mbstring', 'openssl', 'pdo_sqlite', 'sqlite3', 'json'];+ $missing = array_values(array_filter($required, static fn ($e) => !extension_loaded($e)));+ $this->add($missing === [] ? 'PASS' : 'FAIL', 'PHP extensions', $missing === [] ? 'all required extensions loaded' : 'missing: ' . implode(', ', $missing));++ $this->add(config('app.key') !== null && config('app.key') !== '' ? 'PASS' : 'FAIL', 'App key', config('app.key') ? 'set' : 'missing — run: php artisan key:generate');++ $admin = (string) config('app.admin_password', '');+ $this->add($admin !== '' ? 'PASS' : 'WARN', 'Admin password', $admin !== '' ? 'configured (login possible)' : 'ADMIN_PASSWORD empty — login is impossible until you set it in .env');+ }++ private function checkStorage(): void+ {+ $dirs = [storage_path('app'), storage_path('framework'), storage_path('logs'), base_path('bootstrap/cache')];+ $unwritable = array_values(array_filter($dirs, static fn ($d) => !is_dir($d) || !is_writable($d)));+ $this->add($unwritable === [] ? 'PASS' : 'FAIL', 'Storage writable', $unwritable === [] ? 'storage + bootstrap/cache writable' : 'not writable: ' . implode(', ', array_map('realpath', $unwritable)));++ try {+ $raw = Storage::disk('local')->get('maigret/sites.json');+ $doc = is_string($raw) ? json_decode($raw, true) : null;+ $n = is_array($doc) && isset($doc['sites']) && is_array($doc['sites']) ? count($doc['sites']) : 0;+ if ($n >= 100) {+ $this->add('PASS', 'Maigret site database', $n . ' sites loaded (sites.json valid)');+ } elseif ($n > 0) {+ $this->add('WARN', 'Maigret site database', 'only ' . $n . ' sites — username footprint checks will be thin (expected >= 100)');+ } else {+ $this->add('FAIL', 'Maigret site database', 'storage/app/maigret/sites.json missing or invalid JSON — username checks will be unavailable');+ }+ } catch (\Throwable $e) {+ $this->add('FAIL', 'Maigret site database', 'unreadable: ' . $e->getMessage());+ }+ }++ private function checkDatabase(): void+ {+ $connection = (string) config('database.default', 'sqlite');++ if ($connection === 'sqlite' && (string) config('database.connections.sqlite.database') === ':memory:') {+ $this->add('PASS', 'Database', 'in-memory (testing)');++ return;+ }++ try {+ DB::connection($connection)->getPdo();+ $this->add('PASS', 'Database', 'reachable (' . $connection . ')');+ } catch (\Throwable $e) {+ $this->add('FAIL', 'Database', 'not reachable: ' . mb_substr($e->getMessage(), 0, 160));++ return;+ }++ try {+ $files = glob(database_path('migrations/*.php')) ?: [];+ $applied = Schema::hasTable('migrations') ? DB::table('migrations')->count() : 0;+ if ($applied >= count($files) && $files !== []) {+ $this->add('PASS', 'Migrations', $applied . ' applied, none pending');+ } elseif ($files === []) {+ $this->add('WARN', 'Migrations', 'no migration files found');+ } else {+ $this->add('WARN', 'Migrations', (count($files) - $applied) . ' pending — run: php artisan migrate');+ }+ } catch (\Throwable $e) {+ $this->add('WARN', 'Migrations', 'could not inspect: ' . mb_substr($e->getMessage(), 0, 160));+ }++ try {+ if (Schema::hasTable('exposure_checks')) {+ $this->add('PASS', 'Audit table', 'exposure_checks present (' . DB::table('exposure_checks')->count() . ' stored checks)');+ } else {+ $this->add('WARN', 'Audit table', 'exposure_checks missing — run: php artisan migrate');+ }+ } catch (\Throwable $e) {+ $this->add('WARN', 'Audit table', 'could not inspect: ' . mb_substr($e->getMessage(), 0, 160));+ }+ }++ /** @return array<int, OsintSource> */+ private function sources(): array+ {+ $out = [];+ foreach (OsintCheckService::SOURCES as $cls) {+ $out[] = app($cls);+ }++ return $out;+ }++ private function checkSourceRegistry(): void+ {+ $ok = 0;+ $errors = [];+ foreach (OsintCheckService::SOURCES as $cls) {+ try {+ $src = app($cls);+ $src->key();+ $src->label();+ $src->category();+ $ok++;+ } catch (\Throwable $e) {+ $errors[] = class_basename($cls) . ': ' . mb_substr($e->getMessage(), 0, 80);+ }+ }+ $this->add($errors === [] ? 'PASS' : 'FAIL', 'Source registry', $errors === []+ ? $ok . ' source adapters registered'+ : implode('; ', $errors));+ }++ private function probeSources(int $timeout): void+ {+ $samples = [+ 'email' => '[email protected]',+ 'username' => 'doctor',+ 'phone' => '+8801700000000',+ 'password' => '21BD1', // k-anonymity: synthetic 5-hex prefix, harmless range query+ 'ip' => '8.8.8.8',+ ];++ $probes = [];+ foreach ($this->sources() as $src) {+ $type = null;+ foreach (array_keys($samples) as $t) {+ if ($src->supports((string) $t)) {+ $type = (string) $t;++ break;+ }+ }+ if ($type === null) {+ $this->sourceProbes[] = ['key' => $src->key(), 'label' => $src->label(), 'status' => 'WARN', 'http' => null, 'detail' => 'no supported check type — skipped'];++ continue;+ }+ try {+ $specs = $src->requests($type, $samples[$type]);+ } catch (\Throwable $e) {+ $this->sourceProbes[] = ['key' => $src->key(), 'label' => $src->label(), 'status' => 'WARN', 'http' => null, 'detail' => 'probe build failed: ' . mb_substr($e->getMessage(), 0, 80)];++ continue;+ }+ if ($specs === []) {+ $this->sourceProbes[] = ['key' => $src->key(), 'label' => $src->label(), 'status' => 'WARN', 'http' => null, 'detail' => 'no probe request declared'];++ continue;+ }+ $probes[$src->key()] = ['label' => $src->label(), 'spec' => $specs[0]];+ }++ if ($probes === []) {+ return;+ }++ try {+ $responses = Http::pool(function ($pool) use ($probes, $timeout) {+ $pending = [];+ foreach ($probes as $key => $p) {+ $req = $pool->as($key)->timeout($timeout);+ $headers = $p['spec']['headers'] ?? [];+ if (is_array($headers) && $headers !== []) {+ $req = $req->withHeaders($headers);+ }+ $pending[] = strtoupper((string) ($p['spec']['method'] ?? 'GET')) === 'POST'+ ? $req->post((string) $p['spec']['url'], $p['spec']['body'] ?? [])+ : $req->get((string) $p['spec']['url']);+ }++ return $pending;+ });+ } catch (\Throwable $e) {+ foreach ($probes as $key => $p) {+ $this->sourceProbes[] = ['key' => $key, 'label' => $p['label'], 'status' => 'WARN', 'http' => null, 'detail' => 'probe pool failed: ' . mb_substr($e->getMessage(), 0, 80)];+ }++ return;+ }++ foreach ($probes as $key => $p) {+ $resp = $responses[$key] ?? null;+ // Pools surface transport failures either as a Response with+ // status 0 or as the exception object itself — handle both.+ if ($resp instanceof \Illuminate\Http\Client\Response) {+ $status = (int) $resp->status();+ } elseif ($resp instanceof \Throwable) {+ $status = 0;+ } else {+ $status = 0;+ }+ if ($status > 0) {+ $this->sourceProbes[] = ['key' => $key, 'label' => $p['label'], 'status' => 'PASS', 'http' => $status, 'detail' => 'reachable (HTTP ' . $status . ')'];+ } else {+ $this->sourceProbes[] = ['key' => $key, 'label' => $p['label'], 'status' => 'WARN', 'http' => null, 'detail' => 'unreachable (timeout / DNS / transport) — source card will honestly show unavailable'];+ }+ }+ }+}diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.phpnew file mode 100644index 0000000..52b983b--- /dev/null+++ b/app/Http/Controllers/ExportController.php@@ -0,0 +1,119 @@+<?php++declare(strict_types=1);++namespace App\Http\Controllers;++use App\Models\ExposureCheck;+use Illuminate\Http\Request;+use Symfony\Component\HttpFoundation\Response;++/**+ * GET /report/{check}/export/{format} — download a stored check as JSON or CSV.+ *+ * PRIVACY CONTRACT (unchanged from storage):+ * - the identifier stays MASKED in every export (j***[email protected]);+ * - credential material (ProxyNova lines) is re-stripped belt-and-braces+ * even though storage rows are already sanitized at write time;+ * - password checks store no per-source data by design — the CSV exports+ * one honest summary row for them, the JSON a clear empty-source list.+ */+class ExportController extends Controller+{+ public function export(Request $request, ExposureCheck $check, string $format): Response+ {+ if (!in_array($format, ['json', 'csv'], true)) {+ abort(404);+ }++ // Belt-and-braces: never let credential material leave in an export,+ // even if a future code path ever stored it by mistake.+ $sources = $check->results ?? [];+ if (is_array($sources)) {+ foreach ($sources as $i => $src) {+ if (is_array($src) && isset($src['data']) && is_array($src['data'])) {+ unset($sources[$i]['data']['credential_lines']);+ }+ }+ } else {+ $sources = [];+ }++ $checkedAt = $check->created_at?->utc()?->toIso8601String();++ return $format === 'json'+ ? $this->exportJson($check, $sources, $checkedAt)+ : $this->exportCsv($check, $sources, $checkedAt);+ }++ /** Full-fidelity document download (per-source detail included). */+ private function exportJson(ExposureCheck $check, array $sources, ?string $checkedAt): Response+ {+ $payload = [+ 'product' => 'Exposure-Check-OSINT',+ 'version' => (string) config('app.version'),+ 'generated_at' => now()->utc()->toIso8601String(),+ 'check' => [+ 'id' => $check->id,+ 'type' => $check->type,+ 'identifier_masked' => $check->identifier_masked,+ 'checked_at' => $checkedAt,+ 'exposure_score' => $check->exposure_score,+ 'hits' => $check->hits,+ 'sources_assessed' => $check->total_sources,+ ],+ 'sources' => array_values($sources),+ 'privacy' => 'Identifiers are stored masked + salted-hashed only. Password checks store no per-source data (k-anonymity: matching happens in your browser).',+ ];++ $json = json_encode($payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);++ return response($json === false ? '{}' : $json, 200, [+ 'Content-Type' => 'application/json',+ 'Content-Disposition' => 'attachment; filename="exposure-check-' . $check->id . '-' . $check->type . '.json"',+ ]);+ }++ /** Flat one-row-per-source table (opens cleanly in Excel / Sheets). */+ private function exportCsv(ExposureCheck $check, array $sources, ?string $checkedAt): Response+ {+ $filename = 'exposure-check-' . $check->id . '-' . $check->type . '.csv';++ return response()->streamDownload(function () use ($check, $sources, $checkedAt) {+ $out = fopen('php://output', 'w');+ // UTF-8 BOM so Excel detects the encoding+ fwrite($out, "\xEF\xBB\xBF");+ fputcsv($out, [+ 'check_id', 'checked_at_utc', 'type', 'identifier_masked',+ 'exposure_score', 'hits', 'source_key', 'source_label',+ 'category', 'status', 'severity', 'summary',+ ]);++ if ($sources === []) {+ fputcsv($out, [+ $check->id, $checkedAt, $check->type, $check->identifier_masked,+ $check->exposure_score, $check->hits, '(none stored)', 'Password checks match in your browser',+ '', '', '', 'No per-source data is stored by design (k-anonymity).',+ ]);+ } else {+ foreach ($sources as $src) {+ fputcsv($out, [+ $check->id,+ $checkedAt,+ $check->type,+ $check->identifier_masked,+ $check->exposure_score,+ $check->hits,+ (string) ($src['key'] ?? ''),+ (string) ($src['label'] ?? ''),+ (string) ($src['category'] ?? ''),+ (string) ($src['status'] ?? ''),+ (string) ($src['severity'] ?? ''),+ (string) ($src['summary'] ?? ''),+ ]);+ }+ }+ fclose($out);+ }, $filename, ['Content-Type' => 'text/csv; charset=UTF-8']);+ }+}diff --git a/app/Modules/Osint/Sources/MaigretSource.php b/app/Modules/Osint/Sources/MaigretSource.phpindex cc61b21..eff573a 100644--- a/app/Modules/Osint/Sources/MaigretSource.php+++ b/app/Modules/Osint/Sources/MaigretSource.php@@ -158,6 +158,8 @@ class MaigretSource implements OsintSource}$found = [];+ $confirmed = 0;+ $probable = 0;$free = 0;$assessed = 0;$unavailable = [];@@ -176,7 +178,15 @@ class MaigretSource implements OsintSource}if ($verdict['state'] === 'claimed') {$assessed++;- $found[] = ['site' => (string) ($site['name'] ?? $name), 'url' => str_replace('{username}', rawurlencode($identifier), (string) $site['url'])];+ // Confidence tier (v1.1): body- or redirect-verified hits are+ // 'confirmed'; bare 2xx status-code matches are 'probable'.+ $confidence = (($site['checkType'] ?? 'status_code') === 'status_code') ? 'probable' : 'confirmed';+ if ($confidence === 'confirmed') {+ $confirmed++;+ } else {+ $probable++;+ }+ $found[] = ['site' => (string) ($site['name'] ?? $name), 'url' => str_replace('{username}', rawurlencode($identifier), (string) $site['url']), 'confidence' => $confidence];} elseif ($verdict['state'] === 'free') {$assessed++;$free++;@@ -207,7 +217,7 @@ class MaigretSource implements OsintSourceif ($domain !== null) {$logos->registerSite($key, $domain);}- $accounts[] = ['site' => (string) $f['site'], 'url' => (string) $f['url'], 'status' => 'found'];+ $accounts[] = ['site' => (string) $f['site'], 'url' => (string) $f['url'], 'status' => 'found', 'confidence' => (string) ($f['confidence'] ?? 'probable')];}} catch (\Throwable $e) {// logo registration is display sugar — never affects verdicts@@ -219,6 +229,8 @@ class MaigretSource implements OsintSource'sites_in_db' => count($sites),'sites_checked' => $assessed,'sites_found' => $n,+ 'found_confirmed' => $confirmed,+ 'found_probable' => $probable,'sites_unavailable' => count($unavailable),];if ($accounts !== []) {@@ -238,8 +250,8 @@ class MaigretSource implements OsintSource'status' => 'hit','severity' => $n >= 10 ? 'medium' : 'low','summary' => sprintf(- 'This username is registered on %d of %d assessed popular sites, including %s%s — each public account widens the identity footprint.',- $n, $assessed, $list, $more+ 'This username is registered on %d of %d assessed popular sites — %d confirmed by page content, %d probable by status code alone — including %s%s. Each public account widens the identity footprint.',+ $n, $assessed, $confirmed, $probable, $list, $more),'data' => $data,];diff --git a/config/app.php b/config/app.phpindex cfc86cd..9dfc8a6 100644--- a/config/app.php+++ b/config/app.php@@ -2,7 +2,7 @@return ['name' => env('APP_NAME', 'Exposure-Check-OSINT'),- 'version' => '1.0.0',+ 'version' => '1.1.0','env' => env('APP_ENV', 'production'),'debug' => (bool) env('APP_DEBUG', false),'url' => env('APP_URL', 'http://localhost'),diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.phpindex e127346..e80a5fd 100644--- a/resources/views/dashboard.blade.php+++ b/resources/views/dashboard.blade.php@@ -57,6 +57,8 @@</div></div><a id="ox-report-link" class="btn btn-ghost" href="#" target="_blank" rel="noopener" hidden>📄 Open report</a>+ <a id="ox-export-json" class="btn btn-ghost" href="#" hidden>⬇ JSON</a>+ <a id="ox-export-csv" class="btn btn-ghost" href="#" hidden>⬇ CSV</a></div><div id="ox-password-result" class="card" hidden style="margin-top:14px"></div>@@ -223,16 +225,22 @@html += '<div class="ox-accounts">';accounts.slice(0, 60).forEach(function (a) {var key = encodeURIComponent(String(a.site).toLowerCase().replace(/[^a-z0-9]+/g, '_'));+ var conf = a.confidence === 'confirmed' ? '<i class="ox-conf conf-c" title="confirmed: page content verified">✓</i>'+ : (a.confidence === 'probable' ? '<i class="ox-conf conf-p" title="probable: status code only">~</i>' : '');html += '<a class="ox-acct" href="' + esc(a.url || '#') + '" target="_blank" rel="noopener" title="' + esc(a.site) + '">' +'<img class="lg" data-src="/osint-logo/' + key + '" alt="" data-site="' + esc(a.site) + '">' ++ conf +'<span>' + esc(a.site) + '</span></a>';});if (accounts.length > 60) html += '<span class="ox-acct more">+' + (accounts.length - 60) + ' more</span>';html += '</div>';+ if (d.found_confirmed !== undefined || d.found_probable !== undefined) {+ html += '<div class="ox-conf-line">' + (d.found_confirmed || 0) + ' confirmed (page content verified) · ' + (d.found_probable || 0) + ' probable (status code only)</div>';+ }}// data fields (skip the big grid/binary ones)- var skip = { accounts: 1, found_accounts: 1, profile_urls: 1, suffixes: 1, credential_lines: 1, unavailable_examples: 1 };+ var skip = { accounts: 1, found_accounts: 1, profile_urls: 1, suffixes: 1, credential_lines: 1, unavailable_examples: 1, found_confirmed: 1, found_probable: 1 };var kv = '';Object.keys(d).forEach(function (k) { if (!skip[k]) kv += fieldRow(k, d[k]); });if (kv) html += '<div class="ox-body">' + kv + '</div>';@@ -258,7 +266,12 @@document.getElementById('ox-pill-sources').textContent = (s.sources_assessed || 0) + ' sources checked';var link = document.getElementById('ox-report-link');- if (check.check_id) { link.hidden = false; link.href = '/report/' + check.check_id; } else { link.hidden = true; }+ var ej = document.getElementById('ox-export-json'), ec = document.getElementById('ox-export-csv');+ if (check.check_id) {+ link.hidden = false; link.href = '/report/' + check.check_id;+ ej.hidden = false; ej.href = '/report/' + check.check_id + '/export/json';+ ec.hidden = false; ec.href = '/report/' + check.check_id + '/export/csv';+ } else { link.hidden = true; ej.hidden = true; ec.hidden = true; }// category sectionsvar groups = {}, order = [];@@ -372,5 +385,10 @@.ox-acct img, .ox-tile { width:30px; height:30px; object-fit:contain; border-radius:7px; background:#0F172A; }.ox-acct span { max-width:70px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }.ox-acct.more { justify-content:center; font-size:11px; }+ .ox-acct { position:relative; }+ .ox-conf { position:absolute; top:4px; right:6px; font-style:normal; font-size:10px; font-weight:800; line-height:1; pointer-events:none; }+ .ox-conf.conf-c { color:#34D399; }+ .ox-conf.conf-p { color:#FBBF24; }+ .ox-conf-line { color:#64748B; font-size:11px; margin-top:8px; }</style>@endpushdiff --git a/resources/views/history.blade.php b/resources/views/history.blade.phpindex 7055adc..22129c7 100644--- a/resources/views/history.blade.php+++ b/resources/views/history.blade.php@@ -35,6 +35,8 @@<td style="color:var(--muted);font-size:12px">{{ $c->created_at?->format('M j, Y H:i') }}</td><td style="white-space:nowrap"><a class="btn btn-ghost" style="padding:5px 11px;font-size:11.5px" href="{{ route('report', $c) }}" target="_blank" rel="noopener">Report</a>+ <a class="btn btn-ghost" style="padding:5px 11px;font-size:11.5px" href="{{ route('report.export', [$c, 'json']) }}">JSON</a>+ <a class="btn btn-ghost" style="padding:5px 11px;font-size:11.5px" href="{{ route('report.export', [$c, 'csv']) }}">CSV</a><form method="POST" action="{{ route('history.destroy', $c) }}" style="display:inline" onsubmit="return confirm('Delete this check?')">@csrf @method('DELETE')<button class="btn btn-ghost" type="submit" style="padding:5px 11px;font-size:11.5px;color:var(--red)">Delete</button>diff --git a/resources/views/report.blade.php b/resources/views/report.blade.phpindex 2c4c820..838a26b 100644--- a/resources/views/report.blade.php+++ b/resources/views/report.blade.php@@ -29,10 +29,18 @@.footer { border-top:1px solid var(--line); margin-top:34px; padding-top:14px; color:var(--muted); font-size:11px; }.print-btn { position:fixed; right:22px; top:22px; background:#0F172A; color:#fff; border:0; border-radius:9px; padding:9px 16px; font-weight:700; cursor:pointer; }@media print { .print-btn { display:none; } body { font-size:12px; } .page { padding:0; } }+ .export-btns { position:fixed; right:22px; top:64px; display:flex; flex-direction:column; gap:6px; }+ .export-btns a { background:#F1F5F9; color:#0F172A; border-radius:8px; padding:7px 12px; font-size:12px; font-weight:700; text-decoration:none; }+ .export-btns a:hover { background:#E2E8F0; }+ @media print { .export-btns { display:none; } }</style></head><body><button class="print-btn" onclick="window.print()">🖨 Print / Save as PDF</button>+<div class="export-btns">+ <a href="{{ route('report.export', [$check, 'json']) }}">⬇ JSON</a>+ <a href="{{ route('report.export', [$check, 'csv']) }}">⬇ CSV</a>+</div><div class="page"><div class="head"><div>@@ -74,7 +82,16 @@<td><b>{{ $src['label'] ?? $src['key'] }}</b><div class="meta">{{ $src['category'] ?? '' }}</div></td><td><span class="chip {{ $src['status'] === 'hit' ? 'hit' : ($src['status'] === 'clean' ? 'clean' : 'unavail') }}">{{ $src['status'] }}</span>@if ($src['status'] === 'hit' && !empty($src['severity']))<div style="margin-top:4px"><span class="chip sev-{{ $src['severity'] }}">{{ $src['severity'] }}</span></div>@endif</td>- <td>{{ $src['summary'] ?? '' }}</td>+ <td>{{ $src['summary'] ?? '' }}+ @if (!empty($src['data']['found_accounts']))+ <div style="margin-top:6px">+ @foreach (array_slice($src['data']['found_accounts'], 0, 30) as $fa)+ <span class="chip {{ ($fa['confidence'] ?? '') === 'confirmed' ? 'clean' : 'sev-low' }}" style="margin:2px 3px 0 0; font-weight:600">{{ $fa['site'] }}@if (!empty($fa['confidence'])) · {{ $fa['confidence'] }}@endif</span>+ @endforeach+ @if (count($src['data']['found_accounts']) > 30)<span class="meta">+{{ count($src['data']['found_accounts']) - 30 }} more</span>@endif+ </div>+ @endif+ </td></tr>@endforeach@if (empty($check->results))diff --git a/routes/web.php b/routes/web.phpindex 5583053..1406fad 100644--- a/routes/web.php+++ b/routes/web.php@@ -6,6 +6,7 @@ use App\Http\Controllers\AssetController;use App\Http\Controllers\AuthController;use App\Http\Controllers\CheckController;use App\Http\Controllers\DashboardController;+use App\Http\Controllers\ExportController;use App\Http\Controllers\LicenseController;use App\Http\Controllers\SettingsController;use Illuminate\Support\Facades\Route;@@ -33,6 +34,11 @@ Route::middleware(['admin'])->group(function () {Route::get('/', [DashboardController::class, 'index'])->name('dashboard');Route::get('/history', [DashboardController::class, 'history'])->name('history');Route::get('/report/{check}', [DashboardController::class, 'report'])->name('report');++ // v1.1: download a stored check as JSON or CSV (same admin gate as+ // the report itself; identifiers stay masked, credentials stripped).+ Route::get('/report/{check}/export/{format}', [ExportController::class, 'export'])+ ->whereIn('format', ['json', 'csv'])->name('report.export');Route::delete('/history/{check}', [DashboardController::class, 'destroy'])->name('history.destroy');Route::post('/history/purge', [DashboardController::class, 'purge'])->name('history.purge');diff --git a/tests/Feature/DoctorCommandTest.php b/tests/Feature/DoctorCommandTest.phpnew file mode 100644index 0000000..84f748d--- /dev/null+++ b/tests/Feature/DoctorCommandTest.php@@ -0,0 +1,97 @@+<?php++declare(strict_types=1);++namespace Tests\Feature;++use App\Modules\Osint\OsintCheckService;+use Illuminate\Foundation\Testing\RefreshDatabase;+use Illuminate\Support\Facades\Artisan;+use Illuminate\Support\Facades\Http;+use Tests\TestCase;++/**+ * v1.1 ec:doctor — the install self-test command.+ * Pins: command registers + runs, JSON shape, exit code semantics, and the+ * 18-source reachability matrix (with faked network so CI stays hermetic).+ */+class DoctorCommandTest extends TestCase+{+ use RefreshDatabase;++ protected function setUp(): void+ {+ parent::setUp();+ config(['app.admin_password' => 'doctor-test']);+ }++ public function test_doctor_is_registered_and_reports_healthy_install_as_json(): void+ {+ Http::fake(['*' => Http::response('ok', 200)]);++ $exit = Artisan::call('ec:doctor', ['--json' => true]);+ $this->assertSame(0, $exit, 'healthy install must exit 0');++ $out = json_decode(Artisan::output(), true);+ $this->assertIsArray($out);+ $this->assertTrue($out['ok']);+ $this->assertSame(0, $out['failed']);+ $this->assertGreaterThan(0, $out['passed']);+ $this->assertNotEmpty($out['checks']);++ // every shipped source was probed; probed ones saw a response, local+ // data sources (no HTTP request, e.g. the disposable blocklist) WARN+ // honestly with 'no probe request declared' — never 'unreachable'.+ $this->assertCount(count(OsintCheckService::SOURCES), $out['sources']);+ $passes = 0;+ foreach ($out['sources'] as $probe) {+ $this->assertNotSame('FAIL', $probe['status']);+ $this->assertStringNotContainsString('unreachable', $probe['detail']);+ if ($probe['status'] === 'PASS') {+ $passes++;+ $this->assertSame(200, $probe['http']);+ }+ }+ $this->assertGreaterThanOrEqual(15, $passes, 'most sources should be reachable under Http::fake');++ // the config-level checks that must PASS in the test environment+ $byName = collect($out['checks'])->keyBy('name');+ $this->assertSame('PASS', $byName['PHP version']['status']);+ $this->assertSame('PASS', $byName['PHP extensions']['status']);+ $this->assertSame('PASS', $byName['App key']['status']);+ $this->assertSame('PASS', $byName['Admin password']['status']);+ $this->assertSame('PASS', $byName['Maigret site database']['status']);+ }++ public function test_doctor_warns_not_fails_when_a_source_is_unreachable(): void+ {+ // Everything times out (transport failure) — that is a WARN, never a FAIL.+ Http::fake(function () {+ throw new \Illuminate\Http\Client\ConnectionException('connection refused');+ });++ $exit = Artisan::call('ec:doctor', ['--json' => true]);+ $this->assertSame(0, $exit, 'unreachable sources alone must not fail the doctor');++ $out = json_decode(Artisan::output(), true);+ $this->assertTrue($out['ok']);+ $this->assertGreaterThan(0, $out['warned']);+ foreach ($out['sources'] as $probe) {+ $this->assertSame('WARN', $probe['status']);+ }+ }++ public function test_doctor_fails_when_app_key_is_missing(): void+ {+ config(['app.key' => null]);+ Http::fake(['*' => Http::response('ok', 200)]);++ $exit = Artisan::call('ec:doctor', ['--json' => true]);+ $this->assertSame(1, $exit, 'missing app key must FAIL the doctor');++ $out = json_decode(Artisan::output(), true);+ $this->assertFalse($out['ok']);+ $byName = collect($out['checks'])->keyBy('name');+ $this->assertSame('FAIL', $byName['App key']['status']);+ }+}diff --git a/tests/Feature/ExportTest.php b/tests/Feature/ExportTest.phpnew file mode 100644index 0000000..7d42a57--- /dev/null+++ b/tests/Feature/ExportTest.php@@ -0,0 +1,144 @@+<?php++declare(strict_types=1);++namespace Tests\Feature;++use App\Models\ExposureCheck;+use Illuminate\Foundation\Testing\RefreshDatabase;+use Tests\TestCase;++/**+ * v1.1 export endpoints: JSON + CSV downloads of stored checks.+ * Pins: auth gate, privacy (masked identifiers, credential re-strip),+ * correct headers, one-row-per-source CSV shape, password-check honesty.+ */+class ExportTest extends TestCase+{+ use RefreshDatabase;++ protected function setUp(): void+ {+ parent::setUp();+ config(['app.admin_password' => 'test-password-123']);+ }++ private function makeCheck(): ExposureCheck+ {+ return ExposureCheck::create([+ 'type' => 'username',+ 'identifier_hash' => str_repeat('a', 64),+ 'identifier_masked' => 'doc***',+ 'total_sources' => 3,+ 'hits' => 1,+ 'exposure_score' => 88,+ 'results' => [+ [+ 'key' => 'maigret', 'label' => 'Social Account Footprint — 150 popular sites',+ 'category' => 'profile', 'status' => 'hit', 'severity' => 'low',+ 'summary' => 'registered on 2 of 3 assessed popular sites',+ 'data' => [+ 'found_accounts' => [+ ['site' => 'GitHub', 'url' => 'https://github.com/doctor', 'confidence' => 'confirmed'],+ ['site' => 'ExampleSite', 'url' => 'https://example.org/doctor', 'confidence' => 'probable'],+ ],+ 'found_confirmed' => 1,+ 'found_probable' => 1,+ ],+ ],+ [+ 'key' => 'xposedornot', 'label' => 'XposedOrNot', 'category' => 'breach',+ 'status' => 'clean', 'severity' => 'info',+ 'summary' => 'not found in tracked breaches', 'data' => [],+ ],+ [+ 'key' => 'proxynova', 'label' => 'ProxyNova COMB', 'category' => 'breach',+ 'status' => 'hit', 'severity' => 'high',+ 'summary' => 'found in COMB corpus',+ // belt-and-braces: this must NEVER reach an export+ 'data' => ['credential_lines' => ['doctor:hunter2'], 'corpus' => 'comb'],+ ],+ ],+ ]);+ }++ public function test_exports_require_admin_session(): void+ {+ $check = $this->makeCheck();+ $this->get(route('report.export', [$check, 'json']))->assertRedirect(route('login'));+ $this->get(route('report.export', [$check, 'csv']))->assertRedirect(route('login'));+ }++ public function test_json_export_downloads_full_structure_without_credentials(): void+ {+ $check = $this->makeCheck();+ $this->post('/login', ['password' => 'test-password-123']);++ $resp = $this->get(route('report.export', [$check, 'json']));+ $resp->assertOk();+ $resp->assertHeader('Content-Type', 'application/json');+ $this->assertStringContainsString('attachment; filename="exposure-check-1-username.json"', (string) $resp->headers->get('Content-Disposition'));++ $json = $resp->json();+ $this->assertSame('Exposure-Check-OSINT', $json['product']);+ $this->assertSame('doc***', $json['check']['identifier_masked']);+ $this->assertSame(88, $json['check']['exposure_score']);+ $this->assertCount(3, $json['sources']);+ $this->assertSame('confirmed', $json['sources'][0]['data']['found_accounts'][0]['confidence']);++ // privacy: masked identifier only + credential material re-stripped+ $raw = (string) $resp->getContent();+ $this->assertStringNotContainsString('hunter2', $raw);+ $this->assertStringNotContainsString('credential_lines', $raw);+ $this->assertStringNotContainsString('doctor@', $raw);+ }++ public function test_csv_export_is_one_row_per_source_with_bom(): void+ {+ $check = $this->makeCheck();+ $this->post('/login', ['password' => 'test-password-123']);++ $resp = $this->get(route('report.export', [$check, 'csv']));+ $resp->assertOk();+ $this->assertStringContainsString('text/csv', (string) $resp->headers->get('Content-Type'));+ $this->assertStringContainsString('attachment; filename=exposure-check-1-username.csv', (string) $resp->headers->get('Content-Disposition'));++ $body = $resp->streamedContent();+ $this->assertStringStartsWith("\xEF\xBB\xBF", $body); // UTF-8 BOM for Excel+ $this->assertStringContainsString('source_key,source_label', $body);+ $this->assertStringContainsString('maigret', $body);+ $this->assertStringContainsString('xposedornot', $body);+ // 1 header + 3 source rows = 4 lines+ $this->assertCount(4, array_filter(explode("\n", trim($body, "\n"))));+ $this->assertStringNotContainsString('hunter2', $body);+ }++ public function test_password_check_exports_honest_empty_sources(): void+ {+ $check = ExposureCheck::create([+ 'type' => 'password',+ 'identifier_hash' => str_repeat('b', 64),+ 'identifier_masked' => 'SHA-1 prefix 21B**',+ 'total_sources' => 1,+ 'hits' => 0,+ 'exposure_score' => null,+ 'results' => null,+ ]);+ $this->post('/login', ['password' => 'test-password-123']);++ $csv = $this->get(route('report.export', [$check, 'csv']))->streamedContent();+ $this->assertStringContainsString('(none stored)', $csv);+ $this->assertStringContainsString('No per-source data is stored by design', $csv);++ $json = $this->get(route('report.export', [$check, 'json']))->json();+ $this->assertSame([], $json['sources']);+ $this->assertNull($json['check']['exposure_score']);+ }++ public function test_unknown_format_is_404(): void+ {+ $check = $this->makeCheck();+ $this->post('/login', ['password' => 'test-password-123']);+ $this->get('/report/' . $check->id . '/export/xml')->assertNotFound();+ }+}diff --git a/tests/Unit/MaigretConfidenceTest.php b/tests/Unit/MaigretConfidenceTest.phpnew file mode 100644index 0000000..4b92b95--- /dev/null+++ b/tests/Unit/MaigretConfidenceTest.php@@ -0,0 +1,141 @@+<?php++declare(strict_types=1);++namespace Tests\Unit;++use App\Modules\Osint\Sources\MaigretSource;+use GuzzleHttp\Psr7\Response as Psr7Response;+use Illuminate\Http\Client\Response;+use Illuminate\Support\Facades\Storage;+use Tests\TestCase;++/**+ * v1.1 username confidence tiers: body-verified hits are 'confirmed',+ * bare status-code matches are 'probable'. The tier is derived from the+ * site's checkType (maigret semantics) and flows into found_accounts,+ * the accounts grid payload and the summary sentence.+ */+class MaigretConfidenceTest extends TestCase+{+ protected function setUp(): void+ {+ parent::setUp();+ Storage::fake('local');+ Storage::disk('local')->put('maigret/sites.json', (string) json_encode([+ 'sites' => [+ 'BodySite' => [+ 'name' => 'BodySite', 'rank' => 1,+ 'url' => 'https://body.example/u/{username}',+ 'urlProbe' => 'https://body.example/u/{username}',+ 'checkType' => 'message',+ 'presenseStrs' => ['PROFILE_FOUND'],+ 'absenceStrs' => ['no such user'],+ ],+ 'CodeSite' => [+ 'name' => 'CodeSite', 'rank' => 2,+ 'url' => 'https://code.example/u/{username}',+ 'urlProbe' => 'https://code.example/u/{username}',+ 'checkType' => 'status_code',+ ],+ 'AwaySite' => [+ 'name' => 'AwaySite', 'rank' => 3,+ 'url' => 'https://away.example/u/{username}',+ 'urlProbe' => 'https://away.example/u/{username}',+ 'checkType' => 'message',+ 'presenseStrs' => ['PROFILE_FOUND'],+ 'absenceStrs' => ['no such user'],+ ],+ ],+ ]));+ }++ private function resp(int $status, string $body): Response+ {+ return new Response(new Psr7Response($status, [], $body));+ }++ public function test_hits_are_tiered_confirmed_vs_probable(): void+ {+ $src = new MaigretSource();+ $reqs = $src->requests('username', 'doctor');+ $this->assertCount(3, $reqs);++ $responses = [+ $reqs[0]['name'] => $this->resp(200, 'Welcome — PROFILE_FOUND'), // BodySite: message hit+ $reqs[1]['name'] => $this->resp(200, 'anything'), // CodeSite: status-only hit+ $reqs[2]['name'] => $this->resp(200, 'sorry, no such user'), // AwaySite: free+ ];++ $r = $src->parse('username', 'doctor', $responses);++ $this->assertSame('hit', $r['status']);+ $d = $r['data'];+ $this->assertSame(2, $d['sites_found']);+ $this->assertSame(1, $d['found_confirmed']);+ $this->assertSame(1, $d['found_probable']);++ // rank order preserved: BodySite (1) before CodeSite (2)+ $this->assertSame('BodySite', $d['found_accounts'][0]['site']);+ $this->assertSame('confirmed', $d['found_accounts'][0]['confidence']);+ $this->assertSame('CodeSite', $d['found_accounts'][1]['site']);+ $this->assertSame('probable', $d['found_accounts'][1]['confidence']);++ // accounts grid payload carries the tier too+ $this->assertSame('confirmed', $d['accounts'][0]['confidence']);+ $this->assertSame('probable', $d['accounts'][1]['confidence']);++ // the human summary explains the tiers+ $this->assertStringContainsString('1 confirmed by page content', (string) $r['summary']);+ $this->assertStringContainsString('1 probable by status code alone', (string) $r['summary']);+ }++ public function test_clean_verdict_has_zero_confidence_counts(): void+ {+ // MIN_ASSESSED_FOR_CLEAN is 10 — build 12 sites so 'clean' is honest.+ $sites = [];+ for ($i = 1; $i <= 12; $i++) {+ $sites['Site' . $i] = [+ 'name' => 'Site' . $i, 'rank' => $i,+ 'url' => 'https://s' . $i . '.example/u/{username}',+ 'urlProbe' => 'https://s' . $i . '.example/u/{username}',+ 'checkType' => 'message',+ 'presenseStrs' => ['PROFILE_FOUND'],+ 'absenceStrs' => ['no such user'],+ ];+ }+ Storage::disk('local')->put('maigret/sites.json', (string) json_encode(['sites' => $sites]));++ $src = new MaigretSource();+ $reqs = $src->requests('username', 'ghostuser');+ $this->assertCount(12, $reqs);++ $responses = [];+ foreach ($reqs as $i => $req) {+ $responses[$req['name']] = $this->resp($i === 0 ? 404 : 200, $i === 0 ? 'gone' : 'no such user');+ }++ $r = $src->parse('username', 'ghostuser', $responses);+ $this->assertSame('clean', $r['status']); // 12 assessed >= MIN_ASSESSED_FOR_CLEAN (10)+ $this->assertSame(0, $r['data']['found_confirmed']);+ $this->assertSame(0, $r['data']['found_probable']);+ $this->assertStringContainsString('No public account found', (string) $r['summary']);+ }++ public function test_unavailable_sites_never_become_hits(): void+ {+ $src = new MaigretSource();+ $reqs = $src->requests('username', 'doctor');++ $responses = [+ $reqs[0]['name'] => $this->resp(503, 'down'), // BodySite: error+ $reqs[1]['name'] => $this->resp(429, 'slow down'), // CodeSite: error+ $reqs[2]['name'] => $this->resp(200, 'no such user'),// AwaySite: free+ ];++ $r = $src->parse('username', 'doctor', $responses);+ // only 1 site assessed < MIN_ASSESSED_FOR_CLEAN(10) -> honest unavailable+ $this->assertSame('unavailable', $r['status']);+ $this->assertSame(0, $r['data']['sites_found']);+ }+}