Skip to content

Commit 6c8bb63

Browse files
author
Artem Rys
authored
chore: fix semgrep issues (#558)
1 parent 278bfdd commit 6c8bb63

File tree

9 files changed

+66
-56
lines changed

9 files changed

+66
-56
lines changed

poetry.lock

Lines changed: 55 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pytest-ordering = "*"
4444
lovely-pytest-docker = { version="^0", optional = true }
4545
junitparser = "^2.2.0"
4646
addonfactory-splunk-conf-parser-lib = "^0.3.3"
47+
defusedxml = "^0.7.1"
4748

4849

4950
[tool.poetry.extras]

pytest_splunk_addon/splunk.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -883,19 +883,15 @@ def is_responsive_hec(request, splunk):
883883
"Trying to connect Splunk HEC... splunk=%s",
884884
json.dumps(splunk),
885885
)
886-
session_headers = {
887-
"Authorization": f'Splunk {request.config.getoption("splunk_hec_token")}'
888-
}
889-
response = requests.get(
886+
response = requests.get( # nosemgrep: splunk.disabled-cert-validation
890887
f'{request.config.getoption("splunk_hec_scheme")}://{splunk["forwarder_host"]}:{splunk["port_hec"]}/services/collector/health/1.0',
891888
verify=False,
892889
)
893890
LOGGER.debug(f"Status code: {response.status_code}")
894891
if response.status_code in (200, 201):
895892
LOGGER.info("Splunk HEC is responsive.")
896893
return True
897-
else:
898-
return False
894+
return False
899895
except Exception as e:
900896
LOGGER.warning(
901897
"Could not connect to Splunk HEC. Will try again. exception=%s",

pytest_splunk_addon/standard_lib/event_ingestors/file_monitor_ingestor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def create_output_conf(self):
9292
)
9393
LOGGER.debug(f"Creating following stanza in output.conf : {tcp_out_dict}")
9494
try:
95-
response = requests.post(
95+
response = requests.post( # nosemgrep: splunk.disabled-cert-validation
9696
self.outputs_endpoint,
9797
tcp_out_dict,
9898
auth=(self.uf_username, self.uf_password),
@@ -164,7 +164,7 @@ def create_inputs_stanza(self, event):
164164
)
165165
LOGGER.debug(f"Creating following stanza in inputs.conf : {stanza}")
166166
try:
167-
response = requests.post(
167+
response = requests.post( # nosemgrep: splunk.disabled-cert-validation
168168
self.inputs_endpoint,
169169
stanza,
170170
auth=(self.uf_username, self.uf_password),

pytest_splunk_addon/standard_lib/event_ingestors/hec_event_ingestor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def __ingest(self, data):
127127
str(data)
128128
)
129129
)
130-
response = requests.post(
130+
response = requests.post( # nosemgrep: splunk.disabled-cert-validation
131131
"{}/{}".format(self.hec_uri, "event"),
132132
auth=None,
133133
json=data,

pytest_splunk_addon/standard_lib/event_ingestors/hec_metric_ingestor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def ingest(self, data, thread_count):
107107
str(data)
108108
)
109109
)
110-
response = requests.post(
110+
response = requests.post( # nosemgrep: splunk.disabled-cert-validation
111111
self.hec_uri,
112112
auth=None,
113113
json=data,

pytest_splunk_addon/standard_lib/event_ingestors/hec_raw_ingestor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def __ingest(self, event, params):
113113
str(event), str(params)
114114
)
115115
)
116-
response = requests.post(
116+
response = requests.post( # nosemgrep: splunk.disabled-cert-validation
117117
"{}/{}".format(self.hec_uri, "raw"),
118118
auth=None,
119119
data=event,

pytest_splunk_addon/standard_lib/event_ingestors/requirement_event_ingester.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121

2222
import logging
2323
import os
24-
from xml.etree import cElementTree as ET
24+
25+
from defusedxml import cElementTree as ET
2526

2627
from pytest_splunk_addon.standard_lib.sample_generation.sample_event import SampleEvent
2728

pytest_splunk_addon/standard_lib/requirement_tests/test_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
import logging
2020
import os
2121
import re
22-
from xml.etree import cElementTree as ET
2322

2423
import pytest
24+
from defusedxml import cElementTree as ET
2525

2626
LOGGER = logging.getLogger("pytest-splunk-addon")
2727

0 commit comments

Comments
 (0)