Repository navigation
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: caixr23 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 |
Reviewer's GuideImplementation解析并校验主连接设备的 DHCP Captive-Portal URL,并将其用于补足 HTTP 探测结果中的门户网络判定盲区。
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 4 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="network-service-plugin/src/system/connectivitychecker.cpp" line_range="470" />
<code_context>
+
+ const QVariantMap options = dhcp4->options();
+ for (const char *key : { "default_url", "v4_captive_portal" }) {
+ const QString url = options.value(QLatin1String(key)).toString().trimmed();
+ if (url.isEmpty() || !isSafePortalUrl(url)) {
+ if (!url.isEmpty())
</code_context>
<issue_to_address>
**Authenticated clients appear captive**
When the network continues advertising a Captive-Portal URI after authentication, or an HTTP probe fails for a non-captive reason, `realStartCheck()` treats a nonempty result from `dhcpCaptivePortalUrl()` as proof that authentication is required, so it sets connectivity to `Portal` and callers report a captive network.
Determine captive status from the API response or connectivity check rather than treating the URI’s presence as proof of captive status.
Also at `network-service-plugin/src/system/connectivitychecker.cpp:308-313`, `network-service-plugin/src/system/connectivitychecker.cpp:344-348`, `network-service-plugin/src/system/connectivitychecker.cpp:476-478`.
</issue_to_address>
### Comment 2
<location path="network-service-plugin/src/system/connectivitychecker.cpp" line_range="470" />
<code_context>
+
+ const QVariantMap options = dhcp4->options();
+ for (const char *key : { "default_url", "v4_captive_portal" }) {
+ const QString url = options.value(QLatin1String(key)).toString().trimmed();
+ if (url.isEmpty() || !isSafePortalUrl(url)) {
+ if (!url.isEmpty())
</code_context>
<issue_to_address>
**Users see API data, not login page**
When the DHCP option is an RFC 8910 API URI whose response identifies a separate user portal URL, `dhcpCaptivePortalUrl()` returns the API URI unchanged, and `SessionContainer::openPortalUrl` passes it to `UrlHelper::openUrl`, so the browser displays API data instead of the authentication page.
Resolve the API response’s user-facing portal URL and pass that URL to the browser.
Also at `network-service-plugin/src/system/connectivitychecker.cpp:308-313`, `network-service-plugin/src/system/connectivitychecker.cpp:346-348`, `network-service-plugin/src/system/connectivitychecker.cpp:478`.
</issue_to_address>
### Comment 3
<location path="network-service-plugin/src/system/connectivitychecker.cpp" line_range="308" />
<code_context>
- setConnectivity(network::service::Connectivity::Full);
+ // HTTP探测未见劫持时,若DHCP下发了Captive-Portal选项(RFC 8910),
+ // 说明该网络仍需认证(如探测域名被网关白名单放行导致假阴性)
+ portalUrl = dhcpCaptivePortalUrl();
+ if (portalUrl.isEmpty()) {
+ // if the portal is empty, I think it ok
</code_context>
<issue_to_address>
**DHCP fallback is skipped in NM mode**
When `enableConnectivity` is false, `ConnectivityProcesser::createConnectivityChecker(false)` selects `NMConnectionvityChecker`, which never calls `dhcpCaptivePortalUrl()` and exposes no DHCP-derived portal URL. Networks using that supported mode therefore miss the new DHCP-based detection and portal link.
Apply the DHCP captive-portal lookup and URL propagation in the NM checker path as well, or otherwise ensure this mode receives the same fallback.
</issue_to_address>
### Comment 4
<location path="network-service-plugin/src/system/connectivitychecker.cpp" line_range="434-443" />
<code_context>
+static bool isSafePortalUrl(const QString &rawUrl)
+{
+ const QString url = rawUrl.trimmed();
+ if (url.size() < 8 || url.size() > 2048)
+ return false;
+
+ for (const QChar &ch : url) {
+ const uint code = ch.unicode();
+ if (code <= 0x20 || code == 0x7f)
+ return false;
+ }
+
+ return url.startsWith(QLatin1String("http://"), Qt::CaseInsensitive)
+ || url.startsWith(QLatin1String("https://"), Qt::CaseInsensitive);
+}
</code_context>
<issue_to_address>
**Malformed portal URL is accepted**
When a DHCP server supplies a scheme-only or otherwise malformed HTTP(S) URL, `isSafePortalUrl()` checks only the scheme prefix, so `dhcpCaptivePortalUrl()` accepts the malformed value and returns it instead of trying a valid legacy-option URL; callers expose an unusable portal URL.
Parse and validate the URL’s structure before accepting it, so malformed values are rejected and the legacy option can be tried.
</issue_to_address>|
|
||
| const QVariantMap options = dhcp4->options(); | ||
| for (const char *key : { "default_url", "v4_captive_portal" }) { | ||
| const QString url = options.value(QLatin1String(key)).toString().trimmed(); |
There was a problem hiding this comment.
🟠 High · Authenticated clients appear captive
When the network continues advertising a Captive-Portal URI after authentication, or an HTTP probe fails for a non-captive reason, realStartCheck() treats a nonempty result from dhcpCaptivePortalUrl() as proof that authentication is required, so it sets connectivity to Portal and callers report a captive network.
Determine captive status from the API response or connectivity check rather than treating the URI’s presence as proof of captive status.
Also at network-service-plugin/src/system/connectivitychecker.cpp:308-313, network-service-plugin/src/system/connectivitychecker.cpp:344-348, network-service-plugin/src/system/connectivitychecker.cpp:476-478.
Prompt for AI agents
In `network-service-plugin/src/system/connectivitychecker.cpp` at line 470:
**Authenticated clients appear captive**
When the network continues advertising a Captive-Portal URI after authentication, or an HTTP probe fails for a non-captive reason, `realStartCheck()` treats a nonempty result from `dhcpCaptivePortalUrl()` as proof that authentication is required, so it sets connectivity to `Portal` and callers report a captive network.
Determine captive status from the API response or connectivity check rather than treating the URI’s presence as proof of captive status.
Also at `network-service-plugin/src/system/connectivitychecker.cpp:308-313`, `network-service-plugin/src/system/connectivitychecker.cpp:344-348`, `network-service-plugin/src/system/connectivitychecker.cpp:476-478`.|
|
||
| const QVariantMap options = dhcp4->options(); | ||
| for (const char *key : { "default_url", "v4_captive_portal" }) { | ||
| const QString url = options.value(QLatin1String(key)).toString().trimmed(); |
There was a problem hiding this comment.
🟠 High · Users see API data, not login page
When the DHCP option is an RFC 8910 API URI whose response identifies a separate user portal URL, dhcpCaptivePortalUrl() returns the API URI unchanged, and SessionContainer::openPortalUrl passes it to UrlHelper::openUrl, so the browser displays API data instead of the authentication page.
Resolve the API response’s user-facing portal URL and pass that URL to the browser.
Also at network-service-plugin/src/system/connectivitychecker.cpp:308-313, network-service-plugin/src/system/connectivitychecker.cpp:346-348, network-service-plugin/src/system/connectivitychecker.cpp:478.
Prompt for AI agents
In `network-service-plugin/src/system/connectivitychecker.cpp` at line 470:
**Users see API data, not login page**
When the DHCP option is an RFC 8910 API URI whose response identifies a separate user portal URL, `dhcpCaptivePortalUrl()` returns the API URI unchanged, and `SessionContainer::openPortalUrl` passes it to `UrlHelper::openUrl`, so the browser displays API data instead of the authentication page.
Resolve the API response’s user-facing portal URL and pass that URL to the browser.
Also at `network-service-plugin/src/system/connectivitychecker.cpp:308-313`, `network-service-plugin/src/system/connectivitychecker.cpp:346-348`, `network-service-plugin/src/system/connectivitychecker.cpp:478`.| setConnectivity(network::service::Connectivity::Full); | ||
| // HTTP探测未见劫持时,若DHCP下发了Captive-Portal选项(RFC 8910), | ||
| // 说明该网络仍需认证(如探测域名被网关白名单放行导致假阴性) | ||
| portalUrl = dhcpCaptivePortalUrl(); |
There was a problem hiding this comment.
🟡 Medium · DHCP fallback is skipped in NM mode
When enableConnectivity is false, ConnectivityProcesser::createConnectivityChecker(false) selects NMConnectionvityChecker, which never calls dhcpCaptivePortalUrl() and exposes no DHCP-derived portal URL. Networks using that supported mode therefore miss the new DHCP-based detection and portal link.
Apply the DHCP captive-portal lookup and URL propagation in the NM checker path as well, or otherwise ensure this mode receives the same fallback.
Prompt for AI agents
In `network-service-plugin/src/system/connectivitychecker.cpp` at line 308:
**DHCP fallback is skipped in NM mode**
When `enableConnectivity` is false, `ConnectivityProcesser::createConnectivityChecker(false)` selects `NMConnectionvityChecker`, which never calls `dhcpCaptivePortalUrl()` and exposes no DHCP-derived portal URL. Networks using that supported mode therefore miss the new DHCP-based detection and portal link.
Apply the DHCP captive-portal lookup and URL propagation in the NM checker path as well, or otherwise ensure this mode receives the same fallback.| if (url.size() < 8 || url.size() > 2048) | ||
| return false; | ||
|
|
||
| for (const QChar &ch : url) { | ||
| const uint code = ch.unicode(); | ||
| if (code <= 0x20 || code == 0x7f) | ||
| return false; | ||
| } | ||
|
|
||
| return url.startsWith(QLatin1String("http://"), Qt::CaseInsensitive) |
There was a problem hiding this comment.
🟡 Medium · Malformed portal URL is accepted
When a DHCP server supplies a scheme-only or otherwise malformed HTTP(S) URL, isSafePortalUrl() checks only the scheme prefix, so dhcpCaptivePortalUrl() accepts the malformed value and returns it instead of trying a valid legacy-option URL; callers expose an unusable portal URL.
Parse and validate the URL’s structure before accepting it, so malformed values are rejected and the legacy option can be tried.
Prompt for AI agents
In `network-service-plugin/src/system/connectivitychecker.cpp` at lines 434-443:
**Malformed portal URL is accepted**
When a DHCP server supplies a scheme-only or otherwise malformed HTTP(S) URL, `isSafePortalUrl()` checks only the scheme prefix, so `dhcpCaptivePortalUrl()` accepts the malformed value and returns it instead of trying a valid legacy-option URL; callers expose an unusable portal URL.
Parse and validate the URL’s structure before accepting it, so malformed values are rejected and the legacy option can be tried.1. Parse the Captive-Portal URL from the primary connection device's DHCP4 configuration via NM, preferring default_url (RFC 8910, option 114) and falling back to v4_captive_portal (RFC 7710 legacy, option 160). 2. Fill two HTTP probing blind spots: fall back when the probe detects Portal but has no redirect URL, and escalate to Portal when the probe fails but the device is not disconnected. 3. Validate the URL with a scheme allowlist and control-character sanitization, rejecting illegal values from untrusted DHCP servers. Log: connect to captive portal authentication networks Influence: 1. Networks where the DHCP server provides Captive-Portal options feat: 解析DHCP Captive-Portal选项识别portal网络 1. 从主连接设备的DHCP4配置中解析NM导出的Captive-Portal URL,优先取 default_url(RFC 8910, option 114),兜底取v4_captive_portal(RFC 7710 遗留, option 160)。 2. 补齐HTTP探测的两个盲区:探测判Portal但无跳转URL时兜底、探测失败但 设备未断开时升级为Portal。 3. 对URL做scheme白名单与控制字符校验,拒绝不可信DHCP服务端下发的非法值。 Log: 连接captive portal认证网络 Influence: 1. DHCP下发了Captive-Portal选项的网络 PMS: BUG-381939 Change-Id: I80e045154e039f7606e7ffbcda8904dd1164ff59
4e5888d to
1fe2774
Compare
Cherry-pick from Gerrit change 421605
将 Gerrit change https://gerrit.uniontech.com/c/dde-network-core/+/421605 摘取到 linuxdeepin/dde-network-core 仓库,保留原始提交说明。
变更内容
从主连接设备的DHCP4配置中解析NM导出的Captive-Portal URL: 优先取 default_url (RFC 8910, option 114), 兜底取 v4_captive_portal (RFC 7710 遗留, option 160), 补齐 HTTP 探测的两个盲区: 探测判 Portal 但无跳转 URL 时兜底、探测失败但设备未断开时升级为 Portal; 对 URL 做 scheme 白名单与控制字符校验, 拒绝不可信 DHCP 服务端下发的非法值。
冲突解决
cherry-pick 时
network-service-plugin/src/system/connectivitychecker.cpp有一处冲突:目标仓库 master 已移除if块前的setPortalUrl(QString()),Gerrit change 将其移入if (disconnectCount == devices.size())块内并添加注释。解决方式:保留 Gerrit change 的版本。原始信息
Summary by Sourcery
识别并标记由 DHCP Captive-Portal 选项声明的需认证网络,同时增强 HTTP 探测异常场景下的网络状态判断。
New Features:
Bug Fixes: