Files
osint/app/Osint/RunnerRegistry.php
T
cedry2k1992andClaude Sonnet 5 dc4388eabf Add OpenCorporates collector for org targets, gated on an API token
Closes the last coverage gap for org (person remains intentionally
unaddressed — no good free/non-scraping option exists). Unlike the
other 8 sources, OpenCorporates now requires an API token even on its
free tier (confirmed: keyless request gets 401). RunnerRegistry::has()
checks services.opencorporates.token is configured before exposing the
source as runnable, so it degrades to "not yet integrated" in the UI
rather than a broken Run button, until OPENCORPORATES_API_TOKEN is set.

Also fixes a real bug hit while building this: a RunnerRegistry::REQUIRES
class constant mapping source key to a closure crashed on file load
(PHP class constants can't hold closures) — inlined the one check
instead of building an abstraction for a single case.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-20 12:10:27 +03:00

61 lines
1.8 KiB
PHP

<?php
namespace App\Osint;
use App\Osint\Runners\CrtShRunner;
use App\Osint\Runners\DnsRunner;
use App\Osint\Runners\GravatarRunner;
use App\Osint\Runners\HoleheRunner;
use App\Osint\Runners\IpApiRunner;
use App\Osint\Runners\OpenCorporatesRunner;
use App\Osint\Runners\SherlockRunner;
use App\Osint\Runners\TheHarvesterRunner;
use App\Osint\Runners\WhoisRunner;
class RunnerRegistry
{
/**
* Maps a sources.key value to the Runner implementation that handles it.
* A source with no entry here (or a null `runner` column) isn't
* integrated yet.
*
* @var array<string, class-string<Runner>>
*/
private const RUNNERS = [
'sherlock' => SherlockRunner::class,
'crtsh' => CrtShRunner::class,
'whois' => WhoisRunner::class,
'ip-api' => IpApiRunner::class,
'theharvester' => TheHarvesterRunner::class,
'holehe' => HoleheRunner::class,
'gravatar' => GravatarRunner::class,
'dns' => DnsRunner::class,
'opencorporates' => OpenCorporatesRunner::class,
];
public function has(string $sourceKey): bool
{
if (! isset(self::RUNNERS[$sourceKey])) {
return false;
}
// OpenCorporates additionally needs an API token configured before
// it's actually runnable — otherwise it's hidden rather than shown
// as a broken "Run" button that always fails.
if ($sourceKey === 'opencorporates') {
return filled(config('services.opencorporates.token'));
}
return true;
}
public function resolve(string $sourceKey): Runner
{
if (! $this->has($sourceKey)) {
throw new RunnerException("No runner registered for source [{$sourceKey}].");
}
return app(self::RUNNERS[$sourceKey]);
}
}