NVIDIA / ngc-container-replicator

NGC Container Replicator
BSD 3-Clause "New" or "Revised" License
28 stars 12 forks source link

Explicitly use UnsafeLoader to load config/state #29

Closed ajdecon closed 3 years ago

ajdecon commented 3 years ago

PR #22 merged an upgrade to PyYAML which broke our existing use of yaml.load for configuration and state files.

Unfortunately, we can't use safe_load here because we make use of defaultdict datastructures that don't work with this method:

yaml.constructor.ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:python/object/apply:collections.defaultdict'

So this PR explicitly uses the UnsafeLoader to load the config and state files.

This should be fine, as we're not accepting any arbitrary data from untrusted users for this configuration. Anyone who is using this tool has Docker access, so should be assumed to be an administrator anyway.