Skip to content

Commit e4baae6

Browse files
authored
Fix yaml warnings in python scripts and tests (elastic#20606)
1 parent d496d5e commit e4baae6

File tree

7 files changed

+9
-6
lines changed

7 files changed

+9
-6
lines changed

auditbeat/scripts/docs_collector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def collect(base_paths):
5656

5757
# Load title from fields.yml
5858
with open(beat_path + "/fields.yml") as f:
59-
fields = yaml.load(f.read())
59+
fields = yaml.load(f.read(), Loader=yaml.FullLoader)
6060
title = fields[0]["title"]
6161

6262
modules_list[module] = title

filebeat/scripts/docs_collector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def collect(beat_name):
4545

4646
# Load title from fields.yml
4747
with open(beat_path + "/fields.yml", encoding='utf_8') as f:
48-
fields = yaml.load(f.read())
48+
fields = yaml.load(f.read(), Loader=yaml.FullLoader)
4949
title = fields[0]["title"]
5050

5151
modules_list[module] = title

libbeat/scripts/generate_fields_docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def fields_to_asciidoc(input, output, beat):
106106
107107
""".format(**dict))
108108

109-
docs = yaml.load(input)
109+
docs = yaml.load(input, Loader=yaml.FullLoader)
110110

111111
# fields file is empty
112112
if docs is None:

libbeat/tests/system/beat/common_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,5 @@ def test_export_config(self):
7676
Test that the config can be exported with `export config`
7777
"""
7878
output = self.run_export_cmd("config")
79-
yml = yaml.load(output)
79+
yml = yaml.load(output, Loader=yaml.FullLoader)
8080
assert isinstance(yml, dict)

pytest.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ markers =
88

99
# Ignore setup and teardown for the timeout
1010
timeout_func_only = True
11+
12+
filterwarnings =
13+
error::yaml.YAMLLoadWarning

script/config_collector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def collect(beat_name, beat_path, full=False):
4545

4646
# Load title from fields.yml
4747
with open(beat_path + "/fields.yml") as f:
48-
fields = yaml.load(f.read())
48+
fields = yaml.load(f.read(), Loader=yaml.FullLoader)
4949
title = fields[0]["title"]
5050

5151
# Check if short config was disabled in fields.yml

winlogbeat/tests/system/winlogbeat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def read_events(self, config=None, expected_events=1):
111111

112112
def read_registry(self, requireBookmark=False):
113113
f = open(os.path.join(self.working_dir, "data", ".winlogbeat.yml"), "r")
114-
data = yaml.load(f)
114+
data = yaml.load(f, Loader=yaml.FullLoader)
115115
self.assertIn("update_time", data)
116116
self.assertIn("event_logs", data)
117117

0 commit comments

Comments
 (0)