Skip to content

Commit

Permalink
Merge pull request #206 from splunk/select_bug
Browse files Browse the repository at this point in the history
updating error handling on selected testing
  • Loading branch information
pyth0n1c authored Jul 26, 2024
2 parents 5bd600c + b809697 commit 016f616
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions contentctl/actions/detection_testing/GitService.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,22 @@ def getChanges(self, target_branch:str)->List[Detection]:
print(f"[{len(updated_detections)}] Pieces of modifed and new content (this may include experimental/deprecated/manual_test content):\n - {modifiedAndNewContentString}")
return updated_detections

def getSelected(self, detectionFilenames:List[FilePath])->List[Detection]:
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}
def getSelected(self, detectionFilenames: List[FilePath]) -> List[Detection]:
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
}
errors = []
detections:List[Detection] = []
detections: List[Detection] = []
for name in detectionFilenames:
obj = filepath_to_content_map.get(name,None)
if obj == None:
obj = filepath_to_content_map.get(name, None)
if obj is None:
errors.append(f"There is no detection file or security_content_object at '{name}'")
elif not isinstance(obj, Detection):
errors.append(f"The security_content_object at '{name}' is of type '{type(obj).__name__}', NOT '{Detection.__name__}'")
else:
detections.append(obj)

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

raise Exception(f"The following errors were encountered while getting selected detections to test:\n - {errorsString}")
return detections
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "contentctl"
version = "4.2.0"
version = "4.2.1"
description = "Splunk Content Control Tool"
authors = ["STRT <[email protected]>"]
license = "Apache 2.0"
Expand Down

0 comments on commit 016f616

Please sign in to comment.