#NEWLINE# def encode( self , zout ) : #NEWLINE# #INDENT# out = ZMapTransformOutput ( ) #NEWLINE# obj = zout . transformed #NEWLINE# ip = obj [ 'ip_address' ] #NEWLINE# ts = obj [ 'timestamp' ] #NEWLINE# domain = obj . get ( 'domain' , None ) #NEWLINE# if ( zout . metadata . local_metadata is not None ) : #NEWLINE# #INDENT# obj [ 'metadata' ] = zout . metadata . local_metadata . to_dict ( ) #NEWLINE# #UNINDENT# m = zout . metadata . global_metadata . to_dict ( ) #NEWLINE# tags = list ( zout . metadata . tags ) #NEWLINE# data = { x : obj [ x ] for x in obj if ( x not in self . DROP_KEYS ) } #NEWLINE# m = { k : simple_strip ( v ) for ( k , v ) in m . iteritems ( ) } #NEWLINE# metadata = self . Metadatum . from_dict ( m ) #NEWLINE# atom = self . ProtocolAtom ( tags = tags , metadata = metadata , data = data ) #NEWLINE# record = self . Record ( ip , self . port , self . protocol . value , self . subprotocol . value , protocol_atom = atom , domain = domain , timestamp = ts , scan_id = self . scan_id ) #NEWLINE# out . transformed = record . protobuf #NEWLINE# out . certificates = [ ] #NEWLINE# for cert_dict in zout . certificates : #NEWLINE# #INDENT# ar = self . zsearch_definitions . anonstore_pb2 . AnonymousRecord ( ) #NEWLINE# c = ar . certificate #NEWLINE# c . parsed = json . dumps ( out [ 'parsed' ] , sort_keys = True ) #NEWLINE# c . raw = base64 . b64decode ( cert_dict [ 'raw' ] ) #NEWLINE# c . sha1fp = cert_dict [ 'parsed' ] [ 'fingerprint_sha1' ] . decode ( 'hex' ) #NEWLINE# c . sha256fp = cert_dict [ 'parsed' ] [ 'fingerprint_sha256' ] . decode ( 'hex' ) #NEWLINE# valid_nss = cert_dict . get ( 'nss_trusted' , None ) #NEWLINE# if ( valid_nss is not None ) : #NEWLINE# #INDENT# c . valid_nss = valid_nss #NEWLINE# c . validation_timestamp = record . timestamp #NEWLINE# #UNINDENT# parents_sha256 = cert_dict . get ( 'parents' , None ) #NEWLINE# if ( parents_sha256 is not None ) : #NEWLINE# #INDENT# c . parents . extend ( [ sha_value . decode ( 'hex' ) for sha_value in parents_sha256 ] ) #NEWLINE# #UNINDENT# ar . sha256fp = c . sha256fp #NEWLINE# ar . scan_id = self . scan_id #NEWLINE# out . certificates . append ( ar ) #NEWLINE# #UNINDENT# return out