mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-01 04:40:38 +08:00
修复路径穿越
This commit is contained in:
@@ -78,6 +78,12 @@ export default (app: Router) => {
|
||||
if (name.startsWith('data/scripts/')) {
|
||||
path = join(config.rootPath, name);
|
||||
}
|
||||
if (
|
||||
!path.startsWith(config.configPath) &&
|
||||
!path.startsWith(config.scriptPath)
|
||||
) {
|
||||
return res.send({ code: 403, message: '文件路径无效' });
|
||||
}
|
||||
await writeFileWithLock(path, content);
|
||||
res.send({ code: 200, message: '保存成功' });
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user