Implements Spec 118 baseline drift engine improvements: - Resumable, budget-aware evidence capture for baseline capture/compare runs (resume token + UI action) - “Why no findings?” reason-code driven explanations and richer run context panels - Baseline Snapshot resource (list/detail) with fidelity visibility - Retention command + schedule for pruning baseline-purpose PolicyVersions - i18n strings for Baseline Compare landing Verification: - `vendor/bin/sail bin pint --dirty --format agent` - `vendor/bin/sail artisan test --compact --filter=Baseline` (159 passed) Note: - `docs/audits/redaction-audit-2026-03-04.md` left untracked (not part of PR). Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #143
41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\BaselineSnapshot;
|
|
use App\Models\BaselineSnapshotItem;
|
|
use App\Support\Baselines\BaselineSubjectKey;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<BaselineSnapshotItem>
|
|
*/
|
|
class BaselineSnapshotItemFactory extends Factory
|
|
{
|
|
protected $model = BaselineSnapshotItem::class;
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$displayName = fake()->words(3, true);
|
|
$policyType = 'deviceConfiguration';
|
|
|
|
$subjectKey = BaselineSubjectKey::fromDisplayName($displayName);
|
|
$subjectExternalId = $subjectKey !== null
|
|
? BaselineSubjectKey::workspaceSafeSubjectExternalId($policyType, $subjectKey)
|
|
: fake()->uuid();
|
|
|
|
return [
|
|
'baseline_snapshot_id' => BaselineSnapshot::factory(),
|
|
'subject_type' => 'policy',
|
|
'subject_external_id' => $subjectExternalId,
|
|
'subject_key' => $subjectKey,
|
|
'policy_type' => $policyType,
|
|
'baseline_hash' => hash('sha256', fake()->uuid()),
|
|
'meta_jsonb' => ['display_name' => $displayName],
|
|
];
|
|
}
|
|
}
|