Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,17 @@
"description[zh_CN]": "通知自动清理的天数,超过此天数的通知将被自动删除",
"permissions": "readwrite",
"visibility": "public"
},
"safeCommands": {
"value": ["xdg-open","dbus-send","qdbus","deepin-defender","dde-control-center","downloader","dde-file-manager","dde-dconfig","/usr/lib/deepin-daemon/dde-bluetooth-dialog","/usr/bin/dde-hints-dialog","/usr/bin/deepin-devicemanager"],
"serial": 0,
"flags": [],
"name": "safe commands",
"name[zh_CN]": "安全指令",
"description": "safe commands",
"description[zh_CN]": "通知扩展的x-deepin-action-携带的指令白名单",
"permissions": "readonly",
"visibility": "private"
}
}
}
8 changes: 8 additions & 0 deletions panels/notification/server/notificationmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,14 @@ void NotificationManager::doActionInvoked(const NotifyEntity &entity, const QStr
if (!args.isEmpty()) {
QString cmd = args.takeFirst(); // 命令

QScopedPointer<DConfig> config(DConfig::create("org.deepin.dde.shell", "org.deepin.dde.shell.notification"));
QStringList safeCommands = config->value("safeCommands").toStringList();
Comment on lines +536 to +537
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Guard against DConfig::create() returning nullptr before dereferencing config.

If DConfig::create() returns nullptr, config->value(...) will dereference a null pointer and crash. Please check config before use and either treat a null config as "no safe commands" (deny all) or fall back to a reasonable default.


if (!safeCommands.contains(cmd)) {
qWarning(notifyLog) << "The command is not allowed to be executed:" << cmd << safeCommands;
return;
}

QProcess pro;
pro.setProgram(cmd);
pro.setArguments(args);
Expand Down