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

PyYAML 5.4/5.4.1 breaks YAML loader #4569

Closed
jamesjer opened this issue Jan 25, 2021 · 2 comments
Closed

PyYAML 5.4/5.4.1 breaks YAML loader #4569

jamesjer opened this issue Jan 25, 2021 · 2 comments

Comments

@jamesjer
Copy link

Current Behavior

The latest attempt to build networxk 2.5 for Fedora failed to pass the test suite:

=================================== FAILURES ===================================
___________________________ TestYaml.testUndirected ____________________________

self = <networkx.readwrite.tests.test_yaml.TestYaml object at 0x7f57aad7f550>

    def testUndirected(self):
>       self.assert_equal(self.G, data=False)

networkx/readwrite/tests/test_yaml.py:44: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
networkx/readwrite/tests/test_yaml.py:35: in assert_equal
    Gin = nx.read_yaml(fname)
<decorator-gen-682>:2: in read_yaml
    ???
networkx/utils/decorators.py:239: in _open_file
    result = func_to_be_decorated(*new_args, **kwargs)
networkx/readwrite/nx_yaml.py:91: in read_yaml
    G = yaml.load(path, Loader=yaml.FullLoader)
/usr/lib64/python3.10/site-packages/yaml/__init__.py:114: in load
    return loader.get_single_data()
/usr/lib64/python3.10/site-packages/yaml/constructor.py:51: in get_single_data
    return self.construct_document(node)
/usr/lib64/python3.10/site-packages/yaml/constructor.py:55: in construct_document
    data = self.construct_object(node)
/usr/lib64/python3.10/site-packages/yaml/constructor.py:100: in construct_object
    data = constructor(self, node)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <yaml.loader.FullLoader object at 0x7f57aad7fd00>
node = MappingNode(tag='tag:yaml.org,2002:python/object:networkx.classes.graph.Graph', value=[(ScalarNode(tag='tag:yaml.org,2...=[])), (ScalarNode(tag='tag:yaml.org,2002:str', value='g'), MappingNode(tag='tag:yaml.org,2002:map', value=[]))]))]))])

    def construct_undefined(self, node):
>       raise ConstructorError(None, None,
                "could not determine a constructor for the tag %r" % node.tag,
                node.start_mark)
E       yaml.constructor.ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:python/object:networkx.classes.graph.Graph'
E         in "/tmp/tmpkqn21u1g", line 1, column 1

/usr/lib64/python3.10/site-packages/yaml/constructor.py:427: ConstructorError

Identical failures happened for testDirected and testMultiGraph. This is due to the fix for CVE-2020-14343 that was included in the PyYAML 5.4 release. See yaml/pyyaml#420.

Expected Behavior

The test suite should pass.

Steps to Reproduce

Run the test suite with PyYAML 5.4 or 5.4.1 installed.

Environment

Python version: 3.10a4 (but the same issue occurs with 3.9)
NetworkX version: 2.5

Additional context

https://access.redhat.com/security/cve/cve-2020-14343

@MridulS
Copy link
Member

MridulS commented Jan 26, 2021

Can you test the build with the latest master branch too? a6dd458 should have fixed it.

@jamesjer
Copy link
Author

Indeed, building from master works. Thank you for the quick response. I will patch the Fedora package with a6dd458 for now until the next NetworkX release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants