Skip to content

Commit d9c95f9

Browse files
Sandbox Process Creation (#5)
Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com>
1 parent b44051d commit d9c95f9

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ ruyaml = "0.91.0"
4747
six = "1.16.0"
4848
social-auth-app-django = "5.4.0"
4949
uwsgi = "2.0.23"
50+
security = "==1.3.0"
5051

5152
[tool.poetry.group.lint]
5253
optional = true

python/cm/services/job/run/_task.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from cm.issue import lock_affected_objects
2222
from cm.models import TaskLog
2323
from cm.utils import get_env_with_venv_path
24+
from security import safe_command
2425

2526
logger = logging.getLogger("adcm")
2627

@@ -50,7 +51,6 @@ def _run_task(task: TaskLog, command: Literal["start", "restart"]):
5051
str(task.pk),
5152
]
5253
logger.info("task run cmd: %s", " ".join(cmd))
53-
proc = subprocess.Popen( # noqa: SIM115
54-
args=cmd, stderr=err_file, env=get_env_with_venv_path(venv=task.action.venv)
54+
proc = safe_command.run(subprocess.Popen, args=cmd, stderr=err_file, env=get_env_with_venv_path(venv=task.action.venv)
5555
)
5656
logger.info("task run #%s, python process %s", task.pk, proc.pid)

python/core/job/executors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from typing_extensions import Self
2121

2222
from core.job.types import BundleInfo
23+
from security import safe_command
2324

2425

2526
class ExecutionResult(NamedTuple):
@@ -99,8 +100,7 @@ def execute(self) -> Self:
99100
self._open_logs(log_dir=self._config.work_dir, log_prefix=self.script_type)
100101

101102
os.chdir(self._config.bundle.root)
102-
self._process = subprocess.Popen(
103-
command, # noqa S603
103+
self._process = safe_command.run(subprocess.Popen, command, # noqa S603
104104
env=environment,
105105
stdout=self._out_log,
106106
stderr=self._err_log,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy