From f708ea88f4127a916240b83372754e805bfd65a2 Mon Sep 17 00:00:00 2001 From: "pixeebot[bot]" <104101892+pixeebot[bot]@users.noreply.github.com> Date: Sat, 2 Mar 2024 00:57:31 +0000 Subject: [PATCH 1/2] Use `shell=False` in `subprocess` Function Calls --- jtd_codebuild/generators/generator.py | 3 +-- jtd_codebuild/generators/typescript_generator.py | 3 +-- jtd_codebuild/tests/test_example_project_1.py | 3 +-- jtd_codebuild/tests/test_example_project_2.py | 3 +-- jtd_codebuild/tests/test_example_project_3.py | 3 +-- jtd_codebuild/tests/test_example_project_4.py | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/jtd_codebuild/generators/generator.py b/jtd_codebuild/generators/generator.py index e14d902..32577a5 100644 --- a/jtd_codebuild/generators/generator.py +++ b/jtd_codebuild/generators/generator.py @@ -68,8 +68,7 @@ def generate( safe_mkdir(target_path) process = subprocess.Popen( self._codegen_command(self.schema_path, target_path, target_language), - shell=True, - stdout=subprocess.PIPE, + shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) return [process] diff --git a/jtd_codebuild/generators/typescript_generator.py b/jtd_codebuild/generators/typescript_generator.py index 1777441..4535244 100644 --- a/jtd_codebuild/generators/typescript_generator.py +++ b/jtd_codebuild/generators/typescript_generator.py @@ -21,8 +21,7 @@ def _compile_typescript(self, tsconfig_path: str) -> subprocess.Popen: """ return subprocess.run( f"tsc --project {tsconfig_path}", - shell=True, - stdout=subprocess.PIPE, + shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) diff --git a/jtd_codebuild/tests/test_example_project_1.py b/jtd_codebuild/tests/test_example_project_1.py index 02d9d83..2732f91 100644 --- a/jtd_codebuild/tests/test_example_project_1.py +++ b/jtd_codebuild/tests/test_example_project_1.py @@ -14,8 +14,7 @@ def test_example_project_1(): # Run the command subprocess.check_call( "jtd-codebuild fixtures/example_project_1", - shell=True, - cwd=cwd, + shell=False, cwd=cwd, ) # Check the output diff --git a/jtd_codebuild/tests/test_example_project_2.py b/jtd_codebuild/tests/test_example_project_2.py index 9c0762b..0d800ce 100644 --- a/jtd_codebuild/tests/test_example_project_2.py +++ b/jtd_codebuild/tests/test_example_project_2.py @@ -13,8 +13,7 @@ def test_example_project_2(): # Run the command subprocess.check_call( "jtd-codebuild fixtures/example_project_2", - shell=True, - cwd=cwd, + shell=False, cwd=cwd, ) # Check the output diff --git a/jtd_codebuild/tests/test_example_project_3.py b/jtd_codebuild/tests/test_example_project_3.py index a594b4e..a37ff96 100644 --- a/jtd_codebuild/tests/test_example_project_3.py +++ b/jtd_codebuild/tests/test_example_project_3.py @@ -13,8 +13,7 @@ def test_example_project_3(): # Run the command subprocess.check_call( "jtd-codebuild fixtures/example_project_3", - shell=True, - cwd=cwd, + shell=False, cwd=cwd, ) # Check the output diff --git a/jtd_codebuild/tests/test_example_project_4.py b/jtd_codebuild/tests/test_example_project_4.py index 7f9395e..85ad363 100644 --- a/jtd_codebuild/tests/test_example_project_4.py +++ b/jtd_codebuild/tests/test_example_project_4.py @@ -13,8 +13,7 @@ def test_example_project_4(): # Run the command subprocess.check_call( "jtd-codebuild fixtures/example_project_4", - shell=True, - cwd=cwd, + shell=False, cwd=cwd, ) # Check the output From 749238d702e723f118a4148796d77303915fcd00 Mon Sep 17 00:00:00 2001 From: "pixeebot[bot]" <104101892+pixeebot[bot]@users.noreply.github.com> Date: Sat, 2 Mar 2024 00:57:32 +0000 Subject: [PATCH 2/2] Sandbox Process Creation --- jtd_codebuild/generators/generator.py | 4 ++-- jtd_codebuild/generators/typescript_generator.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/jtd_codebuild/generators/generator.py b/jtd_codebuild/generators/generator.py index 32577a5..9150b5c 100644 --- a/jtd_codebuild/generators/generator.py +++ b/jtd_codebuild/generators/generator.py @@ -2,6 +2,7 @@ import subprocess from typing import Dict, Any, AnyStr, List from ..utils import safe_mkdir +from security import safe_command class JTDCodeGenerator: @@ -66,8 +67,7 @@ def generate( target_language = target["language"] target_path = self.get_target_path(target) safe_mkdir(target_path) - process = subprocess.Popen( - self._codegen_command(self.schema_path, target_path, target_language), + process = safe_command.run(subprocess.Popen, self._codegen_command(self.schema_path, target_path, target_language), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) diff --git a/jtd_codebuild/generators/typescript_generator.py b/jtd_codebuild/generators/typescript_generator.py index 4535244..c7a68c2 100644 --- a/jtd_codebuild/generators/typescript_generator.py +++ b/jtd_codebuild/generators/typescript_generator.py @@ -3,6 +3,7 @@ from typing import Dict, Any, AnyStr, List from ..utils import wait_for_processes from .generator import JTDCodeGenerator +from security import safe_command class JTDCodeGeneratorTypescriptTarget(JTDCodeGenerator): @@ -19,8 +20,7 @@ def _compile_typescript(self, tsconfig_path: str) -> subprocess.Popen: Args: tsconfig_path: The path to the tsconfig.json file. """ - return subprocess.run( - f"tsc --project {tsconfig_path}", + return safe_command.run(subprocess.run, f"tsc --project {tsconfig_path}", shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, )
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: