Skip to content

Commit

Permalink
Build: use safe_open for security reasons (#10165)
Browse files Browse the repository at this point in the history
* Build: use `safe_open` for security reasons

Use `safe_open` instead of global open for security reasons.

* Remove outdated comments
  • Loading branch information
humitos authored Mar 20, 2023
1 parent ed732c2 commit 5dab68d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 2 additions & 1 deletion readthedocs/doc_builder/director.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.utils.translation import gettext_lazy as _

from readthedocs.builds.constants import EXTERNAL
from readthedocs.core.utils.filesystem import safe_open
from readthedocs.doc_builder.config import load_yaml_config
from readthedocs.doc_builder.exceptions import BuildUserError
from readthedocs.doc_builder.loader import get_builder_class
Expand Down Expand Up @@ -643,7 +644,7 @@ def store_readthedocs_build_yaml(self):
return

try:
with open(yaml_path, "r") as f:
with safe_open(yaml_path, "r") as f:
data = yaml.safe_load(f)
except Exception:
# NOTE: skip this work for now until we decide whether or not this
Expand Down
3 changes: 0 additions & 3 deletions readthedocs/proxito/views/hosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,9 @@ def get(self, request):
unresolved_domain = request.unresolved_domain
project = unresolved_domain.project

# TODO: why the UnresolvedURL object is not injected in the `request` by the middleware.
# Is is fine to calculate it here?
unresolved_url = unresolver.unresolve_url(url)
version = unresolved_url.version

# TODO: use Referrer header or GET arguments for Version / Build
project.get_default_version()
build = version.builds.last()

Expand Down

0 comments on commit 5dab68d

Please sign in to comment.