Skip to content

Commit e5b2f0e

Browse files
committed
fix: Fix token leaking in logs, improve logging...
1 parent d067971 commit e5b2f0e

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

surface/sca/management/commands/renovate_dependencies.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,27 @@ def run_docker(self, platform: str, temp_config_path: str, is_local: bool) -> bo
9999

100100
docker_image = settings.SCA_INTERNAL_RENOVATE if settings.SCA_INTERNAL_RENOVATE else "renovate/renovate"
101101

102+
_env = {
103+
"RENOVATE_TOKEN": token,
104+
"RENOVATE_PLATFORM": platform,
105+
"RENOVATE_ENDPOINT": endpoint,
106+
}
102107
if is_local:
103108
docker_temp_config_path = Path("/usr/src/app") / Path(temp_config_path).name
104-
command = f"docker run --rm -v {Path.cwd()}:/usr/src/app -e LOG_LEVEL=debug -e RENOVATE_TOKEN={token} -e RENOVATE_CONFIG_FILE={docker_temp_config_path} -e RENOVATE_PLATFORM={platform} -e RENOVATE_ENDPOINT={endpoint} {docker_image}"
109+
_env["RENOVATE_CONFIG_FILE"] = docker_temp_config_path
110+
_env["LOG_LEVEL"] = "debug"
111+
command = f"docker run --rm -v {Path.cwd()}:/usr/src/app -e RENOVATE_TOKEN -e RENOVATE_PLATFORM -e RENOVATE_ENDPOINT -e RENOVATE_CONFIG_FILE -e LOG_LEVEL {docker_image}"
105112
else:
106-
command = f"/usr/bin/docker run --rm -v /renovate:/renovate -e RENOVATE_TOKEN={token} -e RENOVATE_CONFIG_FILE={temp_config_path} -e RENOVATE_PLATFORM={platform} -e RENOVATE_ENDPOINT={endpoint} {docker_image}"
113+
_env["RENOVATE_CONFIG_FILE"] = temp_config_path
114+
command = f"/usr/bin/docker run --rm -v /renovate:/renovate -e RENOVATE_TOKEN -e RENOVATE_PLATFORM -e RENOVATE_ENDPOINT -e RENOVATE_CONFIG_FILE {docker_image}"
107115

108116
try:
109-
result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
117+
result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True, env=_env)
110118
if result.stdout:
111119
self.log("Docker output: %s", result.stdout)
120+
if result.stderr:
121+
self.log_error("Docker error: %s", result.stderr)
112122
except subprocess.CalledProcessError as ex:
113-
self.log_exception("Failed to execute Docker command: %s", ex.stderr)
123+
self.log_exception("Failed to execute Docker command: %s", ex.output)
114124
return False
115125
return True

0 commit comments

Comments
 (0)