mirror of
https://github.com/whyour/qinglong.git
synced 2026-08-11 19:05:20 +08:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4926f6f625 | ||
|
|
f73059ec71 |
+10
-35
@@ -13,29 +13,9 @@ import { isValidToken } from '../shared/auth';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
export default ({ app }: { app: Application }) => {
|
export default ({ app }: { app: Application }) => {
|
||||||
// Security: Enable strict routing to prevent case-insensitive path bypass
|
|
||||||
app.set('case sensitive routing', true);
|
|
||||||
app.set('strict routing', true);
|
|
||||||
app.set('trust proxy', 'loopback');
|
app.set('trust proxy', 'loopback');
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
|
|
||||||
// Security: Path normalization middleware to prevent case variation attacks
|
|
||||||
app.use((req, res, next) => {
|
|
||||||
const originalPath = req.path;
|
|
||||||
const normalizedPath = originalPath.toLowerCase();
|
|
||||||
|
|
||||||
// Block requests with case variations on protected paths
|
|
||||||
if (originalPath !== normalizedPath &&
|
|
||||||
(normalizedPath.startsWith('/api/') || normalizedPath.startsWith('/open/'))) {
|
|
||||||
return res.status(400).json({
|
|
||||||
code: 400,
|
|
||||||
message: 'Invalid path format'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Rewrite URLs to strip baseUrl prefix if configured
|
// Rewrite URLs to strip baseUrl prefix if configured
|
||||||
// This allows the rest of the app to work without baseUrl awareness
|
// This allows the rest of the app to work without baseUrl awareness
|
||||||
if (config.baseUrl) {
|
if (config.baseUrl) {
|
||||||
@@ -56,7 +36,7 @@ export default ({ app }: { app: Application }) => {
|
|||||||
secret: config.jwt.secret,
|
secret: config.jwt.secret,
|
||||||
algorithms: ['HS384'],
|
algorithms: ['HS384'],
|
||||||
}).unless({
|
}).unless({
|
||||||
path: [...config.apiWhiteList, /^(\/(?!api\/).*)$/i],
|
path: [...config.apiWhiteList, /^\/(?!api\/).*/],
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -71,20 +51,19 @@ export default ({ app }: { app: Application }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.use(async (req: Request, res, next) => {
|
app.use(async (req: Request, res, next) => {
|
||||||
const pathLower = req.path.toLowerCase();
|
if (!['/open/', '/api/'].some((x) => req.path.startsWith(x))) {
|
||||||
if (!['/open/', '/api/'].some((x) => pathLower.startsWith(x))) {
|
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
const headerToken = getToken(req);
|
const headerToken = getToken(req);
|
||||||
if (pathLower.startsWith('/open/')) {
|
if (req.path.startsWith('/open/')) {
|
||||||
const apps = await shareStore.getApps();
|
const apps = await shareStore.getApps();
|
||||||
const doc = apps?.filter((x) =>
|
const doc = apps?.filter((x) =>
|
||||||
x.tokens?.find((y) => y.value === headerToken),
|
x.tokens?.find((y) => y.value === headerToken),
|
||||||
)?.[0];
|
)?.[0];
|
||||||
if (doc && doc.tokens && doc.tokens.length > 0) {
|
if (doc && doc.tokens && doc.tokens.length > 0) {
|
||||||
const currentToken = doc.tokens.find((x) => x.value === headerToken);
|
const currentToken = doc.tokens.find((x) => x.value === headerToken);
|
||||||
const keyMatch = pathLower.match(/\/open\/([a-z]+)\/*/);
|
const keyMatch = req.path.match(/\/open\/([a-z]+)\/*/);
|
||||||
const key = keyMatch && keyMatch[1];
|
const key = keyMatch && keyMatch[1];
|
||||||
if (
|
if (
|
||||||
doc.scopes.includes(key as any) &&
|
doc.scopes.includes(key as any) &&
|
||||||
@@ -119,15 +98,7 @@ export default ({ app }: { app: Application }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.use(async (req, res, next) => {
|
app.use(async (req, res, next) => {
|
||||||
const pathLower = req.path.toLowerCase();
|
if (!['/api/user/init', '/api/user/notification/init'].includes(req.path)) {
|
||||||
if (
|
|
||||||
![
|
|
||||||
'/api/user/init',
|
|
||||||
'/api/user/notification/init',
|
|
||||||
'/open/user/init',
|
|
||||||
'/open/user/notification/init',
|
|
||||||
].includes(req.path)
|
|
||||||
) {
|
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
const authInfo =
|
const authInfo =
|
||||||
@@ -152,7 +123,11 @@ export default ({ app }: { app: Application }) => {
|
|||||||
app.use(rewrite('/open/*', '/api/$1'));
|
app.use(rewrite('/open/*', '/api/$1'));
|
||||||
app.use(config.api.prefix, routes());
|
app.use(config.api.prefix, routes());
|
||||||
|
|
||||||
app.get('*', (_, res, next) => {
|
app.get('*', (req, res, next) => {
|
||||||
|
// Don't serve index.html for API routes
|
||||||
|
if (req.path.startsWith('/api/')) {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
const indexPath = path.join(frontendPath, 'index.html');
|
const indexPath = path.join(frontendPath, 'index.html');
|
||||||
res.sendFile(indexPath, (err) => {
|
res.sendFile(indexPath, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
@@ -467,10 +467,7 @@ export default class CronService {
|
|||||||
for (const doc of docs) {
|
for (const doc of docs) {
|
||||||
// Kill all running instances of this task
|
// Kill all running instances of this task
|
||||||
try {
|
try {
|
||||||
if (doc.pid) {
|
const command = this.makeCommand(doc);
|
||||||
await killTask(doc.pid);
|
|
||||||
}
|
|
||||||
const command = doc.command.replace(/\s+/g, ' ').trim();
|
|
||||||
await killAllTasks(command);
|
await killAllTasks(command);
|
||||||
this.logger.info(
|
this.logger.info(
|
||||||
`[panel][停止所有运行中的任务实例] 任务ID: ${doc.id}, 命令: ${command}`,
|
`[panel][停止所有运行中的任务实例] 任务ID: ${doc.id}, 命令: ${command}`,
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import {
|
|||||||
stepPosition,
|
stepPosition,
|
||||||
} from '../data/env';
|
} from '../data/env';
|
||||||
import { writeFileWithLock } from '../shared/utils';
|
import { writeFileWithLock } from '../shared/utils';
|
||||||
import { sequelize } from '../data';
|
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export default class EnvService {
|
export default class EnvService {
|
||||||
@@ -147,7 +146,7 @@ export default class EnvService {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const result = await this.find(condition, [
|
const result = await this.find(condition, [
|
||||||
[sequelize.literal('COALESCE(`isPinned`, 0)'), 'DESC'],
|
['isPinned', 'DESC'],
|
||||||
['position', 'DESC'],
|
['position', 'DESC'],
|
||||||
['createdAt', 'ASC'],
|
['createdAt', 'ASC'],
|
||||||
]);
|
]);
|
||||||
|
|||||||
+46
-10
@@ -1,11 +1,47 @@
|
|||||||
version: 2.20.1
|
version: 2.20.0
|
||||||
changeLogLink: https://t.me/jiao_long/433
|
changeLogLink: https://t.me/jiao_long/432
|
||||||
publishTime: 2025-12-26 22:00
|
publishTime: 2025-12-10 01:05
|
||||||
changeLog: |
|
changeLog: |
|
||||||
1. 修复获取依赖管理列表
|
1. 定时任务(cron / task)相关的大量修复 & 增强
|
||||||
2. notify.js 修复 TG_PROXY_AUTH 参数拼接
|
|
||||||
3. QLAPI.notify larkSecret 参数
|
修复 cron 解析错误(修复 parse cron / 升级 cron-parser)
|
||||||
4. 修复 cron parser 定时规则校验
|
修复集群模式下定时任务可能不执行(race condition)
|
||||||
5. 修复设置 baseUrl 后无法访问
|
定时任务支持订阅筛选
|
||||||
6. 修复环境变量排序
|
定时任务支持排序调整
|
||||||
7. 修复定时任务无法停止
|
定时任务支持自定义日志文件或无日志
|
||||||
|
修复任务实例默认值
|
||||||
|
任务支持单实例 / 多实例模式
|
||||||
|
修复 task 命令软链可能失败问题
|
||||||
|
|
||||||
|
2. 日志系统相关的大更新
|
||||||
|
|
||||||
|
修复日志目录逻辑
|
||||||
|
修复 pm2 日志目录
|
||||||
|
优化日志写入(stream pooling)
|
||||||
|
|
||||||
|
3. 环境变量(env)系统的改进与修复
|
||||||
|
|
||||||
|
修复环境变量复制到剪贴板时可能失败
|
||||||
|
添加环境变量“置顶”功能
|
||||||
|
修复 QlPort 与 QlGrpcPort 环境变量在 host network 模式下被忽略
|
||||||
|
增加全局 SSH 私钥配置
|
||||||
|
|
||||||
|
4. Docker / 非 root 用户 / Alpine 兼容性增强
|
||||||
|
|
||||||
|
新增非 root Docker 用户支持,自动初始化命令
|
||||||
|
修复 Alpine 容器 DNS 解析失败(设置 ndots:0)
|
||||||
|
修复 PM2 在 ARM 路由器(Node.js 不兼容)上的启动失败
|
||||||
|
移除 nginx(可能是考虑更轻量的镜像运行)
|
||||||
|
|
||||||
|
5. API 安全与校验增强
|
||||||
|
|
||||||
|
Dependencies GET endpoint 增加校验
|
||||||
|
Script API routes 增加输入校验
|
||||||
|
修复 JWT 认证问题
|
||||||
|
Feishu 机器人通知增加签名校验
|
||||||
|
QLAPI 增加 cron task 管理功能
|
||||||
|
修复 URIError(错误 cookie 导致白屏)
|
||||||
|
|
||||||
|
6. 系统设置
|
||||||
|
|
||||||
|
新增多终端/多平台的并发登录会话支持
|
||||||
Reference in New Issue
Block a user