You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
5.6 KiB
PHP
112 lines
5.6 KiB
PHP
<?php
|
|
|
|
$root = dirname(__DIR__);
|
|
$read = static function (string $path): string {
|
|
$source = file_get_contents($path);
|
|
if (!is_string($source)) {
|
|
throw new RuntimeException('Unable to read ' . $path);
|
|
}
|
|
return $source;
|
|
};
|
|
$assert = static function (bool $condition, string $message): void {
|
|
if (!$condition) {
|
|
throw new RuntimeException($message);
|
|
}
|
|
};
|
|
|
|
$template = $read($root . '/resources/views/venix/admin/cloud/abuse_monitoring.tpl');
|
|
$script = $read($root . '/public/cloud/admin-abuse-monitoring.js');
|
|
$styles = $read($root . '/public/cloud/admin-abuse-monitoring.css');
|
|
|
|
$assert(str_contains($template, "admin_active value='abuse-monitoring'")
|
|
&& str_contains($template, '只读分析实例公网接口的聚合流量和连接模式')
|
|
&& str_contains($template, '不会自动断网、限速或锁定实例')
|
|
&& str_contains($template, 'data-admin-abuse-monitoring'),
|
|
'The page must be an explicitly read-only administrator-only monitoring surface.');
|
|
|
|
$assert(str_contains($template, '对外可疑行为')
|
|
&& str_contains($template, '正在遭受攻击')
|
|
&& str_contains($template, '双向异常')
|
|
&& str_contains($template, '避免把受攻击实例误判为滥用来源')
|
|
&& str_contains($script, "direction === 'outbound'")
|
|
&& str_contains($script, "direction === 'inbound'")
|
|
&& str_contains($script, "direction === 'both'")
|
|
&& !str_contains($template, 'outbound_abuse')
|
|
&& !str_contains($template, 'inbound_attack')
|
|
&& !str_contains($script, 'outbound_abuse')
|
|
&& !str_contains($script, 'inbound_attack'),
|
|
'Outbound abuse and inbound victim evidence must be presented as different states.');
|
|
|
|
$assert(str_contains($template, '采集异常')
|
|
&& str_contains($template, '缺失数据不会按正常零值处理')
|
|
&& str_contains($template, '不完整、溢出和冷启动窗口不会用于风险判定')
|
|
&& str_contains($script, "return parsed === null ? '不可用'")
|
|
&& !str_contains($script, "return parsed === null ? '0'"),
|
|
'Missing or incomplete observations must never be rendered as a healthy zero.');
|
|
|
|
$assert(str_contains($template, 'name="risk"')
|
|
&& str_contains($template, 'name="direction"')
|
|
&& str_contains($template, 'name="host_id"')
|
|
&& str_contains($template, 'name="line_id"')
|
|
&& str_contains($template, 'name="ip_version"')
|
|
&& str_contains($template, '开放告警协议族')
|
|
&& str_contains($template, 'name="query"'),
|
|
'The administrator list must expose the complete first-phase filter set.');
|
|
|
|
$assert(str_contains($template, '{$item.instance_name|default:')
|
|
&& str_contains($template, '{$item.user_name|default:')
|
|
&& str_contains($template, '{$item.host_name|default:')
|
|
&& str_contains($template, '{$item.line_name|default:')
|
|
&& str_contains($template, '{$item.metrics.rx_bps_display|default:')
|
|
&& str_contains($template, '{$item.metrics.tx_pps_display|default:')
|
|
&& str_contains($template, '{$item.metrics.tcp_active_flows|default:')
|
|
&& str_contains($template, '{$item.metrics.udp_active_flows|default:'),
|
|
'The list must provide identity, placement, throughput, PPS, and flow information.');
|
|
|
|
$assert(str_contains($template, '{$item.instance_name|default:\'未命名实例\'|escape}')
|
|
&& str_contains($template, '{$item.user_name|default:\'未知用户\'|escape}')
|
|
&& str_contains($template, '{$item.sample.quality_label|default:\'样本不完整\'|escape}')
|
|
&& !str_contains($template, ' nofilter'),
|
|
'SSR values must be escaped and must not expose unneeded raw bootstrap JSON.');
|
|
|
|
$assert(str_contains($script, 'window.VenixAdminRequestRuntime?.create?.()')
|
|
&& str_contains($script, 'requestRuntime.read(')
|
|
&& str_contains($script, "timeoutMs: 10000")
|
|
&& !preg_match('/requestRuntime\.(?:mutate|commit|enqueue)\s*\(/', $script),
|
|
'The details drawer must reuse the shared read runtime and expose no mutation path.');
|
|
|
|
$assert(str_contains($script, 'evidence_summary')
|
|
&& str_contains($script, '不保存远端地址或端口明细')
|
|
&& !str_contains($template, 'remote_ip')
|
|
&& !str_contains($template, 'remote_port'),
|
|
'The UI must show only bounded evidence summaries, never remote connection details.');
|
|
|
|
$assert(str_contains($styles, '@media (max-width: 767.98px)')
|
|
&& str_contains($styles, "content: attr(data-label)")
|
|
&& str_contains($styles,
|
|
'tr:not([data-abuse-monitoring-row]) td')
|
|
&& str_contains($styles, '.admin-abuse-detail-metrics')
|
|
&& str_contains($styles, '.admin-abuse-trend-chart')
|
|
&& str_contains($styles, '.admin-abuse-finding'),
|
|
'The list, detail metrics, trend, and findings must have responsive presentation contracts.');
|
|
|
|
$assert(str_contains($template, 'aria-disabled="true" tabindex="-1"'),
|
|
'Disabled pagination links must leave the keyboard tab order.');
|
|
|
|
$assert(str_contains($script, 'function trendScales(series)')
|
|
&& str_contains($script, 'maxBps: Math.max(')
|
|
&& str_contains($script, 'maxPps: Math.max(')
|
|
&& str_contains($styles, '.admin-abuse-finding.is-high')
|
|
&& str_contains($styles, '.admin-abuse-finding.is-info')
|
|
&& !str_contains($styles, '.admin-abuse-finding.is-medium')
|
|
&& !str_contains($styles, '.admin-abuse-finding.is-low')
|
|
&& str_contains($styles, '.admin-abuse-direction-banner.is-both'),
|
|
'Trend units, finding severity, and canonical direction styles must remain distinct.');
|
|
|
|
$assert(str_contains($template, 'data-abuse-time=')
|
|
&& str_contains($script,
|
|
"root.querySelectorAll('[data-abuse-time]')"),
|
|
'UTC service timestamps must be converted by the browser for display.');
|
|
|
|
echo "Administrator network-abuse monitoring UI contracts passed.\n";
|