Skip to content

Commit 4eefa15

Browse files
committed
Fixes for previous lints
1 parent 46049c3 commit 4eefa15

29 files changed

+81
-81
lines changed

contentctl/actions/deploy_acs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def execute(self, config: deploy_acs, appinspect_token: str) -> None:
3535
raise Exception(f"Unsupported stack type: '{config.stack_type}'")
3636
except Exception as e:
3737
raise Exception(
38-
f"Error installing to stack '{config.splunk_cloud_stack}' (stack_type='{config.stack_type}') via ACS:\n{str(e)}"
38+
f"Error installing to stack '{config.splunk_cloud_stack}' (stack_type='{config.stack_type}') via ACS:\n{e!s}"
3939
)
4040

4141
try:

contentctl/actions/detection_testing/DetectionTestingManager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ def sigint_handler(signum, frame):
162162
print()
163163
print(f"[{error_type}]:")
164164
for error in errors[error_type]:
165-
print(f"\t{str(error)}")
165+
print(f"\t{error!s}")
166166
if isinstance(error, ExceptionGroup):
167167
for suberror in error.exceptions: # type: ignore
168-
print(f"\t\t{str(suberror)}") # type: ignore
168+
print(f"\t\t{suberror!s}") # type: ignore
169169
print()
170170

171171
return self.output_dto
@@ -208,7 +208,7 @@ def create_DetectionTestingInfrastructureObjects(self):
208208
except Exception as e:
209209
raise Exception(
210210
"Failed to pull docker container image "
211-
f"[{self.input_dto.config.container_settings.full_image_path}]: {str(e)}"
211+
f"[{self.input_dto.config.container_settings.full_image_path}]: {e!s}"
212212
)
213213

214214
already_staged_container_files = False

contentctl/actions/detection_testing/GitService.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def getChanges(self, target_branch: str) -> List[Detection]:
9999
updated_detections.add(detectionObject)
100100
else:
101101
raise Exception(
102-
f"Error getting detection object for file {str(decoded_path)}"
102+
f"Error getting detection object for file {decoded_path!s}"
103103
)
104104

105105
elif (
@@ -111,7 +111,7 @@ def getChanges(self, target_branch: str) -> List[Detection]:
111111
updated_macros.add(macroObject)
112112
else:
113113
raise Exception(
114-
f"Error getting macro object for file {str(decoded_path)}"
114+
f"Error getting macro object for file {decoded_path!s}"
115115
)
116116

117117
elif (
@@ -125,7 +125,7 @@ def getChanges(self, target_branch: str) -> List[Detection]:
125125
updated_datasources.add(datasourceObject)
126126
else:
127127
raise Exception(
128-
f"Error getting data source object for file {str(decoded_path)}"
128+
f"Error getting data source object for file {decoded_path!s}"
129129
)
130130

131131
elif decoded_path.is_relative_to(self.config.path / "lookups"):
@@ -172,7 +172,7 @@ def getChanges(self, target_branch: str) -> List[Detection]:
172172

173173
else:
174174
raise Exception(
175-
f"Detected a changed file in the lookups/ directory '{str(decoded_path)}'.\n"
175+
f"Detected a changed file in the lookups/ directory '{decoded_path!s}'.\n"
176176
"Only files ending in .csv, .yml, or .mlmodel are supported in this "
177177
"directory. This file must be removed from the lookups/ directory."
178178
)

contentctl/actions/detection_testing/generate_detection_coverage_badge.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@
4747
try:
4848
results = parser.parse_args()
4949
except Exception as e:
50-
print(f"Error parsing arguments: {str(e)}")
50+
print(f"Error parsing arguments: {e!s}")
5151
exit(1)
5252

5353
try:
5454
summary_info = json.loads(results.input_summary_file.read())
5555
except Exception as e:
56-
print(f"Error loading {results.input_summary_file.name} JSON file: {str(e)}")
56+
print(f"Error loading {results.input_summary_file.name} JSON file: {e!s}")
5757
sys.exit(1)
5858

5959
if "summary" not in summary_info:
@@ -75,7 +75,7 @@
7575
RAW_BADGE_SVG.format(results.badge_string, "{:2.1f}%".format(pass_percent))
7676
)
7777
except Exception as e:
78-
print(f"Error generating badge: {str(e)}")
78+
print(f"Error generating badge: {e!s}")
7979
sys.exit(1)
8080

8181

contentctl/actions/detection_testing/infrastructures/DetectionTestingInfrastructure.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def setup(self):
197197
self.check_for_teardown()
198198

199199
except Exception as e:
200-
msg = f"[{self.get_name()}]: {str(e)}"
200+
msg = f"[{self.get_name()}]: {e!s}"
201201
self.finish()
202202
if isinstance(e, ExceptionGroup):
203203
raise ExceptionGroup(msg, e.exceptions) from e # type: ignore
@@ -310,7 +310,7 @@ def configure_hec(self):
310310
return
311311

312312
except Exception as e:
313-
raise (Exception(f"Failure creating HEC Endpoint: {str(e)}"))
313+
raise (Exception(f"Failure creating HEC Endpoint: {e!s}"))
314314

315315
def get_all_indexes(self) -> None:
316316
"""
@@ -327,7 +327,7 @@ def get_all_indexes(self) -> None:
327327
# Retrieve all available indexes on the splunk instance
328328
self.all_indexes_on_server = indexes
329329
except Exception as e:
330-
raise (Exception(f"Failure getting indexes: {str(e)}"))
330+
raise (Exception(f"Failure getting indexes: {e!s}"))
331331

332332
def get_conn(self) -> client.Service:
333333
try:
@@ -382,7 +382,7 @@ def connect_to_api(self, sleep_seconds: int = 5):
382382
pass
383383
except Exception as e:
384384
self.pbar.write(
385-
f"Error getting API connection (not quitting) '{type(e).__name__}': {str(e)}"
385+
f"Error getting API connection (not quitting) '{type(e).__name__}': {e!s}"
386386
)
387387

388388
for _ in range(sleep_seconds):
@@ -402,7 +402,7 @@ def create_replay_index(self):
402402
pass
403403
else:
404404
raise Exception(
405-
f"Error creating index {self.sync_obj.replay_index} - {str(e)}"
405+
f"Error creating index {self.sync_obj.replay_index} - {e!s}"
406406
)
407407

408408
def configure_imported_roles(
@@ -426,7 +426,7 @@ def configure_imported_roles(
426426
)
427427
return
428428
except Exception as e:
429-
msg = f"Error configuring roles: {str(e)}"
429+
msg = f"Error configuring roles: {e!s}"
430430
self.pbar.write(msg)
431431
raise Exception(msg) from e
432432

@@ -436,7 +436,7 @@ def configure_delete_indexes(self):
436436
self.get_conn().post(endpoint, value=";".join(self.all_indexes_on_server))
437437
except Exception as e:
438438
self.pbar.write(
439-
f"Error configuring deleteIndexesAllowed with '{self.all_indexes_on_server}': [{str(e)}]"
439+
f"Error configuring deleteIndexesAllowed with '{self.all_indexes_on_server}': [{e!s}]"
440440
)
441441

442442
def wait_for_conf_file(self, app_name: str, conf_file_name: str):
@@ -474,12 +474,12 @@ def configure_conf_file_datamodels(self, APP_NAME: str = "Splunk_SA_CIM"):
474474
parser.read(custom_acceleration_datamodels)
475475
if len(parser.keys()) > 1:
476476
self.pbar.write(
477-
f"Read {len(parser) - 1} custom datamodels from {str(custom_acceleration_datamodels)}!"
477+
f"Read {len(parser) - 1} custom datamodels from {custom_acceleration_datamodels!s}!"
478478
)
479479

480480
if not cim_acceleration_datamodels.is_file():
481481
self.pbar.write(
482-
f"******************************\nDATAMODEL ACCELERATION FILE {str(cim_acceleration_datamodels)} NOT "
482+
f"******************************\nDATAMODEL ACCELERATION FILE {cim_acceleration_datamodels!s} NOT "
483483
"FOUND. CIM DATAMODELS NOT ACCELERATED\n******************************\n"
484484
)
485485
else:
@@ -499,7 +499,7 @@ def configure_conf_file_datamodels(self, APP_NAME: str = "Splunk_SA_CIM"):
499499

500500
except Exception as e:
501501
self.pbar.write(
502-
f"Error creating the conf Datamodel {datamodel_name} key/value {name}/{value}: {str(e)}"
502+
f"Error creating the conf Datamodel {datamodel_name} key/value {name}/{value}: {e!s}"
503503
)
504504

505505
def execute(self):
@@ -529,7 +529,7 @@ def execute(self):
529529
return
530530
except Exception as e:
531531
self.pbar.write(
532-
f"Error testing detection: {type(e).__name__}: {str(e)}"
532+
f"Error testing detection: {type(e).__name__}: {e!s}"
533533
)
534534
raise e
535535
finally:
@@ -1365,7 +1365,7 @@ def delete_attack_data(self, attack_data_files: list[TestAttackData]):
13651365
except Exception as e:
13661366
raise (
13671367
Exception(
1368-
f"Trouble deleting data using the search {splunk_search}: {str(e)}"
1368+
f"Trouble deleting data using the search {splunk_search}: {e!s}"
13691369
)
13701370
)
13711371

@@ -1440,7 +1440,7 @@ def replay_attack_data_file(
14401440
except Exception as e:
14411441
raise (
14421442
Exception(
1443-
f"Could not download attack data file [{attack_data_file.data}]:{str(e)}"
1443+
f"Could not download attack data file [{attack_data_file.data}]:{e!s}"
14441444
)
14451445
)
14461446

@@ -1514,7 +1514,7 @@ def hec_raw_replay(
15141514
except Exception as e:
15151515
raise (
15161516
Exception(
1517-
f"There was an exception sending attack_data to HEC: {str(e)}"
1517+
f"There was an exception sending attack_data to HEC: {e!s}"
15181518
)
15191519
)
15201520

@@ -1558,7 +1558,7 @@ def hec_raw_replay(
15581558
)
15591559
)
15601560
except Exception as e:
1561-
raise (Exception(f"There was an exception in the post: {str(e)}"))
1561+
raise (Exception(f"There was an exception in the post: {e!s}"))
15621562

15631563
def status(self):
15641564
pass

contentctl/actions/detection_testing/infrastructures/DetectionTestingInfrastructureContainer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def finish(self):
3535
self.removeContainer()
3636
pass
3737
except Exception as e:
38-
raise (Exception(f"Error removing container: {str(e)}"))
38+
raise (Exception(f"Error removing container: {e!s}"))
3939
super().finish()
4040

4141
def get_name(self) -> str:
@@ -47,7 +47,7 @@ def get_docker_client(self):
4747

4848
return c
4949
except Exception as e:
50-
raise (Exception(f"Failed to get docker client: {str(e)}"))
50+
raise (Exception(f"Failed to get docker client: {e!s}"))
5151

5252
def check_for_teardown(self):
5353
try:
@@ -57,7 +57,7 @@ def check_for_teardown(self):
5757
except Exception as e:
5858
if self.sync_obj.terminate is not True:
5959
self.pbar.write(
60-
f"Error: could not get container [{self.get_name()}]: {str(e)}"
60+
f"Error: could not get container [{self.get_name()}]: {e!s}"
6161
)
6262
self.sync_obj.terminate = True
6363
else:
@@ -176,6 +176,6 @@ def removeContainer(self, removeVolumes: bool = True, forceRemove: bool = True):
176176
except Exception as e:
177177
raise (
178178
Exception(
179-
f"Could not remove Docker Container [{self.get_name()}]: {str(e)}"
179+
f"Could not remove Docker Container [{self.get_name()}]: {e!s}"
180180
)
181181
)

contentctl/actions/detection_testing/views/DetectionTestingViewWeb.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
{% for containerName, data in currentTestingQueue.items() %}
4040
<tr>
4141
<td>{{ containerName }}</td>
42-
<td>{{ data["name"] }}</td>
43-
<td>{{ data["search"] }}</td>
42+
<td>{{ data["name"] }}</td>
43+
<td>{{ data["search"] }}</td>
4444
</tr>
4545
{% endfor %}
4646
</tbody>
@@ -69,7 +69,7 @@
6969
{% else %}
7070
<td style="font-weight: bold;background-color: #ff9999"><b>False</b></td>
7171
{% endif %}
72-
72+
7373
</tr>
7474
{% endfor %}
7575
{% endfor %}
@@ -118,7 +118,7 @@ def setup(self):
118118
try:
119119
webbrowser.open(f"http://{self.server.host}:{DEFAULT_WEB_UI_PORT}")
120120
except Exception as e:
121-
print(f"Could not open webbrowser for status page: {str(e)}")
121+
print(f"Could not open webbrowser for status page: {e!s}")
122122

123123
def stop(self):
124124
if self.server.server is None:

contentctl/actions/release_notes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def create_notes(
155155

156156
except yaml.YAMLError as exc:
157157
raise Exception(
158-
f"Error parsing YAML file for release_notes {file_path}: {str(exc)}"
158+
f"Error parsing YAML file for release_notes {file_path}: {exc!s}"
159159
)
160160
else:
161161
warnings.append(

contentctl/actions/reporting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def execute(self, input_dto: ReportingInputDto) -> None:
2424
)
2525
else:
2626
raise Exception(
27-
f"Error writing reporting : '{input_dto.config.getReportingPath()}': {str(e)}"
27+
f"Error writing reporting : '{input_dto.config.getReportingPath()}': {e!s}"
2828
)
2929

3030
print("Creating GitHub Badges...")

contentctl/actions/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,5 @@ def execute(self, input_dto: TestInputDto) -> bool:
150150
return summary.get("success", False)
151151

152152
except Exception as e:
153-
print(f"Error determining if whole test was successful: {str(e)}")
153+
print(f"Error determining if whole test was successful: {e!s}")
154154
return False

0 commit comments

Comments
 (0)