谷歌安全浏览API查找Node.js



我在让谷歌安全搜索查找工作时遇到问题。这是我正在尝试的代码,我总是在响应中得到{}

var request = require("request-promise")
var body = {
  "client": {
    "clientId":      "myclientid",
    "clientVersion": "1.0"
  },
  "threatInfo": {
    "threatTypes":      ["MALWARE"],
    "platformTypes":    ["WINDOWS", "LINUX"],
    "threatEntryTypes": ["URL"],
    "threatEntries": [
      {"url": "http://some-malicious-url"}
    ]
  }
}
var options = {
  headers: {
    "Content-Type": "application/json",
    "Accept": "application/json"
  },
  method: "POST",
  url: "https://safebrowsing.googleapis.com/v4/threatMatches:find?key=my-api-key",
  form: body
}

request(options).then(function (data){
  console.log(data)
})

不确定我是否正确理解了文档,或者我的请求中是否缺少任何参数。我尝试过使用不同的网址。尝试从 Web 搜索恶意网址,这些网址被我的浏览器识别为恶意,但这些网址也返回空白响应。这是我正在关注的文档

我也尝试了他们的threatLists:list API,但总是给出错误

curl -XGET https://safebrowsing.googleapis.com/v4/threatLists:list?key=my_api_key

这是我得到的输出:

<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 404 (Not Found)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>404.</b> <ins>That’s an error.</ins>
  <p>The requested URL <code>/v4/threatLists:list?key=my_api_key</code> was not found on this server.  <ins>That’s all we know.</ins>

threatLists工作示例:

威胁列表在没有:list的情况下工作,例如 curl https://safebrowsing.googleapis.com/v4/threatLists?key=YOUR_KEY

威胁匹配工作示例:

方法:开机自检

内容类型:应用程序/JSON

https://safebrowsing.googleapis.com/v4/threatMatches:find?key=YOUR_KEY

身体: { "client": { "clientId": "testing", "clientVersion": "0.0.1" }, "threatInfo": { "threatTypes": ["MALWARE","SOCIAL_ENGINEERING","UNWANTED_SOFTWARE","MALICIOUS_BINARY"], "platformTypes": ["ANY_PLATFORM"], "threatEntryTypes": ["URL"], "threatEntries": [ {"url": "http://goooogleadsence.biz/"} ] } }

代码是正确的。我有相同的...

似乎Chrome浏览器还有其他(更准确)的安全浏览来源。也许他们专门为某些特定客户保留这些新数据。无论您可以使用什么查找协议版本,结果都是相同的。如果您使用更新 API,则情况相同。

如果有人知道,真的,为什么...我对这些信息非常感兴趣。

请确保在

请求的URL中附加"/"。这样做很重要。

在这种情况下,您的 URL 将变为 http://some-malicious-url/ .

让我知道这是否有效!

最新更新