aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljscontextproperties.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Tests: Clean up includesUlf Hermann2025-09-171-1/+2
| | | | | | | | | | | | | We shouldn't include qtqml-config_p.h manually since it's not header-guarded. And especially we shouldn't include it twice. Also, sort and split the includes. In order to resolve QT_CONFIG, we include qtqmlglobal_p.h or qtqmlglobal.h. Change-Id: I933d8eff8581e91859a8a178bf92caeec2959215 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Add security header for src/qmlcompilerOlivier De Cannière2025-09-171-0/+1
| | | | | | | | | | | | | | | | | | We assume that QML or JS code comes from a trusted source. Therefore, most files are deemed to be significant even if they parse data. This includes the source code itself but also the associated metadata or cache files. However, the QML compiler also generates C++ code. Extra care needs to be taken with the generator as a vulnerability there could propagate and have a disproportionate effect on the program's security. It is marked as critical. QUIP: 23 Fixes: QTBUG-136195 Pick-to: 6.10 6.9 6.8 Change-Id: I70630361ec8e9cb3969f78a3fdf36a41334a33b3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* HeuristicContextProperties: don't grep on empty argumentSami Shalayel2025-08-211-0/+3
| | | | | | | | | In HeuristicContextProperties::collectFromDirs, early return when an empty list is given, instead of running grep without directories (which defaults to the working directory). Change-Id: I96647112eab74e9d68c96aaf14511f06774009d4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmlcontextpropertydump: add extra feature flag to disable/enableSami Shalayel2025-08-211-5/+6
| | | | | | | | | Introduce a new feature flag to disable the qmlcontextpropertydump tool (that will be introduced in a later commit). Task-number: QTBUG-128232 Change-Id: I68436f1007ec40c6b3c8e1059319156251ecdef4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* heuristic context properties: write and load to/from diskSami Shalayel2025-08-211-0/+100
| | | | | | | | | | | | | | | | | Add methods to write and load context properties on disk. Use the .ini format to provide human readable files and to be able to reuse QQmlToolingSettings for finding the setting file. Implement a simple (de)serialization of SourceLocations for the .ini files, and use QSetting to dump/read the lists of properties. Add a test to see if the (de)serialization works. Add equality operators where required for the test's Q_COMPARE(). Task-number: QTBUG-138061 Task-number: QTBUG-128232 Change-Id: I23bd2db0aacad3d395c2909efb209277f7f1d4bd Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: don't grep twice for context propertiesSami Shalayel2025-08-051-4/+12
| | | | | | | | | It seems that we grep twice when grep returns 1. From the manual, a return code of 1 means nothing was found and in this case we shouldn't run the fallback grep method. Change-Id: Id8993ca914cefb8bb806f77334508be46fb60fbe Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: make contextproperties a real class and renameSami Shalayel2025-08-051-30/+40
| | | | | | | | | | | | | | | | | | | | | | | | | Prepares for QTBUG-138061 where we need a way to load user-defined context properties into QQmlJS::ContextProperties. Rename QQmlJS::ContextProperties into HeuristicContextProperties to avoid confusions with the UserContextProperties. Make HeuristicContextProperties a real class so that we can add methods to load and save context properties to and from disk. Make the heuristics be saved in a list instead of a QHash, as the order of the property matters as we write them out into a file and testing becomes complicated when the order changes between different runs. Also note that it might be confusing for qmlls users if their warnings change orders during multiple runs. Rename some methods for clarity. Task-number: QTBUG-138061 Task-number: QTBUG-128232 Change-Id: Ib6302f609e182e622015293366c8b42425566a0e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlJSContextProperty: add isWarningEnabledSami Shalayel2025-05-221-0/+9
| | | | | | | | | Add a helper in QQmlJSContextProperties to check whether the qmlContextProperty warning is enabled. To be used in qmllint and qmlls. Task-number: QTBUG-128232 Change-Id: I644700379b86d8ace4eb0d4174cdef0983b19486 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qqmljscontextproperties: "grep" for setContextProperty callsSami Shalayel2025-05-221-0/+123
Add code to Grep the project folder for "setContextProperty" calls, so that a later commit can warn about usages of those context properties. Use grep to find files with setContextProperty calls, and then run a QRegularExpression on the files to extract the names and locations of the context properties. Add a fallback in case there is no grep on the system, and don't run grep on windows. Also avoid unused functions errors on windows where grep is not run so its output also does not need to be parsed. Task-number: QTBUG-128232 Change-Id: I15ceb2bbeb6ae6ac83f4bfa85b8a44d5a897d0a7 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>