From adbbcb525550d339cf181450f841e3dc6cbd0f07 Mon Sep 17 00:00:00 2001 From: Bhavin Patel Date: Fri, 18 Oct 2024 17:15:39 -0700 Subject: [PATCH 01/10] add a cli flag --- contentctl/actions/release_notes.py | 5 ++++- contentctl/objects/config.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/contentctl/actions/release_notes.py b/contentctl/actions/release_notes.py index 859fcf87..03eeb477 100644 --- a/contentctl/actions/release_notes.py +++ b/contentctl/actions/release_notes.py @@ -114,7 +114,10 @@ def release_notes(self, config:release_notes) -> None: #If a branch name is supplied, compare against develop if config.latest_branch not in repo.branches: raise ValueError(f"latest branch {config.latest_branch} does not exist in the repository. Make sure your branch name is correct") - compare_against = "develop" + if config.compare_against not in repo.branches: + compare_against = config.compare_against + else: + compare_against = "develop" commit1 = repo.commit(config.latest_branch) commit2 = repo.commit(compare_against) diff_index = commit2.diff(commit1) diff --git a/contentctl/objects/config.py b/contentctl/objects/config.py index f287d010..23456e12 100644 --- a/contentctl/objects/config.py +++ b/contentctl/objects/config.py @@ -966,6 +966,7 @@ class release_notes(Config_Base): new_tag:Optional[str] = Field(None, description="Name of the tag containing new content. If it is not supplied," " then it will be inferred as the newest tag at runtime.") latest_branch:Optional[str] = Field(None, description="Branch for which we are generating release notes") + compare_against:Optional[str] = Field(None, description="Branch for which we are generating release notes against") def releaseNotesFilename(self, filename:str)->pathlib.Path: #Assume that notes are written to dist/. This does not respect build_dir since that is From 98808d5772493532e7144ecfe8a5e8d9be869a3f Mon Sep 17 00:00:00 2001 From: Bhavin Patel Date: Mon, 21 Oct 2024 13:07:02 -0700 Subject: [PATCH 02/10] eric feedback --- contentctl/actions/release_notes.py | 3 +-- contentctl/objects/config.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/contentctl/actions/release_notes.py b/contentctl/actions/release_notes.py index 03eeb477..60dd991c 100644 --- a/contentctl/actions/release_notes.py +++ b/contentctl/actions/release_notes.py @@ -115,9 +115,8 @@ def release_notes(self, config:release_notes) -> None: if config.latest_branch not in repo.branches: raise ValueError(f"latest branch {config.latest_branch} does not exist in the repository. Make sure your branch name is correct") if config.compare_against not in repo.branches: + raise ValueError(f"compare_against branch {config.compare_against} does not exist in the repository. Make sure your branch name is correct") compare_against = config.compare_against - else: - compare_against = "develop" commit1 = repo.commit(config.latest_branch) commit2 = repo.commit(compare_against) diff_index = commit2.diff(commit1) diff --git a/contentctl/objects/config.py b/contentctl/objects/config.py index 23456e12..7206b9a6 100644 --- a/contentctl/objects/config.py +++ b/contentctl/objects/config.py @@ -966,8 +966,7 @@ class release_notes(Config_Base): new_tag:Optional[str] = Field(None, description="Name of the tag containing new content. If it is not supplied," " then it will be inferred as the newest tag at runtime.") latest_branch:Optional[str] = Field(None, description="Branch for which we are generating release notes") - compare_against:Optional[str] = Field(None, description="Branch for which we are generating release notes against") - + compare_against: str = Field(default="develop", description="Branch for which we are generating release notes against") def releaseNotesFilename(self, filename:str)->pathlib.Path: #Assume that notes are written to dist/. This does not respect build_dir since that is #only a member of build From d12a173236a4887df431ce03d165877acdd3a30c Mon Sep 17 00:00:00 2001 From: Bhavin Patel Date: Mon, 21 Oct 2024 13:28:15 -0700 Subject: [PATCH 03/10] still optional --- contentctl/actions/release_notes.py | 2 +- contentctl/objects/config.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/contentctl/actions/release_notes.py b/contentctl/actions/release_notes.py index 60dd991c..f3358fa2 100644 --- a/contentctl/actions/release_notes.py +++ b/contentctl/actions/release_notes.py @@ -116,7 +116,7 @@ def release_notes(self, config:release_notes) -> None: raise ValueError(f"latest branch {config.latest_branch} does not exist in the repository. Make sure your branch name is correct") if config.compare_against not in repo.branches: raise ValueError(f"compare_against branch {config.compare_against} does not exist in the repository. Make sure your branch name is correct") - compare_against = config.compare_against + compare_against = config.compare_against commit1 = repo.commit(config.latest_branch) commit2 = repo.commit(compare_against) diff_index = commit2.diff(commit1) diff --git a/contentctl/objects/config.py b/contentctl/objects/config.py index 7206b9a6..6643ae7b 100644 --- a/contentctl/objects/config.py +++ b/contentctl/objects/config.py @@ -965,8 +965,9 @@ class release_notes(Config_Base): "second newest tag at runtime.") new_tag:Optional[str] = Field(None, description="Name of the tag containing new content. If it is not supplied," " then it will be inferred as the newest tag at runtime.") - latest_branch:Optional[str] = Field(None, description="Branch for which we are generating release notes") - compare_against: str = Field(default="develop", description="Branch for which we are generating release notes against") + latest_branch:Optional[str] = Field(None, description="Branch name for which we are generating release notes for") + compare_against:Optional[str] = Field(None, description="Branch name for which we are comparing the files changes against") + def releaseNotesFilename(self, filename:str)->pathlib.Path: #Assume that notes are written to dist/. This does not respect build_dir since that is #only a member of build From f7204a134d94a813e460da47808e8af7529a8203 Mon Sep 17 00:00:00 2001 From: Bhavin Patel Date: Mon, 21 Oct 2024 13:34:27 -0700 Subject: [PATCH 04/10] default to devleop --- contentctl/actions/release_notes.py | 3 +-- contentctl/objects/config.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/contentctl/actions/release_notes.py b/contentctl/actions/release_notes.py index f3358fa2..e750b364 100644 --- a/contentctl/actions/release_notes.py +++ b/contentctl/actions/release_notes.py @@ -116,9 +116,8 @@ def release_notes(self, config:release_notes) -> None: raise ValueError(f"latest branch {config.latest_branch} does not exist in the repository. Make sure your branch name is correct") if config.compare_against not in repo.branches: raise ValueError(f"compare_against branch {config.compare_against} does not exist in the repository. Make sure your branch name is correct") - compare_against = config.compare_against commit1 = repo.commit(config.latest_branch) - commit2 = repo.commit(compare_against) + commit2 = repo.commit(config.compare_against) diff_index = commit2.diff(commit1) modified_files:List[pathlib.Path] = [] diff --git a/contentctl/objects/config.py b/contentctl/objects/config.py index 6643ae7b..9057a4c4 100644 --- a/contentctl/objects/config.py +++ b/contentctl/objects/config.py @@ -966,7 +966,7 @@ class release_notes(Config_Base): new_tag:Optional[str] = Field(None, description="Name of the tag containing new content. If it is not supplied," " then it will be inferred as the newest tag at runtime.") latest_branch:Optional[str] = Field(None, description="Branch name for which we are generating release notes for") - compare_against:Optional[str] = Field(None, description="Branch name for which we are comparing the files changes against") + compare_against:Optional[str] = Field(default="develop", description="Branch name for which we are comparing the files changes against") def releaseNotesFilename(self, filename:str)->pathlib.Path: #Assume that notes are written to dist/. This does not respect build_dir since that is From cc845241b5a048bb78ea3b6c8a8c35fef771c594 Mon Sep 17 00:00:00 2001 From: Bhavin Patel Date: Mon, 21 Oct 2024 13:41:04 -0700 Subject: [PATCH 05/10] updating config --- contentctl/actions/release_notes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contentctl/actions/release_notes.py b/contentctl/actions/release_notes.py index e750b364..fe2c90d4 100644 --- a/contentctl/actions/release_notes.py +++ b/contentctl/actions/release_notes.py @@ -116,6 +116,7 @@ def release_notes(self, config:release_notes) -> None: raise ValueError(f"latest branch {config.latest_branch} does not exist in the repository. Make sure your branch name is correct") if config.compare_against not in repo.branches: raise ValueError(f"compare_against branch {config.compare_against} does not exist in the repository. Make sure your branch name is correct") + commit1 = repo.commit(config.latest_branch) commit2 = repo.commit(config.compare_against) diff_index = commit2.diff(commit1) @@ -190,7 +191,7 @@ def release_notes(self, config:release_notes) -> None: if config.latest_branch: print(f"Generating release notes - \033[92m{config.latest_branch}\033[0m") - print(f"Compared against - \033[92m{compare_against}\033[0m") + print(f"Compared against - \033[92m{config.compare_against}\033[0m") print("\n## Release notes for ESCU " + config.latest_branch) notes = [self.create_notes(config.path, stories_added, header="New Analytic Story"), From 3c884d9e54b05e118c27e97c9d6a12f8b94566f3 Mon Sep 17 00:00:00 2001 From: Bhavin Patel Date: Mon, 21 Oct 2024 15:12:54 -0700 Subject: [PATCH 06/10] udpating toml --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5af34190..ef0803af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,7 @@ [tool.poetry] name = "contentctl" -version = "4.4.0" +version = "4.4.1" + description = "Splunk Content Control Tool" authors = ["STRT "] license = "Apache 2.0" From 0dad9563a57f6fe27e7a46d6389a6657d69eb62e Mon Sep 17 00:00:00 2001 From: pyth0n1c Date: Tue, 22 Oct 2024 10:19:44 -0700 Subject: [PATCH 07/10] remove "cloud" from the security_domain enum --- contentctl/objects/enums.py | 1 - 1 file changed, 1 deletion(-) diff --git a/contentctl/objects/enums.py b/contentctl/objects/enums.py index f4a7822e..333ef358 100644 --- a/contentctl/objects/enums.py +++ b/contentctl/objects/enums.py @@ -330,7 +330,6 @@ class SecurityDomain(str, enum.Enum): IDENTITY = "identity" ACCESS = "access" AUDIT = "audit" - CLOUD = "cloud" class AssetType(str, enum.Enum): AWS_ACCOUNT = "AWS Account" From 6bcb8751db77f445b387293c0ef8d7b4b199fa0d Mon Sep 17 00:00:00 2001 From: pyth0n1c Date: Tue, 22 Oct 2024 15:57:42 -0700 Subject: [PATCH 08/10] Fix path to fetch a saved search by name. Without fixing this path, integration testing fails to find the search and errors out. --- contentctl/objects/correlation_search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contentctl/objects/correlation_search.py b/contentctl/objects/correlation_search.py index 504fdf6f..c64eed6b 100644 --- a/contentctl/objects/correlation_search.py +++ b/contentctl/objects/correlation_search.py @@ -264,7 +264,7 @@ def splunk_path(self) -> str: :returns: the search path :rtype: str """ - return f"/saved/searches/{self.name}" + return f"saved/searches/{self.name}" @computed_field @cached_property From b58027895388f36677e242a1c0d315e57bbb5be7 Mon Sep 17 00:00:00 2001 From: pyth0n1c Date: Tue, 22 Oct 2024 15:59:29 -0700 Subject: [PATCH 09/10] Fix path that was updated incorrectly. This path is used to find a saved search for scheduling to run during integtration testing. This bad path causes every integration test to fail. --- contentctl/objects/correlation_search.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contentctl/objects/correlation_search.py b/contentctl/objects/correlation_search.py index 504fdf6f..232d88e0 100644 --- a/contentctl/objects/correlation_search.py +++ b/contentctl/objects/correlation_search.py @@ -988,6 +988,9 @@ def cleanup(self, delete_test_index=False) -> None: and the cron schedule persist after cleanup :param delete_test_index: flag indicating whether the test index should be cleared or not (defaults to False) """ + print("\n\n\n\npre cleanup\n\n\n\n") + _ = input() + print("\n\n\n\ngot user okay\n\n\n\n") # delete_test_index can't be true when test_index is None if delete_test_index and (self.test_index is None): raise ClientError("test_index is None, cannot delete it") From c9dfa84f0bf89d988d2d7f89f0637e90f8c72a6b Mon Sep 17 00:00:00 2001 From: pyth0n1c Date: Tue, 22 Oct 2024 16:04:27 -0700 Subject: [PATCH 10/10] forgot to save before committing. see previous commit message. --- contentctl/objects/correlation_search.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/contentctl/objects/correlation_search.py b/contentctl/objects/correlation_search.py index 232d88e0..c64eed6b 100644 --- a/contentctl/objects/correlation_search.py +++ b/contentctl/objects/correlation_search.py @@ -264,7 +264,7 @@ def splunk_path(self) -> str: :returns: the search path :rtype: str """ - return f"/saved/searches/{self.name}" + return f"saved/searches/{self.name}" @computed_field @cached_property @@ -988,9 +988,6 @@ def cleanup(self, delete_test_index=False) -> None: and the cron schedule persist after cleanup :param delete_test_index: flag indicating whether the test index should be cleared or not (defaults to False) """ - print("\n\n\n\npre cleanup\n\n\n\n") - _ = input() - print("\n\n\n\ngot user okay\n\n\n\n") # delete_test_index can't be true when test_index is None if delete_test_index and (self.test_index is None): raise ClientError("test_index is None, cannot delete it")