我有一个允许其他人共享网址的网站。为了确保没有人进入“邪恶”网站,我使用了 google safebrowsing api:
$url = 'https://safebrowsing.googleapis.com/v4/threatMatches:find?key='.$key;
$data = array(
'client' => array('clientId'=> $clientId, 'clientVersion'=>'0.1'),
'threatInfo' => array(
'threatTypes'=>array('MALWARE', 'SOCIAL_ENGINEERING','UNWANTED_SOFTWARE'),
'platformTypes'=> array('ANY_PLATFORM','ALL_PLATFORMS', 'ANDROID','WINDOWS','IOS','OSX','LINUX'),
'threatEntryTypes'=> array('URL'),
'threatEntries' => array('url'=>$tsturl)
),
);
$data_json=json_encode($data);
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
这按设计工作。因此,如果我添加像thisisevil.com
api-call 这样的网络钓鱼站点,则会返回警告。
但是,如果有人使用这样的 url 缩短tny.sh/abcefg
器,然后重定向到thisisevil.com
safebrowsing-api 并不会向我显示存在威胁。
有没有办法告诉安全浏览 api 遵循重定向?