mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 01:39:52 +08:00
fix(security): protect system app and task file boundaries
This commit is contained in:
1 parent
487b213dd8
commit
b49b0b63e6
6 files changed
+52
-3
No files matched your search
@@ -8,6 +8,6 @@ export default class LogService {
|
||||
constructor(@Inject('logger') private logger: winston.Logger) {}
|
||||
|
||||
public checkFilePath(filePath: string, fileName: string) {
|
||||
return resolveFileAccess(config.logPath, [filePath || '', fileName]);
|
||||
return resolveFileAccess(config.logPath, [filePath || '', fileName], ['.tmp']);
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,10 @@ export default class OpenService {
|
||||
|
||||
private async updateDb(payload: Partial<App>): Promise<App> {
|
||||
return this.withAppsLock(async () => {
|
||||
const target = await AppModel.findOne({ where: { id: payload.id } });
|
||||
if (target?.name === 'system' || payload.name === 'system') {
|
||||
throw Object.assign(new Error(t('暂无权限')), { status: 403 });
|
||||
}
|
||||
await AppModel.update(payload, { where: { id: payload.id } });
|
||||
const apps = await this.find({});
|
||||
await shareStore.updateApps(apps);
|
||||
@@ -109,6 +113,12 @@ export default class OpenService {
|
||||
|
||||
public async remove(ids: number[]) {
|
||||
return this.withAppsLock(async () => {
|
||||
const systemApp = await AppModel.findOne({
|
||||
where: { id: ids, name: 'system' },
|
||||
});
|
||||
if (systemApp) {
|
||||
throw Object.assign(new Error(t('暂无权限')), { status: 403 });
|
||||
}
|
||||
await AppModel.destroy({ where: { id: ids } });
|
||||
const apps = await this.find({});
|
||||
await shareStore.updateApps(apps);
|
||||
|
||||
@@ -6,6 +6,7 @@ import { t } from './i18n';
|
||||
const reservedNames = new Set([
|
||||
'TASK_BEFORE',
|
||||
'TASK_AFTER',
|
||||
'WORK_DIR',
|
||||
'PATH',
|
||||
'HOME',
|
||||
'SHELL',
|
||||
|
||||
Reference in new issue
Block a user