idx
int64
0
63k
question
stringlengths
53
5.28k
target
stringlengths
5
805
27,600
def url ( self , url , owner = None , ** kwargs ) : return URL ( self . tcex , url , owner = owner , ** kwargs )
Create the URL TI object .
27,601
def email_address ( self , address , owner = None , ** kwargs ) : return EmailAddress ( self . tcex , address , owner = owner , ** kwargs )
Create the Email Address TI object .
27,602
def file ( self , owner = None , ** kwargs ) : return File ( self . tcex , owner = owner , ** kwargs )
Create the File TI object .
27,603
def host ( self , hostname , owner = None , ** kwargs ) : return Host ( self . tcex , hostname , owner = owner , ** kwargs )
Create the Host TI object .
27,604
def indicator ( self , indicator_type = None , owner = None , ** kwargs ) : if not indicator_type : return Indicator ( self . tcex , None , owner = owner , ** kwargs ) upper_indicator_type = indicator_type . upper ( ) indicator = None if upper_indicator_type == 'ADDRESS' : indicator = Address ( self . tcex , kwargs . p...
Create the Indicator TI object .
27,605
def group ( self , group_type = None , owner = None , ** kwargs ) : group = None if not group_type : return Group ( self . tcex , None , None , owner = owner , ** kwargs ) name = kwargs . pop ( 'name' , None ) group_type = group_type . upper ( ) if group_type == 'ADVERSARY' : group = Adversary ( self . tcex , name , ow...
Create the Group TI object .
27,606
def adversary ( self , name , owner = None , ** kwargs ) : return Adversary ( self . tcex , name , owner = owner , ** kwargs )
Create the Adversary TI object .
27,607
def campaign ( self , name , owner = None , ** kwargs ) : return Campaign ( self . tcex , name , owner = owner , ** kwargs )
Create the Campaign TI object .
27,608
def document ( self , name , file_name , owner = None , ** kwargs ) : return Document ( self . tcex , name , file_name , owner = owner , ** kwargs )
Create the Document TI object .
27,609
def event ( self , name , owner = None , ** kwargs ) : return Event ( self . tcex , name , owner = owner , ** kwargs )
Create the Event TI object .
27,610
def email ( self , name , to , from_addr , subject , body , header , owner = None , ** kwargs ) : return Email ( self . tcex , name , to , from_addr , subject , body , header , owner = owner , ** kwargs )
Create the Email TI object .
27,611
def incident ( self , name , owner = None , ** kwargs ) : return Incident ( self . tcex , name , owner = owner , ** kwargs )
Create the Incident TI object .
27,612
def intrusion_sets ( self , name , owner = None , ** kwargs ) : return IntrusionSet ( self . tcex , name , owner = owner , ** kwargs )
Create the Intrustion Set TI object .
27,613
def report ( self , name , owner = None , ** kwargs ) : return Report ( self . tcex , name , owner = owner , ** kwargs )
Create the Report TI object .
27,614
def signature ( self , name , file_name , file_type , file_content , owner = None , ** kwargs ) : return Signature ( self . tcex , name , file_name , file_type , file_content , owner = owner , ** kwargs )
Create the Signature TI object .
27,615
def threat ( self , name , owner = None , ** kwargs ) : return Threat ( self . tcex , name , owner = owner , ** kwargs )
Create the Threat TI object .
27,616
def victim ( self , name , owner = None , ** kwargs ) : return Victim ( self . tcex , name , owner = owner , ** kwargs )
Create the Victim TI object .
27,617
def format ( self , record ) : return { 'timestamp' : int ( float ( record . created or time . time ( ) ) * 1000 ) , 'message' : record . msg or '' , 'level' : record . levelname or 'DEBUG' , }
Format log record for ThreatConnect API .
27,618
def emit ( self , record ) : self . entries . append ( self . format ( record ) ) if len ( self . entries ) > self . flush_limit and not self . session . auth . renewing : self . log_to_api ( ) self . entries = [ ]
Emit the log record .
27,619
def log_to_api ( self ) : if self . entries : try : headers = { 'Content-Type' : 'application/json' } self . session . post ( '/v2/logs/app' , headers = headers , json = self . entries ) except Exception : pass
Best effort API logger .
27,620
def class_factory ( name , base_class , class_dict ) : def __init__ ( self , tcex ) : base_class . __init__ ( self , tcex ) for k , v in class_dict . items ( ) : setattr ( self , k , v ) newclass = type ( str ( name ) , ( base_class , ) , { '__init__' : __init__ } ) return newclass
Internal method for dynamically building Custom Indicator classes .
27,621
def _apply_filters ( self ) : filters = [ ] for f in self . _filters : filters . append ( '{}{}{}' . format ( f [ 'name' ] , f [ 'operator' ] , f [ 'value' ] ) ) self . tcex . log . debug ( u'filters: {}' . format ( filters ) ) if filters : self . _request . add_payload ( 'filters' , ',' . join ( filters ) )
Apply any filters added to the resource .
27,622
def _request_process_json ( self , response ) : data = [ ] try : if self . _api_branch == 'bulk' : response_data = self . _request_bulk ( response ) else : response_data = response . json ( ) if self . _request_entity is None : data = response_data status = 'Success' elif self . _api_branch == 'bulk' : data , status = ...
Handle response data of type JSON
27,623
def _request_process_json_bulk ( self , response_data ) : status = 'Failure' data = response_data . get ( self . request_entity , [ ] ) if data : status = 'Success' return data , status
Handle bulk JSON response
27,624
def _request_process_json_standard ( self , response_data ) : data = response_data . get ( 'data' , { } ) . get ( self . request_entity , [ ] ) status = response_data . get ( 'status' , 'Failure' ) return data , status
Handle JSON response
27,625
def _request_process_octet ( response ) : status = 'Failure' data = response . content if data : status = 'Success' return data , status
Handle Document download .
27,626
def _request_process_text ( response ) : status = 'Failure' data = response . content if data : status = 'Success' return data , status
Handle Signature download .
27,627
def add_filter ( self , name , operator , value ) : self . _filters . append ( { 'name' : name , 'operator' : operator , 'value' : value } )
Add ThreatConnect API Filter for this resource request .
27,628
def association_custom ( self , association_name , association_resource = None ) : resource = self . copy ( ) association_api_branch = self . tcex . indicator_associations_types_data . get ( association_name , { } ) . get ( 'apiBranch' ) if association_api_branch is None : self . tcex . handle_error ( 305 , [ associati...
Custom Indicator association for this resource with resource value .
27,629
def association_pivot ( self , association_resource ) : resource = self . copy ( ) resource . _request_uri = '{}/{}' . format ( association_resource . request_uri , resource . _request_uri ) return resource
Pivot point on association for this resource .
27,630
def associations ( self , association_resource ) : resource = self . copy ( ) resource . _request_entity = association_resource . api_entity resource . _request_uri = '{}/{}' . format ( resource . _request_uri , association_resource . request_uri ) return resource
Retrieve Association for this resource of the type in association_resource .
27,631
def attributes ( self , resource_id = None ) : resource = self . copy ( ) resource . _request_entity = 'attribute' resource . _request_uri = '{}/attributes' . format ( resource . _request_uri ) if resource_id is not None : resource . _request_uri = '{}/{}' . format ( resource . _request_uri , resource_id ) return resou...
Attribute endpoint for this resource with optional attribute id .
27,632
def copy_reset ( self ) : self . _filters = [ ] self . _filter_or = False self . _paginate = True self . _paginate_count = 0 self . _result_count = None self . _result_limit = 500 self . _result_start = 0
Reset values after instance has been copied
27,633
def copy ( self ) : resource = copy . copy ( self ) resource . _request = self . tcex . request ( self . tcex . session ) resource . copy_reset ( ) resource . http_method = self . http_method if self . _request . payload . get ( 'owner' ) is not None : resource . owner = self . _request . payload . get ( 'owner' ) retu...
Return a clean copy of this instance .
27,634
def group_pivot ( self , group_resource ) : resource = self . copy ( ) resource . _request_uri = '{}/{}' . format ( group_resource . request_uri , resource . _request_uri ) return resource
Pivot point on groups for this resource .
27,635
def http_method ( self , data ) : data = data . upper ( ) if data in [ 'DELETE' , 'GET' , 'POST' , 'PUT' ] : self . _request . http_method = data self . _http_method = data
The HTTP Method for this resource request .
27,636
def indicator_pivot ( self , indicator_resource ) : resource = self . copy ( ) resource . _request_uri = '{}/{}' . format ( indicator_resource . request_uri , resource . _request_uri ) return resource
Pivot point on indicators for this resource .
27,637
def owner ( self , data ) : if data is not None : self . _request . add_payload ( 'owner' , data ) else : self . tcex . log . warn ( u'Provided owner was invalid. ({})' . format ( data ) )
The Owner payload value for this resource request .
27,638
def paginate ( self ) : self . tcex . log . warning ( u'Using deprecated method (paginate).' ) resources = [ ] self . _request . add_payload ( 'resultStart' , self . _result_start ) self . _request . add_payload ( 'resultLimit' , self . _result_limit ) results = self . request ( ) response = results . get ( 'response' ...
Paginate results from ThreatConnect API
27,639
def request ( self ) : self . _request . url = '{}/v2/{}' . format ( self . tcex . default_args . tc_api_path , self . _request_uri ) self . _apply_filters ( ) self . tcex . log . debug ( u'Resource URL: ({})' . format ( self . _request . url ) ) response = self . _request . send ( stream = self . _stream ) data , stat...
Send the request to the API .
27,640
def security_label_pivot ( self , security_label_resource ) : resource = self . copy ( ) resource . _request_uri = '{}/{}' . format ( security_label_resource . request_uri , resource . _request_uri ) return resource
Pivot point on security labels for this resource .
27,641
def security_labels ( self , resource_id = None ) : resource = self . copy ( ) resource . _request_entity = 'securityLabel' resource . _request_uri = '{}/securityLabels' . format ( resource . _request_uri ) if resource_id is not None : resource . _request_uri = '{}/{}' . format ( resource . _request_uri , resource_id )...
Security Label endpoint for this resource with optional label name .
27,642
def tag_pivot ( self , tag_resource ) : resource = self . copy ( ) resource . _request_uri = '{}/{}' . format ( tag_resource . request_uri , resource . _request_uri ) return resource
Pivot point on tags for this resource .
27,643
def tags ( self , resource_id = None ) : resource = self . copy ( ) resource . _request_entity = 'tag' resource . _request_uri = '{}/tags' . format ( resource . _request_uri ) if resource_id is not None : resource . _request_uri = '{}/{}' . format ( resource . _request_uri , self . tcex . safetag ( resource_id ) ) retu...
Tag endpoint for this resource with optional tag name .
27,644
def task_pivot ( self , task_resource ) : resource = self . copy ( ) resource . _request_uri = '{}/{}' . format ( task_resource . request_uri , resource . _request_uri ) return resource
Pivot point on Tasks for this resource .
27,645
def victim_assets ( self , asset_type = None , asset_id = None ) : type_entity_map = { 'emailAddresses' : 'victimEmailAddress' , 'networkAccounts' : 'victimNetworkAccount' , 'phoneNumbers' : 'victimPhone' , 'socialNetworks' : 'victimSocialNetwork' , 'webSites' : 'victimWebSite' , } resource = self . copy ( ) resource ....
Victim Asset endpoint for this resource with optional asset type .
27,646
def indicators ( self , indicator_data ) : for indicator_field in self . value_fields : if indicator_field == 'summary' : indicators = self . tcex . expand_indicators ( indicator_data . get ( 'summary' ) ) if indicator_data . get ( 'type' ) == 'File' : hash_patterns = { 'md5' : re . compile ( r'^([a-fA-F\d]{32})$' ) , ...
Generator for indicator values .
27,647
def observed ( self , date_observed = None ) : if self . name != 'Indicator' : self . tcex . log . warning ( u'Observed endpoint only available for "indicator" endpoint.' ) else : self . _request_uri = '{}/observed' . format ( self . _request_uri ) if date_observed is not None : self . _request . add_payload ( 'dateObs...
Retrieve indicator observations count for top 10
27,648
def csv ( self , ondemand = False ) : self . _request_uri = '{}/{}' . format ( self . _api_uri , 'csv' ) self . _stream = True if ondemand : self . _request . add_payload ( 'runNow' , True )
Update request URI to return CSV data .
27,649
def json ( self , ondemand = False ) : self . _request_entity = 'indicator' self . _request_uri = '{}/{}' . format ( self . _api_uri , 'json' ) self . _stream = True if ondemand : self . _request . add_payload ( 'runNow' , True )
Update request URI to return JSON data .
27,650
def indicator_body ( indicators ) : hash_patterns = { 'md5' : re . compile ( r'^([a-fA-F\d]{32})$' ) , 'sha1' : re . compile ( r'^([a-fA-F\d]{40})$' ) , 'sha256' : re . compile ( r'^([a-fA-F\d]{64})$' ) , } body = { } for indicator in indicators : if indicator is None : continue if hash_patterns [ 'md5' ] . match ( ind...
Generate the appropriate dictionary content for POST of an File indicator
27,651
def occurrence ( self , indicator = None ) : self . _request_entity = 'fileOccurrence' self . _request_uri = '{}/fileOccurrences' . format ( self . _request_uri ) if indicator is not None : self . _request_uri = '{}/{}/fileOccurrences' . format ( self . _api_uri , indicator )
Update the URI to retrieve file occurrences for the provided indicator .
27,652
def resolution ( self , indicator = None ) : self . _request_entity = 'dnsResolution' self . _request_uri = '{}/dnsResolutions' . format ( self . _request_uri ) if indicator is not None : self . _request_uri = '{}/{}/dnsResolutions' . format ( self . _api_uri , indicator )
Update the URI to retrieve host resolutions for the provided indicator .
27,653
def group_id ( self , resource_id ) : if self . _name != 'group' : self . _request_uri = '{}/{}' . format ( self . _api_uri , resource_id )
Update the request URI to include the Group ID for specific group retrieval .
27,654
def pdf ( self , resource_id ) : self . resource_id ( str ( resource_id ) ) self . _request_uri = '{}/pdf' . format ( self . _request_uri )
Update the request URI to get the pdf for this resource .
27,655
def download ( self , resource_id ) : self . resource_id ( str ( resource_id ) ) self . _request_uri = '{}/download' . format ( self . _request_uri )
Update the request URI to download the document for this resource .
27,656
def upload ( self , resource_id , data ) : self . body = data self . content_type = 'application/octet-stream' self . resource_id ( str ( resource_id ) ) self . _request_uri = '{}/upload' . format ( self . _request_uri )
Update the request URI to upload the a document to this resource .
27,657
def data ( self , resource_value , return_value = False ) : if return_value : self . _request_entity = None self . _request . add_payload ( 'returnValue' , True ) self . _request_uri = '{}/{}/data' . format ( self . _request_uri , resource_value )
Alias for metric_name method
27,658
def tag ( self , resource_id ) : self . _request_uri = '{}/{}' . format ( self . _request_uri , self . tcex . safetag ( resource_id ) )
Update the request URI to include the Tag for specific retrieval .
27,659
def assignees ( self , assignee = None , resource_id = None ) : if resource_id is not None : self . resource_id ( resource_id ) self . _request_uri = '{}/assignees' . format ( self . _request_uri ) if assignee is not None : self . _request_uri = '{}/{}' . format ( self . _request_uri , assignee )
Add an assignee to a Task
27,660
def escalatees ( self , escalatee = None , resource_id = None ) : if resource_id is not None : self . resource_id ( resource_id ) self . _request_uri = '{}/escalatees' . format ( self . _request_uri ) if escalatee is not None : self . _request_uri = '{}/{}' . format ( self . _request_uri , escalatee )
Add an escalatee to a Task
27,661
def _request ( self , domain , type_name , search_command , db_method , body = None ) : headers = { 'Content-Type' : 'application/json' , 'DB-Method' : db_method } search_command = self . _clean_datastore_path ( search_command ) url = '/v2/exchange/db/{}/{}/{}' . format ( domain , type_name , search_command ) r = self ...
Make the API request for a Data Store CRUD operation
27,662
def create ( self , domain , type_name , search_command , body ) : return self . _request ( domain , type_name , search_command , 'POST' , body )
Create entry in ThreatConnect Data Store
27,663
def delete ( self , domain , type_name , search_command ) : return self . _request ( domain , type_name , search_command , 'DELETE' , None )
Delete entry in ThreatConnect Data Store
27,664
def read ( self , domain , type_name , search_command , body = None ) : return self . _request ( domain , type_name , search_command , 'GET' , body )
Read entry in ThreatConnect Data Store
27,665
def update ( self , domain , type_name , search_command , body ) : return self . _request ( domain , type_name , search_command , 'PUT' , body )
Update entry in ThreatConnect Data Store
27,666
def file_content ( self , file_content , update_if_exists = True ) : if not self . can_update ( ) : self . _tcex . handle_error ( 910 , [ self . type ] ) self . _data [ 'fileContent' ] = file_content return self . tc_requests . upload ( self . api_type , self . api_sub_type , self . unique_id , file_content , update_if...
Updates the file content .
27,667
def file_name ( self , file_name ) : if not self . can_update ( ) : self . _tcex . handle_error ( 910 , [ self . type ] ) self . _data [ 'fileName' ] = file_name request = { 'fileName' : file_name } return self . tc_requests . update ( self . api_type , self . api_sub_type , self . unique_id , request )
Updates the file_name .
27,668
def malware ( self , malware , password , file_name ) : if not self . can_update ( ) : self . _tcex . handle_error ( 910 , [ self . type ] ) self . _data [ 'malware' ] = malware self . _data [ 'password' ] = password self . _data [ 'fileName' ] = file_name request = { 'malware' : malware , 'password' : password , 'file...
Uploads to malware vault .
27,669
def check_imports ( self ) : modules = [ ] for filename in sorted ( os . listdir ( self . app_path ) ) : if not filename . endswith ( '.py' ) : continue fq_path = os . path . join ( self . app_path , filename ) with open ( fq_path , 'rb' ) as f : code_lines = deque ( [ ( f . read ( ) , 1 ) ] ) while code_lines : m_stat...
Check the projects top level directory for missing imports .
27,670
def check_import_stdlib ( module ) : if ( module in stdlib_list ( '2.7' ) or module in stdlib_list ( '3.4' ) or module in stdlib_list ( '3.5' ) or module in stdlib_list ( '3.6' ) or module in stdlib_list ( '3.7' ) or module in [ 'app' , 'args' , 'playbook_app' ] ) : return True return False
Check if module is in Python stdlib .
27,671
def check_install_json ( self ) : if self . install_json_schema is None : return contents = os . listdir ( self . app_path ) if self . args . install_json is not None : contents = [ self . args . install_json ] for install_json in sorted ( contents ) : if 'install.json' not in install_json : continue error = None statu...
Check all install . json files for valid schema .
27,672
def check_layout_json ( self ) : layout_json_file = 'layout.json' if self . layout_json_schema is None or not os . path . isfile ( layout_json_file ) : return error = None status = True try : with open ( layout_json_file ) as fh : data = json . loads ( fh . read ( ) ) validate ( data , self . layout_json_schema ) excep...
Check all layout . json files for valid schema .
27,673
def check_layout_params ( self ) : ij_input_names = [ ] ij_output_names = [ ] if os . path . isfile ( 'install.json' ) : try : with open ( 'install.json' ) as fh : ij = json . loads ( fh . read ( ) ) for p in ij . get ( 'params' , [ ] ) : ij_input_names . append ( p . get ( 'name' ) ) for o in ij . get ( 'playbook' , {...
Check that the layout . json is consistent with install . json .
27,674
def check_syntax ( self , app_path = None ) : app_path = app_path or '.' for filename in sorted ( os . listdir ( app_path ) ) : error = None status = True if filename . endswith ( '.py' ) : try : with open ( filename , 'rb' ) as f : ast . parse ( f . read ( ) , filename = filename ) except SyntaxError : status = False ...
Run syntax on each . py and . json file .
27,675
def install_json_schema ( self ) : if self . _install_json_schema is None and self . install_json_schema_file is not None : if os . path . isfile ( 'tcex_json_schema.json' ) : os . remove ( 'tcex_json_schema.json' ) if os . path . isfile ( self . install_json_schema_file ) : with open ( self . install_json_schema_file ...
Load install . json schema file .
27,676
def interactive ( self ) : while True : line = sys . stdin . readline ( ) . strip ( ) if line == 'quit' : sys . exit ( ) elif line == 'validate' : self . check_syntax ( ) self . check_imports ( ) self . check_install_json ( ) self . check_layout_json ( ) self . print_json ( ) self . validation_data = self . _validation...
Run in interactive mode .
27,677
def layout_json_schema ( self ) : if self . _layout_json_schema is None and self . layout_json_schema_file is not None : if os . path . isfile ( self . layout_json_schema_file ) : with open ( self . layout_json_schema_file ) as fh : self . _layout_json_schema = json . load ( fh ) return self . _layout_json_schema
Load layout . json schema file .
27,678
def print_results ( self ) : if self . validation_data . get ( 'fileSyntax' ) : print ( '\n{}{}Validated File Syntax:' . format ( c . Style . BRIGHT , c . Fore . BLUE ) ) print ( '{}{!s:<60}{!s:<25}' . format ( c . Style . BRIGHT , 'File:' , 'Status:' ) ) for f in self . validation_data . get ( 'fileSyntax' ) : status_...
Print results .
27,679
def status_color ( status ) : status_color = c . Fore . GREEN if not status : status_color = c . Fore . RED return status_color
Return the appropriate status color .
27,680
def _dt_to_epoch ( dt ) : try : epoch = dt . timestamp ( ) except AttributeError : epoch = ( dt - datetime ( 1970 , 1 , 1 ) ) . total_seconds ( ) return epoch
Convert datetime to epoch seconds .
27,681
def get ( self , rid , data_callback = None , raise_on_error = True ) : cached_data = None ds_data = self . ds . get ( rid , raise_on_error = False ) if ds_data is not None : expired = True if ds_data . get ( 'found' ) is True : if self . ttl < int ( ds_data . get ( '_source' , { } ) . get ( 'cache-date' , 0 ) ) : cach...
Get cached data from the data store .
27,682
def update ( self , rid , data , raise_on_error = True ) : cache_data = { 'cache-date' : self . _dt_to_epoch ( datetime . now ( ) ) , 'cache-data' : data } return self . ds . put ( rid , cache_data , raise_on_error )
Write updated cache data to the DataStore .
27,683
def _association_types ( self ) : r = self . session . get ( '/v2/types/associationTypes' ) if not r . ok or 'application/json' not in r . headers . get ( 'content-type' , '' ) : warn = u'Custom Indicators Associations are not supported.' self . log . warning ( warn ) return data = r . json ( ) if data . get ( 'status'...
Retrieve Custom Indicator Associations types from the ThreatConnect API .
27,684
def _log ( self ) : self . _log_platform ( ) self . _log_app_data ( ) self . _log_python_version ( ) self . _log_tcex_version ( ) self . _log_tc_proxy ( )
Send System and App data to logs .
27,685
def _log_app_data ( self ) : if self . install_json : app_commit_hash = self . install_json . get ( 'commitHash' ) app_features = ',' . join ( self . install_json . get ( 'features' , [ ] ) ) app_min_ver = self . install_json . get ( 'minServerVersion' , 'N/A' ) app_name = self . install_json . get ( 'displayName' ) ap...
Log the App data information .
27,686
def _log_python_version ( self ) : self . log . info ( u'Python Version: {}.{}.{}' . format ( sys . version_info . major , sys . version_info . minor , sys . version_info . micro ) )
Log the current Python version .
27,687
def _log_tc_proxy ( self ) : if self . default_args . tc_proxy_tc : self . log . info ( u'Proxy Server (TC): {}:{}.' . format ( self . default_args . tc_proxy_host , self . default_args . tc_proxy_port ) )
Log the proxy settings .
27,688
def _log_tcex_version ( self ) : self . log . info ( u'TcEx Version: {}' . format ( __import__ ( __name__ ) . __version__ ) )
Log the current TcEx version number .
27,689
def _logger ( self ) : level = logging . INFO self . log . setLevel ( level ) self . log . handlers = [ ] if self . default_args . logging is not None : level = self . _logger_levels [ self . default_args . logging ] elif self . default_args . tc_log_level is not None : level = self . _logger_levels [ self . default_ar...
Create TcEx app logger instance .
27,690
def _logger_api ( self ) : from . tcex_logger import TcExLogHandler , TcExLogFormatter api = TcExLogHandler ( self . session ) api . set_name ( 'api' ) api . setLevel ( logging . DEBUG ) api . setFormatter ( TcExLogFormatter ( ) ) self . log . addHandler ( api )
Add API logging handler .
27,691
def _logger_fh ( self ) : logfile = os . path . join ( self . default_args . tc_log_path , self . default_args . tc_log_file ) fh = logging . FileHandler ( logfile ) fh . set_name ( 'fh' ) fh . setLevel ( logging . DEBUG ) fh . setFormatter ( self . _logger_formatter ) self . log . addHandler ( fh )
Add File logging handler .
27,692
def _logger_levels ( self ) : return { 'debug' : logging . DEBUG , 'info' : logging . INFO , 'warning' : logging . WARNING , 'error' : logging . ERROR , 'critical' : logging . CRITICAL , }
Return log levels .
27,693
def _logger_stream ( self ) : sh = logging . StreamHandler ( ) sh . set_name ( 'sh' ) sh . setLevel ( logging . INFO ) sh . setFormatter ( self . _logger_formatter ) self . log . addHandler ( sh )
Add stream logging handler .
27,694
def _resources ( self , custom_indicators = False ) : from importlib import import_module self . resources = import_module ( 'tcex.tcex_resources' ) if custom_indicators : self . log . info ( 'Loading custom indicator types.' ) r = self . session . get ( '/v2/types/indicatorTypes' ) if not r . ok or 'application/json' ...
Initialize the resource module .
27,695
def utils ( self ) : if self . _utils is None : from . tcex_utils import TcExUtils self . _utils = TcExUtils ( self ) return self . _utils
Include the Utils module .
27,696
def batch ( self , owner , action = None , attribute_write_type = None , halt_on_error = False , playbook_triggers_enabled = None , ) : from . tcex_ti_batch import TcExBatch return TcExBatch ( self , owner , action , attribute_write_type , halt_on_error , playbook_triggers_enabled )
Return instance of Batch
27,697
def cache ( self , domain , data_type , ttl_minutes = None , mapping = None ) : from . tcex_cache import TcExCache return TcExCache ( self , domain , data_type , ttl_minutes , mapping )
Get instance of the Cache module .
27,698
def data_filter ( self , data ) : try : from . tcex_data_filter import DataFilter return DataFilter ( self , data ) except ImportError as e : warn = u'Required Module is not installed ({}).' . format ( e ) self . log . warning ( warn )
Return an instance of the Data Filter Class .
27,699
def datastore ( self , domain , data_type , mapping = None ) : from . tcex_datastore import TcExDataStore return TcExDataStore ( self , domain , data_type , mapping )
Get instance of the DataStore module .