Skip to content
Open
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
13 changes: 5 additions & 8 deletions integration_tests/test_dependency_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pytest

from codemodder.codemods.test.integration_utils import SAMPLES_DIR
from security import safe_command


class TestDependencyManager:
Expand Down Expand Up @@ -70,8 +71,7 @@ def test_add_to_pyproject_toml(self, tmp_repo):
"--codemod-include=url-sandbox",
"--verbose",
]
completed_process = subprocess.run(
command,
completed_process = safe_command.run(subprocess.run, command,
check=False,
shell=False,
capture_output=True,
Expand All @@ -93,8 +93,7 @@ def test_add_to_requirements_txt(self, tmp_repo):
"--codemod-include=url-sandbox",
"--verbose",
]
completed_process = subprocess.run(
command,
completed_process = safe_command.run(subprocess.run, command,
check=False,
shell=False,
capture_output=True,
Expand All @@ -118,8 +117,7 @@ def test_add_to_setup(self, tmp_repo):
"--codemod-include=url-sandbox",
"--verbose",
]
completed_process = subprocess.run(
command,
completed_process = safe_command.run(subprocess.run, command,
check=False,
shell=False,
capture_output=True,
Expand All @@ -143,8 +141,7 @@ def test_fail_to_add(self, tmp_repo):
"--codemod-include=url-sandbox",
"--verbose",
]
completed_process = subprocess.run(
command,
completed_process = safe_command.run(subprocess.run, command,
check=False,
shell=False,
capture_output=True,
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/test_multiple_codemods.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest

from codemodder.codemods.test.integration_utils import SAMPLES_DIR
from security import safe_command


class TestMultipleCodemods:
Expand All @@ -32,8 +33,7 @@ def test_two_codemods(self, codemods, tmpdir):
'--path-exclude=""',
]

completed_process = subprocess.run(
command,
completed_process = safe_command.run(subprocess.run, command,
check=False,
shell=False,
)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies = [
"tomlkit~=0.12.0",
"wrapt~=1.16.0",
"chardet~=5.2.0",
"security==1.3.1",

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This library holds security tools for protecting Python API calls.

License: MIT ✅ Open Source ✅ More facts

]
keywords = ["codemod", "codemods", "security", "fix", "fixes"]
classifiers = [
Expand Down
7 changes: 3 additions & 4 deletions src/codemodder/codemods/test/integration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from core_codemods.sonar.api import process_sonar_findings

from .validations import execute_code
from security import safe_command


class DependencyTestMixin:
Expand Down Expand Up @@ -211,8 +212,7 @@ def test_file_rewritten(self, codetf_schema):
self.write_original_code()
self.write_original_dependencies()

completed_process = subprocess.run(
command,
completed_process = safe_command.run(subprocess.run, command,
check=False,
shell=False,
)
Expand All @@ -225,8 +225,7 @@ def test_file_rewritten(self, codetf_schema):

def _run_idempotency_check(self, command):
# idempotency test, run it again and assert no files changed
completed_process = subprocess.run(
command,
completed_process = safe_command.run(subprocess.run, command,
check=False,
)
assert completed_process.returncode == 0
Expand Down
4 changes: 2 additions & 2 deletions src/codemodder/semgrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from codemodder.logging import logger
from codemodder.result import LineInfo, Location, Result, ResultSet
from codemodder.sarifs import AbstractSarifToolDetector
from security import safe_command


class SemgrepSarifToolDetector(AbstractSarifToolDetector):
Expand Down Expand Up @@ -129,8 +130,7 @@ def run(
)
command.extend(map(str, files_to_analyze or [execution_context.directory]))
logger.debug("semgrep command: `%s`", " ".join(command))
call = subprocess.run(
command,
call = safe_command.run(subprocess.run, command,
shell=False,
check=False,
stdout=None if execution_context.verbose else subprocess.PIPE,
Expand Down