-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Command line code sanitation #1627
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ode_executor.py and renamed test for code_utils.py
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1627 +/- ##
===========================================
+ Coverage 39.12% 51.06% +11.94%
===========================================
Files 57 57
Lines 6073 6082 +9
Branches 1360 1482 +122
===========================================
+ Hits 2376 3106 +730
+ Misses 3502 2726 -776
- Partials 195 250 +55
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
sonichi
approved these changes
Feb 18, 2024
whiskyboy
pushed a commit
to whiskyboy/autogen
that referenced
this pull request
Apr 17, 2024
* UPDATE - add commandline sanitation class, update local_commandline_code_executor.py and renamed test for code_utils.py * FIX - precommit run * UPDATE - moved sanitation function to LocalCommandlineCodeExecutor, moved testo to test_commandline_code_executor.py * UPDATE - added docstring notice to sanitize_code * Update autogen/coding/local_commandline_code_executor.py Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> * FIX - regular expression * FIX - function invocation in tests * UPDATE - pre-commit run * FIX - pre-commit run -_- --------- Co-authored-by: Ward <award40@LAMU0CLP74YXVX6.uhc.com> Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This update is a security enhancement for
LocalCommandlineCodeExecutor
to mitigate the risk of executing potentially harmful commands that could lead to unintended consequences such as data loss or system compromise. This utility aims to enhance security by preventing commands likerm -rf /
, direct writes to/dev/sda
, and execution of fork bombs (to name a few). Context of a discussion in PR: #1405 (review).Updates and Changes
CommandSanitizer
utility class tocode_utils.py
, designed to inspect code blocks for patterns associated with dangerous commands before execution.LocalCommandlineCodeExecutor
to include the use ofCommandSanitizer
CommandSanitizer
to validate the effectiveness of the sanitation process.test/test_code.py
totest/test_code_utils.py
Why are these changes needed?
Related issue number
#1405 (review)
Checks