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

upgrade pyyaml as per CVE-2017-18342 #917

Merged
merged 1 commit into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/jnpr/junos/factory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ def loadyaml(path):
# if no extension is given, default to '.yml'
if os.path.splitext(path)[1] == '':
path += '.yml'
return FactoryLoader().load(yaml.load(open(path, 'r')))
return FactoryLoader().load(yaml.load(open(path, 'r'), Loader=yaml.FullLoader))
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ncclient>=0.5.4
paramiko>=1.15.2
scp>=0.7.0
jinja2>=2.7.1
PyYAML<=3.13
PyYAML>=5.1
netaddr
six
pyserial
30 changes: 15 additions & 15 deletions tests/unit/factory/test_cfgtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
args_key: name
options: {}
"""
globals().update(FactoryLoader().load(yaml.load(yaml_data)))
globals().update(FactoryLoader().load(yaml.load(yaml_data, Loader=yaml.FullLoader)))

yaml_bgp_data = \
"""---
Expand All @@ -79,7 +79,7 @@
neigh : name
"""

globals().update(FactoryLoader().load(yaml.load(yaml_bgp_data)))
globals().update(FactoryLoader().load(yaml.load(yaml_bgp_data, Loader=yaml.FullLoader)))


@attr('unit')
Expand Down Expand Up @@ -231,7 +231,7 @@ def test_cfgtable_set_inactive(self, mock_execute):
fields_auth:
password: user/encrypted-password
"""
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data)))
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data, Loader=yaml.FullLoader)))
at = UserConfigTable1(self.dev)
at.rpc.lock_configuration = MagicMock()
at.username = 'user1'
Expand Down Expand Up @@ -264,7 +264,7 @@ def test_cfgtable_set_bool(self, mock_execute):
fields_auth:
password: user/encrypted-password
"""
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data)))
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data, Loader=yaml.FullLoader)))
at = UserConfigTable1(self.dev)
at.rpc.lock_configuration = MagicMock()
at.username = True
Expand Down Expand Up @@ -377,7 +377,7 @@ def test_cfgtable_str_key_field(self, mock_execute):
fields:
as_num: as-number
"""
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data)))
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data, Loader=yaml.FullLoader)))
at = AutoSysTable(self.dev)
at.rpc.lock_configuration = MagicMock()
at.as_num = 100
Expand All @@ -403,7 +403,7 @@ def test_cfgtable_field_value_xpath(self, mock_execute):
fields:
as_num: autonomous-system/as-number
"""
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data)))
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data, Loader=yaml.FullLoader)))
at = AutoSysTable(self.dev)
at.rpc.lock_configuration = MagicMock()
at.as_num = 150
Expand All @@ -429,7 +429,7 @@ def test_cfgtable_user_defined_type_error(self, mock_execute):
fields:
as_num: {'as-number': {'type': {'UserDefined': ''}}}
"""
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data)))
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data, Loader=yaml.FullLoader)))
at = AutoSysTable(self.dev)
at.rpc.lock_configuration = MagicMock()
at.as_num = 100
Expand All @@ -449,7 +449,7 @@ def test_cfgtable_wrong_type_error(self, mock_execute):
fields:
as_num: {'as-number' : { 'type' : 'int'} }
"""
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data)))
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data, Loader=yaml.FullLoader)))
at = AutoSysTable(self.dev)
at.as_num = '100'
self.assertRaises(TypeError, at.append)
Expand All @@ -468,7 +468,7 @@ def test_cfgtable_unsupported_type_error(self, mock_execute):
fields:
as_num: {'as-number' : { 'type' : 'interger'} }
"""
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data)))
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data, Loader=yaml.FullLoader)))
at = AutoSysTable(self.dev)
at.as_num = 100
self.assertRaises(TypeError, at.append)
Expand All @@ -487,7 +487,7 @@ def test_cfgtable_enum_value_str_error(self, mock_execute):
fields:
as_num: {'as-number' : {'type' : {'enum': '100'}}}
"""
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data)))
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data, Loader=yaml.FullLoader)))
at = AutoSysTable(self.dev)
at.as_num = 100
self.assertRaises(ValueError, at.append)
Expand All @@ -506,7 +506,7 @@ def test_cfgtable_enum_value_type_error(self, mock_execute):
fields:
as_num: {'as-number' : {'type' : {'enum': {'100': ''}}}}
"""
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data)))
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data, Loader=yaml.FullLoader)))
at = AutoSysTable(self.dev)
at.as_num = 100
self.assertRaises(TypeError, at.append)
Expand All @@ -525,7 +525,7 @@ def test_cfgtable_invalid_type_error(self, mock_execute):
fields:
as_num: {'as-number': {'type': ['abc']}}
"""
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data)))
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data, Loader=yaml.FullLoader)))
at = AutoSysTable(self.dev)
at.as_num = 100
self.assertRaises(TypeError, at.append)
Expand All @@ -544,7 +544,7 @@ def test_cfgtable_invalid_key_field_type_error(self, mock_execute):
fields:
as_num: as-number
"""
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data)))
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data, Loader=yaml.FullLoader)))
self.assertRaises(TypeError, AutoSysTable, self.dev)

@patch('jnpr.junos.Device.execute')
Expand All @@ -559,7 +559,7 @@ def test_cfgtable_invalid_key_field_not_defined_error(self, mock_execute):
fields:
as_num: as-number
"""
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data)))
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data, Loader=yaml.FullLoader)))
self.assertRaises(ValueError, AutoSysTable, self.dev)

@patch('jnpr.junos.Device.execute')
Expand All @@ -569,7 +569,7 @@ def test_cfgtable_invalid_view_not_defined_type_error(self, mock_execute):
AutoSysTable:
set: routing-options/autonomous-system
"""
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data)))
globals().update(FactoryLoader().load(yaml.load(yaml_auto_data, Loader=yaml.FullLoader)))
self.assertRaises(ValueError, AutoSysTable, self.dev)

@patch('jnpr.junos.Device.execute')
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/facts/test_swver.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_version_to_yaml(self):
import yaml
self.assertEqual(
yaml.dump(version_info('11.4R7.5')),
"build: 5\nmajor: !!python/tuple [11, 4]\nminor: '7'\ntype: R\n")
"build: 5\nmajor: !!python/tuple\n- 11\n- 4\nminor: '7'\ntype: R\n")

def test_version_iter(self):
self.assertItemsEqual(
Expand Down