-
Notifications
You must be signed in to change notification settings - Fork 0
Hardening suggestions for jtd-codebuild / revert-3-pixeebot/drip-2024-02-17-pixee-python/subprocess-shell-false #6
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,10 +67,8 @@ def generate( | |
target_language = target["language"] | ||
target_path = self.get_target_path(target) | ||
safe_mkdir(target_path) | ||
process = subprocess.Popen( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replaces subprocess.{func} with more secure safe_command library functions. |
||
self._codegen_command(self.schema_path, target_path, target_language), | ||
shell=True, | ||
stdout=subprocess.PIPE, | ||
process = safe_command.run(subprocess.Popen, self._codegen_command(self.schema_path, target_path, target_language), | ||
shell=False, stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) | ||
return [process] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,10 +20,8 @@ def _compile_typescript(self, tsconfig_path: str) -> subprocess.Popen: | |
Args: | ||
tsconfig_path: The path to the tsconfig.json file. | ||
""" | ||
return subprocess.run( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replaces subprocess.{func} with more secure safe_command library functions. |
||
f"tsc --project {tsconfig_path}", | ||
shell=True, | ||
stdout=subprocess.PIPE, | ||
return safe_command.run(subprocess.run, f"tsc --project {tsconfig_path}", | ||
shell=False, stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,7 @@ def test_example_project_1(): | |
# Run the command | ||
subprocess.check_call( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set |
||
"jtd-codebuild fixtures/example_project_1", | ||
shell=True, | ||
cwd=cwd, | ||
shell=False, cwd=cwd, | ||
) | ||
|
||
# Check the output | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,7 @@ def test_example_project_2(): | |
# Run the command | ||
subprocess.check_call( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set |
||
"jtd-codebuild fixtures/example_project_2", | ||
shell=True, | ||
cwd=cwd, | ||
shell=False, cwd=cwd, | ||
) | ||
|
||
# Check the output | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,7 @@ def test_example_project_3(): | |
# Run the command | ||
subprocess.check_call( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set |
||
"jtd-codebuild fixtures/example_project_3", | ||
shell=True, | ||
cwd=cwd, | ||
shell=False, cwd=cwd, | ||
) | ||
|
||
# Check the output | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,7 @@ def test_example_project_4(): | |
# Run the command | ||
subprocess.check_call( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set |
||
"jtd-codebuild fixtures/example_project_4", | ||
shell=True, | ||
cwd=cwd, | ||
shell=False, cwd=cwd, | ||
) | ||
|
||
# Check the output | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set
shell
keyword argument toFalse