Skip to content
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

Hardening suggestions for codemodder-python / unit-tests-tmpdir #429

Closed
wants to merge 2 commits into from

Conversation

pixeebot[bot]
Copy link
Contributor

@pixeebot pixeebot bot commented Apr 2, 2024

I've reviewed the recently opened PR (428 - use tmpdir instead of tests/samples in unit tests) and have identified some area(s) that could benefit from additional hardening measures.

These changes should help prevent potential security vulnerabilities and improve overall code quality.

Thank you for your consideration!

docs | feedback
Powered by: pixeebot

@pixeebot pixeebot bot requested a review from drdavella as a code owner April 2, 2024 12:47
@pixeebot pixeebot bot requested a review from clavedeluna April 2, 2024 12:47
@@ -3,16 +3,16 @@
from core_codemods.remove_assertion_in_pytest_raises import (
RemoveAssertionInPytestRaises,
)
from security import safe_command


class TestProgramFails:
def test_no_project_dir_provided(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaces subprocess.{func} with more secure safe_command library functions.



class TestProgramFails:
def test_no_project_dir_provided(self):
completed_process = subprocess.run(["codemodder"], check=False)
completed_process = safe_command.run(subprocess.run, ["codemodder"], check=False)
assert completed_process.returncode == 3

def test_codemods_include_exclude_conflict(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaces subprocess.{func} with more secure safe_command library functions.

@@ -29,8 +29,7 @@ def test_codemods_include_exclude_conflict(self):
def test_load_sast_only_by_flag(self, tmp_path):
tmp_file_path = tmp_path / "sonar.json"
tmp_file_path.touch()
completed_process = subprocess.run(
[
completed_process = safe_command.run(subprocess.run, [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaces subprocess.{func} with more secure safe_command library functions.

@@ -24,6 +24,7 @@ dependencies = [
"tomlkit~=0.12.0",
"wrapt~=1.16.0",
"chardet~=5.2.0",
"security==1.2.1",
Copy link
Contributor 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: MITOpen SourceMore facts

Copy link

sonarqubecloud bot commented Apr 2, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant