mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
chore: 禁止普通用户使用不安全插件,比如复制到本机、自定义js脚本等
This commit is contained in:
@@ -4,7 +4,7 @@ import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput
|
||||
name: 'RestartCertd',
|
||||
title: '重启Certd',
|
||||
icon: 'mdi:restart',
|
||||
desc: '延迟一定时间后自动杀死自己,然后通过Docker来自动重启',
|
||||
desc: '【仅管理员】延迟一定时间后自动杀死自己,然后通过Docker来自动重启',
|
||||
group: pluginGroups.other.key,
|
||||
default: {
|
||||
strategy: {
|
||||
@@ -25,6 +25,9 @@ export class RestartCertdPlugin extends AbstractTaskPlugin {
|
||||
delay = 30;
|
||||
async onInstance() {}
|
||||
async execute(): Promise<void> {
|
||||
if (!this.isAdmin()) {
|
||||
throw new Error('只有管理员才能运行此任务');
|
||||
}
|
||||
this.logger.info(`Certd 将在 ${this.delay} 秒后关闭`);
|
||||
setTimeout(() => {
|
||||
this.logger.info('重启 Certd');
|
||||
|
||||
@@ -9,8 +9,8 @@ export type CustomScriptContext = {
|
||||
@IsTaskPlugin({
|
||||
name: 'CustomScript',
|
||||
title: '自定义js脚本',
|
||||
icon:"ri:javascript-line",
|
||||
desc: '测试',
|
||||
icon: 'ri:javascript-line',
|
||||
desc: '【仅管理员】运行自定义js脚本执行',
|
||||
group: pluginGroups.other.key,
|
||||
default: {
|
||||
strategy: {
|
||||
@@ -45,6 +45,9 @@ export class CustomScriptPlugin extends AbstractTaskPlugin {
|
||||
|
||||
async onInstance() {}
|
||||
async execute(): Promise<void> {
|
||||
if (!this.isAdmin()) {
|
||||
throw new Error('只有管理员才能运行此任务');
|
||||
}
|
||||
this.logger.info('执行自定义脚本:\n', this.script);
|
||||
const ctx: CustomScriptContext = {
|
||||
CertReader,
|
||||
|
||||
Reference in New Issue
Block a user