Skip to content

Commit

Permalink
Use safe YAML loading everywhere.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kfindeisen committed Jun 7, 2019
1 parent 239d49c commit 8eba3b1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion python/lsst/verify/yamlutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
# Solution from http://stackoverflow.com/a/21912744

class OrderedLoader(Loader):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def setUp(self):
yaml_path = os.path.join(os.path.dirname(__file__),
'data', 'metrics', 'testing.yaml')
with open(yaml_path) as f:
self.metric_doc = yaml.load(f)
self.metric_doc = yaml.safe_load(f)

def test_load_all_yaml_metrics(self):
"""Verify that all metrics from testing.yaml can be loaded."""
Expand Down

0 comments on commit 8eba3b1

Please sign in to comment.