-
Notifications
You must be signed in to change notification settings - Fork 991
fix(diagrams): adds ast parsing to block import
and from import
#1528
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances security for AI-generated diagram code by implementing AST-based validation to block import statements and adding checks for potentially harmful built-in functions. The changes enforce stricter Python version requirements (≥3.12) and update dependencies to address security vulnerabilities.
Key changes:
- Implements AST parsing to detect and block both
import
andfrom ... import
statements in generated code - Adds
spawn
to the list of dangerous functions that are explicitly blocked - Updates minimum Python version from 3.10 to 3.12 and refreshes all dependencies to latest secure versions
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
pyproject.toml | Updates Python version requirement to ≥3.12, upgrades all dependencies to latest versions, and reformats configuration sections |
scanner.py | Adds AST-based import statement detection in validate_syntax() and adds spawn to dangerous functions blocklist |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
src/aws-diagram-mcp-server/awslabs/aws_diagram_mcp_server/scanner.py
Outdated
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1528 +/- ##
=======================================
Coverage 89.44% 89.44%
=======================================
Files 724 724
Lines 50959 50966 +7
Branches 8144 8147 +3
=======================================
+ Hits 45581 45588 +7
Misses 3467 3467
Partials 1911 1911 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ner.py Co-authored-by: Scott Schreckengaust <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Instructed to wait for app-sec engineer
Fixes
Summary
Expands blocklist for potentially harmful code execution
Changes
User experience
No change
Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change? (Y/N)
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.