Skip to content

feat support ok-nte#250

Open
Jungle178 wants to merge 7 commits into
AUTO-MAS-Project:devfrom
Jungle178:dev
Open

feat support ok-nte#250
Jungle178 wants to merge 7 commits into
AUTO-MAS-Project:devfrom
Jungle178:dev

Conversation

@Jungle178

@Jungle178 Jungle178 commented Jun 17, 2026

Copy link
Copy Markdown

这次推到了dev分支

Summary by Sourcery

在后端任务编排、配置模型、API 和前端 UI 中新增对 OK-NTE 脚本的一等公民级支持。

新特性:

  • 引入 OkNteConfigOkNteUserConfig 模型,并将其接入全局脚本/用户配置注册表。
  • 新增 OK-NTE 任务管理器和 AutoProxy 任务,用于基于用户级设置驱动 ok-nte.exe,并支持日志监控以及可选的游戏启动/关闭流程。
  • 通过新的 FastAPI 端点以及对应的 TypeScript 客户端服务,暴露 OK-NTE 专用的脚本和用户配置。
  • 扩展脚本 UI 和路由,以创建、编辑和管理 OK-NTE 脚本及其用户;包括一个专用的基于 Web 的 OK-NTE 配置编辑器,可与 JSON 配置文件同步。

增强改进:

  • 在前端通过基于映射的辅助方法统一脚本编辑路由逻辑,以支持更多脚本类型。
  • 在脚本表中与 OK-WW 一致地展示 OK-NTE 用户状态标签,提供统一的 ok-script 使用体验。
Original summary in English

Summary by Sourcery

Add first-class OK-NTE script support across backend task orchestration, configuration models, APIs, and frontend UI.

New Features:

  • Introduce OkNteConfig and OkNteUserConfig models and wire them into the global script/user configuration registry.
  • Add an OK-NTE task manager and AutoProxy task to drive ok-nte.exe with per-user settings, log monitoring, and optional game launch/teardown.
  • Expose OK-NTE-specific script and user configuration via new FastAPI endpoints and corresponding TypeScript client services.
  • Extend the scripts UI and routing to create, edit, and manage OK-NTE scripts and their users, including a dedicated web-based OK-NTE config editor that syncs JSON config files.

Enhancements:

  • Unify script-edit routing logic in the frontend with a mapping-based helper to support additional script types.
  • Show OK-NTE user status tags alongside OK-WW in the script table for a consistent ok-script experience.

@ClozyA

ClozyA commented Jun 17, 2026

Copy link
Copy Markdown
Member

@codex review这个PR,回复请使用中文

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 10b2cab10b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/api/scripts.py Outdated
Comment thread app/task/OkNte/manager.py
Comment thread app/task/OkNte/AutoProxy.py
Comment thread app/task/OkNte/AutoProxy.py
Comment thread app/task/OkNte/AutoProxy.py
@Jungle178

Copy link
Copy Markdown
Author

@codex review这个PR,回复请使用中文

resolve了

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9abbe9c584

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/api/scripts.py Outdated
Comment thread app/task/OkNte/AutoProxy.py
# Conflicts:
#	app/api/scripts.py
#	app/core/config.py
#	app/core/task_manager.py
#	app/models/config.py
#	app/models/schema.py
#	app/task/__init__.py
#	frontend/src/api/models/ScriptCreateIn.ts
#	frontend/src/api/models/ScriptCreateOut.ts
#	frontend/src/api/models/ScriptGetOut.ts
#	frontend/src/api/models/ScriptUpdateIn.ts
#	frontend/src/api/models/UserCreateOut.ts
#	frontend/src/api/models/UserGetOut.ts
#	frontend/src/api/models/UserUpdateIn.ts
#	frontend/src/components/ScriptTable.vue
#	frontend/src/composables/useScriptApi.ts
#	frontend/src/types/script.ts
#	frontend/src/views/Scripts.vue
@qiyinxi

qiyinxi commented Jun 22, 2026

Copy link
Copy Markdown
Contributor
image

@Jungle178

Copy link
Copy Markdown
Author
image

ok,修了

Comment thread app/api/scripts.py
Comment on lines +52 to +79
def _oknte_script_config(script_id: str) -> tuple[uuid.UUID, RuntimeOkNteConfig]:
script_uid = uuid.UUID(script_id)
script_config = Config.ScriptConfig[script_uid]
if not isinstance(script_config, RuntimeOkNteConfig):
raise ValueError("脚本配置类型错误, 不是 OK-NTE 类型")
return script_uid, script_config


def _oknte_legacy_mas_config_dir(script_id: str) -> Path:
script_uid, _ = _oknte_script_config(script_id)
return Path.cwd() / "data" / str(script_uid) / "Default" / "ConfigFile"


def _oknte_mas_config_dir(script_id: str, user_id: str) -> Path:
script_uid, _ = _oknte_script_config(script_id)
user_uid = uuid.UUID(user_id)
return Path.cwd() / "data" / str(script_uid) / str(user_uid) / "ConfigFile"


def _oknte_config_file_path(config_dir: Path, filename: str) -> Path:
file_path = Path(filename)
if (
file_path.name != filename
or file_path.is_absolute()
or ".." in file_path.parts
):
raise ValueError("配置文件名非法")
return config_dir / filename

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.

这块看看要不后续你们ok系列的统一用一套轮子,和@1w1w11w1讨论一下(

Comment thread app/api/scripts.py
Comment on lines +916 to +1122
@router.post(
"/oknte/configs/list",
tags=["OKNTE"],
summary="获取 OK-NTE 配置文件列表及 schema",
status_code=200,
)
async def get_oknte_configs_list(script_id: str, user_id: str):
"""
获取 OK-NTE 配置文件列表及 schema 定义。
读写用户配置目录(data/{script_id}/{user_id}/ConfigFile/),
若为空则自动从 ok-nte configs 目录初始化默认配置。

Args:
script_id: OK-NTE 脚本 ID
user_id: 用户 ID

Returns:
dict: 包含配置文件列表和 schema 的响应
"""
try:
import json
import shutil
from app.task.OkNte.config_schema import (
get_all_config_info, build_fields_for_config, load_oknte_option_labels,
)

_, script_config = _oknte_script_config(script_id)

# 从 ok-nte 安装目录加载翻译 → option_labels
root_path = script_config.get("Info", "RootPath")
option_labels = load_oknte_option_labels(root_path) if root_path else {}

# 用户配置目录;旧版 Default 目录仅作为升级后的初始化来源。
mas_config_dir = _oknte_mas_config_dir(script_id, user_id)

# ok-nte 源配置目录(用于自动初始化)
legacy_config_dir = _oknte_legacy_mas_config_dir(script_id)
oknte_configs_dir = (
legacy_config_dir
if legacy_config_dir.is_dir() and any(legacy_config_dir.iterdir())
else None
)
if oknte_configs_dir is None:
raw_config_path = script_config.get("Script", "ConfigPath")
oknte_configs_dir = Path(raw_config_path) if raw_config_path else None
if not oknte_configs_dir or not oknte_configs_dir.exists():
if root_path:
root = Path(root_path)
packaged_dir = root / "data" / "apps" / "ok-nte" / "working" / "configs"
source_dir = root / "configs"
oknte_configs_dir = packaged_dir if packaged_dir.is_dir() else source_dir

# 自动初始化:用户目录为空时从旧版共享目录或 ok-nte configs 复制默认配置
need_init = not mas_config_dir.exists() or not any(mas_config_dir.iterdir())
if need_init and oknte_configs_dir and oknte_configs_dir.is_dir():
mas_config_dir.mkdir(parents=True, exist_ok=True)
shutil.copytree(oknte_configs_dir, mas_config_dir, dirs_exist_ok=True)

configs_info = get_all_config_info()

# 读取 per-user JSON 配置,通过 build_fields_for_config 构建字段列表
result = []
for info in configs_info:
filename = info["filename"]
filepath = _oknte_config_file_path(mas_config_dir, filename)
current_data: dict[str, Any] = {}
if filepath.exists():
try:
current_data = json.loads(filepath.read_text(encoding="utf-8"))
except Exception:
pass

fields = build_fields_for_config(filename, current_data, option_labels)

result.append({
**info,
"fields": fields,
"currentData": current_data,
})

return {
"code": 200,
"status": "success",
"message": f"共 {len(result)} 个配置文件",
"data": result,
"optionLabels": option_labels,
"configPath": str(mas_config_dir) if mas_config_dir else None,
}
except Exception as e:
return {
"code": 500,
"status": "error",
"message": f"{type(e).__name__}: {str(e)}",
"data": [],
}


@router.post(
"/oknte/configs/update",
tags=["OKNTE"],
summary="更新 OK-NTE 配置文件",
status_code=200,
)
async def update_oknte_config(
script_id: str = Body(...),
user_id: str = Body(...),
filename: str = Body(...),
data: dict = Body(...),
):
"""
更新 OK-NTE 配置文件

Args:
script_id: OK-NTE 脚本 ID
user_id: 用户 ID
filename: 配置文件名(如 DailyTask.json)
data: 要更新的配置数据

Returns:
dict: 操作结果
"""
try:
import json

# 写入用户配置目录
mas_config_dir = _oknte_mas_config_dir(script_id, user_id)
mas_config_dir.mkdir(parents=True, exist_ok=True)

filepath = _oknte_config_file_path(mas_config_dir, filename)

existing_data = {}
if filepath.exists():
with open(filepath, "r", encoding="utf-8") as f:
existing_data = json.load(f)

existing_data.update(data)

with open(filepath, "w", encoding="utf-8") as f:
json.dump(existing_data, f, ensure_ascii=False, indent=4)

return {
"code": 200,
"status": "success",
"message": f"配置文件 {filename} 已更新",
"data": existing_data,
}
except Exception as e:
return {
"code": 500,
"status": "error",
"message": f"{type(e).__name__}: {str(e)}",
}


@router.post(
"/oknte/configs/batch-update",
tags=["OKNTE"],
summary="批量更新 OK-NTE 配置文件",
status_code=200,
)
async def batch_update_oknte_configs(
script_id: str = Body(...),
user_id: str = Body(...),
configs: dict = Body(...),
):
"""
批量更新 OK-NTE 配置文件

Args:
script_id: OK-NTE 脚本 ID
user_id: 用户 ID
configs: { filename: data } 格式的配置数据

Returns:
dict: 操作结果
"""
try:
import json

# 写入用户配置目录
mas_config_dir = _oknte_mas_config_dir(script_id, user_id)
mas_config_dir.mkdir(parents=True, exist_ok=True)

updated_files = []
for filename, data in configs.items():
filepath = _oknte_config_file_path(mas_config_dir, filename)
existing_data = {}
if filepath.exists():
with open(filepath, "r", encoding="utf-8") as f:
existing_data = json.load(f)
existing_data.update(data)
with open(filepath, "w", encoding="utf-8") as f:
json.dump(existing_data, f, ensure_ascii=False, indent=4)
updated_files.append(filename)

return {
"code": 200,
"status": "success",
"message": f"已更新 {len(updated_files)} 个配置文件",
"data": updated_files,
}
except Exception as e:
return {
"code": 500,
"status": "error",
"message": f"{type(e).__name__}: {str(e)}",
}

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.

这边也是,感觉和okww基本没啥区别,后续可以和@1w1w11w1和群主商量下要不要抽出来,具体实现看着没啥问题(

Comment thread app/models/config.py Outdated
Comment on lines +2750 to +2757
self.Game_EmulatorId = ConfigItem(
"Game",
"EmulatorId",
"-",
MultipleUIDValidator("-", self.related_config, "EmulatorConfig"),
)
self.Game_EmulatorIndex = ConfigItem("Game", "EmulatorIndex", "-")

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.

oknte支持模拟器嘛(?

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.

有道理,刚把模拟器字段删了。我做fork分支的PR不好抽逻辑合轮子,动你们原本代码行数太多了,不然每次dev代码更新我都要重新merge解决冲突,现在是尽量并行的。如果要合并逻辑得把这个PR合进主干之后再新起一个单独PR来做。

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.

有道理,刚把模拟器字段删了。我做fork分支的PR不好抽逻辑合轮子,动你们原本代码行数太多了,不然每次dev代码更新我都要重新merge解决冲突,现在是尽量并行的。如果要合并逻辑得把这个PR合进主干之后再新起一个单独PR来做。

ok的,只是看到那部分代码之后感觉可以等合进去之后一起优化一下

@@ -0,0 +1,401 @@
# AUTO-MAS: A Multi-Script, Multi-Config Management and Automation Software

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.

建议把这个文件和autoproxy内的通知模块都抽到tools里(当然只是建议

@ClozyA

ClozyA commented Jun 23, 2026

Copy link
Copy Markdown
Member

@sourcery-ai review

@sourcery-ai

sourcery-ai Bot commented Jun 23, 2026

Copy link
Copy Markdown

审查者指南

在后端任务执行、配置、API 模式以及前端 UI 中为 OK-NTE(ok-script)脚本类型提供一等公民支持,包括按用户的 OK-NTE 任务配置、游戏生命周期管理,以及带有多语言感知模式的 OK-NTE JSON 配置内置编辑器。

OK-NTE 按用户配置编辑流程的时序图

sequenceDiagram
    actor User
    participant OkNteUserEdit as OkNteUserEditVue
    participant OkNteConfigEditor as OkNteConfigEditorVue
    participant OknteService
    participant ScriptsAPI as FastAPI_scripts
    participant Schema as OkNte_config_schema
    participant FS as FileSystem

    User->>OkNteUserEdit: open OkNte user edit page
    OkNteUserEdit->>OkNteConfigEditor: mount with scriptId,userId

    OkNteConfigEditor->>OknteService: getOknteConfigsListApiScriptsOknteConfigsListPost(scriptId,userId)
    OknteService->>ScriptsAPI: POST /api/scripts/oknte/configs/list
    ScriptsAPI->>ScriptsAPI: _oknte_mas_config_dir(script_id,user_id)
    ScriptsAPI->>FS: init/copy configs if needed
    ScriptsAPI->>Schema: get_all_config_info()
    ScriptsAPI->>Schema: build_fields_for_config(filename,current_data,option_labels)
    Schema-->>ScriptsAPI: config_infos with fields
    ScriptsAPI-->>OknteService: config list + optionLabels
    OknteService-->>OkNteConfigEditor: response
    OkNteConfigEditor-->>User: render grouped config files & fields

    User->>OkNteConfigEditor: modify multiple fields
    OkNteConfigEditor->>OknteService: batchUpdateOknteConfigsApiScriptsOknteConfigsBatchUpdatePost(body)
    OknteService->>ScriptsAPI: POST /api/scripts/oknte/configs/batch-update
    ScriptsAPI->>FS: merge & write JSON files
    ScriptsAPI-->>OknteService: updated_files
    OknteService-->>OkNteConfigEditor: success
    OkNteConfigEditor-->>User: show "配置已保存"
Loading

文件级改动

Change Details Files
Introduce OK-NTE-specific script and user configuration models and wire them into the global configuration system and schema.
  • 在核心配置模型中添加 OkNteUserConfig 和 OkNteConfig 类,为 Info/Task/Data/Notify 以及 Script/Game/Run 分区定义专门针对 OK-NTE 使用场景的结构,包括任务索引默认值、标签生成以及按用户的统计数据。
  • 在 ToolsConfig.ScriptConfig、CLASS_BOOK 以及全局配置的 add_script/add_user 流程中注册 OkNteConfig 和 OkNteUserConfig,使 OK-NTE 脚本与用户可以像现有脚本类型一样被创建、更新和列出。
  • 扩展 Pydantic 模式,在脚本/用户索引项、创建/获取/更新载荷联合类型以及脚本创建类型字面量中包含 OkNteConfig 和 OkNteUserConfig。
app/models/config.py
app/models/schema.py
app/core/config.py
app/utils/constants.py
Add backend OK-NTE task execution pipeline, including automatic per-user JSON config management and log-based success/failure detection.
  • 实现 AutoProxyTask,根据每个用户的 TaskIndex/ExitOnFinish 使用 -t N -e 运行 OK-NTE,通过 ProcessManager 管理脚本和游戏进程,并解析 OK-NTE 日志(内置致命错误模式,并支持可配置的成功/错误子串)。
  • 镜像 General/SRC/MaaEnd 的行为:管理每个用户在 MAS 端的 ConfigFile 目录,从旧版或安装路径复制初始配置;根据 UpdateConfigMode 决定是否写回更新后的配置,并持久化 LastProxyStatus/LastTaskIndex/RemainedDay/ProxyTimes。
  • 引入 OkNteManager 作为 TaskExecuteBase 的封装器,用于锁定脚本配置,将 UserData 克隆到 MultipleConfig 中,在符合条件的用户之间编排 AutoProxyTask,管理可选的游戏生命周期(LaunchBeforeTask/CloseOnFinish),从临时配置中恢复原始脚本配置,并在完成或崩溃后写回用户配置。
  • 将 OkNteManager 接入 TaskManager.main_task,使 OkNteConfig 脚本的任务通过新管理器执行。
app/task/OkNte/AutoProxy.py
app/task/OkNte/manager.py
app/task/OkNte/__init__.py
app/core/task_manager.py
Expose OK-NTE per-user JSON configuration files via new FastAPI endpoints and a schema builder that infers fields from JSON plus manually curated select options and translations.
  • 添加辅助函数,根据脚本/用户解析 OK-NTE 配置目录,处理旧版 Default/ConfigFile 路径,并校验文件名以防止目录穿越。
  • 实现 /api/scripts/oknte/configs/list,按需从旧版或安装配置初始化每用户的 ConfigFile 目录,为每个已知的 OK-NTE 配置文件加载 JSON,通过 build_fields_for_config 构建字段定义,并返回 optionLabels 和 configPath。
  • 实现 /api/scripts/oknte/configs/update/api/scripts/oknte/configs/batch-update,将传入数据合并到 ConfigFile 中每用户的 JSON 文件里,同时保留已有键值。
  • 创建 config_schema.py,用于解析 OK-NTE 翻译文件(.mo/.po/.ts),为每个配置文件定义下拉选项目录,按 task/trigger/global 对配置进行分组,将文件名映射到展示名称和任务索引,并向 API 层暴露 get_all_config_info/build_fields_for_config
  • 在前端 API 层生成相应的 OpenAPI 客户端服务 OknteService 以及新端点的请求体模型。
app/api/scripts.py
app/task/OkNte/config_schema.py
frontend/src/api/services/OknteService.ts
frontend/src/api/models/Body_update_oknte_config_api_scripts_oknte_configs_update_post.ts
frontend/src/api/models/Body_batch_update_oknte_configs_api_scripts_oknte_configs_batch_update_post.ts
Integrate OK-NTE script type into the frontend script/user management UX, including routing, typing, and shared helpers.
  • 扩展 ScriptType 联合类型和脚本配置/用户配置的区分联合类型以包含 OkNte*,并相应更新脚本列表、详情、创建和更新的类型。
  • 集中管理脚本编辑路径映射(scriptEditPathMap/getScriptEditPath),更新所有脚本/用户新增与编辑的导航处理逻辑,以支持 'OkNte'
  • 更新脚本列表和表格组件,展示 OK-NTE 图标、类型徽章,并与 Okww 共享 ok-script 风格的用户信息标签渲染。
  • 将 OK-NTE 接入 useScriptApi 的类型映射(SCRIPT_CREATE_TYPE_BY_SCRIPT_TYPE、SCRIPT_TYPE_BY_CONFIG_TYPE),并统一 Okww/OkNte 用户归一化逻辑,包括为 OkNte 用户设置默认 TaskIndex=2。
  • 在 Vue 路由中注册 OkNteScriptEdit 和 OkNteUserAdd/OkNteUserEdit 新路由。
frontend/src/types/script.ts
frontend/src/views/Scripts.vue
frontend/src/components/ScriptTable.vue
frontend/src/composables/useScriptApi.ts
frontend/src/router/index.ts
Provide dedicated OK-NTE script and user edit UIs, including an in-app OK-NTE JSON config editor driven by backend schema.
  • 添加 OkNteScriptEdit.vue,包含基础 Info 区域、游戏管理(Enable/LaunchBeforeTask/CloseOnFinish,以及基于 Neverness To Everness/HTGame.exe 的游戏路径自动检测)和 Run 设置;根据选定的 RootPath 自动推导 ScriptPath/ConfigPath/LogPath/TrackProcessExe,并通过 updateScript 持久化更改。
  • 添加 OkNteUserEdit.vue,如有需要可自动创建用户,暴露 Info(Id/Password/RemainedDay/Notes)、Task(TaskIndex 下拉框映射到 -t N,固定 ExitOnFinish=true)、Notify,并内嵌 WebhookManager 和 OkNteConfigEditor 以支持逐用户 JSON 配置。
  • 实现 OkNteConfigEditor.vue,调用新的 oknte-config API,按逻辑类别对配置进行分组,根据后端提供的 field.type(bool/select/list/int/float/hotkey/string)推断字段控件,按文件跟踪未保存更改,并在卸载时通过 batch-update 自动保存。
  • 在生成的前端 API 中添加 OkNte 相关的 OpenAPI 模型(OkNteConfig*、OkNteUserConfig*),以提供类型支持。
frontend/src/views/EditView/Script/OkNteScriptEdit.vue
frontend/src/views/EditView/User/OkNteUserEdit.vue
frontend/src/views/OkNteUserEdit/OkNteConfigEditor.vue
frontend/src/api/index.ts
frontend/src/api/models/OkNteConfig.ts
frontend/src/api/models/OkNteConfig_Info.ts
frontend/src/api/models/OkNteConfig_Script.ts
frontend/src/api/models/OkNteConfig_Game.ts
frontend/src/api/models/OkNteConfig_Run.ts
frontend/src/api/models/OkNteUserConfig.ts
frontend/src/api/models/OkNteUserConfig_Info.ts
frontend/src/api/models/OkNteUserConfig_Task.ts
frontend/src/api/models/OkNteUserConfig_Data.ts
frontend/src/api/models/OkNteUserConfig_Notify.ts

提示和命令

与 Sourcery 交互

  • 触发新审查: 在 Pull Request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub Issue: 在审查评论下回复,让 Sourcery 从该评论创建一个 issue。你也可以回复审查评论 @sourcery-ai issue 来从中创建 issue。
  • 生成 Pull Request 标题: 在 Pull Request 标题中任意位置写上 @sourcery-ai,即可随时生成标题。也可以在 Pull Request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 Pull Request 摘要: 在 Pull Request 正文中任意位置写上 @sourcery-ai summary,即可在指定位置随时生成 PR 摘要。也可以在 Pull Request 中评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成审查者指南: 在 Pull Request 中评论 @sourcery-ai guide,即可随时(重新)生成审查者指南。
  • 解决所有 Sourcery 评论: 在 Pull Request 中评论 @sourcery-ai resolve,来标记解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 撤销所有 Sourcery 审查: 在 Pull Request 中评论 @sourcery-ai dismiss,来撤销所有已有的 Sourcery 审查。若你希望从零开始新的审查,这尤其有用——别忘了再评论 @sourcery-ai review 来触发新审查!

自定义你的使用体验

访问你的 控制面板 来:

  • 启用或禁用审查功能,例如 Sourcery 自动生成的 Pull Request 摘要、审查者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

Add first-class support for the OK-NTE (ok-script) script type across backend task execution, configuration, API schema, and frontend UI, including per-user OK-NTE task configuration, game lifecycle management, and an in-app editor for OK-NTE JSON configs with translation-aware schema.

Sequence diagram for OK-NTE per-user config editing flow

sequenceDiagram
    actor User
    participant OkNteUserEdit as OkNteUserEditVue
    participant OkNteConfigEditor as OkNteConfigEditorVue
    participant OknteService
    participant ScriptsAPI as FastAPI_scripts
    participant Schema as OkNte_config_schema
    participant FS as FileSystem

    User->>OkNteUserEdit: open OkNte user edit page
    OkNteUserEdit->>OkNteConfigEditor: mount with scriptId,userId

    OkNteConfigEditor->>OknteService: getOknteConfigsListApiScriptsOknteConfigsListPost(scriptId,userId)
    OknteService->>ScriptsAPI: POST /api/scripts/oknte/configs/list
    ScriptsAPI->>ScriptsAPI: _oknte_mas_config_dir(script_id,user_id)
    ScriptsAPI->>FS: init/copy configs if needed
    ScriptsAPI->>Schema: get_all_config_info()
    ScriptsAPI->>Schema: build_fields_for_config(filename,current_data,option_labels)
    Schema-->>ScriptsAPI: config_infos with fields
    ScriptsAPI-->>OknteService: config list + optionLabels
    OknteService-->>OkNteConfigEditor: response
    OkNteConfigEditor-->>User: render grouped config files & fields

    User->>OkNteConfigEditor: modify multiple fields
    OkNteConfigEditor->>OknteService: batchUpdateOknteConfigsApiScriptsOknteConfigsBatchUpdatePost(body)
    OknteService->>ScriptsAPI: POST /api/scripts/oknte/configs/batch-update
    ScriptsAPI->>FS: merge & write JSON files
    ScriptsAPI-->>OknteService: updated_files
    OknteService-->>OkNteConfigEditor: success
    OkNteConfigEditor-->>User: show "配置已保存"
Loading

File-Level Changes

Change Details Files
Introduce OK-NTE-specific script and user configuration models and wire them into the global configuration system and schema.
  • Add OkNteUserConfig and OkNteConfig classes in the core config model, defining Info/Task/Data/Notify and Script/Game/Run sections tailored to OK-NTE usage, including task index defaults, tag generation, and per-user statistics.
  • Register OkNteConfig and OkNteUserConfig in ToolsConfig.ScriptConfig, CLASS_BOOK, and global config add_script/add_user flows so OK-NTE scripts and users can be created, updated, and listed like existing script types.
  • Extend Pydantic schemas to include OkNteConfig and OkNteUserConfig in Script/User index items, create/get/update payload unions, and script creation type literals.
app/models/config.py
app/models/schema.py
app/core/config.py
app/utils/constants.py
Add backend OK-NTE task execution pipeline, including automatic per-user JSON config management and log-based success/failure detection.
  • Implement AutoProxyTask to run OK-NTE with -t N -e based on per-user TaskIndex/ExitOnFinish, manage script and game processes via ProcessManager, and interpret OK-NTE logs (with built-in fatal patterns and configurable success/error substrings).
  • Mirror General/SRC/MaaEnd behavior: manage per-user MAS-side ConfigFile directories, copy initial configs from legacy or installation paths, optionally write back updated configs depending on UpdateConfigMode, and persist LastProxyStatus/LastTaskIndex/RemainedDay/ProxyTimes.
  • Introduce OkNteManager as a TaskExecuteBase wrapper that locks script config, clones UserData into a MultipleConfig, orchestrates AutoProxyTask across eligible users, manages optional game lifecycle (LaunchBeforeTask/CloseOnFinish), restores original script configs from temp, and writes back user config on completion or crash.
  • Wire OkNteManager into TaskManager.main_task so tasks for OkNteConfig scripts are executed via the new manager.
app/task/OkNte/AutoProxy.py
app/task/OkNte/manager.py
app/task/OkNte/__init__.py
app/core/task_manager.py
Expose OK-NTE per-user JSON configuration files via new FastAPI endpoints and a schema builder that infers fields from JSON plus manually curated select options and translations.
  • Add helper functions to resolve OK-NTE config directories per script/user, handle legacy Default/ConfigFile locations, and validate filenames to avoid directory traversal.
  • Implement /api/scripts/oknte/configs/list to lazily initialize a per-user ConfigFile directory from legacy or installation configs, load JSON for each known OK-NTE config file, build field definitions via build_fields_for_config, and return optionLabels plus configPath.
  • Implement /api/scripts/oknte/configs/update and /api/scripts/oknte/configs/batch-update to merge incoming data into per-user JSON files in ConfigFile, preserving existing keys.
  • Create config_schema.py to parse OK-NTE translation files (.mo/.po/.ts), define select-option catalogs per config file, group configs by task/trigger/global, map filenames to display names and task indices, and expose get_all_config_info/build_fields_for_config to the API layer.
  • Generate corresponding OpenAPI client service OknteService and body models for the new endpoints in the frontend API layer.
app/api/scripts.py
app/task/OkNte/config_schema.py
frontend/src/api/services/OknteService.ts
frontend/src/api/models/Body_update_oknte_config_api_scripts_oknte_configs_update_post.ts
frontend/src/api/models/Body_batch_update_oknte_configs_api_scripts_oknte_configs_batch_update_post.ts
Integrate OK-NTE script type into the frontend script/user management UX, including routing, typing, and shared helpers.
  • Extend ScriptType union and script config/user config discriminated unions to include OkNte*, updating script listing, detail, creation, and update types accordingly.
  • Centralize script edit-path mapping with scriptEditPathMap/getScriptEditPath, and update all script/user add/edit navigation handlers to handle 'OkNte'.
  • Update script list and table components to show OK-NTE icons, type badges, and share the ok-script-style user info tag rendering with Okww.
  • Wire OK-NTE into useScriptApi’s type mapping (SCRIPT_CREATE_TYPE_BY_SCRIPT_TYPE, SCRIPT_TYPE_BY_CONFIG_TYPE) and unify Okww/OkNte user normalization, including default TaskIndex=2 for OkNte users.
  • Register new routes for OkNteScriptEdit and OkNteUserAdd/OkNteUserEdit in the Vue router.
frontend/src/types/script.ts
frontend/src/views/Scripts.vue
frontend/src/components/ScriptTable.vue
frontend/src/composables/useScriptApi.ts
frontend/src/router/index.ts
Provide dedicated OK-NTE script and user edit UIs, including an in-app OK-NTE JSON config editor driven by backend schema.
  • Add OkNteScriptEdit.vue with sections for base Info, game management (Enable/LaunchBeforeTask/CloseOnFinish, game path auto-detection based on Neverness To Everness/HTGame.exe), and Run settings; auto-derive ScriptPath/ConfigPath/LogPath/TrackProcessExe from selected RootPath and persist changes via updateScript.
  • Add OkNteUserEdit.vue that auto-creates a user if needed, exposes Info (Id/Password/RemainedDay/Notes), Task (TaskIndex drop-down mapping to -t N, fixed ExitOnFinish=true), Notify, and embeds WebhookManager and OkNteConfigEditor for per-user JSON configs.
  • Implement OkNteConfigEditor.vue which calls the new oknte-config APIs, groups configs by logical category, infers field widgets from backend-provided field.type (bool/select/list/int/float/hotkey/string), tracks unsaved changes per file, and auto-saves on unmount via batch-update.
  • Add OkNte-related OpenAPI models (OkNteConfig*, OkNteUserConfig*) to the generated frontend API for typing support.
frontend/src/views/EditView/Script/OkNteScriptEdit.vue
frontend/src/views/EditView/User/OkNteUserEdit.vue
frontend/src/views/OkNteUserEdit/OkNteConfigEditor.vue
frontend/src/api/index.ts
frontend/src/api/models/OkNteConfig.ts
frontend/src/api/models/OkNteConfig_Info.ts
frontend/src/api/models/OkNteConfig_Script.ts
frontend/src/api/models/OkNteConfig_Game.ts
frontend/src/api/models/OkNteConfig_Run.ts
frontend/src/api/models/OkNteUserConfig.ts
frontend/src/api/models/OkNteUserConfig_Info.ts
frontend/src/api/models/OkNteUserConfig_Task.ts
frontend/src/api/models/OkNteUserConfig_Data.ts
frontend/src/api/models/OkNteUserConfig_Notify.ts

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 - 我发现了 1 个安全问题、1 个其他问题,并留下了一些整体反馈:

安全问题

  • 原生 Python xml 库容易受到 XML 外部实体(XXE)攻击。这类攻击可能会泄露机密数据,而“XML 炸弹”则可能导致拒绝服务。请不要使用该库来解析不受信任的输入。Python 文档推荐使用 defusedxml 作为替代。(link)

总体评论

  • OK-NTE API 客户端方法同时定义在通用的 Service 类和新的 OknteService 中,这会引入冗余并带来潜在混淆;建议只在一个地方保留这些端点(最好是专门的 OknteService),并删除重复实现。
  • 新的 /api/scripts/oknte/configs/list 端点声明为 POST,但只使用查询参数,并且行为上是只读的列表操作;如果能让 HTTP 动词和参数形式与语义保持一致(例如改为带 query 的 GET,或者带 body 的 POST),会让该 API 更清晰、更一致。
给 AI Agents 的提示
Please address the comments from this code review:

## Overall Comments
- The OK-NTE API client methods are defined both on the generic Service class and in the new OknteService, which introduces redundancy and potential confusion; consider keeping these endpoints in just one place (preferably the dedicated OknteService) and removing the duplicates.
- The new /api/scripts/oknte/configs/list endpoint is declared as POST but only uses query parameters and behaves like a read-only list operation; aligning the HTTP verb and parameter style with its semantics (e.g. GET with query or POST with body) would make the API clearer and more consistent.

## Individual Comments

### Comment 1
<location path="frontend/src/views/OkNteUserEdit/OkNteConfigEditor.vue" line_range="3-6" />
<code_context>
+<template>
+  <div class="oknte-config-editor">
+    <div class="editor-header">
+      <h3>OK-NTE 配置编辑</h3>
+      <a-tag v-if="hasChanges" color="warning">有未保存的更改</a-tag>
+      <a-tag v-else color="success">已保存</a-tag>
+    </div>
+
</code_context>
<issue_to_address>
**suggestion (bug_risk):** 编辑器会显示“有未保存的更改”的提示,但没有明确的保存操作,只依赖自动保存。

`hasChanges` 用来切换 `有未保存的更改` 这个标签,但 `saveAll` 只在 `onBeforeUnmount` 中被调用。当前用户无法通过 UI 主动触发保存,任何跳过卸载钩子(强制刷新、意外错误、部分路由守卫流程)的情况,都有可能导致编辑内容丢失。请添加一个明确的“保存配置”操作(例如一个调用 `saveAll(false)` 的按钮),并在 `hasChanges` 为 true 时考虑在导航时进行确认,以避免这些较重的 OK-NTE 配置数据丢失。

建议实现:

```
    <div class="editor-header">
      <h3>OK-NTE 配置编辑</h3>
      <div class="editor-header-right">
        <a-tag v-if="hasChanges" color="warning">有未保存的更改</a-tag>
        <a-tag v-else color="success">已保存</a-tag>
        <a-button
          type="primary"
          size="small"
          :disabled="!hasChanges"
          @click="saveAll(false)"
        >
          保存配置
        </a-button>
      </div>
    </div>

```

要把这一套完全接好并覆盖导航安全性,可以考虑:

1. 确保在 `<script>` 中暴露 `saveAll`,以便在模板里调用(即在 `<script setup>` 中从 `setup()` 返回,或者在传统 Options API 中放进 `setup()`/`methods`)。
2. 如果你希望在导航时进行确认,可以添加:
   -`onMounted`/`onBeforeUnmount` 中添加 `window.beforeunload` 监听器,在 `hasChanges` 为 true 时设置 `event.returnValue` 为某个提示信息。
   - 使用 `vue-router``onBeforeRouteLeave` 守卫,在 `hasChanges` 为 true 时弹出 Ant Design Vue 的确认对话框,在用户确认后再允许路由跳转。
3. 由于我看不到 `<script>` 部分,请按现有风格集成这些钩子(Composition API 或 Options API),并复用现有的 `hasChanges` ref/状态,而不是新增一套标志位。
</issue_to_address>

### Comment 2
<location path="app/task/OkNte/config_schema.py" line_range="105" />
<code_context>
        root = ElementTree.parse(str(ts_path)).getroot()
</code_context>
<issue_to_address>
**security (python.lang.security.use-defused-xml-parse):** 原生 Python `xml` 库容易受到 XML 外部实体(XXE)攻击。这类攻击可能泄露机密数据,而“XML 炸弹”可能导致拒绝服务。请不要使用该库来解析不受信任的输入。Python 文档推荐使用 `defusedxml` 作为替代。

```suggestion
        root = defusedxml.etree.ElementTree.parse(str(ts_path)).getroot()
```

*Source: opengrep*
</issue_to_address>

Sourcery 对开源项目免费——如果你觉得我们的评审有帮助,请考虑分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English

Hey - I've found 1 security issue, 1 other issue, and left some high level feedback:

Security issues:

  • The native Python xml library is vulnerable to XML External Entity (XXE) attacks. These attacks can leak confidential data and "XML bombs" can cause denial of service. Do not use this library to parse untrusted input. Instead the Python documentation recommends using defusedxml. (link)

General comments:

  • The OK-NTE API client methods are defined both on the generic Service class and in the new OknteService, which introduces redundancy and potential confusion; consider keeping these endpoints in just one place (preferably the dedicated OknteService) and removing the duplicates.
  • The new /api/scripts/oknte/configs/list endpoint is declared as POST but only uses query parameters and behaves like a read-only list operation; aligning the HTTP verb and parameter style with its semantics (e.g. GET with query or POST with body) would make the API clearer and more consistent.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The OK-NTE API client methods are defined both on the generic Service class and in the new OknteService, which introduces redundancy and potential confusion; consider keeping these endpoints in just one place (preferably the dedicated OknteService) and removing the duplicates.
- The new /api/scripts/oknte/configs/list endpoint is declared as POST but only uses query parameters and behaves like a read-only list operation; aligning the HTTP verb and parameter style with its semantics (e.g. GET with query or POST with body) would make the API clearer and more consistent.

## Individual Comments

### Comment 1
<location path="frontend/src/views/OkNteUserEdit/OkNteConfigEditor.vue" line_range="3-6" />
<code_context>
+<template>
+  <div class="oknte-config-editor">
+    <div class="editor-header">
+      <h3>OK-NTE 配置编辑</h3>
+      <a-tag v-if="hasChanges" color="warning">有未保存的更改</a-tag>
+      <a-tag v-else color="success">已保存</a-tag>
+    </div>
+
</code_context>
<issue_to_address>
**suggestion (bug_risk):** The editor shows an unsaved-changes indicator but has no explicit save action, relying only on auto-save.

`hasChanges` toggles the `有未保存的更改` tag, but `saveAll` is only invoked in `onBeforeUnmount`. Users currently have no way to trigger a save from the UI, and any flow that skips the unmount hook (hard reload, unexpected error, some route-guard flows) risks losing edits. Please add an explicit “保存配置” action (e.g. a button calling `saveAll(false)`) and consider confirming navigation when `hasChanges` is true to avoid data loss for these heavier OK-NTE configs.

Suggested implementation:

```
    <div class="editor-header">
      <h3>OK-NTE 配置编辑</h3>
      <div class="editor-header-right">
        <a-tag v-if="hasChanges" color="warning">有未保存的更改</a-tag>
        <a-tag v-else color="success">已保存</a-tag>
        <a-button
          type="primary"
          size="small"
          :disabled="!hasChanges"
          @click="saveAll(false)"
        >
          保存配置
        </a-button>
      </div>
    </div>

```

To fully wire this up and cover navigation safety:

1. Ensure `saveAll` is exposed in the `<script>` so it can be called from the template (i.e. returned from `setup()` in `<script setup>` or from `setup()`/`methods` in the options API).
2. If you want navigation confirmation, add:
   - A `window.beforeunload` listener in `onMounted`/`onBeforeUnmount` that checks `hasChanges` and sets `event.returnValue` to a message when true.
   - An `onBeforeRouteLeave` guard from `vue-router` that checks `hasChanges` and shows an Ant Design Vue confirmation modal before allowing route changes.
3. Since I can't see the `<script>` section, please integrate these hooks in the same style already used (Composition API vs Options API) and reuse the existing `hasChanges` ref/state instead of introducing new flags.
</issue_to_address>

### Comment 2
<location path="app/task/OkNte/config_schema.py" line_range="105" />
<code_context>
        root = ElementTree.parse(str(ts_path)).getroot()
</code_context>
<issue_to_address>
**security (python.lang.security.use-defused-xml-parse):** The native Python `xml` library is vulnerable to XML External Entity (XXE) attacks.  These attacks can leak confidential data and "XML bombs" can cause denial of service. Do not use this library to parse untrusted input. Instead  the Python documentation recommends using `defusedxml`.

```suggestion
        root = defusedxml.etree.ElementTree.parse(str(ts_path)).getroot()
```

*Source: opengrep*
</issue_to_address>

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.

Comment on lines +3 to +6
<div class="editor-header">
<h3>OK-NTE 配置编辑</h3>
<a-tag v-if="hasChanges" color="warning">有未保存的更改</a-tag>
<a-tag v-else color="success">已保存</a-tag>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (bug_risk): 编辑器会显示“有未保存的更改”的提示,但没有明确的保存操作,只依赖自动保存。

hasChanges 用来切换 有未保存的更改 这个标签,但 saveAll 只在 onBeforeUnmount 中被调用。当前用户无法通过 UI 主动触发保存,任何跳过卸载钩子(强制刷新、意外错误、部分路由守卫流程)的情况,都有可能导致编辑内容丢失。请添加一个明确的“保存配置”操作(例如一个调用 saveAll(false) 的按钮),并在 hasChanges 为 true 时考虑在导航时进行确认,以避免这些较重的 OK-NTE 配置数据丢失。

建议实现:

    <div class="editor-header">
      <h3>OK-NTE 配置编辑</h3>
      <div class="editor-header-right">
        <a-tag v-if="hasChanges" color="warning">有未保存的更改</a-tag>
        <a-tag v-else color="success">已保存</a-tag>
        <a-button
          type="primary"
          size="small"
          :disabled="!hasChanges"
          @click="saveAll(false)"
        >
          保存配置
        </a-button>
      </div>
    </div>

要把这一套完全接好并覆盖导航安全性,可以考虑:

  1. 确保在 <script> 中暴露 saveAll,以便在模板里调用(即在 <script setup> 中从 setup() 返回,或者在传统 Options API 中放进 setup()/methods)。
  2. 如果你希望在导航时进行确认,可以添加:
    • onMounted/onBeforeUnmount 中添加 window.beforeunload 监听器,在 hasChanges 为 true 时设置 event.returnValue 为某个提示信息。
    • 使用 vue-routeronBeforeRouteLeave 守卫,在 hasChanges 为 true 时弹出 Ant Design Vue 的确认对话框,在用户确认后再允许路由跳转。
  3. 由于我看不到 <script> 部分,请按现有风格集成这些钩子(Composition API 或 Options API),并复用现有的 hasChanges ref/状态,而不是新增一套标志位。
Original comment in English

suggestion (bug_risk): The editor shows an unsaved-changes indicator but has no explicit save action, relying only on auto-save.

hasChanges toggles the 有未保存的更改 tag, but saveAll is only invoked in onBeforeUnmount. Users currently have no way to trigger a save from the UI, and any flow that skips the unmount hook (hard reload, unexpected error, some route-guard flows) risks losing edits. Please add an explicit “保存配置” action (e.g. a button calling saveAll(false)) and consider confirming navigation when hasChanges is true to avoid data loss for these heavier OK-NTE configs.

Suggested implementation:

    <div class="editor-header">
      <h3>OK-NTE 配置编辑</h3>
      <div class="editor-header-right">
        <a-tag v-if="hasChanges" color="warning">有未保存的更改</a-tag>
        <a-tag v-else color="success">已保存</a-tag>
        <a-button
          type="primary"
          size="small"
          :disabled="!hasChanges"
          @click="saveAll(false)"
        >
          保存配置
        </a-button>
      </div>
    </div>

To fully wire this up and cover navigation safety:

  1. Ensure saveAll is exposed in the <script> so it can be called from the template (i.e. returned from setup() in <script setup> or from setup()/methods in the options API).
  2. If you want navigation confirmation, add:
    • A window.beforeunload listener in onMounted/onBeforeUnmount that checks hasChanges and sets event.returnValue to a message when true.
    • An onBeforeRouteLeave guard from vue-router that checks hasChanges and shows an Ant Design Vue confirmation modal before allowing route changes.
  3. Since I can't see the <script> section, please integrate these hooks in the same style already used (Composition API vs Options API) and reuse the existing hasChanges ref/state instead of introducing new flags.

"""解析 Qt .ts 翻译文件(ok-script 框架级翻译)。"""
labels: dict[str, str] = {}
try:
root = ElementTree.parse(str(ts_path)).getroot()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

security (python.lang.security.use-defused-xml-parse): 原生 Python xml 库容易受到 XML 外部实体(XXE)攻击。这类攻击可能泄露机密数据,而“XML 炸弹”可能导致拒绝服务。请不要使用该库来解析不受信任的输入。Python 文档推荐使用 defusedxml 作为替代。

Suggested change
root = ElementTree.parse(str(ts_path)).getroot()
root = defusedxml.etree.ElementTree.parse(str(ts_path)).getroot()

Source: opengrep

Original comment in English

security (python.lang.security.use-defused-xml-parse): The native Python xml library is vulnerable to XML External Entity (XXE) attacks. These attacks can leak confidential data and "XML bombs" can cause denial of service. Do not use this library to parse untrusted input. Instead the Python documentation recommends using defusedxml.

Suggested change
root = ElementTree.parse(str(ts_path)).getroot()
root = defusedxml.etree.ElementTree.parse(str(ts_path)).getroot()

Source: opengrep

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