Skip to content

Commit

Permalink
[requirements] bump pyyaml to 5.3.1 (#3892)
Browse files Browse the repository at this point in the history
* [requirements] bump pyyaml to 5.3.1

* Revert "[pyyaml] allow patching of unsafe pyyaml operations (#3808)"

This reverts commit f2c90aa.
  • Loading branch information
truthbk authored Jul 29, 2020
1 parent e6b7566 commit b4d15df
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 220 deletions.
6 changes: 2 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ Style/Documentation:
Style/SingleLineBlockParams:
Enabled: false

Style/FrozenStringLiteralComment:
Enabled: false

Lint/RescueWithoutErrorClass:
Enabled: false

BlockLength:
Max: 110

Layout/EndOfLine:
Style/EndOfLine:
Enabled: false

5 changes: 0 additions & 5 deletions agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
from utils.service_discovery.sd_backend import get_sd_backend
from utils.watchdog import Watchdog
from utils.windows_configuration import get_sdk_integration_paths
from utils.ddyaml import monkey_patch_pyyaml

# Constants
PID_NAME = "dd-agent"
Expand Down Expand Up @@ -503,10 +502,6 @@ def main():
hostname = get_hostname(agentConfig)
in_developer_mode = agentConfig.get('developer_mode')

# do this early on
if agentConfig.get('disable_unsafe_yaml'):
monkey_patch_pyyaml()

COMMANDS_AGENT = [
'start',
'stop',
Expand Down
3 changes: 1 addition & 2 deletions checks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@
# project
from checks import check_status
from config import AGENT_VERSION, _is_affirmative
from util import get_next_id
from util import get_next_id, yLoader
from utils.hostname import get_hostname
from utils.proxy import get_proxy
from utils.profile import pretty_statistics
from utils.proxy import get_no_proxy_from_env, config_proxy_skip
from utils.ddyaml import yLoader


log = logging.getLogger(__name__)
Expand Down
4 changes: 0 additions & 4 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,6 @@ def get_config(parse_args=True, cfg_path=None, options=None, can_query_registry=
if config.has_option("Main", "skip_ssl_validation"):
agentConfig["skip_ssl_validation"] = _is_affirmative(config.get("Main", "skip_ssl_validation"))

agentConfig["disable_unsafe_yaml"] = True
if config.has_option("Main", "disable_unsafe_yaml"):
agentConfig["disable_unsafe_yaml"] = _is_affirmative(config.get("Main", "disable_unsafe_yaml"))

agentConfig["collect_instance_metadata"] = True
if config.has_option("Main", "collect_instance_metadata"):
agentConfig["collect_instance_metadata"] = _is_affirmative(config.get("Main", "collect_instance_metadata"))
Expand Down
6 changes: 1 addition & 5 deletions jmxfetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
_is_affirmative,
)
from daemon import ProcessRunner
from util import yLoader
from utils.jmx import JMX_FETCH_JAR_NAME, JMXFiles
from utils.platform import Platform
from utils.ddyaml import monkey_patch_pyyaml, yLoader

log = logging.getLogger('jmxfetch')

Expand Down Expand Up @@ -507,10 +507,6 @@ def main(config_path=None):
""" JMXFetch main entry point """
confd_path, agent_config = init(config_path)

# do this early on
if agent_config.get('disable_unsafe_yaml'):
monkey_patch_pyyaml()

jmx = JMXFetch(confd_path, agent_config)
return jmx.run()

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ python-consul==0.4.7
# utils/service_discovery/config_stores.py
python-etcd==0.4.5
# the libyaml bindings are optional
pyyaml==3.11
pyyaml==5.3.1
# note: requests is also used in many checks
# upgrade with caution
requests==2.20.1
Expand Down
94 changes: 0 additions & 94 deletions tests/core/test_utils_yaml.py

This file was deleted.

9 changes: 7 additions & 2 deletions util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@

# 3p
import yaml # noqa, let's guess, probably imported somewhere
try:
from yaml import CSafeLoader as yLoader
from yaml import CSafeDumper as yDumper
except ImportError:
# On source install C Extensions might have not been built
from yaml import SafeLoader as yLoader # noqa, imported from here elsewhere
from yaml import SafeDumper as yDumper # noqa, imported from here elsewhere

# These classes are now in utils/, they are just here for compatibility reasons,
# if a user actually uses them in a custom check
Expand All @@ -19,7 +26,6 @@
from utils.platform import Platform, get_os # noqa, see ^^^
from utils.proxy import get_proxy # noqa, see ^^^
from utils.timer import Timer # noqa, see ^^^
from utils.ddyaml import yLoader

COLON_NON_WIN_PATH = re.compile(':(?!\\\\)')

Expand Down Expand Up @@ -98,7 +104,6 @@ def get_next_id(name):
class NoInstancesFound(Exception):
pass


def check_yaml(conf_path):
with open(conf_path) as f:
check_config = yaml.load(f.read(), Loader=yLoader)
Expand Down
101 changes: 0 additions & 101 deletions utils/ddyaml.py

This file was deleted.

2 changes: 1 addition & 1 deletion utils/jmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

# datadog
from config import _windows_commondata_path, get_confd_path, JMX_VERSION
from util import yDumper
from utils.pidfile import PidFile
from utils.platform import Platform
from utils.ddyaml import yDumper

# JMXFetch java version
JMX_FETCH_JAR_NAME = "jmxfetch-{ver}-jar-with-dependencies.jar".format(ver=JMX_VERSION)
Expand Down
2 changes: 1 addition & 1 deletion win32/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@
get_logging_config,
get_version
)
from util import yLoader
from utils.flare import Flare
from utils.platform import Platform
from utils.ddyaml import yLoader

# Constants describing the agent state
AGENT_RUNNING = 0
Expand Down

0 comments on commit b4d15df

Please sign in to comment.