import type { Detection, Observations } from '../core/types.js'; import { faixaDe } from './confidence.js'; export function heuristicas(obs: Observations, jaDetectadas: Detection[]): Detection[] { const extra: Detection[] = []; const nomes = new Set(jaDetectadas.map((d) => d.nome)); if (obs.cdnAparente && !nomes.has(obs.cdnAparente)) { const evidencia = pistaCdn(obs); if (evidencia) { extra.push({ nome: obs.cdnAparente, categorias: ['CDN'], confianca: 80, faixa: faixaDe(80), evidencias: [evidencia], }); } } return extra; } function pistaCdn(obs: Observations) { const h = obs.headers; const cabecalhos = ['cf-ray', 'x-vercel-id', 'x-amz-cf-id', 'x-fastly-request-id', 'x-nf-request-id']; for (const c of cabecalhos) { if (h[c] != null) { return { fonte: 'header' as const, descricao: `cabeƧalho ${c}`, trecho: h[c] }; } } if (h['server']) { return { fonte: 'header' as const, descricao: 'cabeƧalho Server', trecho: h['server'] }; } return undefined; }