|
|
|
|
@ -510,18 +510,20 @@ class UserDataDeletionService
|
|
|
|
|
)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$owned = $connection->table('cloud_network_alert_events as event')
|
|
|
|
|
// Match ingestion's instance -> finding/event order. Holding an event
|
|
|
|
|
// first and deleting its instance later would create the inverse edge
|
|
|
|
|
// when a final Agent window is being committed concurrently.
|
|
|
|
|
$ownedInstanceIds = $connection->table('cloud_instances')
|
|
|
|
|
->whereIn('user_id', $userIds)->orderBy('id')->lockForUpdate()
|
|
|
|
|
->pluck('id')->map(static fn ($id): int => (int) $id)->all();
|
|
|
|
|
$owned = $ownedInstanceIds === [] ? [] : $connection
|
|
|
|
|
->table('cloud_network_alert_events as event')
|
|
|
|
|
->join(
|
|
|
|
|
'cloud_network_findings as finding',
|
|
|
|
|
'finding.id',
|
|
|
|
|
'=',
|
|
|
|
|
'event.finding_id'
|
|
|
|
|
)->join(
|
|
|
|
|
'cloud_instances as instance',
|
|
|
|
|
'instance.id',
|
|
|
|
|
'=',
|
|
|
|
|
'finding.instance_id'
|
|
|
|
|
)->whereIn('instance.user_id', $userIds)
|
|
|
|
|
)->whereIn('finding.instance_id', $ownedInstanceIds)
|
|
|
|
|
->pluck('event.id')->all();
|
|
|
|
|
$bound = $connection->table('cloud_network_alert_deliveries')
|
|
|
|
|
->whereIn('bound_admin_id', $userIds)->pluck('event_id')->all();
|
|
|
|
|
|