From e8af795c461361f04e9628a0e99d7de674d4b5bb Mon Sep 17 00:00:00 2001 From: Bhavin Patel Date: Fri, 26 Jul 2024 09:40:03 -0500 Subject: [PATCH 1/2] updating error handling on selected testing --- .../actions/detection_testing/GitService.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/contentctl/actions/detection_testing/GitService.py b/contentctl/actions/detection_testing/GitService.py index 36c45cc2..bfed85a3 100644 --- a/contentctl/actions/detection_testing/GitService.py +++ b/contentctl/actions/detection_testing/GitService.py @@ -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 \ No newline at end of file From b80969721c3c8dace0c2ed24bc97a069911dc1ad Mon Sep 17 00:00:00 2001 From: pyth0n1c Date: Fri, 26 Jul 2024 09:54:09 -0700 Subject: [PATCH 2/2] bump patch version for release --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 28bfa0bd..fe7632ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "contentctl" -version = "4.2.0" +version = "4.2.1" description = "Splunk Content Control Tool" authors = ["STRT "] license = "Apache 2.0"