>, settings_table?: array, warnings: array} */ public function normalize(?array $snapshot, string $policyType, ?string $platform = null): array { $snapshot = is_array($snapshot) ? $snapshot : []; $displayName = Arr::get($snapshot, 'displayName') ?? Arr::get($snapshot, 'name'); $description = Arr::get($snapshot, 'description'); $settings = []; $settings[] = ['key' => 'Type', 'value' => $policyType]; if (is_string($displayName) && $displayName !== '') { $settings[] = ['key' => 'Display name', 'value' => $displayName]; } if (is_string($description) && $description !== '') { $settings[] = ['key' => 'Description', 'value' => $description]; } // Script content and large blobs should not dominate normalized output. // Keep only safe summary fields if present. $contentKeys = [ 'scriptContent', 'scriptContentBase64', 'detectionScriptContent', 'remediationScriptContent', ]; foreach ($contentKeys as $key) { $value = Arr::get($snapshot, $key); if (is_string($value) && $value !== '') { $settings[] = ['key' => $key, 'value' => sprintf('[content: %d chars]', strlen($value))]; } } $schedule = Arr::get($snapshot, 'runSchedule'); if (is_array($schedule) && $schedule !== []) { $settings[] = ['key' => 'Run schedule', 'value' => Arr::except($schedule, ['@odata.type'])]; } $frequency = Arr::get($snapshot, 'runFrequency'); if (is_string($frequency) && $frequency !== '') { $settings[] = ['key' => 'Run frequency', 'value' => $frequency]; } $roleScopeTagIds = Arr::get($snapshot, 'roleScopeTagIds'); if (is_array($roleScopeTagIds) && $roleScopeTagIds !== []) { $settings[] = ['key' => 'Scope tag IDs', 'value' => array_values($roleScopeTagIds)]; } return [ 'status' => 'ok', 'settings' => $settings, 'warnings' => [], ]; } /** * @return array */ public function flattenForDiff(?array $snapshot, string $policyType, ?string $platform = null): array { $normalized = $this->normalize($snapshot, $policyType, $platform); return $this->defaultNormalizer->flattenForDiff($normalized['settings'] ?? []); } }