When you write or modify Python code in the codebase, it's important to add or update the docstrings accordingly. If you wish to display these docstrings in the documentation, follow these steps.
Suppose the docstrings are located in the following path: docs/Submodules/IntelOwl/api_app/analyzers_manager/classes, and you want to show the description of a class, such as BaseAnalyzerMixin.
To include this in the documentation, use the following command:
classBaseAnalyzerMixin(Plugin,metaclass=ABCMeta):""" Abstract Base class for Analyzers. Never inherit from this branch, always use either one of ObservableAnalyzer or FileAnalyzer classes. """HashChoices=HashChoicesObservableTypes=ObservableTypesTypeChoices=TypeChoices@classmethod@propertydefconfig_exception(cls):"""Returns the AnalyzerConfigurationException class."""returnAnalyzerConfigurationException@propertydefanalyzer_name(self)->str:"""Returns the name of the analyzer."""returnself._config.name@classmethod@propertydefreport_model(cls):"""Returns the AnalyzerReport model."""returnAnalyzerReport@classmethod@propertydefconfig_model(cls):"""Returns the AnalyzerConfig model."""returnAnalyzerConfigdefget_exceptions_to_catch(self):""" Returns additional exceptions to catch when running *start* fn """return(AnalyzerConfigurationException,AnalyzerRunException,)def_validate_result(self,result,level=0,max_recursion=190):""" function to validate result, allowing to store inside postgres without errors. If the character \u0000 is present in the string, postgres will throw an error If an integer is bigger than max_int, Mongodb is not capable to store and will throw an error. If we have more than 200 recursion levels, every encoding will throw a maximum_nested_object exception """iflevel==max_recursion:logger.info(f"We have reached max_recursion {max_recursion} level. "f"The following object will be pruned {result} ")returnNoneifisinstance(result,dict):forkey,valuesinresult.items():result[key]=self._validate_result(values,level=level+1,max_recursion=max_recursion)elifisinstance(result,list):fori,_inenumerate(result):result[i]=self._validate_result(result[i],level=level+1,max_recursion=max_recursion)elifisinstance(result,str):returnresult.replace("\u0000","")elifisinstance(result,int)andresult>9223372036854775807:# max int 8bytesresult=9223372036854775807returnresultdefafter_run_success(self,content):""" Handles actions after a successful run. Args: content (any): The content to process after a successful run. """super().after_run_success(self._validate_result(content,max_recursion=15))
analyzer_name:strproperty
Returns the name of the analyzer.
config_exceptionclassmethodproperty
Returns the AnalyzerConfigurationException class.
config_modelclassmethodproperty
Returns the AnalyzerConfig model.
report_modelclassmethodproperty
Returns the AnalyzerReport model.
after_run_success(content)
Handles actions after a successful run.
Parameters:
Name
Type
Description
Default
content
any
The content to process after a successful run.
required
Source code in docs/Submodules/IntelOwl/api_app/analyzers_manager/classes.py
defafter_run_success(self,content):""" Handles actions after a successful run. Args: content (any): The content to process after a successful run. """super().after_run_success(self._validate_result(content,max_recursion=15))
get_exceptions_to_catch()
Returns additional exceptions to catch when running start fn
Source code in docs/Submodules/IntelOwl/api_app/analyzers_manager/classes.py