QGIS-Documentation
QGIS-Documentation copied to clipboard
Project trust for embedded code enhancement (Request in QGIS)
Request for documentation
From pull request qgis/QGIS#63693 Author: @nirvn QGIS version: 4.0
Project trust for embedded code enhancement
PR Description:
Description
This PR implements the Trusted Projects and Folders QEP.
The PR implements a project-level "trust" mechanism that grants or denies execution of embedded python code within projects. As established in the QEP, the embedded code types cover here are:
- macros;
- expression functions;
- actions; and
- attribute form init code
This (finally :wink:) gives users the ability to allow for granular code execution, where allowance is not global.
The help the users take an informed decision, QGIS will throw users a project trust dialog. The dialog will display a list of all embedded code, and offer the user with generic information on how to proceed as well as a mean to preview code if desired. Here's how it looks:
https://github.com/user-attachments/assets/609bf275-0b99-4652-9e06-41f3938db974
When users permanently allow or deny a given project, the project path (or its folder, if the user decides to grant/deny a folder-wide permission) will be saved into the user profile settings. Editing the list is done in the options window through this UI:
One slight deviation from the QEP is that I've implemented the embeddedCode() functionality inside the QgsProjectUtils as I felt like the added #include headers might not be welcome in qgsproject.cpp itself. Happy to revisit that if people have strong opinions.
That said, may trust begin! :)