Skip to content

Commit befff48

Browse files
authored
Merge branch 'main' into ruff_update
2 parents f4e2695 + 7936972 commit befff48

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

contentctl/objects/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
CONTENTCTL_DETECTION_STANZA_NAME_FORMAT_TEMPLATE = (
124124
"{app_label} - {detection_name} - Rule"
125125
)
126+
126127
CONTENTCTL_BASELINE_STANZA_NAME_FORMAT_TEMPLATE = "{app_label} - {detection_name}"
127128
CONTENTCTL_RESPONSE_TASK_NAME_FORMAT_TEMPLATE = (
128129
"{app_label} - {detection_name} - Response Task"

contentctl/objects/dashboard.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
import json
2+
import pathlib
3+
from enum import StrEnum
14
from typing import Any
2-
from pydantic import Field, Json, model_validator
35

4-
import pathlib
56
from jinja2 import Environment
6-
import json
7-
from contentctl.objects.security_content_object import SecurityContentObject
7+
from pydantic import Field, Json, model_validator
8+
89
from contentctl.objects.config import build
9-
from enum import StrEnum
10+
from contentctl.objects.security_content_object import SecurityContentObject
1011

11-
DEFAULT_DASHBAORD_JINJA2_TEMPLATE = """<dashboard version="2" theme="{{ dashboard.theme }}">
12-
<label>{{ dashboard.label(config) }}</label>
12+
DEFAULT_DASHBOARD_JINJA2_TEMPLATE = """<dashboard version="2" theme="{{ dashboard.theme }}">
13+
<label>{{ dashboard.name }}</label>
1314
<description></description>
1415
<definition><![CDATA[
1516
{{ dashboard.pretty_print_json_obj() }}
@@ -31,7 +32,7 @@ class DashboardTheme(StrEnum):
3132

3233
class Dashboard(SecurityContentObject):
3334
j2_template: str = Field(
34-
default=DEFAULT_DASHBAORD_JINJA2_TEMPLATE,
35+
default=DEFAULT_DASHBOARD_JINJA2_TEMPLATE,
3536
description="Jinja2 Template used to construct the dashboard",
3637
)
3738
description: str = Field(
@@ -48,9 +49,6 @@ class Dashboard(SecurityContentObject):
4849
..., description="Valid JSON object that describes the dashboard"
4950
)
5051

51-
def label(self, config: build) -> str:
52-
return f"{config.app.label} - {self.name}"
53-
5452
@model_validator(mode="before")
5553
@classmethod
5654
def validate_fields_from_json(cls, data: Any) -> Any:
@@ -98,7 +96,16 @@ def pretty_print_json_obj(self):
9896
return json.dumps(self.json_obj, indent=4)
9997

10098
def getOutputFilepathRelativeToAppRoot(self, config: build) -> pathlib.Path:
101-
filename = f"{self.file_path.stem}.xml".lower()
99+
if self.file_path is None:
100+
raise FileNotFoundError(
101+
f"Dashboard {self.name} file_path was None. Dashboards must be backed by a file."
102+
)
103+
# Prefix with the appLabel__ in order to make a search for these easy with match="__"
104+
# in the default.xml file
105+
filename = f"{config.app.label}__{self.file_path.stem}.xml".lower().replace(
106+
" ", "_"
107+
)
108+
102109
return pathlib.Path("default/data/ui/views") / filename
103110

104111
def writeDashboardFile(self, j2_env: Environment, config: build):
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<nav search_view="search" color="#65A637">
22
<view name="escu_summary" default="true"/>
3-
<view name="feedback"/>
43
<view name="search"/>
5-
<view name="dashboards"/>
6-
<a href="http://docs.splunk.com/Documentation/ESSOC">Docs</a>
4+
<collection label="Dashboards">
5+
<view source="unclassified" match="__"/>
6+
</collection>
77
</nav>

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "contentctl"
3-
version = "5.0.3"
3+
version = "5.0.5"
44

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

0 commit comments

Comments
 (0)