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

Rework the safety related API code #189

Closed
wants to merge 1 commit into from
Closed

Rework the safety related API code #189

wants to merge 1 commit into from

Commits on Jun 28, 2018

  1. Rework the safety related API code

    The main change is that 'Danger' has been renamed to 'Python' and that
    the default `dump()` and `dump_all()` functions use the 'Python' schema
    to be able to dump any Python data structure.
    
    NOTE: In YAML, 'Schema' is used to mean all the semantics and rules of
    what a YAML document means and how it is processed.
    
    The `load()` and `load_all()` functions continue to use the Safe schema.
    
    The dump() and load() sugar functions should be similar in that they
    both do the must useful and safe operations.
    
    There are top level functions for each schema (Safe and Python) and
    those functions should be used when feeding data from one system to the
    other and expecting the same semantics (schema):
    
    * safe_dump safe_dump_all
    * safe_load safe_load_all
    * python_dump python_dump_all
    * python_load python_load_all
    
    When we have a schema language for YAML, the generic methods with be:
    
    * yaml.dump(node, Schema='foo.schema')
    * yaml.load(yaml, Schema='foo.schema')
    
    A loader class like SafeLoader is a loader with a hardcoded schema.
    Right now pyyaml has 2 schemas:
    
    * Python - serialize any python data
    * Safe - only serialize in a way that won't trigger code
    
    'Danger' was used in response to a situation where people were caught
    unaware that something bad could happen in a seemingly normal, default
    situation. Now we've fixed the default to be safe, and Safe is an OK
    name for a schema, but Danger really is not. It's not the purpose of the
    schema to be dangerous. The purpose is to serialize Python data
    structures.
    
    The danger_ API functions can be removed because they have only been
    released for a couple days and they aren't documented anywhere.
    
    ----
    
    This also fixes a bug in that safe_load() and load() were aliases. They
    shouldn't be, because load() accepts a Loader kwarg, and safe_load()
    should not. ie safe_load(yaml, Loader=PythonLoader) shouldn't be
    allowed.
    ingydotnet committed Jun 28, 2018
    Configuration menu
    Copy the full SHA
    3dc3f5f View commit details
    Browse the repository at this point in the history