Repository navigation
Conversation
Reviewer's GuideAPIAdd UnionTech copyright attribution to the extended D-Bus helper interface and its implementation files.
ImplementationRefactor qdbusxml2cpp into explicit command-line, XML parsing/model, code rendering, and output stages while retaining legacy behavior and adding the Qt-compatible adaptor mode.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 5 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tools/qdbusxml2cpp/qdbusxml2cpp.cpp" line_range="539" />
<code_context>
+ const auto append = [&names](const QList<Argument> &args, const QString &prefix) {
+ for (int i = 0; i < args.size(); ++i) {
+ QString name = args.at(i).name;
+ name = name.isEmpty() ? prefix + QString::number(i) : name.replace(QLatin1Char('-'), QLatin1Char('_'));
+ while (names.contains(name))
+ name += QLatin1Char('_');
</code_context>
<issue_to_address>
**Untrusted XML injects generated C++**
When an attacker can supply interface XML containing C++ syntax in an argument name or Qt annotation, and the generated bindings are compiled, `memberOf` copies argument names, but `argumentNames` only replaces hyphens before `parameters`, `proxyMethod`, and `adaptorMethod` splice them into C++ declarations and expressions. The method, property, and type annotation paths also return XML values without checking their intended C++ grammar, allowing attacker-controlled XML to alter generated code that downstream builds compile.
Validate XML argument names and annotation values against their intended C++ identifier or type grammar before rendering, rejecting invalid values or substituting safe identifiers.
Also at `tools/qdbusxml2cpp/qdbusxml2cpp.cpp:513`, `tools/qdbusxml2cpp/qdbusxml2cpp.cpp:568`, `tools/qdbusxml2cpp/qdbusxml2cpp.cpp:629`.
</issue_to_address>
### Comment 2
<location path="tools/qdbusxml2cpp/qdbusxml2cpp.cpp" line_range="851" />
<code_context>
+ if (d_ptr->${name} != ${name})
+ {
+ d_ptr->${name} = ${name};
+ Q_EMIT ${notifier}Changed(d_ptr->${name});
}
+ return;
</code_context>
<issue_to_address>
**Custom notifier breaks generated source**
When a property’s `org.qtproject.QtDBus.PropertyNotifier` annotation differs from the default signal name, the generated `onPropertyChanged` handler emits the default property-changed signal instead of the configured notifier, so the source calls an undeclared signal and fails to compile.
Make the generated handler emit the signal selected by the property notifier annotation.
Also at `tools/qdbusxml2cpp/qdbusxml2cpp.cpp:890`.
</issue_to_address>
### Comment 3
<location path="tools/qdbusxml2cpp/qdbusxml2cpp.cpp" line_range="1210-1213" />
<code_context>
+ QString base = result.header;
+ base.chop(1);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ result.moc = QLatin1String("moc_") + base + QLatin1String("cpp");
+#else
+ result.moc = base + QLatin1String("moc");
+#endif
+ }
+ return result;
</code_context>
<issue_to_address>
**Invalid moc include for stdout**
When `-m` is used with `-p -` or `-a -`, `output.header` is `-`, so `base.chop(1)` empties the name but the Qt-version branches still assign a moc filename. With `-m` and stdout output, `document()` appends that nonexistent moc file to the generated code, so compiling the output fails.
Leave `result.moc` empty when the header name is `-`.
</issue_to_address>
### Comment 4
<location path="tools/qdbusxml2cpp/qdbusxml2cpp.cpp" line_range="389" />
<code_context>
+ for (int i = element.children.size(); i > 0; --i)
+ pending += element.children.at(i - 1);
+ } else {
+ collectInterface(element, document, interfaces, compatible);
}
- else {
</code_context>
<issue_to_address>
**Nested interfaces are omitted**
When introspection XML places an interface beneath a nested `<node>`, the node branch enqueues only the current node’s children; `collectInterface` immediately returns for a nested `node`, so interfaces beneath it never reach generation and are missing from the output.
Traverse nested node children as well as root-node children before collecting interfaces.
</issue_to_address>
### Comment 5
<location path="tools/qdbusxml2cpp/qdbusxml2cpp.cpp" line_range="176" />
<code_context>
+ for (int i = 1; i < argc; ++i) {
+ const QString arg = QString::fromLocal8Bit(argv[i]);
+ if (arg == QLatin1String("--qt-compatible")) {
+ result.qtCompatible = true;
+ continue;
+ }
</code_context>
<issue_to_address>
**Recorded command omits format flag**
When the generated adaptor is produced with `--qt-compatible`, `commandArguments` never receives `--qt-compatible`, so the generated-file banner records a command that omits the option required to reproduce the historical adaptor format.
Append `--qt-compatible` to `commandArguments` before continuing.
</issue_to_address>| const auto append = [&names](const QList<Argument> &args, const QString &prefix) { | ||
| for (int i = 0; i < args.size(); ++i) { | ||
| QString name = args.at(i).name; | ||
| name = name.isEmpty() ? prefix + QString::number(i) : name.replace(QLatin1Char('-'), QLatin1Char('_')); |
There was a problem hiding this comment.
🟠 High · Untrusted XML injects generated C++
When an attacker can supply interface XML containing C++ syntax in an argument name or Qt annotation, and the generated bindings are compiled, memberOf copies argument names, but argumentNames only replaces hyphens before parameters, proxyMethod, and adaptorMethod splice them into C++ declarations and expressions. The method, property, and type annotation paths also return XML values without checking their intended C++ grammar, allowing attacker-controlled XML to alter generated code that downstream builds compile.
Validate XML argument names and annotation values against their intended C++ identifier or type grammar before rendering, rejecting invalid values or substituting safe identifiers.
Also at tools/qdbusxml2cpp/qdbusxml2cpp.cpp:513, tools/qdbusxml2cpp/qdbusxml2cpp.cpp:568, tools/qdbusxml2cpp/qdbusxml2cpp.cpp:629.
Prompt for AI agents
In `tools/qdbusxml2cpp/qdbusxml2cpp.cpp` at line 539:
**Untrusted XML injects generated C++**
When an attacker can supply interface XML containing C++ syntax in an argument name or Qt annotation, and the generated bindings are compiled, `memberOf` copies argument names, but `argumentNames` only replaces hyphens before `parameters`, `proxyMethod`, and `adaptorMethod` splice them into C++ declarations and expressions. The method, property, and type annotation paths also return XML values without checking their intended C++ grammar, allowing attacker-controlled XML to alter generated code that downstream builds compile.
Validate XML argument names and annotation values against their intended C++ identifier or type grammar before rendering, rejecting invalid values or substituting safe identifiers.
Also at `tools/qdbusxml2cpp/qdbusxml2cpp.cpp:513`, `tools/qdbusxml2cpp/qdbusxml2cpp.cpp:568`, `tools/qdbusxml2cpp/qdbusxml2cpp.cpp:629`.| if (d_ptr->${name} != ${name}) | ||
| { | ||
| d_ptr->${name} = ${name}; | ||
| Q_EMIT ${notifier}Changed(d_ptr->${name}); |
There was a problem hiding this comment.
🟡 Medium · Custom notifier breaks generated source
When a property’s org.qtproject.QtDBus.PropertyNotifier annotation differs from the default signal name, the generated onPropertyChanged handler emits the default property-changed signal instead of the configured notifier, so the source calls an undeclared signal and fails to compile.
Make the generated handler emit the signal selected by the property notifier annotation.
Also at tools/qdbusxml2cpp/qdbusxml2cpp.cpp:890.
Prompt for AI agents
In `tools/qdbusxml2cpp/qdbusxml2cpp.cpp` at line 851:
**Custom notifier breaks generated source**
When a property’s `org.qtproject.QtDBus.PropertyNotifier` annotation differs from the default signal name, the generated `onPropertyChanged` handler emits the default property-changed signal instead of the configured notifier, so the source calls an undeclared signal and fails to compile.
Make the generated handler emit the signal selected by the property notifier annotation.
Also at `tools/qdbusxml2cpp/qdbusxml2cpp.cpp:890`.| result.moc = QLatin1String("moc_") + base + QLatin1String("cpp"); | ||
| #else | ||
| result.moc = base + QLatin1String("moc"); | ||
| #endif |
There was a problem hiding this comment.
🟡 Medium · Invalid moc include for stdout
When -m is used with -p - or -a -, output.header is -, so base.chop(1) empties the name but the Qt-version branches still assign a moc filename. With -m and stdout output, document() appends that nonexistent moc file to the generated code, so compiling the output fails.
Leave result.moc empty when the header name is -.
Prompt for AI agents
In `tools/qdbusxml2cpp/qdbusxml2cpp.cpp` at lines 1210-1213:
**Invalid moc include for stdout**
When `-m` is used with `-p -` or `-a -`, `output.header` is `-`, so `base.chop(1)` empties the name but the Qt-version branches still assign a moc filename. With `-m` and stdout output, `document()` appends that nonexistent moc file to the generated code, so compiling the output fails.
Leave `result.moc` empty when the header name is `-`.| for (int i = 1; i < argc; ++i) { | ||
| const QString arg = QString::fromLocal8Bit(argv[i]); | ||
| if (arg == QLatin1String("--qt-compatible")) { | ||
| result.qtCompatible = true; |
There was a problem hiding this comment.
⚪ Low · Recorded command omits format flag
When the generated adaptor is produced with --qt-compatible, commandArguments never receives --qt-compatible, so the generated-file banner records a command that omits the option required to reproduce the historical adaptor format.
Append --qt-compatible to commandArguments before continuing.
Prompt for AI agents
In `tools/qdbusxml2cpp/qdbusxml2cpp.cpp` at line 176:
**Recorded command omits format flag**
When the generated adaptor is produced with `--qt-compatible`, `commandArguments` never receives `--qt-compatible`, so the generated-file banner records a command that omits the option required to reproduce the historical adaptor format.
Append `--qt-compatible` to `commandArguments` before continuing.| @@ -1,4 +1,5 @@ | |||
| // SPDX-FileCopyrightText: 2015 Jolla Ltd. | |||
| // SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. | |||
There was a problem hiding this comment.
SPDX-FileCopyrightText: 2015 Jolla Ltd. 这种是需要保留的么,
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, xujin177 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary by Sourcery
Restructure D-Bus binding generation to provide more robust, compatible, and maintainable proxy and adaptor output.
New Features:
Bug Fixes:
Enhancements:
Chores: