Skip to content

Commit 5dab68d

Browse files
authored
Build: use safe_open for security reasons (#10165)
* Build: use `safe_open` for security reasons Use `safe_open` instead of global open for security reasons. * Remove outdated comments
1 parent ed732c2 commit 5dab68d

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

readthedocs/doc_builder/director.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from django.utils.translation import gettext_lazy as _
88

99
from readthedocs.builds.constants import EXTERNAL
10+
from readthedocs.core.utils.filesystem import safe_open
1011
from readthedocs.doc_builder.config import load_yaml_config
1112
from readthedocs.doc_builder.exceptions import BuildUserError
1213
from readthedocs.doc_builder.loader import get_builder_class
@@ -643,7 +644,7 @@ def store_readthedocs_build_yaml(self):
643644
return
644645

645646
try:
646-
with open(yaml_path, "r") as f:
647+
with safe_open(yaml_path, "r") as f:
647648
data = yaml.safe_load(f)
648649
except Exception:
649650
# NOTE: skip this work for now until we decide whether or not this

readthedocs/proxito/views/hosting.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,9 @@ def get(self, request):
2626
unresolved_domain = request.unresolved_domain
2727
project = unresolved_domain.project
2828

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

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

0 commit comments

Comments
 (0)