#NEWLINE# def run( self , scanObject , result , depth , args ) : #NEWLINE# #INDENT# 'Wrapper method around _run for error handling' #NEWLINE# moduleLoggingBool = config . modulelogging #NEWLINE# try : #NEWLINE# #INDENT# starttime = time . time ( ) #NEWLINE# if moduleLoggingBool : #NEWLINE# #INDENT# log_module ( 'START' , self . module_name , 0 , scanObject , result ) #NEWLINE# #UNINDENT# timeout_seconds = int ( get_option ( args , 'module_timeout' , 'global_module_timeout' , 3600 ) ) #NEWLINE# with timeout ( timeout_seconds , exception = GlobalModuleTimeoutError ) : #NEWLINE# #INDENT# moduleResult = self . _run ( scanObject , result , depth , args ) #NEWLINE# #UNINDENT# if moduleLoggingBool : #NEWLINE# #INDENT# log_module ( 'END' , self . module_name , ( time . time ( ) - starttime ) , scanObject , result ) #NEWLINE# #UNINDENT# if ( type ( moduleResult ) is not list ) : #NEWLINE# #INDENT# msg = ( '%s returned an object with type %s. Only lists are allowed! Skipping this result.' % ( self . module_name , type ( moduleResult ) ) ) #NEWLINE# logging . debug ( msg ) #NEWLINE# if moduleLoggingBool : #NEWLINE# #INDENT# log_module_error ( self . module_name , scanObject , result , msg ) #NEWLINE# #UNINDENT# return [ ] #NEWLINE# #UNINDENT# return moduleResult #NEWLINE# #UNINDENT# except GlobalScanTimeoutError : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# except GlobalModuleTimeoutError : #NEWLINE# #INDENT# scanObject . addFlag ( ( 'dispatch:err:module_timeout:%s' % timeout_seconds . module_name ) ) #NEWLINE# ( exc_type , exc_value , exc_traceback ) = sys . exc_info ( ) #NEWLINE# logging . exception ( 'error on %s running module %s. exception details below: ' , get_scanObjectUID ( getRootObject ( result ) ) , self . module_name ) #NEWLINE# if moduleLoggingBool : #NEWLINE# #INDENT# log_module_error ( self . module_name , scanObject , result , repr ( traceback . format_exception ( exc_type , exc_value , exc_traceback ) ) ) #NEWLINE# #UNINDENT# return [ ] #NEWLINE# #UNINDENT# except QuitScanException : #NEWLINE# #INDENT# scanObject . addFlag ( 'dispatch:err:quit_scan' ) #NEWLINE# logging . warn ( 'quitting scan while running module %s' , self . module_name ) #NEWLINE# raise #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# ( exc_type , exc_value , exc_traceback ) = sys . exc_info ( ) #NEWLINE# logging . exception ( 'error on %s running module %s. exception details below: ' , get_scanObjectUID ( getRootObject ( result ) ) , self . module_name ) #NEWLINE# if moduleLoggingBool : #NEWLINE# #INDENT# log_module_error ( self . module_name , scanObject , result , repr ( traceback . format_exception ( exc_type , exc_value , exc_traceback ) ) ) #NEWLINE# #UNINDENT# return [ ]