Skip to content

fix: remove redundant global flags from dsettings config#444

Merged
qiuzhiqian merged 1 commit into
masterfrom
fix-dconfig-global
Jul 2, 2026
Merged

fix: remove redundant global flags from dsettings config#444
qiuzhiqian merged 1 commit into
masterfrom
fix-dconfig-global

Conversation

@qiuzhiqian

@qiuzhiqian qiuzhiqian commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

The "flags": ["global"] entries were redundant across multiple dsettings keys (use-dsettings, version, system-sources, delivery limit configs, etc.). Remove them to simplify the configuration.

Bug: https://pms.uniontech.com/bug-view-368375.html

Summary by Sourcery

Bug Fixes:

  • Eliminate unnecessary "flags": ["global"] entries in dsettings keys to resolve configuration issues in lastore.

@sourcery-ai

sourcery-ai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR cleans up the dsettings configuration for org.deepin.dde.lastore by removing redundant "flags": ["global"] entries from multiple configuration keys to simplify and clarify how settings are applied.

File-Level Changes

Change Details Files
Remove redundant global flags from dsettings keys in the org.deepin.dde.lastore configuration.
  • Identify configuration keys that explicitly set "flags": ["global"] despite being globally scoped by default.
  • Delete the "flags": ["global"] entries from those keys while preserving all other key properties and values.
  • Ensure resulting JSON remains valid and maintains existing behavior, relying on default global scoping instead of explicit flags.
usr/share/dsg/configs/org.deepin.dde.lastore/org.deepin.dde.lastore.json

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

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

CLA Assistant Lite bot:
提交邮箱中包含我们的合作伙伴,但您似乎并非合作伙伴的成员或对接人,请联系相关对接人将您添加至组织之中,或由其重新发起 Pull Request。
The commit email domain belongs to one of our partners, but it seems you are not yet a member of the current organization, please contact the contact person to add you to the organization or let them submit the Pull Request.

xml seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request

@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 reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

The "flags": ["global"] entries were redundant across multiple dsettings
keys (use-dsettings, version, system-sources, delivery limit configs, etc.).
Remove them to simplify the configuration.

Bug: https://pms.uniontech.com/bug-view-368375.html
@qiuzhiqian qiuzhiqian force-pushed the fix-dconfig-global branch from c891afb to 981a6e8 Compare July 1, 2026 09:51
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:20分

■ 【总体评价】

代码执行了配置清理与对齐,但移除核心白名单校验字段导致严重权限绕过漏洞
因存在1个严重安全漏洞且代码质量与逻辑存在严重缺陷,触发安全一票否决并降至上限20分

■ 【详细分析】

  • 1.语法逻辑(存在严重错误)✕

src/internal/config/config.go 中彻底移除了 AllowInstallRemovePkgExecPaths 字段、常量、解析逻辑与 Setter 方法。作为系统级包管理守护进程,若业务调用方仍依赖该字段进行白名单校验,此删除操作将直接导致空指针异常或逻辑失效。未提供调用方同步修改的代码,属于严重的破坏性变更。
潜在问题:下游依赖此字段的模块在读取时将发生编译失败或运行时 panic;配置迁移逻辑被删除可能导致旧配置丢失。
建议:全面检索仓库中引用 AllowInstallRemovePkgExecPaths 的业务代码并进行同步重构;若确需废弃,应保留兼容性逻辑或使用 Deprecated 标记过渡。

  • 2.代码质量(存在严重问题)✕

org.deepin.dde.lastore.json 中大面积删除了近 20 个配置项的 "flags": ["global"] 声明,涉及内网升级、系统源、限速配置等核心业务。此变更缺乏任何注释说明或设计文档支撑,破坏了多机配置同步能力的完整性。
潜在问题:无文档记录的隐式行为变更,导致企业级部署场景下多终端配置策略同步失效;代码审查难以追溯变更意图。
建议:恢复 global 标记或在提交信息及代码注释中明确说明 DSettings 层已统一接管全局标记的架构演进背景。

  • 3.代码性能(高效)✓

移除了无用字段的解析与存储逻辑,轻微减少了内存占用与 D-Bus 数据转换开销,对性能有正向优化作用。
建议:保持当前的精简状态。

  • 4.代码安全(存在 1 个安全漏洞(严重1个))✕

漏洞对比统计:新增漏洞 1 个,减少漏洞 0 个,持平 0 个
移除包安装卸载可执行路径白名单机制,导致系统失去对恶意进程调用 lastore 安装卸载软件的管控,形成本地权限提升攻击面。

  • 安全漏洞1:【严重】权限绕过与提权漏洞 在 src/internal/config/config.goConfig 结构体及 getConfigFromDSettings 函数中,删除了 AllowInstallRemovePkgExecPaths 白名单字段及其解析逻辑。由于 lastore 以系统高权限运行,原本通过该白名单限制仅允许特定路径的可执行文件触发包管理操作。删除后,若调用方未做其他拦截,任何普通用户进程均可通过 D-Bus 接口触发系统级软件包的安装与卸载,导致本地权限提升及系统环境被恶意篡改 ——非常重要

  • 建议:立即回退 AllowInstallRemovePkgExecPaths 相关删除操作,恢复白名单校验机制;若需重构白名单实现方式,应在新方案完成并经过安全审计后再移除旧代码。

■ 【改进建议代码示例】

// 建议回退删除操作,保留白名单校验逻辑,并在结构体中增加废弃警告注释
type Config struct {
	// ... 其他字段
	// Deprecated: AllowInstallRemovePkgExecPaths is deprecated for removal in next major release. 
	// Use new security module instead.
	AllowInstallRemovePkgExecPaths []string
	AutoInstallUpdates             bool
	AutoInstallUpdateType          system.UpdateType
	// ...
}

const (
	// ...
	dSettingsKeyAllowInstallRemovePkgExecPaths       = "allow-install-remove-pkg-exec-paths"
	// ...
)

// getConfigFromDSettings 中恢复白名单解析并增加类型断言保护
v, err = c.dsLastoreManager.Value(0, dSettingsKeyAllowInstallRemovePkgExecPaths)
if err != nil {
	logger.Warningf("failed to get allow install remove pkg exec paths: %v", err)
} else {
	if variants, ok := v.Value().([]dbus.Variant); ok {
		for _, s := range variants {
			if path, ok := s.Value().(string); ok {
				c.AllowInstallRemovePkgExecPaths = append(c.AllowInstallRemovePkgExecPaths, path)
			}
		}
	}
}

// json2DSettings 中恢复配置迁移
_ = c.SetAllowInstallRemovePkgExecPaths(append(oldConfig.AllowInstallRemovePkgExecPaths, c.AllowInstallRemovePkgExecPaths...))

// 恢复 Setter 方法
func (c *Config) SetAllowInstallRemovePkgExecPaths(paths []string) error {
	c.AllowInstallRemovePkgExecPaths = paths
	return c.save(dSettingsKeyAllowInstallRemovePkgExecPaths, paths)
}

@deepin-ci-robot

Copy link
Copy Markdown

@qiuzhiqian: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
github-pr-review-ci 981a6e8 link true /test github-pr-review-ci

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: qiuzhiqian, zhaohuiw42

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

@qiuzhiqian qiuzhiqian merged commit debf7d6 into master Jul 2, 2026
24 of 31 checks passed
@qiuzhiqian qiuzhiqian deleted the fix-dconfig-global branch July 2, 2026 01:38
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