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

Build: use safe_open for security reasons #10165

Merged
merged 2 commits into from
Mar 20, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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