Files
osint/app/Models/Target.php
T
cedry2k1992andClaude Sonnet 5 873699e23e Initial commit: Laravel OSINT platform
Multi-user OSINT investigation tool with owner-controlled per-user and
per-group access grants. Includes Sherlock, theHarvester, crt.sh, WHOIS,
and ip-api.com collectors wired through a pluggable Runner/queue pipeline,
investigation search, and printable/CSV/JSON reporting.

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

48 lines
1.5 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
#[Fillable(['investigation_id', 'created_by', 'type', 'value', 'notes'])]
class Target extends Model
{
public const TYPES = ['person', 'domain', 'email', 'username', 'ip', 'org'];
/**
* Format validation for the `value` column, per target type.
* Kept in sync with runners that assume a given shape (e.g.
* SherlockRunner's username charset check).
*
* @return array<int, string>
*/
public static function valueRulesFor(string $type): array
{
return match ($type) {
'email' => ['required', 'string', 'email', 'max:255'],
'domain' => ['required', 'string', 'max:255', 'regex:/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/'],
'ip' => ['required', 'ip'],
'username' => ['required', 'string', 'max:255', 'regex:/^[a-zA-Z0-9._-]+$/'],
default => ['required', 'string', 'max:255'],
};
}
public function investigation(): BelongsTo
{
return $this->belongsTo(Investigation::class);
}
public function creator(): BelongsTo
{
return $this->belongsTo(User::class, 'created_by');
}
public function findings(): HasMany
{
return $this->hasMany(Finding::class);
}
}