From dc7ab0d71b9615333de2d6e1b089c3a6d69607ca Mon Sep 17 00:00:00 2001 From: ljstella Date: Tue, 22 Apr 2025 13:55:26 -0500 Subject: [PATCH 1/2] New type of version bumping error --- contentctl/actions/inspect.py | 16 +++++++++++++++- contentctl/objects/errors.py | 30 ++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/contentctl/actions/inspect.py b/contentctl/actions/inspect.py index 4a59b135..40c0ff27 100644 --- a/contentctl/actions/inspect.py +++ b/contentctl/actions/inspect.py @@ -16,6 +16,7 @@ DetectionMissingError, MetadataValidationError, VersionBumpingError, + VersionBumpingTooFarError, VersionDecrementedError, ) from contentctl.objects.savedsearches_conf import SavedsearchesConf @@ -101,7 +102,7 @@ def inspectAppAPI(self, config: inspect) -> str: -F "app_package=@" \ -F "included_tags=cloud" \ --url "https://appinspect.splunk.com/v1/app/validate" - + This is confirmed by the great resource: https://curlconverter.com/ """ @@ -429,6 +430,19 @@ def check_detection_metadata(self, config: inspect) -> None: ) ) + # Versions should never increase more than one version between releases + if ( + current_stanza.metadata.detection_version + > previous_stanza.metadata.detection_version + 1 + ): + validation_errors[rule_name].append( + VersionBumpingTooFarError( + rule_name=rule_name, + current_version=current_stanza.metadata.detection_version, + previous_version=previous_stanza.metadata.detection_version, + ) + ) + # Convert our dict mapping to a flat list of errors for use in reporting validation_error_list = [ x for inner_list in validation_errors.values() for x in inner_list diff --git a/contentctl/objects/errors.py b/contentctl/objects/errors.py index 9d81f546..3da48acc 100644 --- a/contentctl/objects/errors.py +++ b/contentctl/objects/errors.py @@ -185,7 +185,7 @@ def long_message(self) -> str: return ( f"Rule '{self.rule_name}' has changed in current build compared to previous " "build (stanza hashes differ); the detection version should be bumped " - f"to at least {self.previous_version + 1}." + f"to {self.previous_version + 1}." ) @property @@ -194,4 +194,30 @@ def short_message(self) -> str: A short-form error message :returns: a str, the message """ - return f"Detection version in current build should be bumped to at least {self.previous_version + 1}." + return f"Detection version in current build should be bumped to {self.previous_version + 1}." + + +class VersionBumpingTooFarError(VersioningError): + """ + An error indicating the detection changed but its version was bumped too far + """ + + @property + def long_message(self) -> str: + """ + A long-form error message + :returns: a str, the message + """ + return ( + f"Rule '{self.rule_name}' has changed in current build compared to previous " + "build (stanza hashes differ); however the detection version increased too much" + f"The version should be reduced to {self.previous_version + 1}." + ) + + @property + def short_message(self) -> str: + """ + A short-form error message + :returns: a str, the message + """ + return f"Detection version in current build should be reduced to {self.previous_version + 1}." From 4d9f5e03cda9026bb8fc98fb548029e8e721e8f7 Mon Sep 17 00:00:00 2001 From: ljstella Date: Tue, 22 Apr 2025 14:17:03 -0500 Subject: [PATCH 2/2] Bumping version... --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5cfa1620..0b97931f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "contentctl" -version = "5.3.1" +version = "5.3.2" description = "Splunk Content Control Tool" authors = ["STRT "]