Skip to content

master - #603

Closed
xujin177 wants to merge 0 commit into
linuxdeepin:masterfrom
xujin177:master
Closed

master#603
xujin177 wants to merge 0 commit into
linuxdeepin:masterfrom
xujin177:master

Conversation

@xujin177

@xujin177 xujin177 commented Nov 24, 2026 •

Copy link
Copy Markdown
  • chore: New release 6.7.54
  • refactor: restructure D-Bus binding generation

Summary by Sourcery

Restructure D-Bus binding generation to provide more robust, compatible, and maintainable proxy and adaptor output.

New Features:

  • Add a Qt-compatible generation mode to the D-Bus binding tool while preserving the existing extended binding output.

Bug Fixes:

  • Improve handling of XML parsing, validation, type annotations, generated signatures, and output routing for D-Bus bindings.

Enhancements:

  • Refactor D-Bus binding generation into distinct command-line parsing, XML modeling, code generation, and file output stages.
  • Modernize Qt includes and consolidate generated proxy and adaptor rendering around structured intermediate representations.
  • Refresh SPDX copyright attribution for the D-Bus utility sources and generator.

Chores:

  • Prepare the 6.7.54 release.

@sourcery-ai

sourcery-ai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

API

Add UnionTech copyright attribution to the extended D-Bus helper interface and its implementation files.

  • include/util/ddbusextendedabstractinterface.h L2
  • src/util/ddbusextendedabstractinterface.cpp L2
  • src/util/ddbusextendedpendingcallwatcher.cpp L2
  • src/util/ddbusextendedpendingcallwatcher_p.h L2

Implementation

Refactor qdbusxml2cpp into explicit command-line, XML parsing/model, code rendering, and output stages while retaining legacy behavior and adding the Qt-compatible adaptor mode.

  • tools/qdbusxml2cpp/qdbusxml2cpp.cpp L24-211, L216-389, L394-1360 (+4 small edits)

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread tools/qdbusxml2cpp/qdbusxml2cpp.cpp Outdated
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('_'));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 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`.

Comment thread tools/qdbusxml2cpp/qdbusxml2cpp.cpp Outdated
if (d_ptr->${name} != ${name})
{
d_ptr->${name} = ${name};
Q_EMIT ${notifier}Changed(d_ptr->${name});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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`.

Comment thread tools/qdbusxml2cpp/qdbusxml2cpp.cpp Outdated
Comment on lines +1210 to +1213
result.moc = QLatin1String("moc_") + base + QLatin1String("cpp");
#else
result.moc = base + QLatin1String("moc");
#endif

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 `-`.

Comment thread tools/qdbusxml2cpp/qdbusxml2cpp.cpp Resolved
Comment thread tools/qdbusxml2cpp/qdbusxml2cpp.cpp Outdated
for (int i = 1; i < argc; ++i) {
const QString arg = QString::fromLocal8Bit(argv[i]);
if (arg == QLatin1String("--qt-compatible")) {
result.qtCompatible = true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SPDX-FileCopyrightText: 2015 Jolla Ltd. 这种是需要保留的么,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文件最早是从这里扣过来的,保留一份比较好吧

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

This branch was previously deployed

1 inactive deployment
github-pages — 935ee1bf Deployed Nov 10, 2026 by deepin-bot[bot] via deploydocs / deploy #373
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants