Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SafeLoader to load settingsmeta yaml #2133

Merged
merged 1 commit into from May 27, 2019

Conversation

forslund
Copy link
Collaborator

Description

SafeLoader limits the amount of custom methods that can be supplied with
the yaml and supports the basic yaml features.

I'm not certain this is 100% correct but after reading @krisgesling's issue on msm and the related docs it seems like the way to go.

How to test

Ensure that settingsmeta.yaml files works.

Contributor license agreement signed?

CLA [ Yes ]

@forslund forslund added the CLA: Yes Contributor License Agreement exists (see https://github.com/MycroftAI/contributors) label May 22, 2019
Copy link
Collaborator

@ChristopherRogers1991 ChristopherRogers1991 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the docs, it looks like we're using the default loader now, which supports creating arbitrary python objects. Doesn't seem like there will be any need for that for settingsmeta, so safe loader seems like a sane choice. Only minor note is I think we should use yaml.safe_load(...) rather than passing in loader to load.

@@ -268,7 +268,7 @@ def _load_settings_meta(self):
if json_file:
data = json.load(f)
else:
data = yaml.load(f)
data = yaml.load(f, Loader=yaml.SafeLoader)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit, but I think it would be simpler to use yaml.safe_load, rather than pass in the loader.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True that, change incoming!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

safe_load limits the amount of custom methods that can be supplied with
the yaml and supports the basic yaml features.
@ChristopherRogers1991 ChristopherRogers1991 merged commit b5279e4 into MycroftAI:dev May 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA: Yes Contributor License Agreement exists (see https://github.com/MycroftAI/contributors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants