Example #1
0
    def __init__(self, host="", proxy=None, timeout=30):
        api_key = lamson.server.shivaconf.get('analyzer',
                                              'google_safe_browsing_api_key')

        try:
            self.api_key = api_key
            self.client = SafebrowsinglookupClient(key=api_key)
        except Exception:
            self.client = None
            pass
        super(GoogleSafeBrowsingAPI, self).__init__(host, proxy, timeout)
Example #2
0
class GoogleSafeBrowsingAPI(RankProvider):
    def __init__(self, host="", proxy=None, timeout=30):
        api_key = lamson.server.shivaconf.get('analyzer',
                                              'google_safe_browsing_api_key')

        try:
            self.api_key = api_key
            self.client = SafebrowsinglookupClient(key=api_key)
        except Exception:
            self.client = None
            pass
        super(GoogleSafeBrowsingAPI, self).__init__(host, proxy, timeout)

    def get_rank(self, url):
        """
        return True if given URL is considered 'phishing','malware' or 'unwanted' by Google Safe Browsing API
        """
        if not url or not self.client:
            return False

        try:
            for url, result in self.client.lookup(url).iteritems():
                if re.search('(?i)(phishing|malware|unwanted)', result):
                    return True
        except Exception:
            return False
        return False
Example #3
0
class GoogleSafeBrowsingAPI(RankProvider):
    def __init__(self, host="", proxy=None, timeout=30):
        api_key = lamson.server.shivaconf.get("analyzer", "google_safe_browsing_api_key")

        try:
            self.api_key = api_key
            self.client = SafebrowsinglookupClient(key=api_key)
        except Exception:
            self.client = None
            pass
        super(GoogleSafeBrowsingAPI, self).__init__(host, proxy, timeout)

    def get_rank(self, url):
        """
        return True if given URL is considered 'phishing','malware' or 'unwanted' by Google Safe Browsing API
        """
        if not url or not self.client:
            return False

        try:
            for url, result in self.client.lookup(url).iteritems():
                if re.search("(?i)(phishing|malware|unwanted)", result):
                    return True
        except Exception:
            return False
        return False
Example #4
0
    def __init__(self, host="", proxy=None, timeout=30):
        api_key = lamson.server.shivaconf.get("analyzer", "google_safe_browsing_api_key")

        try:
            self.api_key = api_key
            self.client = SafebrowsinglookupClient(key=api_key)
        except Exception:
            self.client = None
            pass
        super(GoogleSafeBrowsingAPI, self).__init__(host, proxy, timeout)