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
18 changes: 17 additions & 1 deletion astrbot/core/star/star_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,19 @@ async def load(
requirements_path=requirements_path,
)
except Exception as e:
logger.error(traceback.format_exc())
error_trace = traceback.format_exc()
logger.error(error_trace)
logger.error(f"插件 {root_dir_name} 导入失败。原因:{e!s}")
fail_rec += f"加载 {root_dir_name} 插件时出现问题,原因 {e!s}。\n"
self.failed_plugin_dict[root_dir_name] = {
"error": str(e),
"traceback": error_trace,
}
Comment on lines +536 to +539
Copy link
Contributor

Choose a reason for hiding this comment

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

security-medium medium

The application captures and stores full Python stack traces in self.failed_plugin_dict when a plugin fails to load. This data is intended to be sent to the frontend dashboard. Stack traces can reveal sensitive information about the server's internal file structure, installed libraries, and code logic, which can be leveraged by an attacker to plan further attacks.

Recommendation: Avoid sending full stack traces to the frontend. Log the full traceback on the server for debugging purposes and return only a generic error message or a sanitized version of the error to the client.

                    self.failed_plugin_dict[root_dir_name] = {
                        "error": str(e),
                    }

if path in star_map:
logger.info("失败插件依旧在插件列表中,正在清理...")
metadata = star_map.pop(path)
if metadata in star_registry:
star_registry.remove(metadata)
continue

# 检查 _conf_schema.json
Expand Down Expand Up @@ -784,6 +795,11 @@ async def load(
"traceback": errors,
}
# 记录注册失败的插件名称,以便后续重载插件
if path in star_map:
logger.info("失败插件依旧在插件列表中,正在清理...")
metadata = star_map.pop(path)
if metadata in star_registry:
star_registry.remove(metadata)

# 清除 pip.main 导致的多余的 logging handlers
for handler in logging.root.handlers[:]:
Expand Down
3 changes: 2 additions & 1 deletion dashboard/src/views/ExtensionPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -747,12 +747,13 @@ const showPluginInfo = (plugin) => {
const reloadPlugin = async (plugin_name) => {
try {
const res = await axios.post("/api/plugin/reload", { name: plugin_name });
await getExtensions();
if (res.data.status === "error") {
toast(res.data.message, "error");
return;
}
toast(tm("messages.reloadSuccess"), "success");
getExtensions();
//getExtensions();
} catch (err) {
toast(err, "error");
}
Expand Down