Skip to content

Commit

Permalink
removing hardcoded references to ESCU and the ESCU app UID
Browse files Browse the repository at this point in the history
  • Loading branch information
cmcginley-splunk committed Sep 16, 2024
1 parent f00e886 commit 44cbee7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion contentctl/actions/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 8 additions & 5 deletions contentctl/objects/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions contentctl/objects/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
6 changes: 3 additions & 3 deletions contentctl/objects/savedsearches_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 44cbee7

Please sign in to comment.