Skip to content

Commit d1e015b

Browse files
committed
small cleanup to use CsvLookup class.
Also move warning message to end of error printout.
1 parent 3a47036 commit d1e015b

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

contentctl/actions/detection_testing/GitService.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
if TYPE_CHECKING:
1111
from contentctl.input.director import DirectorOutputDto
1212

13-
1413
from contentctl.objects.config import All, Changes, Selected, test_common
1514
from contentctl.objects.data_source import DataSource
1615
from contentctl.objects.detection import Detection
17-
from contentctl.objects.lookup import Lookup, Lookup_Type
16+
from contentctl.objects.lookup import CSVLookup, Lookup
1817
from contentctl.objects.macro import Macro
1918
from contentctl.objects.security_content_object import SecurityContentObject
2019

@@ -150,8 +149,7 @@ def getChanges(self, target_branch: str) -> List[Detection]:
150149
# Filter to find the Lookup Object the references this CSV
151150
matched = list(
152151
filter(
153-
lambda x: x.lookup_type == Lookup_Type.csv
154-
and x.filename is not None
152+
lambda x: isinstance(x, CSVLookup)
155153
and x.filename == decoded_path,
156154
self.director.lookups,
157155
)
@@ -162,7 +160,7 @@ def getChanges(self, target_branch: str) -> List[Detection]:
162160
)
163161
elif len(matched) > 1:
164162
raise Exception(
165-
f"More than 1 Lookup reference the modified CSV file '{decoded_path}': {[l.file_path for l in matched]}"
163+
f"More than 1 Lookup reference the modified CSV file '{decoded_path}': {[match.file_path for match in matched]}"
166164
)
167165
else:
168166
updatedLookup = matched[0]
@@ -195,7 +193,7 @@ def getChanges(self, target_branch: str) -> List[Detection]:
195193
# If a detection has at least one dependency on changed content,
196194
# then we must test it again
197195

198-
changed_macros_and_lookups_and_datasources: set[SecurityContentObject] = (
196+
changed_macros_and_lookups_and_datasources: set[Macro | Lookup | DataSource] = (
199197
updated_macros.union(updated_lookups, updated_datasources)
200198
)
201199

contentctl/contentctl.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,6 @@ def main():
246246
print(e)
247247
sys.exit(1)
248248
except Exception as e:
249-
print(CONTENTCTL_5_WARNING)
250-
251249
if config is None:
252250
print(
253251
"There was a serious issue where the config file could not be created.\n"
@@ -265,8 +263,9 @@ def main():
265263
"Verbose error logging is DISABLED.\n"
266264
"Please use the --verbose command line argument if you need more context for your error or file a bug report."
267265
)
268-
print(e)
269266

267+
print(e)
268+
print(CONTENTCTL_5_WARNING)
270269
sys.exit(1)
271270

272271

0 commit comments

Comments
 (0)