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

DM-18906: Use safe YAML loading in verify #43

Merged
merged 1 commit into from Jun 8, 2019
Merged

Conversation

kfindeisen
Copy link
Member

This PR removes all YAMLLoadWarnings from building verify. I also manually searched for yaml.load calls that are not exercised by the unit tests, but didn't find any.

Using yaml.load with a generic loader is discouraged, as it allows
code injection attacks. All calls have been rewritten to use safe_load
or CSafeLoader.
@kfindeisen kfindeisen requested a review from timj June 8, 2019 00:42
@@ -80,7 +80,8 @@ def load_all_ordered_yaml(stream, **kwargs):
return yaml.load_all(stream, OrderedLoader)


def _build_ordered_loader(Loader=yaml.Loader, object_pairs_hook=OrderedDict):
def _build_ordered_loader(Loader=yaml.CSafeLoader,
object_pairs_hook=OrderedDict):
Copy link
Member

Choose a reason for hiding this comment

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

It's possible that this ordered dict code is no longer needed since python3.7 guarantees dicts are ordered. The main problem with yaml is that on write it forces key sort (which can be disabled with sort_keys=False)

Copy link
Member Author

Choose a reason for hiding this comment

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

Could be. I'm not sure how to check that a rewrite wouldn't have ill effects, and I agree that it's out of scope.

@kfindeisen kfindeisen merged commit 8eba3b1 into master Jun 8, 2019
@kfindeisen kfindeisen deleted the tickets/DM-18906 branch June 8, 2019 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants