Option to open Blend file with Python disabled #17701

Closed
opened 2008-09-28 19:35:11 +02:00 by Dalai Felinto · 12 comments

%%%After some conversation with cambpell and ianwill I took the time to code this patch.

This is a method to improve the safety of Blender Files providing the use with the option to enable or not Python to the file that is loaded.

The option is in the Load File window, by the "LOAD UI" option.
The default option is ON, so there is no backward/console incompatibility.

I'm creating a new global variable G.fileflags G_FILE_NO_PYTHON and checking it to pyNodes, pyDrivers, pyConstraint, Pythons Scripts, BGE scripts, Space Handles, Script Links.

The files that still have an isolated G_DOSCRIPTLINKS are:

1)Scene.c, lines 822, 826 and 831
2)blender.c 392
(In the patch these lines have the comment: // G.fileflags & G_FILE_NO_PYTHON)

I kept the -y command line option disabling only SpaceHandler (this is the way it was). But not I'm using -Y to completely disable Python.

I don't know how to test pyConstraint properly (I never used them). If someone could test it better would great.
I'm attaching as well some demofiles I was using to test the patch.

EDIT::
console -Y is not working, console -y disable Python for almost everything.
%%%

%%%After some conversation with cambpell and ianwill I took the time to code this patch. This is a method to improve the safety of Blender Files providing the use with the option to enable or not Python to the file that is loaded. The option is in the Load File window, by the "LOAD UI" option. The default option is ON, so there is no backward/console incompatibility. I'm creating a new global variable G.fileflags G_FILE_NO_PYTHON and checking it to pyNodes, pyDrivers, pyConstraint, Pythons Scripts, BGE scripts, Space Handles, Script Links. The files that still have an isolated G_DOSCRIPTLINKS are: 1)Scene.c, lines 822, 826 and 831 2)blender.c 392 (In the patch these lines have the comment: // G.fileflags & G_FILE_NO_PYTHON) I kept the -y command line option disabling only SpaceHandler (this is the way it was). But not I'm using -Y to completely disable Python. I don't know how to test pyConstraint properly (I never used them). If someone could test it better would great. I'm attaching as well some demofiles I was using to test the patch. EDIT:: console -Y is not working, console -y disable Python for almost everything. %%%
Author
Owner

Changed status to: 'Open'

Changed status to: 'Open'
Author
Owner

%%%I'm rewriting this patch, so don't need to waste your time reviewing it yet :)%%%

%%%I'm rewriting this patch, so don't need to waste your time reviewing it yet :)%%%
Author
Owner

%%%New Patch against the current trunk (16851).

The console is working now
Everything is working but ...

  1. Once you disable the pyDriver, you need to enable, and click in the object driver, and then in pyDriver again (they are the same button).

I think the problem is my "python disabled message".

  1. by-design, and limitations, I'm using the same flag for user preferences and the Load GUI. And when we run in the console with -y, even if you press Ctrl+X, the python will be disabled by default (even if your default configuration is enabled)... off course can be enabled by the gui.
    ...lets consider this a safe-mode :)

Im attaching two more tests files (space Handler and script with menu). To test pyConstraint i used http://graphicall.org/bbb/chars/bird.blend ).

I tested (a lot) and is working and would be ready for integration.

%%%

%%%New Patch against the current trunk (16851). The console is working now Everything is working but ... 1) Once you disable the pyDriver, you need to enable, and click in the object driver, and then in pyDriver again (they are the same button). I think the problem is my "python disabled message". 2) by-design, and limitations, I'm using the same flag for user preferences and the Load GUI. And when we run in the console with -y, even if you press Ctrl+X, the python will be disabled by default (even if your default configuration is enabled)... off course can be enabled by the gui. ...lets consider this a safe-mode :) Im attaching two more tests files (space Handler and script with menu). To test pyConstraint i used http://graphicall.org/bbb/chars/bird.blend ). I tested (a lot) and is working and would be ready for integration. %%%
Member

%%%With PyDrivers, I think the problem might be more with how their depsgraph recalcs are done. IIRC, we currently have a problem where they sometimes need to have one of their fields clicked on before they can correctly function.

+1%%%

%%%With PyDrivers, I think the problem might be more with how their depsgraph recalcs are done. IIRC, we currently have a problem where they sometimes need to have one of their fields clicked on before they can correctly function. +1%%%
Author
Owner

%%%A lot of changes :)
I'm sending the file 06_oct.patch now.

The only Pything I need to double check/test/reduce number of calls is the PyConstraint.

The Patch is very complete though.
In the end I will organize better the buttons_script.c.

But basically is working very well.


Know Issues:

  • To optimize I should toggle an internal pyDriver related flag when I Enable/Disable it. (instead of checking for my 2 flags)

  • drawnode.c - I should redraw the node window when toggle PyNode.

  • interface.c - ui_act_as_text_but() - commentaries in file

  • BPY_interface.c - line 880 - I'm blocking menu (official) scripts but we don't have specific flags for them (this is not a setup from file, therefore I don't think we need flags).

  • would be nice to KILL scripts that are already running when you disable Python
    %%%

%%%A lot of changes :) I'm sending the file 06_oct.patch now. The only Pything I need to double check/test/reduce number of calls is the PyConstraint. The Patch is very complete though. In the end I will organize better the buttons_script.c. But basically is working very well. **** Know Issues: - To optimize I should toggle an internal pyDriver related flag when I Enable/Disable it. (instead of checking for my 2 flags) - drawnode.c - I should redraw the node window when toggle PyNode. - interface.c - ui_act_as_text_but() - commentaries in file - BPY_interface.c - line 880 - I'm blocking menu (official) scripts but we don't have specific flags for them (this is not a setup from file, therefore I don't think we need flags). - would be nice to KILL scripts that are already running when you disable Python %%%
Author
Owner

%%%Well, now it looks ok for me.

I would like some feedback regarding pyContraints.
This is the patch file - 07_oct_B

I'm also attaching the final files I used for testing - pyFILES.zip

And I also posted a windows binary using this patch - http://www.graphicall.org/builds/builds/showbuild.php?action=show&id=830
%%%

%%%Well, now it looks ok for me. I would like some feedback regarding pyContraints. This is the patch file - 07_oct_B I'm also attaching the final files I used for testing - pyFILES.zip And I also posted a windows binary using this patch - http://www.graphicall.org/builds/builds/showbuild.php?action=show&id=830 %%%
Author
Owner

%%%Thanks to same feedback from BlenderArtists I finished the PyConstraint part.

file: 08_oct_pyconstraints.patch

Now the patch is 99% ready. Maybe a good time to think in the GUI? (buttons_script.c)%%%

%%%Thanks to same feedback from BlenderArtists I finished the PyConstraint part. file: 08_oct_pyconstraints.patch Now the patch is 99% ready. Maybe a good time to think in the GUI? (buttons_script.c)%%%
Author
Owner

%%%I'm uploading an example file showing the vulnerability in pyNodes.

Dont need to worry, it's opening this webpage and printing in the console only.
(If you dont trust use one of the NoPython binaries from Graphicall :p)%%%

%%%I'm uploading an example file showing the vulnerability in pyNodes. Dont need to worry, it's opening this webpage and printing in the console only. (If you dont trust use one of the NoPython binaries from Graphicall :p)%%%
Author
Owner

%%%Well, for security reasons the testing file was removed. If you wanna test in your system send me an email - dfelintoATyahoo.com%%%

%%%Well, for security reasons the testing file was removed. If you wanna test in your system send me an email - dfelintoATyahoo.com%%%
Member

%%%Same comment as others - if it is relevant and a good patch commit, otherwise please close :)%%%

%%%Same comment as others - if it is relevant and a good patch commit, otherwise please close :)%%%
Author
Owner

%%%I'm closing this patch thread.

The main reason being (1) it's totally outdated, (2) Ton really didn't liked the idea (back in 2008 @ bconf) (3) people are aware of python insecurity so this patch is not needed even as a reminding of this.%%%

%%%I'm closing this patch thread. The main reason being (1) it's totally outdated, (2) Ton really didn't liked the idea (back in 2008 @ bconf) (3) people are aware of python insecurity so this patch is not needed even as a reminding of this.%%%
Author
Owner

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#17701
No description provided.