(g)ULP!
Loading...
Searching...
No Matches
PluginBase Class Reference
Inheritance diagram for PluginBase:
Collaboration diagram for PluginBase:

Public Member Functions

None __init__ (self, str path, **kwargs)
 
None cleanup (self)
 
list[str] depends_on (self)
 
str desc (self)
 
str event_type_field (self)
 
str get_unmapped_field_name (self, str field)
 
GulpRequestStatus ingest (self, str index, str req_id, int client_id, int operation_id, str context, str|list[dict] source, str ws_id, GulpPluginParams plugin_params=None, GulpIngestionFilter flt=None, **kwargs)
 
tuple[dict, GulpMapping] ingest_plugin_initialize (self, str index, str|dict source, bool skip_mapping=False, ProcessingPipeline pipeline=None, str mapping_file=None, str mapping_id=None, GulpPluginParams plugin_params=None)
 
bool internal (self)
 
str name (self)
 
list[GulpPluginOptionoptions (self)
 
ProcessingPipeline pipeline (self, GulpPluginParams plugin_params=None, **kwargs)
 
tuple[int, GulpRequestStatus] query (self, int operation_id, int client_id, int user_id, str username, str ws_id, str req_id, GulpPluginParams plugin_params, GulpQueryFilter flt, GulpQueryOptions options=None)
 
list[GulpDocument] record_to_gulp_document (self, int operation_id, int client_id, str context, str source, TmpIngestStats fs, any record, int record_idx, GulpMapping custom_mapping=None, dict index_type_mapping=None, str plugin=None, GulpPluginParams plugin_params=None, **kwargs)
 
ProcessingPipeline sigma_plugin_initialize (self, ProcessingPipeline pipeline=None, str mapping_file=None, str mapping_id=None, str product=None, GulpPluginParams plugin_params=None)
 
list[str] tags (self)
 
GulpPluginType type (self)
 
str version (self)
 

Public Attributes

list buffer = []
 
str client_id = None
 
str context = None
 
str index = None
 
str operation_id = None
 
 path = path
 
str req_id = None
 
str ws_id = None
 

Protected Member Functions

list[GulpDocument] _build_gulpdocuments (self, list[FieldMappingEntry] fme, int idx, int operation_id, str context, str plugin, int client_id, str raw_event, str original_id, str src_file, int timestamp=None, int timestamp_nsec=None, str event_code=None, list[str] cat=None, int duration_nsec=0, GulpLogLevel gulp_log_level=None, str original_log_level=None, bool remove_raw_event=False, **kwargs)
 
list[dict] _build_ingestion_chunk_for_ws (self, list[dict] docs, GulpIngestionFilter flt=None)
 
list[GulpDocument] _call_record_to_gulp_document_funcs (self, int operation_id, int client_id, str context, str source, TmpIngestStats fs, any record, int record_idx, GulpMapping custom_mapping=None, dict index_type_mapping=None, str plugin=None, GulpPluginParams plugin_params=None, Callable record_to_gulp_document_fun=None, **kwargs)
 
GulpRequestStatus _finish_ingestion (self, str index, str|dict source, str req_id, int client_id, str ws_id, TmpIngestStats fs, GulpIngestionFilter flt=None)
 
TmpIngestStats _flush_buffer (self, str index, TmpIngestStats fs, str ws_id, str req_id, GulpIngestionFilter flt=None, bool wait_for_refresh=False)
 
TmpIngestStats _ingest_record (self, str index, GulpDocument|dict doc, TmpIngestStats fs, str ws_id, str req_id, GulpIngestionFilter flt=None, bool flush_enabled=True, **kwargs)
 
list[FieldMappingEntry] _map_source_key (self, GulpPluginParams plugin_params, GulpMapping custom_mapping, str source_key, Any v, dict index_type_mapping=None, bool ignore_custom_mapping=False, **kwargs)
 
TmpIngestStats _parser_failed (self, TmpIngestStats fs, str|dict source, Exception|str ex)
 
tuple[GulpMapping, GulpPluginParams_process_plugin_params (self, GulpMapping custom_mapping, GulpPluginParams plugin_params=None)
 
tuple[TmpIngestStats, bool] _process_record (self, str index, any record, int record_idx, Callable my_record_to_gulp_document_fun, str ws_id, str req_id, int operation_id, int client_id, str context, str source, TmpIngestStats fs, GulpMapping custom_mapping=None, dict index_type_mapping=None, str plugin=None, GulpPluginParams plugin_params=None, GulpIngestionFilter flt=None, **kwargs)
 
TmpIngestStats _record_failed (self, TmpIngestStats fs, any entry, str|dict source, Exception|str ex)
 
any _type_checks (self, any v, str k, dict index_type_mapping)
 

Detailed Description

Base class for all Gulp plugins.

Definition at line 46 of file plugin.py.

Constructor & Destructor Documentation

◆ __init__()

None __init__ ( self,
str path,
** kwargs )
Initializes a new instance of the PluginBase class.

Args:
    path (str): The path to the plugin.
    kwargs: additional arguments if any

Definition at line 51 of file plugin.py.

55 ) -> None:
56 """
57 Initializes a new instance of the PluginBase class.
58
59 Args:
60 path (str): The path to the plugin.
61 kwargs: additional arguments if any
62 """
63 self.req_id: str = None
64 self.index: str = None
65 self.client_id: str = None
66 self.operation_id: str = None
67 self.context: str = None
68 self.ws_id: str = None
69 self.path = path
70
71 self.buffer: list[GulpDocument] = []
72 for k, v in kwargs.items():
73 self.__dict__[k] = v
74
75 super().__init__()
76

Member Function Documentation

◆ _build_gulpdocuments()

list[GulpDocument] _build_gulpdocuments ( self,
list[FieldMappingEntry] fme,
int idx,
int operation_id,
str context,
str plugin,
int client_id,
str raw_event,
str original_id,
str src_file,
int timestamp = None,
int timestamp_nsec = None,
str event_code = None,
list[str] cat = None,
int duration_nsec = 0,
GulpLogLevel gulp_log_level = None,
str original_log_level = None,
bool remove_raw_event = False,
** kwargs )
protected
build one or more GulpDocument objects from a list of FieldMappingEntry objects:

this function creates as many GulpDocument objects as there are FieldMappingEntry objects with is_timestamp=True.
if no FieldMappingEntry object has is_timestamp=True, it creates a single GulpDocument object with the first FieldMappingEntry object.

Definition at line 558 of file plugin.py.

578 ) -> list[GulpDocument]:
579 """
580 build one or more GulpDocument objects from a list of FieldMappingEntry objects:
581
582 this function creates as many GulpDocument objects as there are FieldMappingEntry objects with is_timestamp=True.
583 if no FieldMappingEntry object has is_timestamp=True, it creates a single GulpDocument object with the first FieldMappingEntry object.
584 """
585 docs: list[GulpDocument] = []
586 append_doc = docs.append # local variable for faster access
587
588 common_params = {
589 "idx": idx,
590 "operation_id": operation_id,
591 "context": context,
592 "plugin": plugin,
593 "client_id": client_id,
594 "raw_event": raw_event,
595 "original_id": original_id,
596 "src_file": src_file,
597 "timestamp": timestamp,
598 "timestamp_nsec": timestamp_nsec,
599 "event_code": event_code,
600 "cat": cat,
601 "duration_nsec": duration_nsec,
602 "gulp_log_level": gulp_log_level,
603 "original_log_level": original_log_level,
604 **kwargs,
605 }
606 for f in fme:
607 # print("%s\n\n" % (f))
608 # for each is_timestamp build a gulpdocument with all the fields in fme
609 if f.is_timestamp:
610 d = GulpDocument(fme=fme, f=f, **common_params)
611 if remove_raw_event:
612 d.original_event = None
613
614 # print("%s\n\n" % (d))
615 append_doc(d)
616
617 if len(docs) == 0:
618 # create a document with the given timestamp in timestamp/timestamp_nsec (if any, either it will be set to 0/invalid)
619 d = GulpDocument(fme=fme, **common_params)
620 if remove_raw_event:
621 d.original_event = None
622 append_doc(d)
623
624 return docs
625

◆ _build_ingestion_chunk_for_ws()

list[dict] _build_ingestion_chunk_for_ws ( self,
list[dict] docs,
GulpIngestionFilter flt = None )
protected
Builds the ingestion chunk for the websocket, filtering if needed.

Definition at line 829 of file plugin.py.

831 ) -> list[dict]:
832 """
833 Builds the ingestion chunk for the websocket, filtering if needed.
834 """
835 # logger().debug("building ingestion chunk, flt=%s" % (flt))
836 if not docs:
837 return []
838
839 ws_docs = [
840 {
841 "_id": doc["_id"],
842 "@timestamp": doc["@timestamp"],
843 "gulp.source.file": doc["gulp.source.file"],
844 "event.duration": doc["event.duration"],
845 "gulp.context": doc["gulp.context"],
846 "gulp.log.level": doc.get("gulp.log.level", int(GulpLogLevel.INFO)),
847 "event.category": doc.get("event.category", None),
848 "event.code": doc["event.code"],
849 "gulp.event.code": doc["gulp.event.code"],
850 }
851 for doc in docs
852 if elastic_api.filter_doc_for_ingestion(
853 doc, flt, ignore_store_all_documents=True
854 )
855 == GulpEventFilterResult.ACCEPT
856 ]
857
858 return ws_docs
859
Here is the caller graph for this function:

◆ _call_record_to_gulp_document_funcs()

list[GulpDocument] _call_record_to_gulp_document_funcs ( self,
int operation_id,
int client_id,
str context,
str source,
TmpIngestStats fs,
any record,
int record_idx,
GulpMapping custom_mapping = None,
dict index_type_mapping = None,
str plugin = None,
GulpPluginParams plugin_params = None,
Callable record_to_gulp_document_fun = None,
** kwargs )
protected
Stub function to call stacked plugins record_to_document_gulp_document.
Each function is called with the previously returned GulpDocument.

Args:
    operation_id (int): the operation ID associated with the record
    client_id (int): client ID performing the ingestion
    context (str): context associated with the record
    source (str): source of the record (source file name or path, usually)
    fs (TmpIngestStats): _description_
    record (any): a single record (first time) or a list of GulpDocument objects (in stacked plugins)
    record_idx (int): The index of the record in source.
    custom_mapping (GulpMapping, optional): The custom mapping to use for the conversion. Defaults to None.
    index_type_mapping (dict, optional): elastic search index type mappings { "field": "type", ... }. Defaults to None.
    plugin (str, optional): "agent.type" to be set in the GulpDocument. Defaults to None.
    plugin_params (GulpPluginParams, optional): The plugin parameters to use, if any. Defaults to None.
    record_to_gulp_document_fun (Callable, optional): function to parse record into a gulp document, if stacked this receives a list of GulpDocuments

Returns:
    list[GulpDocument]: zero or more GulpDocument objects

Definition at line 379 of file plugin.py.

394 ) -> list[GulpDocument]:
395 """Stub function to call stacked plugins record_to_document_gulp_document.
396 Each function is called with the previously returned GulpDocument.
397
398 Args:
399 operation_id (int): the operation ID associated with the record
400 client_id (int): client ID performing the ingestion
401 context (str): context associated with the record
402 source (str): source of the record (source file name or path, usually)
403 fs (TmpIngestStats): _description_
404 record (any): a single record (first time) or a list of GulpDocument objects (in stacked plugins)
405 record_idx (int): The index of the record in source.
406 custom_mapping (GulpMapping, optional): The custom mapping to use for the conversion. Defaults to None.
407 index_type_mapping (dict, optional): elastic search index type mappings { "field": "type", ... }. Defaults to None.
408 plugin (str, optional): "agent.type" to be set in the GulpDocument. Defaults to None.
409 plugin_params (GulpPluginParams, optional): The plugin parameters to use, if any. Defaults to None.
410 record_to_gulp_document_fun (Callable, optional): function to parse record into a gulp document, if stacked this receives a list of GulpDocuments
411
412 Returns:
413 list[GulpDocument]: zero or more GulpDocument objects
414 """
415 # plugin_params=deepcopy(plugin_params)
416
417 if plugin_params is None:
418 plugin_params = GulpPluginParams()
419
420 docs = record
421
422 if record_to_gulp_document_fun is not None:
423 docs = await record_to_gulp_document_fun(
424 operation_id,
425 client_id,
426 context,
427 source,
428 fs,
429 record,
430 record_idx,
431 custom_mapping,
432 index_type_mapping,
433 plugin,
434 plugin_params,
435 **kwargs,
436 )
437
438 for fun in plugin_params.record_to_gulp_document_fun:
439 docs = await fun(
440 operation_id,
441 client_id,
442 context,
443 source,
444 fs,
445 docs,
446 record_idx,
447 custom_mapping,
448 index_type_mapping,
449 plugin,
450 plugin_params,
451 **kwargs,
452 )
453
454 if docs is None:
455 return []
456 return docs
457
Here is the caller graph for this function:

◆ _finish_ingestion()

GulpRequestStatus _finish_ingestion ( self,
str index,
str | dict source,
str req_id,
int client_id,
str ws_id,
TmpIngestStats fs,
GulpIngestionFilter flt = None )
protected
to be called whenever ingest() must exit: flushes the buffer and updates the ingestion stats

Definition at line 970 of file plugin.py.

979 ) -> GulpRequestStatus:
980 """
981 to be called whenever ingest() must exit: flushes the buffer and updates the ingestion stats
982 """
983 try:
984 # finally flush ingestion buffer
985 fs = await self._flush_buffer(index, fs, ws_id, req_id, flt)
986 logger().info(
987 "INGESTION DONE FOR source=%s,\n\tclient_id=%d (processed(ingested)=%d, failed=%d, skipped=%d, errors=%d, parser_errors=%d)"
988 % (
989 muty.string.make_shorter(str(source), 260),
990 client_id,
991 fs.ev_processed,
992 fs.ev_failed,
993 fs.ev_skipped,
994 len(fs.ingest_errors),
995 fs.parser_failed,
996 )
997 )
998 except Exception as ex:
999 fs = fs.update(ingest_errors=[ex])
1000 logger().exception(
1001 "FAILED finalizing ingestion for source=%s"
1002 % (muty.string.make_shorter(str(source), 260))
1003 )
1004
1005 finally:
1006 status, _ = await GulpStats.update(
1007 await collab_api.collab(),
1008 req_id,
1009 ws_id,
1010 fs=fs,
1011 force=True,
1012 file_done=True,
1013 )
1014 return status
1015
1016
Here is the call graph for this function:

◆ _flush_buffer()

TmpIngestStats _flush_buffer ( self,
str index,
TmpIngestStats fs,
str ws_id,
str req_id,
GulpIngestionFilter flt = None,
bool wait_for_refresh = False )
protected
NOTE: errors appended by this function are intended as INGESTION errors:
it means something wrong with the format of the event, and must be fixed ASAP if this happens.
ideally, function should NEVER append errors and the errors total should be the same before and after this function returns (this function may only change the skipped total, which means some duplicates were found).

Definition at line 860 of file plugin.py.

868 ) -> TmpIngestStats:
869 """
870 NOTE: errors appended by this function are intended as INGESTION errors:
871 it means something wrong with the format of the event, and must be fixed ASAP if this happens.
872 ideally, function should NEVER append errors and the errors total should be the same before and after this function returns (this function may only change the skipped total, which means some duplicates were found).
873 """
874 if len(self.buffer) == 0:
875 # already flushed
876 return fs
877
878 # logger().debug('flushing ingestion buffer, len=%d' % (len(self.buffer)))
879
880 skipped, failed, failed_ar, ingested_docs = await elastic_api.ingest_bulk(
881 elastic_api.elastic(),
882 index,
883 self.buffer,
884 flt=flt,
885 wait_for_refresh=wait_for_refresh,
886 )
887 # print(json.dumps(ingested_docs, indent=2))
888
889 if failed > 0:
890 if config.debug_abort_on_elasticsearch_ingestion_error():
891 raise Exception(
892 "elasticsearch ingestion errors means GulpDocument contains invalid data, review errors on collab db!"
893 )
894
895 self.buffer = []
896
897 # build ingestion chunk
898 ws_docs = self._build_ingestion_chunk_for_ws(ingested_docs, flt)
899
900 # send ingested docs to websocket
901 if len(ws_docs) > 0:
902 ws_api.shared_queue_add_data(
903 WsQueueDataType.INGESTION_CHUNK,
904 req_id,
905 {"plugin": self.name(), "events": ws_docs},
906 ws_id=ws_id,
907 )
908
909 # update stats
910 fs = fs.update(
911 failed=failed,
912 skipped=skipped,
913 ingest_errors=failed_ar,
914 )
915 return fs
916
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _ingest_record()

TmpIngestStats _ingest_record ( self,
str index,
GulpDocument | dict doc,
TmpIngestStats fs,
str ws_id,
str req_id,
GulpIngestionFilter flt = None,
bool flush_enabled = True,
** kwargs )
protected
bufferize as much as ingestion_buffer_size, then flush (writes to elasticsearch)

Definition at line 917 of file plugin.py.

927 ) -> TmpIngestStats:
928 """
929 bufferize as much as ingestion_buffer_size, then flush (writes to elasticsearch)
930 """
931 ingestion_buffer_size = config.config().get("ingestion_buffer_size", 1000)
932 self.buffer.append(doc)
933 if len(self.buffer) >= ingestion_buffer_size and flush_enabled:
934 # time to flush
935 fs = await self._flush_buffer(index, fs, ws_id, req_id, flt)
936
937 return fs
938
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _map_source_key()

list[FieldMappingEntry] _map_source_key ( self,
GulpPluginParams plugin_params,
GulpMapping custom_mapping,
str source_key,
Any v,
dict index_type_mapping = None,
bool ignore_custom_mapping = False,
** kwargs )
protected
map source key to a field mapping entry with "result": {mapped_key: v}

Args:
    plugin_params (GulpPluginParams): The plugin parameters.
    custom_mapping (GulpMapping): The custom mapping.
    source_key (str): The key to look for(=the event record key to be mapped) in the custom_mapping dictionary
    v (any): value to set for mapped key/s.
    index_type_mapping (dict, optional): The elasticsearch index key->type mappings. Defaults to None.
    ignore_custom_mapping (bool, optional): Whether to ignore custom_mapping and directly map source_key to v. Defaults to False.
    kwargs: Additional keyword arguments.

Returns:
    list[FieldMappingEntry]: zero or more FieldMappingEntry objects with "result" set.

Definition at line 686 of file plugin.py.

695 ) -> list[FieldMappingEntry]:
696 """
697 map source key to a field mapping entry with "result": {mapped_key: v}
698
699 Args:
700 plugin_params (GulpPluginParams): The plugin parameters.
701 custom_mapping (GulpMapping): The custom mapping.
702 source_key (str): The key to look for(=the event record key to be mapped) in the custom_mapping dictionary
703 v (any): value to set for mapped key/s.
704 index_type_mapping (dict, optional): The elasticsearch index key->type mappings. Defaults to None.
705 ignore_custom_mapping (bool, optional): Whether to ignore custom_mapping and directly map source_key to v. Defaults to False.
706 kwargs: Additional keyword arguments.
707
708 Returns:
709 list[FieldMappingEntry]: zero or more FieldMappingEntry objects with "result" set.
710 """
711 # get mapping and option from custom_mapping
712 if index_type_mapping is None:
713 index_type_mapping = {}
714 # logger().debug('len index type mapping=%d' % (len(index_type_mapping)))
715 mapping_dict: dict = custom_mapping.fields
716 mapping_options = (
717 custom_mapping.options
718 if custom_mapping.options is not None
719 else GulpMappingOptions()
720 )
721
722 # basic checks
723 if v == "-" or v is None:
724 return []
725
726 if isinstance(v, str):
727 v = v.strip()
728 if not v and mapping_options.ignore_blanks:
729 # not adding blank strings
730 return []
731
732 # fix value if needed, and add to extra
733 if ignore_custom_mapping or (
734 plugin_params is not None and plugin_params.ignore_mapping_ingest
735 ):
736 # direct mapping, no need to check custom_mappings
737 return [FieldMappingEntry(result={source_key: v})]
738
739 if source_key not in mapping_dict:
740 # logger().error('key "%s" not found in custom mapping, mapping_dict=%s!' % (source_key, muty.string.make_shorter(str(mapping_dict))))
741 # key not found in custom_mapping, check if we have to map it anyway
742 if not mapping_options.ignore_unmapped:
743 return [
744 FieldMappingEntry(
745 result={self.get_unmapped_field_name(source_key): str(v)}
746 )
747 ]
748
749 # there is a mapping defined to be processed
750 fm: FieldMappingEntry = mapping_dict[source_key]
751 map_to_list = (
752 [fm.map_to] if isinstance(fm.map_to, (str, type(None))) else fm.map_to
753 )
754
755 # in the end, this function will return a list of FieldMappingEntry objects with "result" set: these results will be used to create the GulpDocument object
756 fme_list: list[FieldMappingEntry] = []
757 for k in map_to_list:
758 # make a copy of fme without using deepcopy)
759 dest_fm = FieldMappingEntry(
760 is_timestamp=fm.is_timestamp,
761 event_code=fm.event_code,
762 do_multiply=fm.do_multiply,
763 is_timestamp_chrome=fm.is_timestamp_chrome,
764 is_variable_mapping=fm.is_variable_mapping,
765 result={},
766 )
767
768 # check if it is a number and/or a timestamp (including chrome timestamp, which is a special case)
769 is_numeric = isinstance(v, int) or str(v).isnumeric()
770 if is_numeric:
771 v = int(v)
772 # ensure chrome timestamp is properly converted to nanos
773 # logger().debug('***** is_numeric, v=%d' % (v))
774 if fm.is_timestamp_chrome:
775 v = int(muty.time.chrome_epoch_to_nanos(v))
776 # logger().debug('***** is_timestamp_chrome, v nsec=%d' % (v))
777
778 if fm.do_multiply is not None:
779 # apply a multipler if any (must turn v to nanoseconds)
780 # logger().debug("***** is_numeric, multiply, v=%d" % (v))
781 v = int(v * fm.do_multiply)
782 # logger().debug("***** is_numeric, AFTER multiply, v=%d" % (v))
783
784 elif isinstance(v, str) and fm.is_timestamp:
785 v = int(
786 muty.time.string_to_epoch_nsec(
787 v,
788 utc=mapping_options.timestamp_utc,
789 dayfirst=mapping_options.timestamp_dayfirst,
790 yearfirst=mapping_options.timestamp_yearfirst,
791 )
792 )
793 # logger().debug('***** str and is_timestamp, v nsec=%d' % (v))
794 if fm.is_timestamp:
795 # it's a timestamp, another event will be generated
796 vv = muty.time.nanos_to_millis(v)
797 dest_fm.result["@timestamp"] = vv
798 dest_fm.result["@timestamp_nsec"] = v
799 # logger().debug('***** timestamp nanos, v=%d' % (v))
800 # logger().debug('***** timestamp to millis, v=%d' % (vv))
801
802 if fm.is_timestamp or fm.is_timestamp_chrome:
803 # logger().debug('***** timestamp or timestamp_chrome, v=%d' % (v))
804 if v < 0:
805 # logger().debug('***** adding invalid timestamp')
806 v = 0
807 GulpDocument.add_invalid_timestamp(dest_fm.result)
808 if k is not None:
809 # also add to mapped key
810 dest_fm.result[k] = v
811 else:
812 # not a timestamp, map
813 if k is None:
814 # add unmapped
815 k = self.get_unmapped_field_name(source_key)
816 else:
817 v = self._type_checks(v, k, index_type_mapping)
818 dest_fm.result[k] = v
819
820 fme_list.append(dest_fm)
821 """
822 logger().debug('FME LIST FOR THIS RECORD:')
823 for p in fme_list:
824 logger().debug(p)
825 logger().debug('---------------------------------')
826 """
827 return fme_list
828
Here is the call graph for this function:

◆ _parser_failed()

TmpIngestStats _parser_failed ( self,
TmpIngestStats fs,
str | dict source,
Exception | str ex )
protected
whole source failed ingestion (error happened before the record parsing loop), helper to update stats

Definition at line 939 of file plugin.py.

941 ) -> TmpIngestStats:
942 """
943 whole source failed ingestion (error happened before the record parsing loop), helper to update stats
944 """
945 logger().exception(
946 "PARSER FAILED: source=%s, ex=%s"
947 % (muty.string.make_shorter(str(source), 260), ex)
948 )
949 fs = fs.update(ingest_errors=[ex], parser_failed=1)
950 return fs
951

◆ _process_plugin_params()

tuple[GulpMapping, GulpPluginParams] _process_plugin_params ( self,
GulpMapping custom_mapping,
GulpPluginParams plugin_params = None )
protected
Process the plugin parameters checking parameters as `timestamp_field`, ... and update the custom mapping accordingly.

Args:
    custom_mapping (GulpMapping): The custom mapping provided: if it is not empty, it will be used as is (plugin_params will be ignored)
    plugin_params (GulpPluginParams, optional): The plugin parameters. Defaults to None.

Returns:
    tuple[GulpMapping, GulpPluginParams]: The updated custom mapping and plugin parameters.

Definition at line 169 of file plugin.py.

171 ) -> tuple[GulpMapping, GulpPluginParams]:
172 """
173 Process the plugin parameters checking parameters as `timestamp_field`, ... and update the custom mapping accordingly.
174
175 Args:
176 custom_mapping (GulpMapping): The custom mapping provided: if it is not empty, it will be used as is (plugin_params will be ignored)
177 plugin_params (GulpPluginParams, optional): The plugin parameters. Defaults to None.
178
179 Returns:
180 tuple[GulpMapping, GulpPluginParams]: The updated custom mapping and plugin parameters.
181 """
182 if plugin_params is None:
183 plugin_params = GulpPluginParams()
184
185 if len(custom_mapping.fields) > 0:
186 # custom_mapping provided
187 return custom_mapping, plugin_params
188
189 logger().warning("no custom mapping provided")
190
191 tf = plugin_params.timestamp_field
192 if tf is not None:
193 logger().debug("using timestamp_field=%s" % (tf))
194 # build a proper custom_mapping with just timestamp
195 custom_mapping.fields[tf] = FieldMappingEntry(is_timestamp=True)
196 # logger().debug(custom_mapping)
197 return custom_mapping, plugin_params
198

◆ _process_record()

tuple[TmpIngestStats, bool] _process_record ( self,
str index,
any record,
int record_idx,
Callable my_record_to_gulp_document_fun,
str ws_id,
str req_id,
int operation_id,
int client_id,
str context,
str source,
TmpIngestStats fs,
GulpMapping custom_mapping = None,
dict index_type_mapping = None,
str plugin = None,
GulpPluginParams plugin_params = None,
GulpIngestionFilter flt = None,
** kwargs )
protected
Process a record for ingestion, updating ingestion stats.
Args:
    index (str): The index to ingest the record into.
    record (any): The record to process.
    record_idx (int): The index of the record as in the source.
    my_record_to_gulp_document_fun (Callable): The function (for this plugin) to convert the record to one or more GulpDocument/s.
    ws_id (str): The websocket ID
    req_id (str): The request ID.
    operation_id (int): The operation ID.
    client_id (int): The client ID.
    context (str): The context of the record.
    source (str): The source of the record.
    fs (TmpIngestStats): The temporary ingestion statistics.
    custom_mapping (GulpMapping, optional): The custom mapping for the record. Defaults to None.
    index_type_mapping (dict, optional): The elastic index type mapping. Defaults to None.
    plugin (str, optional): The plugin name. Defaults to None.
    plugin_params (GulpPluginParams, optional): The plugin parameters. Defaults to None.
    flt (GulpIngestionFilter, optional): The ingestion filter. Defaults to None.
    **kwargs: Additional keyword arguments.
Returns:
    tuple[TmpIngestStats, bool]: A tuple containing the updated temporary ingestion statistics and a flag indicating whether to break the ingestion process.

Definition at line 243 of file plugin.py.

262 ) -> tuple[TmpIngestStats, bool]:
263 """
264 Process a record for ingestion, updating ingestion stats.
265 Args:
266 index (str): The index to ingest the record into.
267 record (any): The record to process.
268 record_idx (int): The index of the record as in the source.
269 my_record_to_gulp_document_fun (Callable): The function (for this plugin) to convert the record to one or more GulpDocument/s.
270 ws_id (str): The websocket ID
271 req_id (str): The request ID.
272 operation_id (int): The operation ID.
273 client_id (int): The client ID.
274 context (str): The context of the record.
275 source (str): The source of the record.
276 fs (TmpIngestStats): The temporary ingestion statistics.
277 custom_mapping (GulpMapping, optional): The custom mapping for the record. Defaults to None.
278 index_type_mapping (dict, optional): The elastic index type mapping. Defaults to None.
279 plugin (str, optional): The plugin name. Defaults to None.
280 plugin_params (GulpPluginParams, optional): The plugin parameters. Defaults to None.
281 flt (GulpIngestionFilter, optional): The ingestion filter. Defaults to None.
282 **kwargs: Additional keyword arguments.
283 Returns:
284 tuple[TmpIngestStats, bool]: A tuple containing the updated temporary ingestion statistics and a flag indicating whether to break the ingestion process.
285 """
286
287 # convert record to one or more GulpDocument objects
288 docs = await self._call_record_to_gulp_document_funcs(
289 operation_id=operation_id,
290 client_id=client_id,
291 context=context,
292 source=source,
293 fs=fs,
294 record=record,
295 record_idx=record_idx,
296 custom_mapping=custom_mapping,
297 index_type_mapping=index_type_mapping,
298 plugin=plugin,
299 plugin_params=plugin_params,
300 record_to_gulp_document_fun=my_record_to_gulp_document_fun,
301 **kwargs,
302 )
303 # ingest record
304 for d in docs:
305 fs = await self._ingest_record(index, d, fs, ws_id, req_id, flt, **kwargs)
306
307 status, _ = await GulpStats.update(
308 await collab_api.collab(),
309 req_id,
310 ws_id,
311 fs=fs.update(processed=len(docs)),
312 )
313 must_break = False
314 if status in [GulpRequestStatus.FAILED, GulpRequestStatus.CANCELED]:
315 must_break = True
316
317 return fs, must_break
318
Here is the call graph for this function:

◆ _record_failed()

TmpIngestStats _record_failed ( self,
TmpIngestStats fs,
any entry,
str | dict source,
Exception | str ex )
protected
record failed ingestion (in the record parser loop), helper to update stats

Args:
    fs (TmpIngestStats): The temporary ingestion statistics.
    entry (any): The entry that failed.
    source (str): The source of the record.
    ex (Exception|str): The exception that caused the failure.
Returns:
    TmpIngestStats: The updated temporary ingestion statistics.

Definition at line 952 of file plugin.py.

954 ) -> TmpIngestStats:
955 """
956 record failed ingestion (in the record parser loop), helper to update stats
957
958 Args:
959 fs (TmpIngestStats): The temporary ingestion statistics.
960 entry (any): The entry that failed.
961 source (str): The source of the record.
962 ex (Exception|str): The exception that caused the failure.
963 Returns:
964 TmpIngestStats: The updated temporary ingestion statistics.
965 """
966 # logger().exception("RECORD FAILED: source=%s, record=%s, ex=%s" % (muty.string.make_shorter(str(source),260), muty.string.make_shorter(str(entry),260), ex))
967 fs = fs.update(failed=1, ingest_errors=[ex])
968 return fs
969

◆ _type_checks()

any _type_checks ( self,
any v,
str k,
dict index_type_mapping )
protected
check if the value should be fixed based on the index type mapping

Args:
    v (any): The value to check.
    k (str): The mapped field (i.e. "user.id", may also be an unmapped (i.e. "gulp.unmapped") field)
    index_type_mapping (dict): The elasticsearch index key->type mappings.

Definition at line 641 of file plugin.py.

641 def _type_checks(self, v: any, k: str, index_type_mapping: dict) -> any:
642 """
643 check if the value should be fixed based on the index type mapping
644
645 Args:
646 v (any): The value to check.
647 k (str): The mapped field (i.e. "user.id", may also be an unmapped (i.e. "gulp.unmapped") field)
648 index_type_mapping (dict): The elasticsearch index key->type mappings.
649 """
650 if k not in index_type_mapping:
651 # logger().debug("key %s not found in index_type_mapping" % (k))
652 return str(v)
653
654 index_type = index_type_mapping[k]
655 if index_type == "long":
656 # logger().debug("converting %s:%s to long" % (k, v))
657 if isinstance(v, str):
658 if v.isnumeric():
659 return int(v)
660 if v.startswith("0x"):
661 return int(v, 16)
662 return v
663
664 if index_type == "date" and isinstance(v, str) and v.lower().startswith("0x"):
665 # convert hex to int
666 return int(v, 16)
667
668 if index_type == "keyword" or index_type == "text":
669 # logger().debug("converting %s:%s to keyword" % (k, v))
670 return str(v)
671
672 if index_type == "ip":
673 # logger().debug("converting %s:%s to ip" % (k, v))
674 if "local" in v.lower():
675 return "127.0.0.1"
676 try:
677 ipaddress.ip_address(v)
678 except ValueError as ex:
679 logger().exception(ex)
680 return None
681
682 # add more types here if needed ...
683 # logger().debug("returning %s:%s" % (k, v))
684 return str(v)
685
Here is the caller graph for this function:

◆ cleanup()

None cleanup ( self)
Optional cleanup routine to call on unload.

Definition at line 552 of file plugin.py.

552 def cleanup(self) -> None:
553 """
554 Optional cleanup routine to call on unload.
555 """
556 return
557

◆ depends_on()

list[str] depends_on ( self)
Returns a list of plugins this plugin depends on.

Definition at line 113 of file plugin.py.

113 def depends_on(self) -> list[str]:
114 """
115 Returns a list of plugins this plugin depends on.
116 """
117 return []
118

◆ desc()

str desc ( self)
Returns a description of the plugin.

Definition at line 96 of file plugin.py.

96 def desc(self) -> str:
97 """
98 Returns a description of the plugin.
99 """
100
Here is the caller graph for this function:

◆ event_type_field()

str event_type_field ( self)
Returns the field name for the event type.

Definition at line 107 of file plugin.py.

107 def event_type_field(self) -> str:
108 """
109 Returns the field name for the event type.
110 """
111 return "event.code"
112

◆ get_unmapped_field_name()

str get_unmapped_field_name ( self,
str field )
Returns the name of the unmapped field.

Parameters:
- field (str): The name of the field.

Returns:
- str: The name of the unmapped field.

Definition at line 626 of file plugin.py.

626 def get_unmapped_field_name(self, field: str) -> str:
627 """
628 Returns the name of the unmapped field.
629
630 Parameters:
631 - field (str): The name of the field.
632
633 Returns:
634 - str: The name of the unmapped field.
635 """
636 if not elastic_api.UNMAPPED_PREFIX:
637 return field
638
639 return f"{elastic_api.UNMAPPED_PREFIX}.{field}"
640
Here is the caller graph for this function:

◆ ingest()

GulpRequestStatus ingest ( self,
str index,
str req_id,
int client_id,
int operation_id,
str context,
str | list[dict] source,
str ws_id,
GulpPluginParams plugin_params = None,
GulpIngestionFilter flt = None,
** kwargs )
Ingests a file using the plugin.

NOTE: implementers should call super().ingest() in their implementation.
NOTE: this function *SHOULD NOT* raise exceptions

Args:
    index (str): name of the elasticsearch index to ingest the document into.
    req_id (str): The request ID related to this ingestion (must exist on the collab db).
    client_id (int): The client ID performing the ingestion.
    operation_id (int): The operation ID related to this ingestion.
    context (str): Context related to this ingestion.
    source (str|list[dict]): The path to the file to ingest, or a list of events dicts.
    ws_id (str): The websocket ID
    plugin_params (GulpPluginParams): additional parameters to pass to the ingestion function. Defaults to None.
    flt (GulpIngestionFilter, optional): filter to apply to this ingestion, if any. Defaults to None.
    kwargs: additional arguments if any

Definition at line 499 of file plugin.py.

511 ) -> GulpRequestStatus:
512 """
513 Ingests a file using the plugin.
514
515 NOTE: implementers should call super().ingest() in their implementation.
516 NOTE: this function *SHOULD NOT* raise exceptions
517
518 Args:
519 index (str): name of the elasticsearch index to ingest the document into.
520 req_id (str): The request ID related to this ingestion (must exist on the collab db).
521 client_id (int): The client ID performing the ingestion.
522 operation_id (int): The operation ID related to this ingestion.
523 context (str): Context related to this ingestion.
524 source (str|list[dict]): The path to the file to ingest, or a list of events dicts.
525 ws_id (str): The websocket ID
526 plugin_params (GulpPluginParams): additional parameters to pass to the ingestion function. Defaults to None.
527 flt (GulpIngestionFilter, optional): filter to apply to this ingestion, if any. Defaults to None.
528 kwargs: additional arguments if any
529 """
530 self.req_id = req_id
531 self.client_id = client_id
532 self.operation_id = operation_id
533 self.context = context
534 self.ws_id = ws_id
535 self.index = index
536 # raise NotImplementedError("not implemented!")
537

◆ ingest_plugin_initialize()

tuple[dict, GulpMapping] ingest_plugin_initialize ( self,
str index,
str | dict source,
bool skip_mapping = False,
ProcessingPipeline pipeline = None,
str mapping_file = None,
str mapping_id = None,
GulpPluginParams plugin_params = None )
Initializes the ingestion plugin.

Args:
    index (str): The name of the elasticsearch index.
    source (str|dict): The source of the record (source file name or path, usually. may also be a dictionary.).
    skip_mapping (bool, optional): Whether to skip mapping initialization (just prints source and plugin name, and return empty index mapping and custom mapping). Defaults to False.
    pipeline (ProcessingPipeline, optional): The psyigma pipeline to borrow the mapping from, if any. Defaults to None (use mapping file only).
    mapping_file (str, optional): name of the mapping file (i.e. 'windows.json') in the gulp/mapping_files directory. Defaults to None (use pipeline mapping only).
    mapping_id (str, optional): The mapping ID (options.mapping_id) in the mapping file, to get a specific mapping. Defaults to None (use first).
    plugin_params (GulpPluginParams, optional): The plugin parameters (i.e. to override mapping_file, mapping_id, ...). Defaults to None.
Returns:
    tuple[dict, GulpMapping]: A tuple containing the elasticsearch index type mappings and the enriched GulpMapping (or an empty GulpMapping is no valid pipeline and/or mapping_file are provided).

Definition at line 319 of file plugin.py.

328 ) -> tuple[dict, GulpMapping]:
329 """
330 Initializes the ingestion plugin.
331
332 Args:
333 index (str): The name of the elasticsearch index.
334 source (str|dict): The source of the record (source file name or path, usually. may also be a dictionary.).
335 skip_mapping (bool, optional): Whether to skip mapping initialization (just prints source and plugin name, and return empty index mapping and custom mapping). Defaults to False.
336 pipeline (ProcessingPipeline, optional): The psyigma pipeline to borrow the mapping from, if any. Defaults to None (use mapping file only).
337 mapping_file (str, optional): name of the mapping file (i.e. 'windows.json') in the gulp/mapping_files directory. Defaults to None (use pipeline mapping only).
338 mapping_id (str, optional): The mapping ID (options.mapping_id) in the mapping file, to get a specific mapping. Defaults to None (use first).
339 plugin_params (GulpPluginParams, optional): The plugin parameters (i.e. to override mapping_file, mapping_id, ...). Defaults to None.
340 Returns:
341 tuple[dict, GulpMapping]: A tuple containing the elasticsearch index type mappings and the enriched GulpMapping (or an empty GulpMapping is no valid pipeline and/or mapping_file are provided).
342
343 """
344 # logger().debug("ingest_plugin_initialize: index=%s, pipeline=%s, mapping_file=%s, mapping_id=%s, plugin_params=%s" % (index, pipeline, mapping_file, mapping_id, plugin_params))
345 logger().debug(
346 "INITIALIZING INGESTION for source=%s, plugin=%s"
347 % (muty.string.make_shorter(source, 260), self.name())
348 )
349 if skip_mapping:
350 return {}, GulpMapping()
351
352 # get path of the mapping file in gulp/mapping_files folder
353 mapping_file_path = None
354 if mapping_file is not None:
355 mapping_file_path = gulp_utils.build_mapping_file_path(mapping_file)
356
357 if plugin_params is not None:
358 # override with plugin_params
359 if plugin_params.mapping_file is not None:
360 mapping_file_path = gulp_utils.build_mapping_file_path(
361 plugin_params.mapping_file
362 )
363 if plugin_params.mapping_id is not None:
364 mapping_id = plugin_params.mapping_id
365 if plugin_params.pipeline is not None:
366 pipeline = plugin_params.pipeline
367
368 index_type_mappings = await elastic_api.index_get_mapping(
369 elastic_api.elastic(), index, False
370 )
371 # index_type_mappings = await elastic_api.datastream_get_mapping(self.elastic, index + '-template')
372 m: GulpMapping = await mapping_helpers.get_enriched_mapping_for_ingestion(
373 pipeline=pipeline,
374 mapping_file_path=mapping_file_path,
375 mapping_id=mapping_id,
376 )
377 return index_type_mappings, m
378
Here is the call graph for this function:

◆ internal()

bool internal ( self)
Returns whether the plugin is for internal use only

Definition at line 150 of file plugin.py.

150 def internal(self) -> bool:
151 """
152 Returns whether the plugin is for internal use only
153 """
154 return False
155

◆ name()

str name ( self)
Returns the name of the plugin.

Definition at line 102 of file plugin.py.

102 def name(self) -> str:
103 """
104 Returns the name of the plugin.
105 """
106
Here is the caller graph for this function:

◆ options()

list[GulpPluginOption] options ( self)
return available GulpPluginOption list (plugin specific parameters)

Definition at line 77 of file plugin.py.

77 def options(self) -> list[GulpPluginOption]:
78 """
79 return available GulpPluginOption list (plugin specific parameters)
80 """
81 return []
82
Here is the caller graph for this function:

◆ pipeline()

ProcessingPipeline pipeline ( self,
GulpPluginParams plugin_params = None,
** kwargs )
Returns the pysigma processing pipeline for the plugin, if any.

Args:
    plugin_params (GulpPluginParams, optional): additional parameters to pass to the pipeline. Defaults to None.
    kwargs: additional arguments if any.
Returns:
    ProcessingPipeline: The processing pipeline.

Definition at line 538 of file plugin.py.

540 ) -> ProcessingPipeline:
541 """
542 Returns the pysigma processing pipeline for the plugin, if any.
543
544 Args:
545 plugin_params (GulpPluginParams, optional): additional parameters to pass to the pipeline. Defaults to None.
546 kwargs: additional arguments if any.
547 Returns:
548 ProcessingPipeline: The processing pipeline.
549 """
550 raise NotImplementedError("not implemented!")
551
Here is the caller graph for this function:

◆ query()

tuple[int, GulpRequestStatus] query ( self,
int operation_id,
int client_id,
int user_id,
str username,
str ws_id,
str req_id,
GulpPluginParams plugin_params,
GulpQueryFilter flt,
GulpQueryOptions options = None )
used in query plugins to query data directly from external sources.

Args:
    operation_id (int): operation ID
    client_id (int): client ID
    user_id (int): user ID performing the query
    username (str): username performing the query
    ws_id (str): websocket ID to stream the returned data to
    req_id (str): request ID
    plugin_params (GulpPluginParams, optional): plugin parameters, including i.e. in GulpPluginParams.extra the login/pwd/token to connect to the external source, plugin dependent.
    flt (GulpQueryFilter): query filter (will be converted to the external source query format)
    options (GulpQueryOptions, optional): query options, i.e. to limit the number of returned records. Defaults to None.
        due to the nature of query plugins, not all options may be supported (i.e. limit, offset, ...) and notes creation is always disabled.
Returns:
    tuple[int, GulpRequestStatus]: the number of records returned and the status of the query.

Definition at line 119 of file plugin.py.

130 ) -> tuple[int, GulpRequestStatus]:
131 """
132 used in query plugins to query data directly from external sources.
133
134 Args:
135 operation_id (int): operation ID
136 client_id (int): client ID
137 user_id (int): user ID performing the query
138 username (str): username performing the query
139 ws_id (str): websocket ID to stream the returned data to
140 req_id (str): request ID
141 plugin_params (GulpPluginParams, optional): plugin parameters, including i.e. in GulpPluginParams.extra the login/pwd/token to connect to the external source, plugin dependent.
142 flt (GulpQueryFilter): query filter (will be converted to the external source query format)
143 options (GulpQueryOptions, optional): query options, i.e. to limit the number of returned records. Defaults to None.
144 due to the nature of query plugins, not all options may be supported (i.e. limit, offset, ...) and notes creation is always disabled.
145 Returns:
146 tuple[int, GulpRequestStatus]: the number of records returned and the status of the query.
147 """
148 return 0, GulpRequestStatus.FAILED
149

◆ record_to_gulp_document()

list[GulpDocument] record_to_gulp_document ( self,
int operation_id,
int client_id,
str context,
str source,
TmpIngestStats fs,
any record,
int record_idx,
GulpMapping custom_mapping = None,
dict index_type_mapping = None,
str plugin = None,
GulpPluginParams plugin_params = None,
** kwargs )
Converts a record to one or more GulpDocument objects based on the provided index mappings.

Args:
    operation_id (int): The operation ID associated with the record.
    client_id (int): The client ID associated with the record.
    context (str): The context associated with the record.
    source (str): The source of the record (source file name or path, usually).
    fs (TmpIngestStats): The temporary ingestion statistics (may be updated on return).
    record (any): record to convert, plugin dependent format: note that here stacked plugins receives a list of GulpDocument objects instead (since the original record may generate one or more documents).
    record_idx (int): The index of the record in source.
    custom_mapping (GulpMapping, optional): The custom mapping to use for the conversion. Defaults to None.
    index_type_mapping (dict, optional): elastic search index type mappings { "ecs_field": "type", ... }. Defaults to None.
    plugin (str, optional): "agent.type" to be set in the GulpDocument. Defaults to None.
    plugin_params (GulpPluginParams, optional): The plugin parameters to use, if any. Defaults to None.
    extra (dict, optional): Additional fields to add to the GulpDocument (after applying mapping). Defaults to None.
    **kwargs: Additional keyword arguments:

Returns:
    list[GulDocument]: The converted GulpDocument objects or None if an exception occurred (fs is updated then).

Raises:
    NotImplementedError: This method is not implemented yet.

Definition at line 458 of file plugin.py.

472 ) -> list[GulpDocument]:
473 """
474 Converts a record to one or more GulpDocument objects based on the provided index mappings.
475
476 Args:
477 operation_id (int): The operation ID associated with the record.
478 client_id (int): The client ID associated with the record.
479 context (str): The context associated with the record.
480 source (str): The source of the record (source file name or path, usually).
481 fs (TmpIngestStats): The temporary ingestion statistics (may be updated on return).
482 record (any): record to convert, plugin dependent format: note that here stacked plugins receives a list of GulpDocument objects instead (since the original record may generate one or more documents).
483 record_idx (int): The index of the record in source.
484 custom_mapping (GulpMapping, optional): The custom mapping to use for the conversion. Defaults to None.
485 index_type_mapping (dict, optional): elastic search index type mappings { "ecs_field": "type", ... }. Defaults to None.
486 plugin (str, optional): "agent.type" to be set in the GulpDocument. Defaults to None.
487 plugin_params (GulpPluginParams, optional): The plugin parameters to use, if any. Defaults to None.
488 extra (dict, optional): Additional fields to add to the GulpDocument (after applying mapping). Defaults to None.
489 **kwargs: Additional keyword arguments:
490
491 Returns:
492 list[GulDocument]: The converted GulpDocument objects or None if an exception occurred (fs is updated then).
493
494 Raises:
495 NotImplementedError: This method is not implemented yet.
496 """
497 raise NotImplementedError("not implemented!")
498

◆ sigma_plugin_initialize()

ProcessingPipeline sigma_plugin_initialize ( self,
ProcessingPipeline pipeline = None,
str mapping_file = None,
str mapping_id = None,
str product = None,
GulpPluginParams plugin_params = None )
Initializes the Sigma plugin to convert sigma rules YAML to elasticsearch DSL query.

Args:
    pipeline (ProcessingPipeline, optional): The processing pipeline. Defaults to None (empty pipeline, plugin must fill it).
    mapping_file (str, optional): The name of the mapping file (i.e. 'windows.json') in the gulp/mapping_files directory. Defaults to None (use pipeline mapping only).
    mapping_id (str, optional): The mapping ID (["options"]["mapping_id"] in the mapping file, to get a specific mapping). Defaults to None (use first).
    product (str, optional): The product. Defaults to None.
    plugin_params (GulpPluginParams, optional): The plugin parameters, to override i.e. mapping_file_path, mapping_id, ... Defaults to None.
Returns:
    ProcessingPipeline: The initialized processing pipeline.

Definition at line 199 of file plugin.py.

206 ) -> ProcessingPipeline:
207 """
208 Initializes the Sigma plugin to convert sigma rules YAML to elasticsearch DSL query.
209
210 Args:
211 pipeline (ProcessingPipeline, optional): The processing pipeline. Defaults to None (empty pipeline, plugin must fill it).
212 mapping_file (str, optional): The name of the mapping file (i.e. 'windows.json') in the gulp/mapping_files directory. Defaults to None (use pipeline mapping only).
213 mapping_id (str, optional): The mapping ID (["options"]["mapping_id"] in the mapping file, to get a specific mapping). Defaults to None (use first).
214 product (str, optional): The product. Defaults to None.
215 plugin_params (GulpPluginParams, optional): The plugin parameters, to override i.e. mapping_file_path, mapping_id, ... Defaults to None.
216 Returns:
217 ProcessingPipeline: The initialized processing pipeline.
218 """
219 logger().debug("INITIALIZING SIGMA plugin=%s" % (self.name()))
220
221 mapping_file_path = None
222 if mapping_file is not None:
223 # get path in mapping directory
224 mapping_file_path = gulp_utils.build_mapping_file_path(mapping_file)
225
226 if plugin_params is not None:
227 # override with plugin_params
228 if plugin_params.mapping_file is not None:
229 mapping_file_path = gulp_utils.build_mapping_file_path(
230 plugin_params.mapping_file
231 )
232 if plugin_params.mapping_id is not None:
233 mapping_id = plugin_params.mapping_id
234
235 p = await mapping_helpers.get_enriched_pipeline(
236 pipeline=pipeline,
237 mapping_file_path=mapping_file_path,
238 mapping_id=mapping_id,
239 product=product,
240 )
241 return p
242
Here is the call graph for this function:

◆ tags()

list[str] tags ( self)
returns a list of tags for the plugin. Tags are used to aid filtering of plugins/query filters in the UI.
- "event"
- "network"
- "file"
- "process"
- "threat"
- "threat.enrichments"
- ...

Definition at line 156 of file plugin.py.

156 def tags(self) -> list[str]:
157 """
158 returns a list of tags for the plugin. Tags are used to aid filtering of plugins/query filters in the UI.
159 - "event"
160 - "network"
161 - "file"
162 - "process"
163 - "threat"
164 - "threat.enrichments"
165 - ...
166 """
167 return []
168

◆ type()

GulpPluginType type ( self)
Returns the plugin type.

Definition at line 84 of file plugin.py.

84 def type(self) -> GulpPluginType:
85 """
86 Returns the plugin type.
87 """
88
Here is the caller graph for this function:

◆ version()

str version ( self)
Returns plugin version.

Definition at line 90 of file plugin.py.

90 def version(self) -> str:
91 """
92 Returns plugin version.
93 """
94

Member Data Documentation

◆ buffer

list buffer = []

Definition at line 71 of file plugin.py.

◆ client_id

str client_id = None

Definition at line 65 of file plugin.py.

◆ context

str context = None

Definition at line 67 of file plugin.py.

◆ index

str index = None

Definition at line 64 of file plugin.py.

◆ operation_id

str operation_id = None

Definition at line 66 of file plugin.py.

◆ path

path = path

Definition at line 69 of file plugin.py.

◆ req_id

str req_id = None

Definition at line 63 of file plugin.py.

◆ ws_id

str ws_id = None

Definition at line 68 of file plugin.py.


The documentation for this class was generated from the following file: