Skip to content

Commit d78668d

Browse files
authored
Merge pull request #400 from splunk/version_bumping_check_change
New type of version bumping error
2 parents 8411908 + 4d9f5e0 commit d78668d

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

contentctl/actions/inspect.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
DetectionMissingError,
1717
MetadataValidationError,
1818
VersionBumpingError,
19+
VersionBumpingTooFarError,
1920
VersionDecrementedError,
2021
)
2122
from contentctl.objects.savedsearches_conf import SavedsearchesConf
@@ -101,7 +102,7 @@ def inspectAppAPI(self, config: inspect) -> str:
101102
-F "app_package=@<PATH/APP-PACKAGE>" \
102103
-F "included_tags=cloud" \
103104
--url "https://appinspect.splunk.com/v1/app/validate"
104-
105+
105106
This is confirmed by the great resource:
106107
https://curlconverter.com/
107108
"""
@@ -429,6 +430,19 @@ def check_detection_metadata(self, config: inspect) -> None:
429430
)
430431
)
431432

433+
# Versions should never increase more than one version between releases
434+
if (
435+
current_stanza.metadata.detection_version
436+
> previous_stanza.metadata.detection_version + 1
437+
):
438+
validation_errors[rule_name].append(
439+
VersionBumpingTooFarError(
440+
rule_name=rule_name,
441+
current_version=current_stanza.metadata.detection_version,
442+
previous_version=previous_stanza.metadata.detection_version,
443+
)
444+
)
445+
432446
# Convert our dict mapping to a flat list of errors for use in reporting
433447
validation_error_list = [
434448
x for inner_list in validation_errors.values() for x in inner_list

contentctl/objects/errors.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def long_message(self) -> str:
185185
return (
186186
f"Rule '{self.rule_name}' has changed in current build compared to previous "
187187
"build (stanza hashes differ); the detection version should be bumped "
188-
f"to at least {self.previous_version + 1}."
188+
f"to {self.previous_version + 1}."
189189
)
190190

191191
@property
@@ -194,4 +194,30 @@ def short_message(self) -> str:
194194
A short-form error message
195195
:returns: a str, the message
196196
"""
197-
return f"Detection version in current build should be bumped to at least {self.previous_version + 1}."
197+
return f"Detection version in current build should be bumped to {self.previous_version + 1}."
198+
199+
200+
class VersionBumpingTooFarError(VersioningError):
201+
"""
202+
An error indicating the detection changed but its version was bumped too far
203+
"""
204+
205+
@property
206+
def long_message(self) -> str:
207+
"""
208+
A long-form error message
209+
:returns: a str, the message
210+
"""
211+
return (
212+
f"Rule '{self.rule_name}' has changed in current build compared to previous "
213+
"build (stanza hashes differ); however the detection version increased too much"
214+
f"The version should be reduced to {self.previous_version + 1}."
215+
)
216+
217+
@property
218+
def short_message(self) -> str:
219+
"""
220+
A short-form error message
221+
:returns: a str, the message
222+
"""
223+
return f"Detection version in current build should be reduced to {self.previous_version + 1}."

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.poetry]
22
name = "contentctl"
33

4-
version = "5.3.1"
4+
version = "5.3.2"
55

66
description = "Splunk Content Control Tool"
77
authors = ["STRT <[email protected]>"]

0 commit comments

Comments
 (0)