Skip to content

Commit ec3a50f

Browse files
formatting
1 parent 12afdd5 commit ec3a50f

File tree

8 files changed

+146
-110
lines changed

8 files changed

+146
-110
lines changed

contentctl/actions/detection_testing/DetectionTestingManager.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@
99
from pydantic import BaseModel
1010

1111
from contentctl.actions.detection_testing.infrastructures.DetectionTestingInfrastructure import (
12-
DetectionTestingInfrastructure, DetectionTestingManagerOutputDto)
13-
from contentctl.actions.detection_testing.infrastructures.DetectionTestingInfrastructureContainer import \
14-
DetectionTestingInfrastructureContainer
15-
from contentctl.actions.detection_testing.infrastructures.DetectionTestingInfrastructureServer import \
16-
DetectionTestingInfrastructureServer
17-
from contentctl.actions.detection_testing.views.DetectionTestingView import \
18-
DetectionTestingView
19-
from contentctl.objects.config import (Container, Infrastructure, test,
20-
test_servers)
12+
DetectionTestingInfrastructure,
13+
DetectionTestingManagerOutputDto,
14+
)
15+
from contentctl.actions.detection_testing.infrastructures.DetectionTestingInfrastructureContainer import (
16+
DetectionTestingInfrastructureContainer,
17+
)
18+
from contentctl.actions.detection_testing.infrastructures.DetectionTestingInfrastructureServer import (
19+
DetectionTestingInfrastructureServer,
20+
)
21+
from contentctl.actions.detection_testing.views.DetectionTestingView import (
22+
DetectionTestingView,
23+
)
24+
from contentctl.objects.config import Container, Infrastructure, test, test_servers
2125
from contentctl.objects.detection import Detection
2226
from contentctl.objects.enums import PostTestBehavior
2327

@@ -160,8 +164,8 @@ def sigint_handler(signum, frame):
160164
for error in errors[error_type]:
161165
print(f"\t{str(error)}")
162166
if isinstance(error, ExceptionGroup):
163-
for suberror in error.exceptions: # type: ignore
164-
print(f"\t\t{str(suberror)}") # type: ignore
167+
for suberror in error.exceptions: # type: ignore
168+
print(f"\t\t{str(suberror)}") # type: ignore
165169
print()
166170

167171
return self.output_dto

contentctl/actions/detection_testing/infrastructures/DetectionTestingInfrastructure.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,30 @@
1616
import requests # type: ignore
1717
import splunklib.client as client # type: ignore
1818
import tqdm # type: ignore
19-
from pydantic import (BaseModel, ConfigDict, Field, PrivateAttr,
20-
computed_field, dataclasses)
19+
from pydantic import (
20+
BaseModel,
21+
ConfigDict,
22+
Field,
23+
PrivateAttr,
24+
computed_field,
25+
dataclasses,
26+
)
2127
from semantic_version import Version
2228
from splunklib.binding import HTTPError # type: ignore
2329
from splunklib.results import JSONResultsReader, Message # type: ignore
2430
from urllib3 import disable_warnings
2531

2632
from contentctl.actions.detection_testing.progress_bar import (
27-
FinalTestingStates, TestingStates, TestReportingType, format_pbar_string)
33+
FinalTestingStates,
34+
TestingStates,
35+
TestReportingType,
36+
format_pbar_string,
37+
)
2838
from contentctl.helper.utils import Utils
2939
from contentctl.objects.base_test import BaseTest
3040
from contentctl.objects.base_test_result import TestResultStatus
3141
from contentctl.objects.config import All, Infrastructure, test_common
32-
from contentctl.objects.content_versioning_service import \
33-
ContentVersioningService
42+
from contentctl.objects.content_versioning_service import ContentVersioningService
3443
from contentctl.objects.correlation_search import CorrelationSearch, PbarData
3544
from contentctl.objects.detection import Detection
3645
from contentctl.objects.enums import AnalyticsType, PostTestBehavior
@@ -140,7 +149,9 @@ def setup(self):
140149
self.start_time = time.time()
141150

142151
# Init the list of setup functions we always need
143-
primary_setup_functions: list[tuple[Callable[[], None | client.Service], str]] = [
152+
primary_setup_functions: list[
153+
tuple[Callable[[], None | client.Service], str]
154+
] = [
144155
(self.start, "Starting"),
145156
(self.get_conn, "Waiting for App Installation"),
146157
(self.configure_conf_file_datamodels, "Configuring Datamodels"),
@@ -150,7 +161,7 @@ def setup(self):
150161
(self.configure_imported_roles, "Configuring Roles"),
151162
(self.configure_delete_indexes, "Configuring Indexes"),
152163
(self.configure_hec, "Configuring HEC"),
153-
(self.wait_for_ui_ready, "Finishing Primary Setup")
164+
(self.wait_for_ui_ready, "Finishing Primary Setup"),
154165
]
155166

156167
# Execute and report on each setup function
@@ -173,7 +184,7 @@ def setup(self):
173184
TestReportingType.SETUP,
174185
self.get_name(),
175186
"Beginning Content Versioning Validation...",
176-
set_pbar=False
187+
set_pbar=False,
177188
)
178189
)
179190
for func, msg in self.content_versioning_service.setup_functions:
@@ -190,15 +201,15 @@ def setup(self):
190201
msg = f"[{self.get_name()}]: {str(e)}"
191202
self.finish()
192203
if isinstance(e, ExceptionGroup):
193-
raise ExceptionGroup(msg, e.exceptions) from e # type: ignore
204+
raise ExceptionGroup(msg, e.exceptions) from e # type: ignore
194205
raise Exception(msg) from e
195206

196207
self.pbar.write(
197208
self.format_pbar_string(
198209
TestReportingType.SETUP,
199210
self.get_name(),
200211
"Finished Setup!",
201-
set_pbar=False
212+
set_pbar=False,
202213
)
203214
)
204215

@@ -220,7 +231,7 @@ def content_versioning_service(self) -> ContentVersioningService:
220231
global_config=self.global_config,
221232
infrastructure=self.infrastructure,
222233
service=self.get_conn(),
223-
detections=self.sync_obj.inputQueue
234+
detections=self.sync_obj.inputQueue,
224235
)
225236

226237
@property
@@ -251,7 +262,7 @@ def es_version(self) -> Version | None:
251262
"""
252263
if not self.es_installed:
253264
return None
254-
return Version(self.get_conn().apps[ES_APP_NAME]["version"]) # type: ignore
265+
return Version(self.get_conn().apps[ES_APP_NAME]["version"]) # type: ignore
255266

256267
@property
257268
def es_installed(self) -> bool:
@@ -400,7 +411,6 @@ def configure_imported_roles(
400411
imported_roles: list[str] = ["user", "power", "can_delete"],
401412
enterprise_security_roles: list[str] = ["ess_admin", "ess_analyst", "ess_user"],
402413
):
403-
404414
# Set which roles should be configured. For Enterprise Security/Integration Testing,
405415
# we must add some extra foles.
406416
if self.global_config.enable_integration_testing:

contentctl/actions/test.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,21 @@
33
from typing import List
44

55
from contentctl.actions.detection_testing.DetectionTestingManager import (
6-
DetectionTestingManager, DetectionTestingManagerInputDto)
7-
from contentctl.actions.detection_testing.infrastructures.DetectionTestingInfrastructure import \
8-
DetectionTestingManagerOutputDto
9-
from contentctl.actions.detection_testing.views.DetectionTestingViewCLI import \
10-
DetectionTestingViewCLI
11-
from contentctl.actions.detection_testing.views.DetectionTestingViewFile import \
12-
DetectionTestingViewFile
13-
from contentctl.actions.detection_testing.views.DetectionTestingViewWeb import \
14-
DetectionTestingViewWeb
6+
DetectionTestingManager,
7+
DetectionTestingManagerInputDto,
8+
)
9+
from contentctl.actions.detection_testing.infrastructures.DetectionTestingInfrastructure import (
10+
DetectionTestingManagerOutputDto,
11+
)
12+
from contentctl.actions.detection_testing.views.DetectionTestingViewCLI import (
13+
DetectionTestingViewCLI,
14+
)
15+
from contentctl.actions.detection_testing.views.DetectionTestingViewFile import (
16+
DetectionTestingViewFile,
17+
)
18+
from contentctl.actions.detection_testing.views.DetectionTestingViewWeb import (
19+
DetectionTestingViewWeb,
20+
)
1521
from contentctl.objects.config import Changes, Selected
1622
from contentctl.objects.config import test as test_
1723
from contentctl.objects.config import test_servers

contentctl/helper/utils.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -491,13 +491,10 @@ def getPercent(numerator: float, denominator: float, decimal_places: int) -> str
491491
ratio = numerator / denominator
492492
percent = ratio * 100
493493
return Utils.getFixedWidth(percent, decimal_places) + "%"
494-
494+
495495
@staticmethod
496496
def get_logger(
497-
name: str,
498-
log_level: int,
499-
log_path: str,
500-
enable_logging: bool
497+
name: str, log_level: int, log_path: str, enable_logging: bool
501498
) -> logging.Logger:
502499
"""
503500
Gets a logger instance for the given name; logger is configured if not already configured.
@@ -539,7 +536,9 @@ def get_logger(
539536
handler = logging.NullHandler()
540537

541538
# Format our output
542-
formatter = logging.Formatter('%(asctime)s - %(levelname)s:%(name)s - %(message)s')
539+
formatter = logging.Formatter(
540+
"%(asctime)s - %(levelname)s:%(name)s - %(message)s"
541+
)
543542
handler.setFormatter(formatter)
544543

545544
# Set handler level and add to logger

contentctl/objects/config.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,20 @@
1212

1313
import semantic_version
1414
import tqdm
15-
from pydantic import (AnyUrl, BaseModel, ConfigDict, DirectoryPath, Field,
16-
FilePath, HttpUrl, PositiveInt, ValidationInfo,
17-
field_serializer, field_validator, model_validator)
15+
from pydantic import (
16+
AnyUrl,
17+
BaseModel,
18+
ConfigDict,
19+
DirectoryPath,
20+
Field,
21+
FilePath,
22+
HttpUrl,
23+
PositiveInt,
24+
ValidationInfo,
25+
field_serializer,
26+
field_validator,
27+
model_validator,
28+
)
1829

1930
from contentctl.helper.splunk_app import SplunkApp
2031
from contentctl.helper.utils import Utils
@@ -408,8 +419,8 @@ class inspect(build):
408419
description=(
409420
"[NOTE: enrichments must be ENABLED for inspect to run. Please adjust your config "
410421
f"or CLI invocation appropriately] {validate.model_fields['enrichments'].description}"
411-
)
412-
)
422+
),
423+
)
413424
previous_build: str | None = Field(
414425
default=None,
415426
description=(

0 commit comments

Comments
 (0)