idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
16,800 | def getThirdPartyLibLinkerFlags ( self , libs ) : fmt = PrintingFormat . singleLine ( ) if libs [ 0 ] == '--multiline' : fmt = PrintingFormat . multiLine ( ) libs = libs [ 1 : ] includeLibs = True if ( libs [ 0 ] == '--flagsonly' ) : includeLibs = False libs = libs [ 1 : ] platformDefaults = True if libs [ 0 ] == '--no... | Retrieves the linker flags for building against the Unreal - bundled versions of the specified third - party libraries |
16,801 | def getThirdPartyLibCmakeFlags ( self , libs ) : fmt = PrintingFormat . singleLine ( ) if libs [ 0 ] == '--multiline' : fmt = PrintingFormat . multiLine ( ) libs = libs [ 1 : ] platformDefaults = True if libs [ 0 ] == '--nodefaults' : platformDefaults = False libs = libs [ 1 : ] details = self . getThirdpartyLibs ( lib... | Retrieves the CMake invocation flags for building against the Unreal - bundled versions of the specified third - party libraries |
16,802 | def getThirdPartyLibIncludeDirs ( self , libs ) : platformDefaults = True if libs [ 0 ] == '--nodefaults' : platformDefaults = False libs = libs [ 1 : ] details = self . getThirdpartyLibs ( libs , includePlatformDefaults = platformDefaults ) return details . getIncludeDirectories ( self . getEngineRoot ( ) , delimiter ... | Retrieves the list of include directories for building against the Unreal - bundled versions of the specified third - party libraries |
16,803 | def getThirdPartyLibFiles ( self , libs ) : platformDefaults = True if libs [ 0 ] == '--nodefaults' : platformDefaults = False libs = libs [ 1 : ] details = self . getThirdpartyLibs ( libs , includePlatformDefaults = platformDefaults ) return details . getLibraryFiles ( self . getEngineRoot ( ) , delimiter = '\n' ) | Retrieves the list of library files for building against the Unreal - bundled versions of the specified third - party libraries |
16,804 | def getThirdPartyLibDefinitions ( self , libs ) : platformDefaults = True if libs [ 0 ] == '--nodefaults' : platformDefaults = False libs = libs [ 1 : ] details = self . getThirdpartyLibs ( libs , includePlatformDefaults = platformDefaults ) return details . getPreprocessorDefinitions ( self . getEngineRoot ( ) , delim... | Retrieves the list of preprocessor definitions for building against the Unreal - bundled versions of the specified third - party libraries |
16,805 | def generateProjectFiles ( self , dir = os . getcwd ( ) , args = [ ] ) : if os . path . exists ( os . path . join ( dir , 'Source' ) ) == False : Utility . printStderr ( 'Pure Blueprint project, nothing to generate project files for.' ) return genScript = self . getGenerateScript ( ) projectFile = self . getProjectDesc... | Generates IDE project files for the Unreal project in the specified directory |
16,806 | def cleanDescriptor ( self , dir = os . getcwd ( ) ) : descriptor = self . getDescriptor ( dir ) shutil . rmtree ( os . path . join ( dir , 'Binaries' ) , ignore_errors = True ) shutil . rmtree ( os . path . join ( dir , 'Intermediate' ) , ignore_errors = True ) if self . isProject ( descriptor ) : projectPlugins = glo... | Cleans the build artifacts for the Unreal project or plugin in the specified directory |
16,807 | def buildDescriptor ( self , dir = os . getcwd ( ) , configuration = 'Development' , args = [ ] , suppressOutput = False ) : descriptor = self . getDescriptor ( dir ) descriptorType = 'project' if self . isProject ( descriptor ) else 'plugin' if os . path . exists ( os . path . join ( dir , 'Source' ) ) == False : Util... | Builds the editor modules for the Unreal project or plugin in the specified directory using the specified build configuration |
16,808 | def runUAT ( self , args ) : Utility . run ( [ self . getRunUATScript ( ) ] + args , cwd = self . getEngineRoot ( ) , raiseOnError = True ) | Runs the Unreal Automation Tool with the supplied arguments |
16,809 | def packageProject ( self , dir = os . getcwd ( ) , configuration = 'Shipping' , extraArgs = [ ] ) : if configuration not in self . validBuildConfigurations ( ) : raise UnrealManagerException ( 'invalid build configuration "' + configuration + '"' ) extraArgs = Utility . stripArgs ( extraArgs , [ '-nocompileeditor' ] )... | Packages a build of the Unreal project in the specified directory using common packaging options |
16,810 | def packagePlugin ( self , dir = os . getcwd ( ) , extraArgs = [ ] ) : distDir = os . path . join ( os . path . abspath ( dir ) , 'dist' ) self . runUAT ( [ 'BuildPlugin' , '-Plugin=' + self . getPluginDescriptor ( dir ) , '-Package=' + distDir ] + extraArgs ) | Packages a build of the Unreal plugin in the specified directory suitable for use as a prebuilt Engine module |
16,811 | def packageDescriptor ( self , dir = os . getcwd ( ) , args = [ ] ) : descriptor = self . getDescriptor ( dir ) if self . isProject ( descriptor ) : self . packageProject ( dir , args [ 0 ] if len ( args ) > 0 else 'Shipping' , args [ 1 : ] ) else : self . packagePlugin ( dir , args ) | Packages a build of the Unreal project or plugin in the specified directory |
16,812 | def runAutomationCommands ( self , projectFile , commands , capture = False ) : command = '{} {}' . format ( Utility . escapePathForShell ( self . getEditorBinary ( True ) ) , Utility . escapePathForShell ( projectFile ) ) command += ' -game -buildmachine -stdout -fullstdoutlogoutput -forcelogflush -unattended -nopause... | Invokes the Automation Test commandlet for the specified project with the supplied automation test commands |
16,813 | def _getEngineVersionDetails ( self ) : versionFile = os . path . join ( self . getEngineRoot ( ) , 'Engine' , 'Build' , 'Build.version' ) return json . loads ( Utility . readFile ( versionFile ) ) | Parses the JSON version details for the latest installed version of UE4 |
16,814 | def _getEngineVersionHash ( self ) : versionDetails = self . _getEngineVersionDetails ( ) hash = hashlib . sha256 ( ) hash . update ( json . dumps ( versionDetails , sort_keys = True , indent = 0 ) . encode ( 'utf-8' ) ) return hash . hexdigest ( ) | Computes the SHA - 256 hash of the JSON version details for the latest installed version of UE4 |
16,815 | def _runUnrealBuildTool ( self , target , platform , configuration , args , capture = False ) : platform = self . _transformBuildToolPlatform ( platform ) arguments = [ self . getBuildScript ( ) , target , platform , configuration ] + args if capture == True : return Utility . capture ( arguments , cwd = self . getEngi... | Invokes UnrealBuildTool with the specified parameters |
16,816 | def _getUE4BuildInterrogator ( self ) : ubtLambda = lambda target , platform , config , args : self . _runUnrealBuildTool ( target , platform , config , args , True ) interrogator = UE4BuildInterrogator ( self . getEngineRoot ( ) , self . _getEngineVersionDetails ( ) , self . _getEngineVersionHash ( ) , ubtLambda ) ret... | Uses UE4BuildInterrogator to interrogate UnrealBuildTool about third - party library details |
16,817 | def getKey ( self , key ) : data = self . getDictionary ( ) if key in data : return data [ key ] else : return None | Retrieves the value for the specified dictionary key |
16,818 | def getDictionary ( self ) : if os . path . exists ( self . jsonFile ) : return json . loads ( Utility . readFile ( self . jsonFile ) ) else : return { } | Retrieves the entire data dictionary |
16,819 | def setKey ( self , key , value ) : data = self . getDictionary ( ) data [ key ] = value self . setDictionary ( data ) | Sets the value for the specified dictionary key |
16,820 | def setDictionary ( self , data ) : jsonDir = os . path . dirname ( self . jsonFile ) if os . path . exists ( jsonDir ) == False : os . makedirs ( jsonDir ) Utility . writeFile ( self . jsonFile , json . dumps ( data ) ) | Overwrites the entire dictionary |
16,821 | def list ( self , platformIdentifier , configuration , libOverrides = { } ) : modules = self . _getThirdPartyLibs ( platformIdentifier , configuration ) return sorted ( [ m [ 'Name' ] for m in modules ] + [ key for key in libOverrides ] ) | Returns the list of supported UE4 - bundled third - party libraries |
16,822 | def interrogate ( self , platformIdentifier , configuration , libraries , libOverrides = { } ) : libModules = list ( [ lib for lib in libraries if lib not in libOverrides ] ) details = ThirdPartyLibraryDetails ( ) if len ( libModules ) > 0 : modules = self . _getThirdPartyLibs ( platformIdentifier , configuration ) mod... | Interrogates UnrealBuildTool about the build flags for the specified third - party libraries |
16,823 | def _flatten ( self , field , items , transform = None ) : values = [ item [ field ] for item in items ] flattened = [ ] for value in values : flattened . extend ( [ value ] if isinstance ( value , str ) else value ) return transform ( flattened ) if transform != None else flattened | Extracts the entry field from each item in the supplied iterable flattening any nested lists |
16,824 | def _getThirdPartyLibs ( self , platformIdentifier , configuration ) : cachedList = CachedDataManager . getCachedDataKey ( self . engineVersionHash , 'ThirdPartyLibraries' ) if cachedList != None : return cachedList tempDir = tempfile . mkdtemp ( ) jsonFile = os . path . join ( tempDir , 'ubt_output.json' ) sentinelFil... | Runs UnrealBuildTool in JSON export mode and extracts the list of third - party libraries |
16,825 | def processLibraryDetails ( details ) : for includeDir in details . includeDirs : for pattern in CUSTOM_FLAGS_FOR_INCLUDE_DIRS : if pattern in includeDir : flag = '-D' + CUSTOM_FLAGS_FOR_INCLUDE_DIRS [ pattern ] + '=' + includeDir details . cmakeFlags . append ( flag ) for lib in details . libs : filename = os . path .... | Processes the supplied ThirdPartyLibraryDetails instance and sets any custom CMake flags |
16,826 | def getPlugins ( ) : plugins = { entry_point . name : entry_point . load ( ) for entry_point in pkg_resources . iter_entry_points ( 'ue4cli.plugins' ) } plugins = { name : plugins [ name ] for name in plugins if 'action' in plugins [ name ] and 'description' in plugins [ name ] and 'args' in plugins [ name ] and callab... | Returns the list of valid ue4cli plugins |
16,827 | def getCompilerFlags ( self , engineRoot , fmt ) : return Utility . join ( fmt . delim , self . prefixedStrings ( self . definitionPrefix , self . definitions , engineRoot ) + self . prefixedStrings ( self . includeDirPrefix , self . includeDirs , engineRoot ) + self . resolveRoot ( self . cxxFlags , engineRoot ) , fmt... | Constructs the compiler flags string for building against this library |
16,828 | def getLinkerFlags ( self , engineRoot , fmt , includeLibs = True ) : components = self . resolveRoot ( self . ldFlags , engineRoot ) if includeLibs == True : components . extend ( self . prefixedStrings ( self . linkerDirPrefix , self . linkDirs , engineRoot ) ) components . extend ( self . resolveRoot ( self . libs ,... | Constructs the linker flags string for building against this library |
16,829 | def getPrefixDirectories ( self , engineRoot , delimiter = ' ' ) : return delimiter . join ( self . resolveRoot ( self . prefixDirs , engineRoot ) ) | Returns the list of prefix directories for this library joined using the specified delimiter |
16,830 | def getIncludeDirectories ( self , engineRoot , delimiter = ' ' ) : return delimiter . join ( self . resolveRoot ( self . includeDirs , engineRoot ) ) | Returns the list of include directories for this library joined using the specified delimiter |
16,831 | def getLinkerDirectories ( self , engineRoot , delimiter = ' ' ) : return delimiter . join ( self . resolveRoot ( self . linkDirs , engineRoot ) ) | Returns the list of linker directories for this library joined using the specified delimiter |
16,832 | def getLibraryFiles ( self , engineRoot , delimiter = ' ' ) : return delimiter . join ( self . resolveRoot ( self . libs , engineRoot ) ) | Returns the list of library files for this library joined using the specified delimiter |
16,833 | def getPreprocessorDefinitions ( self , engineRoot , delimiter = ' ' ) : return delimiter . join ( self . resolveRoot ( self . definitions , engineRoot ) ) | Returns the list of preprocessor definitions for this library joined using the specified delimiter |
16,834 | def getCMakeFlags ( self , engineRoot , fmt ) : return Utility . join ( fmt . delim , [ '-DCMAKE_PREFIX_PATH=' + self . getPrefixDirectories ( engineRoot , ';' ) , '-DCMAKE_INCLUDE_PATH=' + self . getIncludeDirectories ( engineRoot , ';' ) , '-DCMAKE_LIBRARY_PATH=' + self . getLinkerDirectories ( engineRoot , ';' ) , ]... | Constructs the CMake invocation flags string for building against this library |
16,835 | def is_changed ( ) : executed , changed_lines = execute_git ( 'status --porcelain' , output = False ) merge_not_finished = mod_path . exists ( '.git/MERGE_HEAD' ) return changed_lines . strip ( ) or merge_not_finished | Checks if current project has any noncommited changes . |
16,836 | def user_agent ( ) : client_name = 'unknown_client_name' try : client_name = os . environ . get ( "EDX_REST_API_CLIENT_NAME" ) or socket . gethostbyname ( socket . gethostname ( ) ) except : pass return "{} edx-rest-api-client/{} {}" . format ( requests . utils . default_user_agent ( ) , __version__ , client_name ) | Return a User - Agent that identifies this client . |
16,837 | def get_oauth_access_token ( url , client_id , client_secret , token_type = 'jwt' , grant_type = 'client_credentials' , refresh_token = None ) : now = datetime . datetime . utcnow ( ) data = { 'grant_type' : grant_type , 'client_id' : client_id , 'client_secret' : client_secret , 'token_type' : token_type , } if refres... | Retrieves OAuth 2 . 0 access token using the given grant type . |
16,838 | def request ( self , method , url , ** kwargs ) : self . _check_auth ( ) return super ( OAuthAPIClient , self ) . request ( method , url , ** kwargs ) | Overrides Session . request to ensure that the session is authenticated |
16,839 | def run_command ( self , scan_id , host , cmd ) : ssh = paramiko . SSHClient ( ) ssh . set_missing_host_key_policy ( paramiko . AutoAddPolicy ( ) ) options = self . get_scan_options ( scan_id ) port = int ( options [ 'port' ] ) timeout = int ( options [ 'ssh_timeout' ] ) credentials = self . get_scan_credentials ( scan... | Run a single command via SSH and return the content of stdout or None in case of an Error . A scan error is issued in the latter case . |
16,840 | def get_result_xml ( result ) : result_xml = Element ( 'result' ) for name , value in [ ( 'name' , result [ 'name' ] ) , ( 'type' , ResultType . get_str ( result [ 'type' ] ) ) , ( 'severity' , result [ 'severity' ] ) , ( 'host' , result [ 'host' ] ) , ( 'test_id' , result [ 'test_id' ] ) , ( 'port' , result [ 'port' ]... | Formats a scan result to XML format . |
16,841 | def simple_response_str ( command , status , status_text , content = "" ) : response = Element ( '%s_response' % command ) for name , value in [ ( 'status' , str ( status ) ) , ( 'status_text' , status_text ) ] : response . set ( name , str ( value ) ) if isinstance ( content , list ) : for elem in content : response .... | Creates an OSP response XML string . |
16,842 | def close_client_stream ( client_stream , unix_path ) : try : client_stream . shutdown ( socket . SHUT_RDWR ) if unix_path : logger . debug ( '%s: Connection closed' , unix_path ) else : peer = client_stream . getpeername ( ) logger . debug ( '%s:%s: Connection closed' , peer [ 0 ] , peer [ 1 ] ) except ( socket . erro... | Closes provided client stream |
16,843 | def set_command_attributes ( self , name , attributes ) : if self . command_exists ( name ) : command = self . commands . get ( name ) command [ 'attributes' ] = attributes | Sets the xml attributes of a specified command . |
16,844 | def add_scanner_param ( self , name , scanner_param ) : assert name assert scanner_param self . scanner_params [ name ] = scanner_param command = self . commands . get ( 'start_scan' ) command [ 'elements' ] = { 'scanner_params' : { k : v [ 'name' ] for k , v in self . scanner_params . items ( ) } } | Add a scanner parameter . |
16,845 | def add_vt ( self , vt_id , name = None , vt_params = None , vt_refs = None , custom = None , vt_creation_time = None , vt_modification_time = None , vt_dependencies = None , summary = None , impact = None , affected = None , insight = None , solution = None , solution_t = None , detection = None , qod_t = None , qod_v... | Add a vulnerability test information . |
16,846 | def _preprocess_scan_params ( self , xml_params ) : params = { } for param in xml_params : params [ param . tag ] = param . text or '' for key in self . scanner_params : if key not in params : params [ key ] = self . get_scanner_param_default ( key ) if self . get_scanner_param_type ( key ) == 'selection' : params [ ke... | Processes the scan parameters . |
16,847 | def process_vts_params ( self , scanner_vts ) : vt_selection = { } filters = list ( ) for vt in scanner_vts : if vt . tag == 'vt_single' : vt_id = vt . attrib . get ( 'id' ) vt_selection [ vt_id ] = { } for vt_value in vt : if not vt_value . attrib . get ( 'id' ) : raise OSPDError ( 'Invalid VT preference. No attribute... | Receive an XML object with the Vulnerability Tests an their parameters to be use in a scan and return a dictionary . |
16,848 | def process_credentials_elements ( cred_tree ) : credentials = { } for credential in cred_tree : service = credential . attrib . get ( 'service' ) credentials [ service ] = { } credentials [ service ] [ 'type' ] = credential . attrib . get ( 'type' ) if service == 'ssh' : credentials [ service ] [ 'port' ] = credential... | Receive an XML object with the credentials to run a scan against a given target . |
16,849 | def process_targets_element ( cls , scanner_target ) : target_list = [ ] for target in scanner_target : ports = '' credentials = { } for child in target : if child . tag == 'hosts' : hosts = child . text if child . tag == 'ports' : ports = child . text if child . tag == 'credentials' : credentials = cls . process_crede... | Receive an XML object with the target ports and credentials to run a scan against . |
16,850 | def finish_scan ( self , scan_id ) : self . set_scan_progress ( scan_id , 100 ) self . set_scan_status ( scan_id , ScanStatus . FINISHED ) logger . info ( "%s: Scan finished." , scan_id ) | Sets a scan as finished . |
16,851 | def get_scanner_param_type ( self , param ) : assert isinstance ( param , str ) entry = self . scanner_params . get ( param ) if not entry : return None return entry . get ( 'type' ) | Returns type of a scanner parameter . |
16,852 | def get_scanner_param_mandatory ( self , param ) : assert isinstance ( param , str ) entry = self . scanner_params . get ( param ) if not entry : return False return entry . get ( 'mandatory' ) | Returns if a scanner parameter is mandatory . |
16,853 | def get_scanner_param_default ( self , param ) : assert isinstance ( param , str ) entry = self . scanner_params . get ( param ) if not entry : return None return entry . get ( 'default' ) | Returns default value of a scanner parameter . |
16,854 | def get_scanner_params_xml ( self ) : scanner_params = Element ( 'scanner_params' ) for param_id , param in self . scanner_params . items ( ) : param_xml = SubElement ( scanner_params , 'scanner_param' ) for name , value in [ ( 'id' , param_id ) , ( 'type' , param [ 'type' ] ) ] : param_xml . set ( name , value ) for n... | Returns the OSP Daemon s scanner params in xml format . |
16,855 | def new_client_stream ( self , sock ) : assert sock newsocket , fromaddr = sock . accept ( ) logger . debug ( "New connection from" " %s:%s" , fromaddr [ 0 ] , fromaddr [ 1 ] ) try : ssl_socket = ssl . wrap_socket ( newsocket , cert_reqs = ssl . CERT_REQUIRED , server_side = True , certfile = self . certs [ 'cert_file'... | Returns a new ssl client stream from bind_socket . |
16,856 | def write_to_stream ( stream , response , block_len = 1024 ) : try : i_start = 0 i_end = block_len while True : if i_end > len ( response ) : stream ( response [ i_start : ] ) break stream ( response [ i_start : i_end ] ) i_start = i_end i_end += block_len except ( socket . timeout , socket . error ) as exception : log... | Send the response in blocks of the given len using the passed method dependending on the socket type . |
16,857 | def handle_client_stream ( self , stream , is_unix = False ) : assert stream data = [ ] stream . settimeout ( 2 ) while True : try : if is_unix : buf = stream . recv ( 1024 ) else : buf = stream . read ( 1024 ) if not buf : break data . append ( buf ) except ( AttributeError , ValueError ) as message : logger . error (... | Handles stream of data received from client . |
16,858 | def parallel_scan ( self , scan_id , target ) : try : ret = self . exec_scan ( scan_id , target ) if ret == 0 : self . add_scan_host_detail ( scan_id , name = 'host_status' , host = target , value = '0' ) elif ret == 1 : self . add_scan_host_detail ( scan_id , name = 'host_status' , host = target , value = '1' ) elif r... | Starts the scan with scan_id . |
16,859 | def calculate_progress ( self , scan_id ) : t_prog = dict ( ) for target in self . get_scan_target ( scan_id ) : t_prog [ target ] = self . get_scan_target_progress ( scan_id , target ) return sum ( t_prog . values ( ) ) / len ( t_prog ) | Calculate the total scan progress from the partial target progress . |
16,860 | def start_scan ( self , scan_id , targets , parallel = 1 ) : os . setsid ( ) multiscan_proc = [ ] logger . info ( "%s: Scan started." , scan_id ) target_list = targets if target_list is None or not target_list : raise OSPDError ( 'Erroneous targets list' , 'start_scan' ) for index , target in enumerate ( target_list ) ... | Handle N parallel scans if parallel is greater than 1 . |
16,861 | def dry_run_scan ( self , scan_id , targets ) : os . setsid ( ) for _ , target in enumerate ( targets ) : host = resolve_hostname ( target [ 0 ] ) if host is None : logger . info ( "Couldn't resolve %s." , target [ 0 ] ) continue port = self . get_scan_ports ( scan_id , target = target [ 0 ] ) logger . info ( "%s:%s: D... | Dry runs a scan . |
16,862 | def handle_timeout ( self , scan_id , host ) : self . add_scan_error ( scan_id , host = host , name = "Timeout" , value = "{0} exec timeout." . format ( self . get_scanner_name ( ) ) ) | Handles scanner reaching timeout error . |
16,863 | def set_scan_target_progress ( self , scan_id , target , host , progress ) : self . scan_collection . set_target_progress ( scan_id , target , host , progress ) | Sets host s progress which is part of target . |
16,864 | def get_help_text ( self ) : txt = str ( '\n' ) for name , info in self . commands . items ( ) : command_txt = "\t{0: <22} {1}\n" . format ( name , info [ 'description' ] ) if info [ 'attributes' ] : command_txt = '' . join ( [ command_txt , "\t Attributes:\n" ] ) for attrname , attrdesc in info [ 'attributes' ] . item... | Returns the help output in plain text format . |
16,865 | def elements_as_text ( self , elems , indent = 2 ) : assert elems text = "" for elename , eledesc in elems . items ( ) : if isinstance ( eledesc , dict ) : desc_txt = self . elements_as_text ( eledesc , indent + 2 ) desc_txt = '' . join ( [ '\n' , desc_txt ] ) elif isinstance ( eledesc , str ) : desc_txt = '' . join ( ... | Returns the elems dictionary as formatted plain text . |
16,866 | def delete_scan ( self , scan_id ) : if self . get_scan_status ( scan_id ) == ScanStatus . RUNNING : return 0 try : del self . scan_processes [ scan_id ] except KeyError : logger . debug ( 'Scan process for %s not found' , scan_id ) return self . scan_collection . delete_scan ( scan_id ) | Deletes scan_id scan from collection . |
16,867 | def get_scan_results_xml ( self , scan_id , pop_res ) : results = Element ( 'results' ) for result in self . scan_collection . results_iterator ( scan_id , pop_res ) : results . append ( get_result_xml ( result ) ) logger . info ( 'Returning %d results' , len ( results ) ) return results | Gets scan_id scan s results in XML format . |
16,868 | def get_xml_str ( self , data ) : responses = [ ] for tag , value in data . items ( ) : elem = Element ( tag ) if isinstance ( value , dict ) : for value in self . get_xml_str ( value ) : elem . append ( value ) elif isinstance ( value , list ) : value = ', ' . join ( [ m for m in value ] ) elem . text = value else : e... | Creates a string in XML Format using the provided data structure . |
16,869 | def get_scan_xml ( self , scan_id , detailed = True , pop_res = False ) : if not scan_id : return Element ( 'scan' ) target = ',' . join ( self . get_scan_target ( scan_id ) ) progress = self . get_scan_progress ( scan_id ) status = self . get_scan_status ( scan_id ) start_time = self . get_scan_start_time ( scan_id ) ... | Gets scan in XML format . |
16,870 | def get_vts_xml ( self , vt_id = None , filtered_vts = None ) : vts_xml = Element ( 'vts' ) if vt_id : vts_xml . append ( self . get_vt_xml ( vt_id ) ) elif filtered_vts : for vt_id in filtered_vts : vts_xml . append ( self . get_vt_xml ( vt_id ) ) else : for vt_id in self . vts : vts_xml . append ( self . get_vt_xml (... | Gets collection of vulnerability test information in XML format . If vt_id is specified the collection will contain only this vt if found . If no vt_id is specified the collection will contain all vts or those passed in filtered_vts . |
16,871 | def handle_command ( self , command ) : try : tree = secET . fromstring ( command ) except secET . ParseError : logger . debug ( "Erroneous client input: %s" , command ) raise OSPDError ( 'Invalid data' ) if not self . command_exists ( tree . tag ) and tree . tag != "authenticate" : raise OSPDError ( 'Bogus command nam... | Handles an osp command in a string . |
16,872 | def run ( self , address , port , unix_path ) : assert address or unix_path if unix_path : sock = bind_unix_socket ( unix_path ) else : sock = bind_socket ( address , port ) if sock is None : return False sock . setblocking ( False ) inputs = [ sock ] outputs = [ ] try : while True : readable , _ , _ = select . select ... | Starts the Daemon handling commands until interrupted . |
16,873 | def create_scan ( self , scan_id , targets , options , vts ) : if self . scan_exists ( scan_id ) : logger . info ( "Scan %s exists. Resuming scan." , scan_id ) return self . scan_collection . create_scan ( scan_id , targets , options , vts ) | Creates a new scan . |
16,874 | def set_scan_option ( self , scan_id , name , value ) : return self . scan_collection . set_option ( scan_id , name , value ) | Sets a scan s option to a provided value . |
16,875 | def check_scan_process ( self , scan_id ) : scan_process = self . scan_processes [ scan_id ] progress = self . get_scan_progress ( scan_id ) if progress < 100 and not scan_process . is_alive ( ) : self . set_scan_status ( scan_id , ScanStatus . STOPPED ) self . add_scan_error ( scan_id , name = "" , host = "" , value =... | Check the scan s process and terminate the scan if not alive . |
16,876 | def add_scan_log ( self , scan_id , host = '' , name = '' , value = '' , port = '' , test_id = '' , qod = '' ) : self . scan_collection . add_result ( scan_id , ResultType . LOG , host , name , value , port , test_id , 0.0 , qod ) | Adds a log result to scan_id scan . |
16,877 | def add_scan_error ( self , scan_id , host = '' , name = '' , value = '' , port = '' ) : self . scan_collection . add_result ( scan_id , ResultType . ERROR , host , name , value , port ) | Adds an error result to scan_id scan . |
16,878 | def add_scan_host_detail ( self , scan_id , host = '' , name = '' , value = '' ) : self . scan_collection . add_result ( scan_id , ResultType . HOST_DETAIL , host , name , value ) | Adds a host detail result to scan_id scan . |
16,879 | def add_scan_alarm ( self , scan_id , host = '' , name = '' , value = '' , port = '' , test_id = '' , severity = '' , qod = '' ) : self . scan_collection . add_result ( scan_id , ResultType . ALARM , host , name , value , port , test_id , severity , qod ) | Adds an alarm result to scan_id scan . |
16,880 | def parse_filters ( self , vt_filter ) : filter_list = vt_filter . split ( ';' ) filters = list ( ) for single_filter in filter_list : filter_aux = re . split ( '(\W)' , single_filter , 1 ) if len ( filter_aux ) < 3 : raise OSPDError ( "Invalid number of argument in the filter" , "get_vts" ) _element , _oper , _val = f... | Parse a string containing one or more filters and return a list of filters |
16,881 | def format_filter_value ( self , element , value ) : format_func = self . allowed_filter . get ( element ) return format_func ( value ) | Calls the specific function to format value depending on the given element . |
16,882 | def get_filtered_vts_list ( self , vts , vt_filter ) : if not vt_filter : raise RequiredArgument ( 'vt_filter: A valid filter is required.' ) filters = self . parse_filters ( vt_filter ) if not filters : return None _vts_aux = vts . copy ( ) for _element , _oper , _filter_val in filters : for vt_id in _vts_aux . copy (... | Gets a collection of vulnerability test from the vts dictionary which match the filter . |
16,883 | def inet_pton ( address_family , ip_string ) : global __inet_pton if __inet_pton is None : if hasattr ( socket , 'inet_pton' ) : __inet_pton = socket . inet_pton else : from ospd import win_socket __inet_pton = win_socket . inet_pton return __inet_pton ( address_family , ip_string ) | A platform independent version of inet_pton |
16,884 | def inet_ntop ( address_family , packed_ip ) : global __inet_ntop if __inet_ntop is None : if hasattr ( socket , 'inet_ntop' ) : __inet_ntop = socket . inet_ntop else : from ospd import win_socket __inet_ntop = win_socket . inet_ntop return __inet_ntop ( address_family , packed_ip ) | A platform independent version of inet_ntop |
16,885 | def ipv4_range_to_list ( start_packed , end_packed ) : new_list = list ( ) start = struct . unpack ( '!L' , start_packed ) [ 0 ] end = struct . unpack ( '!L' , end_packed ) [ 0 ] for value in range ( start , end + 1 ) : new_ip = socket . inet_ntoa ( struct . pack ( '!L' , value ) ) new_list . append ( new_ip ) return n... | Return a list of IPv4 entries from start_packed to end_packed . |
16,886 | def target_to_ipv4_short ( target ) : splitted = target . split ( '-' ) if len ( splitted ) != 2 : return None try : start_packed = inet_pton ( socket . AF_INET , splitted [ 0 ] ) end_value = int ( splitted [ 1 ] ) except ( socket . error , ValueError ) : return None start_value = int ( binascii . hexlify ( bytes ( sta... | Attempt to return a IPv4 short range list from a target string . |
16,887 | def target_to_ipv4_cidr ( target ) : splitted = target . split ( '/' ) if len ( splitted ) != 2 : return None try : start_packed = inet_pton ( socket . AF_INET , splitted [ 0 ] ) block = int ( splitted [ 1 ] ) except ( socket . error , ValueError ) : return None if block <= 0 or block > 30 : return None start_value = i... | Attempt to return a IPv4 CIDR list from a target string . |
16,888 | def target_to_ipv6_cidr ( target ) : splitted = target . split ( '/' ) if len ( splitted ) != 2 : return None try : start_packed = inet_pton ( socket . AF_INET6 , splitted [ 0 ] ) block = int ( splitted [ 1 ] ) except ( socket . error , ValueError ) : return None if block <= 0 or block > 126 : return None start_value =... | Attempt to return a IPv6 CIDR list from a target string . |
16,889 | def target_to_ipv4_long ( target ) : splitted = target . split ( '-' ) if len ( splitted ) != 2 : return None try : start_packed = inet_pton ( socket . AF_INET , splitted [ 0 ] ) end_packed = inet_pton ( socket . AF_INET , splitted [ 1 ] ) except socket . error : return None if end_packed < start_packed : return None r... | Attempt to return a IPv4 long - range list from a target string . |
16,890 | def ipv6_range_to_list ( start_packed , end_packed ) : new_list = list ( ) start = int ( binascii . hexlify ( start_packed ) , 16 ) end = int ( binascii . hexlify ( end_packed ) , 16 ) for value in range ( start , end + 1 ) : high = value >> 64 low = value & ( ( 1 << 64 ) - 1 ) new_ip = inet_ntop ( socket . AF_INET6 , ... | Return a list of IPv6 entries from start_packed to end_packed . |
16,891 | def target_to_ipv6_short ( target ) : splitted = target . split ( '-' ) if len ( splitted ) != 2 : return None try : start_packed = inet_pton ( socket . AF_INET6 , splitted [ 0 ] ) end_value = int ( splitted [ 1 ] , 16 ) except ( socket . error , ValueError ) : return None start_value = int ( binascii . hexlify ( start... | Attempt to return a IPv6 short - range list from a target string . |
16,892 | def target_to_ipv6_long ( target ) : splitted = target . split ( '-' ) if len ( splitted ) != 2 : return None try : start_packed = inet_pton ( socket . AF_INET6 , splitted [ 0 ] ) end_packed = inet_pton ( socket . AF_INET6 , splitted [ 1 ] ) except socket . error : return None if end_packed < start_packed : return None... | Attempt to return a IPv6 long - range list from a target string . |
16,893 | def target_to_hostname ( target ) : if len ( target ) == 0 or len ( target ) > 255 : return None if not re . match ( r'^[\w.-]+$' , target ) : return None return [ target ] | Attempt to return a single hostname list from a target string . |
16,894 | def target_to_list ( target ) : new_list = target_to_ipv4 ( target ) if not new_list : new_list = target_to_ipv6 ( target ) if not new_list : new_list = target_to_ipv4_cidr ( target ) if not new_list : new_list = target_to_ipv6_cidr ( target ) if not new_list : new_list = target_to_ipv4_short ( target ) if not new_list... | Attempt to return a list of single hosts from a target string . |
16,895 | def target_str_to_list ( target_str ) : new_list = list ( ) for target in target_str . split ( ',' ) : target = target . strip ( ) target_list = target_to_list ( target ) if target_list : new_list . extend ( target_list ) else : LOGGER . info ( "{0}: Invalid target value" . format ( target ) ) return None return list (... | Parses a targets string into a list of individual targets . |
16,896 | def port_range_expand ( portrange ) : if not portrange or '-' not in portrange : LOGGER . info ( "Invalid port range format" ) return None port_list = list ( ) for single_port in range ( int ( portrange [ : portrange . index ( '-' ) ] ) , int ( portrange [ portrange . index ( '-' ) + 1 : ] ) + 1 ) : port_list . append ... | Receive a port range and expands it in individual ports . |
16,897 | def ports_str_check_failed ( port_str ) : pattern = r'[^TU:0-9, \-]' if ( re . search ( pattern , port_str ) or port_str . count ( 'T' ) > 1 or port_str . count ( 'U' ) > 1 or port_str . count ( ':' ) < ( port_str . count ( 'T' ) + port_str . count ( 'U' ) ) ) : return True return False | Check if the port string is well formed . Return True if fail False other case . |
16,898 | def ports_as_list ( port_str ) : if not port_str : LOGGER . info ( "Invalid port value" ) return [ None , None ] if ports_str_check_failed ( port_str ) : LOGGER . info ( "{0}: Port list malformed." ) return [ None , None ] tcp_list = list ( ) udp_list = list ( ) ports = port_str . replace ( ' ' , '' ) b_tcp = ports . f... | Parses a ports string into two list of individual tcp and udp ports . |
16,899 | def port_list_compress ( port_list ) : if not port_list or len ( port_list ) == 0 : LOGGER . info ( "Invalid or empty port list." ) return '' port_list = sorted ( set ( port_list ) ) compressed_list = [ ] for key , group in itertools . groupby ( enumerate ( port_list ) , lambda t : t [ 1 ] - t [ 0 ] ) : group = list ( ... | Compress a port list and return a string . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.