fix: harden account email and recovery contracts
parent
eaea180b49
commit
e0497dd08f
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cloud;
|
||||
|
||||
/** Canonical SQL predicates for administrator recovery inventories. */
|
||||
final class CloudJobRecoverySql
|
||||
{
|
||||
public static function pendingSql(string $alias): string
|
||||
{
|
||||
return '(' . self::incidentSql($alias) . ' OR '
|
||||
. CloudJobService::terminalRecoveryStateConflictSql($alias) . ')';
|
||||
}
|
||||
|
||||
public static function resourceLockedSql(string $alias): string
|
||||
{
|
||||
return '((' . $alias . ".phase = 'terminal' AND "
|
||||
. $alias . ".outcome = 'failed' AND "
|
||||
. $alias . ".effect_resolution = 'unknown' AND "
|
||||
. $alias . ".kind <> 'host_storage_configure') OR "
|
||||
. self::pendingSql($alias) . ')';
|
||||
}
|
||||
|
||||
private static function incidentSql(string $alias): string
|
||||
{
|
||||
$supported = self::sqlList(CloudOperationRecoveryPolicy::kinds());
|
||||
$repair = self::sqlList(CloudDispatchLedger::repairIncidentCodes());
|
||||
$aggregateKinds = self::sqlList(CloudJobService::aggregateKinds());
|
||||
$agent = '(' . $alias . ".execution_mode = 'agent' AND ("
|
||||
. '(' . $alias . '.dispatch_attempts IS NULL OR '
|
||||
. $alias . '.dispatch_attempts NOT IN (0, 1)) OR ('
|
||||
. $alias . ".phase = 'terminal' AND "
|
||||
. $alias . '.finalization_incident = 1 AND ('
|
||||
. $alias . '.finalization_error_code IN (' . $repair . ') OR ('
|
||||
. $alias . ".outcome = 'failed' AND "
|
||||
. $alias . ".status = 'failed' AND "
|
||||
. $alias . '.dispatch_attempts = 0 AND '
|
||||
. $alias . '.kind IN (' . $supported . ')) OR ('
|
||||
. $alias . '.dispatch_attempts IN (0, 1) AND '
|
||||
. $alias . '.effect_resolution IN (\'applied\', \'not_applied\') '
|
||||
. 'AND ' . $alias . '.kind IN (' . $supported . '))))))';
|
||||
$aggregateIncident = '(' . $alias . ".phase = 'terminal' AND "
|
||||
. $alias . '.parent_job_id IS NULL AND '
|
||||
. $alias . '.finalization_incident = 1 AND '
|
||||
. '(' . $alias . ".execution_mode = 'aggregate' OR "
|
||||
. $alias . '.kind IN (' . $aggregateKinds . ') OR '
|
||||
. $alias . '.finalization_error_code = '
|
||||
. "'recovery_aggregate_state_conflict'))";
|
||||
return '(' . $agent . ' OR '
|
||||
. CloudJobService::aggregateLocalStateConflictSql($alias)
|
||||
. ' OR ' . $aggregateIncident . ')';
|
||||
}
|
||||
|
||||
/** @param list<string> $values */
|
||||
private static function sqlList(array $values): string
|
||||
{
|
||||
return implode(', ', array_map(
|
||||
static fn (string $value): string => "'"
|
||||
. str_replace("'", "''", $value) . "'",
|
||||
$values
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -1,2 +1,2 @@
|
||||
{* Shared Venix CSS/JS cache key. Increment whenever a shared browser asset changes. *}
|
||||
{assign var=venix_asset_version value='2026102410' scope='global'}
|
||||
{assign var=venix_asset_version value='2026102411' scope='global'}
|
||||
|
||||
Loading…
Reference in New Issue