风险系数判断修复

This commit is contained in:
root
2026-06-14 18:30:06 +08:00
parent 235bf939b8
commit eb2724e3de
143 changed files with 68315 additions and 73 deletions
+55
View File
@@ -50,6 +50,61 @@ if (!function_exists('cloak_visitor_log_format_timing')) {
}
}
if (!function_exists('cloak_visitor_log_format_fp_hdata')) {
/**
* 指纹 hdata JSON 单行摘要(表格展示用)
*
* @param mixed $raw
*/
function cloak_visitor_log_format_fp_hdata($raw)
{
$raw = trim((string) $raw);
if ($raw === '') {
return '';
}
$decoded = json_decode($raw, true);
if (!is_array($decoded)) {
return $raw;
}
$parts = [];
foreach (['domain', 'ip', 'ciso', 'referer', 'log_id', 'risk_enhanced'] as $key) {
if (!empty($decoded[$key])) {
$parts[] = $key . '=' . $decoded[$key];
}
}
if (!empty($decoded['automation']) && is_array($decoded['automation'])) {
$auto = [];
foreach ($decoded['automation'] as $k => $v) {
if ($v) {
$auto[] = $k;
}
}
if ($auto !== []) {
$parts[] = 'automation=' . implode(',', $auto);
}
}
if ($parts !== []) {
return implode(' | ', $parts);
}
return json_encode($decoded, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
}
}
if (!function_exists('cloak_visitor_log_fp_risk_explain')) {
/**
* 二次风控 hdata + reason 判定过程解析
*
* @return array{summary:string,html:string,data:array}
*/
function cloak_visitor_log_fp_risk_explain($fpHdata, $reason, $result, $domain = '')
{
if (!class_exists('FpRiskExplain', false)) {
require_once dirname(__DIR__) . '/Cloak/FpRiskExplain.php';
}
return FpRiskExplain::build($fpHdata, $reason, $result, $domain);
}
}
if (!function_exists('cloak_visitor_log_apply_result_filter')) {
/**
* 日志列表 result 筛选:默认排除 wait(检测中);显式选 wait/true/false 时精确匹配