@@ -76,33 +76,28 @@ def getChanges(self, target_branch:str)->List[Detection]:
76
76
if diff .delta .status in (DeltaStatus .ADDED , DeltaStatus .MODIFIED , DeltaStatus .RENAMED ):
77
77
#print(f"{DeltaStatus(diff.delta.status).name:<8}:{diff.delta.new_file.raw_path}")
78
78
decoded_path = pathlib .Path (diff .delta .new_file .raw_path .decode ('utf-8' ))
79
- if 'app_template/' in str (decoded_path ) or 'ssa_detections' in str (decoded_path ) or str (self .config .getBuildDir ()) in str (decoded_path ):
80
- #Ignore anything that is embedded in the app template.
81
- #Also ignore ssa detections
82
- pass
83
- elif 'detections/' in str (decoded_path ) and decoded_path .suffix == ".yml" :
79
+ # Note that we only handle updates to detections, lookups, and macros at this time. All other changes are ignored.
80
+ if decoded_path .is_relative_to (self .config .path / "detections" ) and decoded_path .suffix == ".yml" :
84
81
detectionObject = filepath_to_content_map .get (decoded_path , None )
85
82
if isinstance (detectionObject , Detection ):
86
83
updated_detections .append (detectionObject )
87
84
else :
88
85
raise Exception (f"Error getting detection object for file { str (decoded_path )} " )
89
86
90
- elif 'macros/' in str ( decoded_path ) and decoded_path .suffix == ".yml" :
87
+ elif decoded_path . is_relative_to ( self . config . path / "macros" ) and decoded_path .suffix == ".yml" :
91
88
macroObject = filepath_to_content_map .get (decoded_path , None )
92
89
if isinstance (macroObject , Macro ):
93
90
updated_macros .append (macroObject )
94
91
else :
95
92
raise Exception (f"Error getting macro object for file { str (decoded_path )} " )
96
93
97
- elif 'lookups/' in str ( decoded_path ):
94
+ elif decoded_path . is_relative_to ( self . config . path / "lookups" ):
98
95
# We need to convert this to a yml. This means we will catch
99
96
# both changes to a csv AND changes to the YML that uses it
100
-
101
-
102
97
if decoded_path .suffix == ".yml" :
103
98
updatedLookup = filepath_to_content_map .get (decoded_path , None )
104
99
if not isinstance (updatedLookup ,Lookup ):
105
- raise Exception (f"Expected { decoded_path } to be type { type (Lookup )} , but instead if was { (type (lookupObject ))} " )
100
+ raise Exception (f"Expected { decoded_path } to be type { type (Lookup )} , but instead if was { (type (updatedLookup ))} " )
106
101
updated_lookups .append (updatedLookup )
107
102
108
103
elif decoded_path .suffix == ".csv" :
@@ -127,12 +122,8 @@ def getChanges(self, target_branch:str)->List[Detection]:
127
122
else :
128
123
pass
129
124
#print(f"Ignore changes to file {decoded_path} since it is not a detection, macro, or lookup.")
130
-
131
- # else:
132
- # print(f"{diff.delta.new_file.raw_path}:{DeltaStatus(diff.delta.status).name} (IGNORED)")
133
- # pass
134
125
else :
135
- raise Exception (f"Unrecognized type { type (diff )} " )
126
+ raise Exception (f"Unrecognized diff type { type (diff )} " )
136
127
137
128
138
129
# If a detection has at least one dependency on changed content,
@@ -153,7 +144,7 @@ def getChanges(self, target_branch:str)->List[Detection]:
153
144
#Print out the names of all modified/new content
154
145
modifiedAndNewContentString = "\n - " .join (sorted ([d .name for d in updated_detections ]))
155
146
156
- print (f"[{ len (updated_detections )} ] Pieces of modifed and new content to test :\n - { modifiedAndNewContentString } " )
147
+ print (f"[{ len (updated_detections )} ] Pieces of modifed and new content (this may include experimental/deprecated/manual_test content) :\n - { modifiedAndNewContentString } " )
157
148
return updated_detections
158
149
159
150
def getSelected (self , detectionFilenames :List [FilePath ])-> List [Detection ]:
0 commit comments