def Analyze(self, hashes):
    """Looks up hashes in VirusTotal using the VirusTotal HTTP API.

    The API is documented here:
      https://www.virustotal.com/en/documentation/public-api/

    Args:
      hashes (list[str]): hashes to look up.

    Returns:
      list[HashAnalysis]: analysis results.

    Raises:
      RuntimeError: If the VirusTotal API key has not been set.
    """
    if not self._api_key:
      raise RuntimeError('No API key specified for VirusTotal lookup.')

    hash_analyses = []

    json_response = self._QueryHashes(hashes) or []

    # VirusTotal returns a dictionary when a single hash is queried
    # and a list when multiple hashes are queried.
    if isinstance(json_response, dict):
      json_response = [json_response]

    for result in json_response:
      resource = result['resource']
      hash_analysis = interface.HashAnalysis(resource, result)
      hash_analyses.append(hash_analysis)

    return hash_analyses
def Analyze ( self , hashes ) : if not self . _api_key : raise RuntimeError ( 'No API key specified for VirusTotal lookup.' ) hash_analyses = [ ] json_response = self . _QueryHashes ( hashes ) or [ ] if isinstance ( json_response , dict ) : json_response = [ json_response ] for result in json_response : resource = result [ 'resource' ] hash_analysis = interface . HashAnalysis ( resource , result ) hash_analyses . append ( hash_analysis ) return hash_analyses
Looks up hashes in VirusTotal using the VirusTotal HTTP API.

    The API is documented here:
      https://www.virustotal.com/en/documentation/public-api/

    Args:
      hashes (list[str]): hashes to look up.

    Returns:
      list[HashAnalysis]: analysis results.

    Raises:
      RuntimeError: If the VirusTotal API key has not been set.