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

Refactor execute_code to support custom globals dictionary #53

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

leonvanbokhorst
Copy link
Owner

@leonvanbokhorst leonvanbokhorst commented Nov 15, 2024

Summary by Sourcery

Enhancements:

  • Refactor the execute_code method to allow execution with a custom globals dictionary, providing flexibility in code execution environments.

Copy link
Contributor

sourcery-ai bot commented Nov 15, 2024

Reviewer's Guide by Sourcery

This PR simplifies the code execution process by removing complex error handling and recovery mechanisms, and adds support for custom globals. The new implementation provides a more straightforward execution flow with basic safety measures through a restricted set of built-in functions.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Simplified code execution logic by removing error recovery and user permission flows
  • Removed code cleaning and recovery through CoderAgent
  • Removed static analysis and syntax error handling
  • Removed user permission request flow
  • Removed execution result storage in orchestrator
mas_learn/agents/code_executor.py
Added support for custom globals in code execution
  • Added optional globals parameter to execute_code method
  • Implemented default globals dictionary with name set to main
  • Added restricted set of safe built-in functions
  • Modified execution to use provided or default globals dictionary
mas_learn/agents/code_executor.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @leonvanbokhorst - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • The globals parameter allows injection of arbitrary builtins which is a security risk (link)

Overall Comments:

  • This change removes critical security features including static analysis, user approval, and error recovery. These safety checks should be preserved while adding support for custom globals.
  • The removal of orchestrator.store_execution_result calls eliminates important logging and error tracking functionality that should be maintained.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🔴 Security: 1 blocking issue
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@leonvanbokhorst leonvanbokhorst changed the title Refactor code_executor.py to allow execution with custom globals @sourcery-ai Nov 15, 2024
@sourcery-ai sourcery-ai bot changed the title @sourcery-ai Refactor execute_code to support custom globals dictionary Nov 15, 2024
@leonvanbokhorst leonvanbokhorst merged commit 4cfdaf8 into main Nov 15, 2024
1 check failed
@leonvanbokhorst leonvanbokhorst deleted the mas-learn branch November 15, 2024 13:56
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