Skip to content

Commit 016f616

Browse files
authored
Merge pull request #206 from splunk/select_bug
updating error handling on selected testing
2 parents 5bd600c + b809697 commit 016f616

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

contentctl/actions/detection_testing/GitService.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,21 +155,22 @@ def getChanges(self, target_branch:str)->List[Detection]:
155155
print(f"[{len(updated_detections)}] Pieces of modifed and new content (this may include experimental/deprecated/manual_test content):\n - {modifiedAndNewContentString}")
156156
return updated_detections
157157

158-
def getSelected(self, detectionFilenames:List[FilePath])->List[Detection]:
159-
filepath_to_content_map:dict[FilePath, SecurityContentObject] = { obj.file_path:obj for (_,obj) in self.director.name_to_content_map.items() if obj.file_path is not None}
158+
def getSelected(self, detectionFilenames: List[FilePath]) -> List[Detection]:
159+
filepath_to_content_map: dict[FilePath, SecurityContentObject] = {
160+
obj.file_path: obj for (_, obj) in self.director.name_to_content_map.items() if obj.file_path is not None
161+
}
160162
errors = []
161-
detections:List[Detection] = []
163+
detections: List[Detection] = []
162164
for name in detectionFilenames:
163-
obj = filepath_to_content_map.get(name,None)
164-
if obj == None:
165+
obj = filepath_to_content_map.get(name, None)
166+
if obj is None:
165167
errors.append(f"There is no detection file or security_content_object at '{name}'")
166168
elif not isinstance(obj, Detection):
167169
errors.append(f"The security_content_object at '{name}' is of type '{type(obj).__name__}', NOT '{Detection.__name__}'")
168170
else:
169171
detections.append(obj)
170172

171-
if len(errors) > 0:
173+
if errors:
172174
errorsString = "\n - ".join(errors)
173-
raise Exception(f"There following errors were encountered while getting selected detections to test:\n - {errorsString}")
174-
return detections
175-
175+
raise Exception(f"The following errors were encountered while getting selected detections to test:\n - {errorsString}")
176+
return detections

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "contentctl"
3-
version = "4.2.0"
3+
version = "4.2.1"
44
description = "Splunk Content Control Tool"
55
authors = ["STRT <[email protected]>"]
66
license = "Apache 2.0"

0 commit comments

Comments
 (0)