When clients choose to use Google Safe Browsing v5 in this mode, the client behavior is similar to the v4 Update API except using the improved API surface of v5. Clients will maintain in their local database a set of threat lists formatted as SHA256 hash prefixes of host-suffix/path-prefix URL expressions. Whenever the client wishes to check a particular URL, a check is performed using the local threat list. If and only if there is a match, the client connects to the server to continue the check.
As with the above, the client will also maintain a local cache that need not be in persistent storage.
The Local Threat List URL Check Procedure
This procedure is also performed when the client is using the Real-Time Mode procedure and it returns the value UNSURE.
This procedure takes a single URL u and returns SAFE or UNSAFE.
- Let
expressionsbe a list of suffix/prefix expressions generated by the URLu. - Let
expressionHashesbe a list, where the elements are SHA256 hashes of each expression inexpressions. - Let
expressionHashPrefixesbe a list, where the elements are the first 4 bytes of each hash inexpressionHashes. - For each
expressionHashPrefixofexpressionHashPrefixes:- Look up
expressionHashPrefixin the local cache. - If the cached entry is found:
- Determine whether the current time is greater than its expiration time.
- If it is greater:
- Remove the found cached entry from the local cache.
- Continue with the loop.
- If it is not greater:
- Remove this particular
expressionHashPrefixfromexpressionHashPrefixes. - Check whether the corresponding full hash within
expressionHashesis found in the cached entry. - If found, return
UNSAFE. - If not found, continue with the loop.
- Remove this particular
- If the cached entry is not found, continue with the loop.
- Look up
- For each
expressionHashPrefixofexpressionHashPrefixes:- Look up
expressionHashPrefixin the local threat list database. - If the
expressionHashPrefixcannot be found in the local threat list database, remove it fromexpressionHashPrefixes.
- Look up
- Send
expressionHashPrefixesto the Google Safe Browsing v5 server using RPC SearchHashes or the REST method hashes.search. If an error occurred (including network errors, HTTP errors, etc), returnSAFE. Otherwise, let response be theresponsereceived from the SB server, which is a list of full hashes together with some auxiliary information identifying the nature of the threat (social engineering, malware, etc), as well as the cache expiration timeexpiration. - For each
fullHashofresponse:- Insert
fullHashinto the local cache, together withexpiration.
- Insert
- For each
fullHashofresponse:- Let
isFoundbe the result of findingfullHashinexpressionHashes. - If
isFoundis False, continue with the loop. - If
isFoundis True, returnUNSAFE.
- Let
- Return
SAFE.