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

Default to safe=True? #21

Closed
ypid opened this issue Feb 22, 2017 · 10 comments
Closed

Default to safe=True? #21

ypid opened this issue Feb 22, 2017 · 10 comments

Comments

@ypid
Copy link

ypid commented Feb 22, 2017

Currently, pyaml.dump defaults to safe=False. Maybe it could be changed to safe=True by default (security by default)?

Would there be any noticeable difference from that and do you think safe=True would limit normal use cases?

If you disagree with changing the default, maybe the docs can be updated to use the safe=True where possible?

See also: Make load safe_load

Thanks for your nice library!

@mk-fg
Copy link
Owner

mk-fg commented Feb 22, 2017

Hi, thanks for comment, but are you sure safe=True is about security?

@mk-fg
Copy link
Owner

mk-fg commented Feb 22, 2017

Iirc it makes pyyaml output as simple types as possible, so that even dumbest stripped-down parsers can read it, i.e. "safe" in a "most compatible" sense.

@mk-fg
Copy link
Owner

mk-fg commented Feb 22, 2017

Which, iirc also makes resulting YAML as ugly as possible, which clearly contradicts the goal of the module.

@mk-fg
Copy link
Owner

mk-fg commented Feb 22, 2017

Also, totally agree on load vs safe_load, always use the latter myself, but don't think it's related, though will need to check it, not 100% sure.

@ypid
Copy link
Author

ypid commented Feb 22, 2017

Hi, thanks for comment, but are you sure safe=True is about security?

I don’t really think so. The issues with unsafe load are much more severe.

@mk-fg
Copy link
Owner

mk-fg commented Feb 22, 2017

I don’t really think so. The issues with unsafe load are much more severe.

But this module doesn't do loading at all! ;)

@ypid
Copy link
Author

ypid commented Feb 22, 2017

But this module doesn't do loading at all! ;)

Seen that :) I also noticed that you use safe_dump in your examples. Nicely done 👍

@mk-fg
Copy link
Owner

mk-fg commented Feb 22, 2017

Just noticed that safe= is actually a flag in pyaml, and I think it's and unfortunately named option, which I've copied from PyYAML's similarly-named safe_dump thing, which does similar "most compatible" output.

pyaml, similarly, uses UnsafePrettyYAMLDumper, which dabbles with scalar and sequence styles, and can occasionally produce broken output, hence the option to avoid it.

Don't think renaming it now is a good idea though, and it's at least somewhat consistent that way, if nothing else, so guess I'll just leave it be.

@mk-fg mk-fg closed this as completed Feb 22, 2017
@mk-fg
Copy link
Owner

mk-fg commented Feb 22, 2017

Also, PrettyYAMLDumper and co always based on yaml.dumper.SafeDumper, and I dare you to look at the things with exclamation marks non-safe pyyaml dumper produces, it's just ridiculous.

@ypid
Copy link
Author

ypid commented Feb 22, 2017

Sounds reasonable. Thanks for explaining.

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

No branches or pull requests

2 participants