Home ⌂Doc Index ◂Up ▴

eric6.WebBrowser.SafeBrowsing.SafeBrowsingAPIClient

Module implementing the low level interface for Google Safe Browsing.

Global Attributes

None

Classes

SafeBrowsingAPIClient Class implementing the low level interface for Google Safe Browsing.

Functions

None


SafeBrowsingAPIClient

Class implementing the low level interface for Google Safe Browsing.

Signals

networkError(str)
emitted to indicate a network error

Derived from

QObject

Class Attributes

ClientId
ClientVersion
GsbUrlTemplate

Class Methods

definedPlatformTypes Class method to get all platform types defined in API v4.
definedThreatEntryTypes Class method to get all threat entry types defined in API v4.
definedThreatTypes Class method to get all threat types defined in API v4.
getPlatformString Class method to get the platform string for a given platform type.
getPlatformTypes Class method to get the platform types for a given platform.
getThreatEntryString Class method to get the threat entry string.
getThreatMessage Class method to get a warning message for the given threat type.
getThreatType Class method to get a display string for a given threat type.

Methods

SafeBrowsingAPIClient Constructor
__extractData Private method to extract the data of a network reply.
__setWaitDuration Private method to set the minimum wait duration.
fairUseDelayExpired Public method to check, if the fair use wait period has expired.
getFairUseDelayExpirationDateTime Public method to get the date and time the fair use delay will expire.
getFullHashes Public method to find full hashes matching hash prefixes.
getThreatLists Public method to retrieve all available threat lists.
getThreatsUpdate Public method to fetch hash prefix updates for the given threat list.
lookupUrl Public method to send an URL to Google for checking.
setApiKey Public method to set the API key.

Static Methods

None

SafeBrowsingAPIClient.definedPlatformTypes (class method)

definedPlatformTypes()

Class method to get all platform types defined in API v4.

Returns:
list of all defined platform types
Return Type:
list of str

SafeBrowsingAPIClient.definedThreatEntryTypes (class method)

definedThreatEntryTypes()

Class method to get all threat entry types defined in API v4.

Returns:
list of all defined threat entry types
Return Type:
list of str

SafeBrowsingAPIClient.definedThreatTypes (class method)

definedThreatTypes()

Class method to get all threat types defined in API v4.

Returns:
list of defined threat types
Return Type:
list of str

SafeBrowsingAPIClient.getPlatformString (class method)

getPlatformString(platformType)

Class method to get the platform string for a given platform type.

platformType (str)
platform type as defined in the v4 API
Returns:
platform string
Return Type:
str

SafeBrowsingAPIClient.getPlatformTypes (class method)

getPlatformTypes(platform)

Class method to get the platform types for a given platform.

platform (str (one of 'linux', 'windows', 'macos'))
platform string
Returns:
list of platform types as defined in the v4 API for the given platform
Return Type:
list of str
Raises ValueError:
raised to indicate an invalid platform string

SafeBrowsingAPIClient.getThreatEntryString (class method)

getThreatEntryString(threatEntry)

Class method to get the threat entry string.

threatEntry (str)
threat entry type as defined in the v4 API
Returns:
threat entry string
Return Type:
str

SafeBrowsingAPIClient.getThreatMessage (class method)

getThreatMessage(threatType)

Class method to get a warning message for the given threat type.

threatType (str)
threat type to get the message for
Returns:
threat message
Return Type:
str

SafeBrowsingAPIClient.getThreatType (class method)

getThreatType(threatType)

Class method to get a display string for a given threat type.

threatType (str)
threat type to get display string for
Returns:
display string
Return Type:
str

SafeBrowsingAPIClient (Constructor)

SafeBrowsingAPIClient(apiKey, fairUse=True, parent=None)

Constructor

apiKey (str)
API key to be used
fairUse (bool)
flag indicating to follow the fair use policy
parent (QObject)
reference to the parent object

SafeBrowsingAPIClient.__extractData

__extractData(reply)

Private method to extract the data of a network reply.

reply (QNetworkReply)
reference to the network reply object
Returns:
extracted data
Return Type:
list or dict

SafeBrowsingAPIClient.__setWaitDuration

__setWaitDuration(minimumWaitDuration)

Private method to set the minimum wait duration.

minimumWaitDuration (str)
duration to be set

SafeBrowsingAPIClient.fairUseDelayExpired

fairUseDelayExpired()

Public method to check, if the fair use wait period has expired.

Returns:
flag indicating expiration
Return Type:
bool

SafeBrowsingAPIClient.getFairUseDelayExpirationDateTime

getFairUseDelayExpirationDateTime()

Public method to get the date and time the fair use delay will expire.

Returns:
fair use delay expiration date and time
Return Type:
QDateTime

SafeBrowsingAPIClient.getFullHashes

getFullHashes(prefixes, clientState)

Public method to find full hashes matching hash prefixes.

prefixes (list of bytes)
list of hash prefixes to find
clientState (dict)
dictionary of client states with keys like (threatType, platformType, threatEntryType)
Returns:
dictionary containing the list of found hashes and the negative cache duration
Return Type:
dict

SafeBrowsingAPIClient.getThreatLists

getThreatLists()

Public method to retrieve all available threat lists.

Returns:
tuple containing list of threat lists and an error message
Return Type:
tuple of (list of dict containing 'threatType', 'platformType' and 'threatEntryType', bool)

SafeBrowsingAPIClient.getThreatsUpdate

getThreatsUpdate(clientStates)

Public method to fetch hash prefix updates for the given threat list.

clientStates (dict)
dictionary of client states with keys like (threatType, platformType, threatEntryType)
Returns:
tuple containing the list of threat updates and an error message
Return Type:
tuple of (list of dict, bool)

SafeBrowsingAPIClient.lookupUrl

lookupUrl(url, platforms)

Public method to send an URL to Google for checking.

url (QUrl)
URL to be checked
platforms (list of str)
list of platform types to check against
Returns:
tuple containing the list of threat list info objects and an error message
Return Type:
tuple of (list of ThreatList, str)

SafeBrowsingAPIClient.setApiKey

setApiKey(apiKey)

Public method to set the API key.

apiKey (str)
API key to be set
Up



Home ⌂Doc Index ◂Up ▴