From 44cbee7c265ef5684e6ae9ee9857bce7e1c12619 Mon Sep 17 00:00:00 2001 From: Casey McGinley Date: Mon, 16 Sep 2024 10:25:05 -0700 Subject: [PATCH] removing hardcoded references to ESCU and the ESCU app UID --- contentctl/actions/inspect.py | 2 +- contentctl/objects/config.py | 13 ++++++++----- contentctl/objects/constants.py | 3 --- contentctl/objects/savedsearches_conf.py | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/contentctl/actions/inspect.py b/contentctl/actions/inspect.py index ef2be053..38bc2b23 100644 --- a/contentctl/actions/inspect.py +++ b/contentctl/actions/inspect.py @@ -279,7 +279,7 @@ def check_detection_metadata(self, config: inspect) -> None: """ # TODO (#282): We should be inspect the same artifact we're passing around from the # build stage ideally - # Unpack the savedsearch.conf of each ESCU package + # Unpack the savedsearch.conf of each app package current_build_conf = SavedsearchesConf.init_from_package( package_path=config.getPackageFilePath(include_version=False), app_name=config.app.label, diff --git a/contentctl/objects/config.py b/contentctl/objects/config.py index affbfd8e..974fa9c3 100644 --- a/contentctl/objects/config.py +++ b/contentctl/objects/config.py @@ -19,7 +19,7 @@ ValidationInfo ) -from contentctl.objects.constants import ESCU_APP_UID, DOWNLOADS_DIRECTORY +from contentctl.objects.constants import DOWNLOADS_DIRECTORY from contentctl.output.yml_writer import YmlWriter from contentctl.helper.utils import Utils from contentctl.objects.enums import PostTestBehavior, DetectionTestingMode @@ -286,7 +286,7 @@ class inspect(build): default=None, description=( "Local path to the previous app build for metatdata validation and versioning " - "enforcement (defaults to the latest release of ESCU published on Splunkbase)." + "enforcement (defaults to the latest release of the app published on Splunkbase)." ) ) stack_type: StackType = Field(description="The type of your Splunk Cloud Stack") @@ -317,14 +317,17 @@ def get_previous_package_file_path(self) -> pathlib.Path: latest version is downloaded from Splunkbase and it's filepath is returned, and saved to the in-memory config (so download doesn't happen twice in the same run). - :returns: Path object to previous ESCU build + :returns: Path object to previous app build :rtype: :class:`pathlib.Path` """ previous_build_path = self.previous_build # Download the previous build as the latest release on Splunkbase if no path was provided if previous_build_path is None: - print("Downloading latest ESCU build from Splunkbase to serve as previous build during validation...") - app = SplunkApp(app_uid=ESCU_APP_UID) + print( + f"Downloading latest {self.app.label} build from Splunkbase to serve as previous " + "build during validation..." + ) + app = SplunkApp(app_uid=self.app.uid) previous_build_path = app.download( out=pathlib.Path(DOWNLOADS_DIRECTORY), username=self.splunk_api_username, diff --git a/contentctl/objects/constants.py b/contentctl/objects/constants.py index 503dd950..a65e317c 100644 --- a/contentctl/objects/constants.py +++ b/contentctl/objects/constants.py @@ -138,8 +138,5 @@ "Victim": 1 } -# The app UID in Splunkbase of ESCU -ESCU_APP_UID = 3449 - # The relative path to the directory where any apps/packages will be downloaded DOWNLOADS_DIRECTORY = "downloads" diff --git a/contentctl/objects/savedsearches_conf.py b/contentctl/objects/savedsearches_conf.py index f66653e4..79e559c8 100644 --- a/contentctl/objects/savedsearches_conf.py +++ b/contentctl/objects/savedsearches_conf.py @@ -133,8 +133,8 @@ def _parse_detection_stanzas(self) -> None: for line in file: self._current_line_no += 1 - # Break when we get to the end of the ESCU detections - if line.strip() == "### END ESCU DETECTIONS ###": + # Break when we get to the end of the app detections + if line.strip() == f"### END {self.app_label} DETECTIONS ###": break elif self._in_detections: # Check if we are in the detections portion of the conf, and then if we are in a @@ -164,7 +164,7 @@ def _parse_detection_stanzas(self) -> None: "Found a non-empty line outside a stanza [see line " f"{self._current_line_no} in {self.path}]." ) - elif line.strip() == "### ESCU DETECTIONS ###": + elif line.strip() == f"### {self.app_label} DETECTIONS ###": # We have hit the detections portion of the conf and we adjust the state # accordingly self._in_detections = True