(btn, statusDiv, logDiv)
| 10746 | const qs = '?seconds=' + encodeURIComponent(secs) + (iface ? '&interface=' + encodeURIComponent(iface) : '') + |
| 10747 | (ceil !== '' ? '&md_ceiling=' + encodeURIComponent(ceil) : ''); |
| 10748 | const d = await fetchAPI('/api/net/cfm-watch' + qs); |
| 10749 | if (!d || d.success === false) { |
| 10750 | const msg = (d && d.error) || 'failed'; |
| 10751 | let extra = ''; |
| 10752 | if (d && d.missing_tool) extra = ' <button onclick="installNetTool(\'tcpdump\', this, runCfmWatch)" class="ml-2 underline text-cyan-400">Install tcpdump</button>'; |
| 10753 | out.innerHTML = '<p class="text-sm text-red-400">Error: ' + escapeHtml(msg) + extra + '</p>'; |
| 10754 | return; |
| 10755 | } |
| 10756 | const [cls, label] = _CFM_VERDICT_STYLE[d.verdict] || _CFM_VERDICT_STYLE.unknown; |
| 10757 | const inv = d.inventory || {}; |
| 10758 | let html = `<div class="mb-2 px-3 py-2 rounded border ${cls} text-sm">${label}</div>`; |
| 10759 | html += `<p class="text-xs text-gray-500 mb-2">Interface: ${escapeHtml(d.interface || '—')} · ${d.seconds}s · ${d.packet_count} CFM frame(s) · ${(inv.meps || []).length} MEP(s)` + |
| 10760 | (d.md_ceiling !== null && d.md_ceiling !== undefined ? ` · MD ceiling ${d.md_ceiling}` : '') + '</p>'; |
| 10761 | const findings = (d.findings || []).filter(f => f.klass !== 'P'); |
| 10762 | if (findings.length) { |
| 10763 | html += '<table class="min-w-full text-xs text-gray-300 whitespace-nowrap"><thead>' + |
| 10764 | '<tr class="text-left text-gray-500"><th class="px-2 py-1">Sev</th><th class="px-2 py-1">Code</th><th class="px-2 py-1">What</th><th class="px-2 py-1">Source</th><th class="px-2 py-1">#</th></tr>' + |
| 10765 | '</thead><tbody>' + |
| 10766 | findings.slice(0, 40).map(f => { |
| 10767 | const sc = _OAM_SEV_STYLE[f.severity] || 'text-gray-400'; |
| 10768 | const cves = (f.cves || []).filter(c => !(f.name || '').includes(c)); |
| 10769 | const cve = cves.length ? ` <span class="text-red-300 font-mono">${escapeHtml(cves.join(', '))}</span>` : ''; |
| 10770 | const conf = f.confidence === 'low' ? ' <span class="text-gray-500">(low confidence)</span>' : ''; |
| 10771 | return `<tr class="border-t border-slate-800"> |
| 10772 | <td class="px-2 py-1 ${sc}">${escapeHtml(f.severity || '')}</td> |
| 10773 | <td class="px-2 py-1 font-mono ${sc}">${escapeHtml(f.code || '')}</td> |
| 10774 | <td class="px-2 py-1 text-gray-300 whitespace-normal" style="min-width:16rem">${escapeHtml(f.name || '')}${cve}${conf} <span class="text-gray-600">${escapeHtml(f.class_name || '')}</span><span class="block text-gray-500">${escapeHtml(f.detail || '')}</span></td> |
| 10775 | <td class="px-2 py-1 font-mono text-gray-400">${escapeHtml(f.src || f.context || '')}</td> |
| 10776 | <td class="px-2 py-1 font-mono text-gray-400">${f.count}</td> |
| 10777 | </tr>`; }).join('') + |
| 10778 | '</tbody></table>'; |
| 10779 | } |
| 10780 | const meps = inv.meps || []; |
| 10781 | if (meps.length) { |
| 10782 | html += '<div class="text-xs text-gray-500 mt-3 mb-1">Maintenance endpoints (state kept across scans)</div>' + |
| 10783 | '<table class="min-w-full text-xs text-gray-300 whitespace-nowrap"><thead>' + |
no test coverage detected