13
13
from contentctl .objects .macro import Macro
14
14
from contentctl .objects .lookup import Lookup
15
15
from contentctl .objects .detection import Detection
16
+ from contentctl .objects .data_source import DataSource
16
17
from contentctl .objects .security_content_object import SecurityContentObject
17
18
from contentctl .objects .config import test_common , All , Changes , Selected
18
19
@@ -70,6 +71,7 @@ def getChanges(self, target_branch:str)->List[Detection]:
70
71
updated_detections :List [Detection ] = []
71
72
updated_macros :List [Macro ] = []
72
73
updated_lookups :List [Lookup ] = []
74
+ updated_datasources :List [DataSource ] = []
73
75
74
76
for diff in all_diffs :
75
77
if type (diff ) == pygit2 .Patch :
@@ -90,6 +92,13 @@ def getChanges(self, target_branch:str)->List[Detection]:
90
92
updated_macros .append (macroObject )
91
93
else :
92
94
raise Exception (f"Error getting macro object for file { str (decoded_path )} " )
95
+
96
+ elif decoded_path .is_relative_to (self .config .path / "data_sources" ) and decoded_path .suffix == ".yml" :
97
+ datasourceObject = filepath_to_content_map .get (decoded_path , None )
98
+ if isinstance (datasourceObject , DataSource ):
99
+ updated_datasources .append (datasourceObject )
100
+ else :
101
+ raise Exception (f"Error getting data source object for file { str (decoded_path )} " )
93
102
94
103
elif decoded_path .is_relative_to (self .config .path / "lookups" ):
95
104
# We need to convert this to a yml. This means we will catch
@@ -115,7 +124,6 @@ def getChanges(self, target_branch:str)->List[Detection]:
115
124
# Detected a changed .mlmodel file. However, since we do not have testing for these detections at
116
125
# this time, we will ignore this change.
117
126
updatedLookup = None
118
-
119
127
120
128
else :
121
129
raise Exception (f"Detected a changed file in the lookups/ directory '{ str (decoded_path )} '.\n "
@@ -136,15 +144,15 @@ def getChanges(self, target_branch:str)->List[Detection]:
136
144
137
145
# If a detection has at least one dependency on changed content,
138
146
# then we must test it again
139
- changed_macros_and_lookups = updated_macros + updated_lookups
147
+ changed_macros_and_lookups_and_datasources = updated_macros + updated_lookups + updated_datasources
140
148
141
149
for detection in self .director .detections :
142
150
if detection in updated_detections :
143
151
# we are already planning to test it, don't need
144
152
# to add it again
145
153
continue
146
154
147
- for obj in changed_macros_and_lookups :
155
+ for obj in changed_macros_and_lookups_and_datasources :
148
156
if obj in detection .get_content_dependencies ():
149
157
updated_detections .append (detection )
150
158
break
0 commit comments