Skip to content

Commit

Permalink
TODO (revert): temporarily disabling some v
Browse files Browse the repository at this point in the history
alidations
  • Loading branch information
cmcginley-splunk committed Oct 30, 2024
1 parent aac149c commit b3c6948
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -569,25 +569,26 @@ def model_post_init(self, __context: Any) -> None:
# 1 of the drilldowns contains the string Drilldown.SEARCH_PLACEHOLDER.
# This is presently a requirement when 1 or more drilldowns are added to a detection.
# Note that this is only required for production searches that are not hunting

# TODO (cmcginley): commenting out for testing
# if self.type == AnalyticsType.Hunting.value or self.status != DetectionStatus.production.value:
# #No additional check need to happen on the potential drilldowns.
# pass
# else:
# found_placeholder = False
# if len(self.drilldown_searches) < 2:
# raise ValueError(f"This detection is required to have 2 drilldown_searches, but only has [{len(self.drilldown_searches)}]")
# for drilldown in self.drilldown_searches:
# if DRILLDOWN_SEARCH_PLACEHOLDER in drilldown.search:
# found_placeholder = True
# if not found_placeholder:
# raise ValueError("Detection has one or more drilldown_searches, but none of them "
# f"contained '{DRILLDOWN_SEARCH_PLACEHOLDER}. This is a requirement "
# "if drilldown_searches are defined.'")

if self.type == AnalyticsType.Hunting.value or self.status != DetectionStatus.production.value:
#No additional check need to happen on the potential drilldowns.
pass
else:
found_placeholder = False
if len(self.drilldown_searches) < 2:
raise ValueError(f"This detection is required to have 2 drilldown_searches, but only has [{len(self.drilldown_searches)}]")
for drilldown in self.drilldown_searches:
if DRILLDOWN_SEARCH_PLACEHOLDER in drilldown.search:
found_placeholder = True
if not found_placeholder:
raise ValueError("Detection has one or more drilldown_searches, but none of them "
f"contained '{DRILLDOWN_SEARCH_PLACEHOLDER}. This is a requirement "
"if drilldown_searches are defined.'")

# Update the search fields with the original search, if required
for drilldown in self.drilldown_searches:
drilldown.perform_search_substitutions(self)
# # Update the search fields with the original search, if required
# for drilldown in self.drilldown_searches:
# drilldown.perform_search_substitutions(self)

#For experimental purposes, add the default drilldowns
#self.drilldown_searches.extend(Drilldown.constructDrilldownsFromDetection(self))
Expand Down
5 changes: 3 additions & 2 deletions contentctl/output/conf_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ def writeDashboardFiles(config:build, dashboards:list[Dashboard])->set[pathlib.P
output_file_path = dashboard.getOutputFilepathRelativeToAppRoot(config)
# Check that the full output path does not exist so that we are not having an
# name collision with a file in app_template
if (config.getPackageDirectoryPath()/output_file_path).exists():
raise FileExistsError(f"ERROR: Overwriting Dashboard File {output_file_path}. Does this file exist in {config.getAppTemplatePath()} AND {config.path/'dashboards'}?")
# TODO (cmcginley): commenting out for testing
# if (config.getPackageDirectoryPath()/output_file_path).exists():
# raise FileExistsError(f"ERROR: Overwriting Dashboard File {output_file_path}. Does this file exist in {config.getAppTemplatePath()} AND {config.path/'dashboards'}?")

ConfWriter.writeXmlFileHeader(output_file_path, config)
dashboard.writeDashboardFile(ConfWriter.getJ2Environment(), config)
Expand Down

0 comments on commit b3c6948

Please sign in to comment.