Skip to content
This repository was archived by the owner on Mar 13, 2022. It is now read-only.

Use yaml.safe_load and yaml.safe_dump #111

Merged
merged 2 commits into from
Jan 8, 2019
Merged

Use yaml.safe_load and yaml.safe_dump #111

merged 2 commits into from
Jan 8, 2019

Conversation

xvello
Copy link
Contributor

@xvello xvello commented Jan 8, 2019

When loading a kubeconfig file, the library uses the unsafe yaml.load method, which is vulnerable to arbitrary code execution, as described in https://nvd.nist.gov/vuln/detail/CVE-2017-18342

This PR makes sure we use the safe_load method. For consistency, I also change test to use the safe_dump method, although there is probably no risk there.

The use case for the unsafe load is to load data in arbitrary python classes, but in this case we unmarshal the file in a classic dict. safe_load has what we need for this use case.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 8, 2019
@codecov-io
Copy link

codecov-io commented Jan 8, 2019

Codecov Report

Merging #111 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #111   +/-   ##
=======================================
  Coverage   92.04%   92.04%           
=======================================
  Files          13       13           
  Lines        1182     1182           
=======================================
  Hits         1088     1088           
  Misses         94       94
Impacted Files Coverage Δ
config/kube_config.py 84.24% <ø> (ø) ⬆️
config/kube_config_test.py 94.41% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5c242ea...13ff518. Read the comment docs.

Copy link
Contributor

@micw523 micw523 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 8, 2019
@yliaog
Copy link
Contributor

yliaog commented Jan 8, 2019

/lgtm

@yliaog
Copy link
Contributor

yliaog commented Jan 8, 2019

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: xvello, yliaog

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants