This repository was archived by the owner on Nov 2, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +8
-17
lines changed
Expand file tree Collapse file tree 4 files changed +8
-17
lines changed Original file line number Diff line number Diff line change 11from django .conf import settings
2- from django .utils .timezone import now
32from rest_framework import serializers as rfs
43from rest_framework .exceptions import ValidationError
54from rest_framework .fields import Field
6- from rest_framework .serializers import ModelSerializer
75
86from api_app .interfaces import OwnershipAbstractModel
97from certego_saas .apps .organization .organization import Organization
8+ from certego_saas .ext .upload .elastic import BISerializer
109
1110
12- class AbstractBIInterface (ModelSerializer ):
11+ class AbstractBIInterface (BISerializer ):
1312 application = rfs .CharField (read_only = True , default = "IntelOwl" )
1413 environment = rfs .SerializerMethodField (method_name = "get_environment" )
15- timestamp : Field
1614 username : Field
1715 name : Field
1816 class_instance = rfs .SerializerMethodField (
@@ -23,10 +21,7 @@ class AbstractBIInterface(ModelSerializer):
2321 end_time : Field
2422
2523 class Meta :
26- fields = [
27- "application" ,
28- "environment" ,
29- "timestamp" ,
24+ fields = BISerializer .Meta .fields + [
3025 "username" ,
3126 "name" ,
3227 "class_instance" ,
@@ -48,12 +43,8 @@ def get_environment(instance):
4843 return "test"
4944
5045 @staticmethod
51- def to_elastic_dict (data ):
52- return {
53- "_source" : data ,
54- "_index" : settings .ELASTICSEARCH_BI_INDEX + "-" + now ().strftime ("%Y.%m" ),
55- "_op_type" : "index" ,
56- }
46+ def get_index ():
47+ return settings .ELASTICSEARCH_BI_INDEX
5748
5849
5950class ModelWithOwnershipSerializer (rfs .ModelSerializer ):
Original file line number Diff line number Diff line change @@ -1079,7 +1079,7 @@ class Meta:
10791079
10801080 def to_representation (self , instance : Job ):
10811081 data = super ().to_representation (instance )
1082- return self .to_elastic_dict (data )
1082+ return self .to_elastic_dict (data , self . get_index () )
10831083
10841084 @staticmethod
10851085 def get_playbook (instance : Job ):
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ class Meta:
3232
3333 def to_representation (self , instance : AbstractReport ):
3434 data = super ().to_representation (instance )
35- return self .to_elastic_dict (data )
35+ return self .to_elastic_dict (data , self . get_index () )
3636
3737 def get_class_instance (self , instance : AbstractReport ):
3838 return super ().get_class_instance (instance ).split ("report" )[0 ]
Original file line number Diff line number Diff line change 1- certego-saas==0.7.7
1+ certego-saas==0.7.10
22# While developing for certego-saas, comment the previous line.
33# Then, add a line like the one below to your forked repo and your most recent commit
44# In this way you can test your changes directly in IntelOwl with the complete application
You can’t perform that action at this time.
0 commit comments