chore: 禁止普通用户使用不安全插件,比如复制到本机、自定义js脚本等

This commit is contained in:
xiaojunnuo
2024-09-29 01:14:21 +08:00
parent 5aa06f5b07
commit 4fcaab5feb
10 changed files with 70 additions and 27 deletions

View File

@@ -9,7 +9,10 @@ import { ILogger, logger, utils } from "../utils/index.js";
import { HttpClient } from "../utils/util.request";
import dayjs from "dayjs";
import _ from "lodash-es";
export type UserInfo = {
role: "admin" | "user";
id: any;
};
export enum ContextScope {
global,
pipeline,
@@ -81,6 +84,8 @@ export type TaskInstanceContext = {
signal: AbortSignal;
//工具类
utils: typeof utils;
user: UserInfo;
};
export abstract class AbstractTaskPlugin implements ITaskPlugin {
@@ -170,6 +175,10 @@ export abstract class AbstractTaskPlugin implements ITaskPlugin {
}
throw new Error(`action ${req.action} not found`);
}
isAdmin() {
return this.ctx.user.role === "admin";
}
}
export type OutputVO = {