Command line code sanitation#1627
Merged
sonichi merged 21 commits intomicrosoft:mainfrom Feb 18, 2024
AaronWard:aw-sanitation
Merged
Command line code sanitation#1627sonichi merged 21 commits intomicrosoft:mainfrom AaronWard:aw-sanitation
sonichi merged 21 commits intomicrosoft:mainfrom
AaronWard:aw-sanitation
Conversation
…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>
This file contains hidden or 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
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
LocalCommandlineCodeExecutorto 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
CommandSanitizerutility class tocode_utils.py, designed to inspect code blocks for patterns associated with dangerous commands before execution.LocalCommandlineCodeExecutorto include the use ofCommandSanitizerCommandSanitizerto validate the effectiveness of the sanitation process.test/test_code.pytotest/test_code_utils.pyWhy are these changes needed?
Related issue number
#1405 (review)
Checks