Skip to content

Fix Python scripts failing to read relative paths in subdirectories + upgrade multer to patch DoS vulns#2961

Draft
Copilot wants to merge 3 commits intodevelopfrom
copilot/fix-python-relative-path-issue
Draft

Fix Python scripts failing to read relative paths in subdirectories + upgrade multer to patch DoS vulns#2961
Copilot wants to merge 3 commits intodevelopfrom
copilot/fix-python-relative-path-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 7, 2026

Python scripts in subdirectories (e.g. btdr/app.py) had their working directory set to $dir_scripts root instead of the script's own directory, breaking relative file access like open('./config.json').

Root cause

run_normal() in shell/otask.sh had an [[ ${file_param} != /* ]] guard that skipped the cd into the script's subdirectory for absolute paths. run_concurrent() and run_designated() had no such guard and worked correctly.

Changes

shell/otask.sh

  • Removed [[ ${file_param} != /* ]] && from the run_normal() path-handling condition — CWD is now correctly set to the script's directory for both relative and absolute invocations, consistent with the other run modes.
# Before — absolute paths skipped the cd, CWD stayed at $dir_scripts
if [[ ${file_param} != /* ]] && [[ ! -z ${relative_path} ]] && [[ ${file_param} =~ "/" ]]; then

# After — all paths with a directory component cd into the script's directory
if [[ ! -z ${relative_path} ]] && [[ ${file_param} =~ "/" ]]; then

shell/preload/sitecustomize.py

  • Use os.path.abspath(sys.argv[0]) instead of bare sys.argv[0] when computing the script's relative path from dir_scripts. When Python is invoked as python3 app.py from a subdirectory, sys.argv[0] is just app.py; abspath resolves it to the full path first so task_before.sh receives btdr/app.py rather than a bare filename.

package.json / pnpm-lock.yaml

  • Upgraded multer 1.4.5-lts.12.1.1 and @types/multer ^1.4.7^2.0.0 to address 7 DoS CVEs (uncontrolled recursion, resource exhaustion, memory leaks from unclosed streams, unhandled exceptions from malformed requests). The v2 API is backwards-compatible with all usage in this codebase.
Original prompt

This section details on the original issue you should resolve

<issue_title>创建容器python读取不到相对路径</issue_title>
<issue_description>### Qinglong version

2.20.2

Steps to reproduce

Traceback (most recent call last):
File "/ql/data/scripts/btdr/app.py", line 32, in
with open('config.yaml', 'r', encoding='utf-8') as f:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'config.yaml'

app.py和config.yaml在同一个文件夹目录下,
之前程序可以跑, 被攻击后删除重新建, 升级最新版本都一样, 执行python的路径正常, 但是python运行的时候它获取当前目录不是程序所在目录, 写出config.yaml的绝对路径是可以运行的, 因为很多脚本包括以后写的都使用程序所在目录读取文件,所以这个问题怎么解决 ,

What is expected?

What is actually happening?

System Info

Any additional comments?

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
qinglong Ready Ready Preview, Comment Mar 7, 2026 1:45pm
qinglong-back Ready Ready Preview, Comment Mar 7, 2026 1:45pm

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix relative path issue for config.yaml in Python script Fix Python scripts failing to read relative paths in subdirectories + upgrade multer to patch DoS vulns Mar 7, 2026
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.

创建容器python读取不到相对路径

2 participants