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

Do not expose env variables on external versions #6440

Merged
merged 1 commit into from
Dec 5, 2019
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
5 changes: 5 additions & 0 deletions readthedocs/doc_builder/python_environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from django.conf import settings

from readthedocs.builds.constants import EXTERNAL
from readthedocs.config import PIP, SETUPTOOLS, ParseError, parse as parse_yaml
from readthedocs.config.models import PythonInstall, PythonInstallRequirements
from readthedocs.doc_builder.config import load_yaml_config
Expand Down Expand Up @@ -234,7 +235,11 @@ def _get_env_vars_hash(self):
it returns sha256 hash of empty string.
"""
m = hashlib.sha256()

env_vars = self.version.project.environment_variables
if self.version.type == EXTERNAL:
env_vars = {}

for variable, value in env_vars.items():
hash_str = f'_{variable}_{value}_'
m.update(hash_str.encode('utf-8'))
Expand Down
7 changes: 5 additions & 2 deletions readthedocs/projects/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,11 @@ def get_env_vars(self):
),
})

# Update environment from Project's specific environment variables
env.update(self.project.environment_variables)
# Update environment from Project's specific environment variables,
# avoiding to expose environment variables if the version is external
# for security reasons.
if self.version.type != EXTERNAL:
env.update(self.project.environment_variables)

return env

Expand Down