certtools / intelmq

IntelMQ is a solution for IT security teams for collecting and processing security feeds using a message queuing protocol.

Home Page:https://docs.intelmq.org/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

intelmq_gen_feeds_conf: yaml.load deprecated

barbich opened this issue · comments

Hi

Environment

running: Latest (as of March2024) docker compose of intelmq.

Description

Call to intelmq_gen_feeds_conf fails due to deprecation of "Use of PyYAML's yaml.load function without specifying the Loader=... parameter, has been deprecated. In PyYAML version 5.1+, you will get a warning, but the function will still work."
See https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation

For example:

root@fe8423630f14:/opt/intelmq/contrib/feeds-config-generator# python3 intelmq_gen_feeds_conf --feeds-file /opt/intelmq/etc/feeds.yaml
Traceback (most recent call last):
  File "/opt/intelmq/contrib/feeds-config-generator/intelmq_gen_feeds_conf", line 124, in <module>
    feeds_config = yaml.load(fp.read())
TypeError: load() missing 1 required positional argument: 'Loader'
root@fe8423630f14:/opt/intelmq/contrib/feeds-config-generator#

Fix

replace yaml.load(fp.read()) by:

  • option 1: call yaml.safe_load instead of yaml.load
  • option 2: call yaml.load(fp.read(), Loader=yaml.Loader)

Hi, thanks for catching that. The safe_load is the right solution here, would you like to create a PR to change it?

option 3: use ruaml.yaml as has been done in the rest of the codebase

would it not be better for consistency reasons ?

I missed it, but yeah, it would be better :)