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

Safety check implemented incorrectly #1444

Open
rhiever opened this issue Dec 3, 2024 · 3 comments
Open

Safety check implemented incorrectly #1444

rhiever opened this issue Dec 3, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@rhiever
Copy link

rhiever commented Dec 3, 2024

System Info

OS version: Latest MacOS
Python version: 3.9
The current version of pandasai being used: 2.4.0

🐛 Describe the bug

The current safety check seems to be checking if any of these strings are in any of the generated code: "io", "os", "subprocess", "sys", "importlib"

So it's firing off on a matplotlib plt.title command with the word "Distribution" in it, for example.

Please fix!

Copy link

dosubot bot commented Dec 3, 2024

Hey @rhiever! I'm here to help you with bug fixes, answer your questions, and guide you on becoming a contributor. Let's squash those bugs together! 🤖

The issue you're encountering is due to the safety check in the BaseRestrictedModule class, which is designed to prevent the use of potentially unsafe modules by checking for specific strings like "io", "os", "subprocess", "sys", and "importlib" in the arguments of functions [1]. This check is likely too broad, causing it to incorrectly flag safe code, such as a matplotlib plt.title command containing the word "Distribution".

To address this, you might consider refining the safety check to be more context-aware. For example, you could implement a more sophisticated parsing mechanism that distinguishes between safe and unsafe uses of these keywords, or adjust the logic to only flag these keywords when they appear in specific contexts that are more likely to indicate a security risk.

To continue talking to Dosu, mention @dosu.

@dosubot dosubot bot added the bug Something isn't working label Dec 3, 2024
@ilyasch199
Copy link

i just got the same problem :
pandasai.safe_libs.base_restricted_module.SecurityError: Potential security risk: 'Distribution of Sepal Length in cm' is not allowed

@XJTU-JP
Copy link

XJTU-JP commented Dec 12, 2024

I also met the same problem. How did you solve it? Hope to hear your suggestions @rhiever @ilyasch199

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants