pref: 日志中加密授权信息输出替换成星号

pull/370/head
xiaojunnuo 2025-04-12 00:14:55 +08:00
parent 3d9620abb0
commit 759cfdaabd
46 changed files with 122 additions and 88 deletions

View File

@ -1,4 +1,4 @@
import log4js, { LoggingEvent, Logger } from 'log4js';
import log4js, { LoggingEvent, Logger } from "log4js";
const OutputAppender = {
configure: (config: any, layouts: any, findAppender: any, levels: any) => {
@ -21,17 +21,29 @@ const OutputAppender = {
export function resetLogConfigure() {
// @ts-ignore
log4js.configure({
appenders: { std: { type: 'stdout' }, output: { type: OutputAppender } },
categories: { default: { appenders: ['std'], level: 'info' }, pipeline: { appenders: ['std', 'output'], level: 'info' } },
appenders: { std: { type: "stdout" }, output: { type: OutputAppender } },
categories: { default: { appenders: ["std"], level: "info" }, pipeline: { appenders: ["std", "output"], level: "info" } },
});
}
resetLogConfigure();
export const logger = log4js.getLogger('default');
export const logger = log4js.getLogger("default");
export function buildLogger(write: (text: string) => void) {
const logger = log4js.getLogger('pipeline');
logger.addContext('outputHandler', {
write,
const logger = log4js.getLogger("pipeline");
const _secrets: string[] = [];
//@ts-ignore
logger.addSecret = (secret: string) => {
_secrets.push(secret);
};
logger.addContext("outputHandler", {
write: (text: string) => {
for (const item of _secrets) {
//换成同长度的*号, item可能有多行
const reg = new RegExp(item, "g");
text = text.replaceAll(reg, "*".repeat(item.length));
write(text);
}
},
});
return logger;
}

View File

@ -57,5 +57,6 @@ export function newAccess(type: string, input: any, ctx?: AccessContext) {
};
}
access.setCtx(ctx);
access._type = type;
return access;
}

View File

@ -150,11 +150,11 @@ export class RunnableCollection {
pipeline.stages = [];
return;
}
pipeline.stages.forEach((stage) => {
pipeline.stages.forEach(stage => {
stage.runnableType = "stage";
stage.tasks.forEach((task) => {
stage.tasks.forEach(task => {
task.runnableType = "task";
task.steps.forEach((step) => {
task.steps.forEach(step => {
step.runnableType = "step";
});
});
@ -162,7 +162,7 @@ export class RunnableCollection {
}
static each<T extends Runnable>(list: T[], exec: (item: Runnable) => void) {
list.forEach((item) => {
list.forEach(item => {
exec(item);
if (item.runnableType === "pipeline") {
// @ts-ignore
@ -179,7 +179,7 @@ export class RunnableCollection {
public toMap(pipeline: Pipeline) {
const map: RunnableMap = {};
RunnableCollection.each(pipeline.stages, (item) => {
RunnableCollection.each(pipeline.stages, item => {
map[item.id] = item;
});
return map;
@ -193,7 +193,7 @@ export class RunnableCollection {
if (!this.pipeline) {
return;
}
RunnableCollection.each(this.pipeline.stages, (item) => {
RunnableCollection.each(this.pipeline.stages, item => {
item.status = undefined;
});
}

View File

@ -1,7 +1,7 @@
import { Registrable } from "../registry/index.js";
import { FileItem, FormItemProps, Pipeline, Runnable, Step } from "../dt/index.js";
import { FileStore } from "../core/file-store.js";
import { IAccessService } from "../access/index.js";
import { accessRegistry, IAccessService } from "../access/index.js";
import { ICnameProxyService, IEmailService, IServiceGetter, IUrlService } from "../service/index.js";
import { CancelError, IContext, RunHistory, RunnableCollection } from "../core/index.js";
import { HttpRequestConfig, ILogger, logger, utils } from "@certd/basic";
@ -158,14 +158,35 @@ export abstract class AbstractTaskPlugin implements ITaskPlugin {
this.http = ctx.http;
}
async getAccess<T = any>(accessId: string) {
async getAccess<T = any>(accessId: string | number, isCommon = false) {
if (accessId == null) {
throw new Error("您还没有配置授权");
}
const res = await this.ctx.accessService.getById(accessId);
let res: any = null;
if (isCommon) {
res = await this.ctx.accessService.getCommonById(accessId);
} else {
res = await this.ctx.accessService.getById(accessId);
}
if (res == null) {
throw new Error("授权不存在,可能已被删除,请前往任务配置里面重新选择授权");
}
// @ts-ignore
if (this.logger?.addSecret) {
// 隐藏加密信息,不在日志中输出
const type = res._type;
const plugin = accessRegistry.get(type);
const define = plugin.define;
// @ts-ignore
const input = define.input;
for (const key in input) {
if (input[key].encrypt) {
// @ts-ignore
this.logger.addSecret(res[key]);
}
}
}
return res as T;
}

View File

@ -288,7 +288,7 @@ HTTP文件验证不支持泛域名需要配置网站文件上传`,
if (this.sslProvider === "google") {
if (this.googleAccessId) {
this.logger.info("当前正在使用 google服务账号授权获取EAB");
const googleAccess = await this.ctx.accessService.getById(this.googleAccessId);
const googleAccess = await this.getAccess(this.googleAccessId);
const googleClient = new GoogleClient({
access: googleAccess,
logger: this.logger,
@ -296,20 +296,20 @@ HTTP文件验证不支持泛域名需要配置网站文件上传`,
eab = await googleClient.getEab();
} else if (this.eabAccessId) {
this.logger.info("当前正在使用 google EAB授权");
eab = await this.ctx.accessService.getById(this.eabAccessId);
eab = await this.getAccess(this.eabAccessId);
} else if (this.googleCommonEabAccessId) {
this.logger.info("当前正在使用 google公共EAB授权");
eab = await this.ctx.accessService.getCommonById(this.googleCommonEabAccessId);
eab = await this.getAccess(this.googleCommonEabAccessId, true);
} else {
throw new Error("google需要配置EAB授权或服务账号授权");
}
} else if (this.sslProvider === "zerossl") {
if (this.eabAccessId) {
this.logger.info("当前正在使用 zerossl EAB授权");
eab = await this.ctx.accessService.getById(this.eabAccessId);
eab = await this.getAccess(this.eabAccessId);
} else if (this.zerosslCommonEabAccessId) {
this.logger.info("当前正在使用 zerossl 公共EAB授权");
eab = await this.ctx.accessService.getCommonById(this.zerosslCommonEabAccessId);
eab = await this.getAccess(this.zerosslCommonEabAccessId, true);
} else {
throw new Error("zerossl需要配置EAB授权");
}
@ -359,7 +359,7 @@ HTTP文件验证不支持泛域名需要配置网站文件上传`,
domainsVerifyPlan = await this.createDomainsVerifyPlan();
} else {
const dnsProviderType = this.dnsProviderType;
const access = await this.ctx.accessService.getById(this.dnsProviderAccess);
const access = await this.getAccess(this.dnsProviderAccess);
dnsProvider = await this.createDnsProvider(dnsProviderType, access);
}
@ -406,7 +406,7 @@ HTTP文件验证不支持泛域名需要配置网站文件上传`,
const cnameVerifyPlan: Record<string, CnameVerifyPlan> = {};
const httpVerifyPlan: Record<string, HttpVerifyPlan> = {};
if (domainVerifyPlan.type === "dns") {
const access = await this.ctx.accessService.getById(domainVerifyPlan.dnsProviderAccessId);
const access = await this.getAccess(domainVerifyPlan.dnsProviderAccessId);
dnsProvider = await this.createDnsProvider(domainVerifyPlan.dnsProviderType, access);
} else if (domainVerifyPlan.type === "cname") {
for (const key in domainVerifyPlan.cnameVerifyPlan) {
@ -430,7 +430,7 @@ HTTP文件验证不支持泛域名需要配置网站文件上传`,
};
for (const key in domainVerifyPlan.httpVerifyPlan) {
const httpRecord = domainVerifyPlan.httpVerifyPlan[key];
const access = await this.ctx.accessService.getById(httpRecord.httpUploaderAccess);
const access = await this.getAccess(httpRecord.httpUploaderAccess);
let rootDir = httpRecord.httpUploadRootDir;
if (!rootDir.endsWith("/") && !rootDir.endsWith("\\")) {
rootDir = rootDir + "/";

View File

@ -110,7 +110,7 @@ return class DemoTask extends AbstractTaskPlugin {
// 编写执行方法
async execute(){
# accessId
const access = await this.accessService.getById(this.accessId)
const access = await this.getAccess(this.accessId)
//必须使用this.logger打印日志
// this.logger.info("cert:",this.cert);

View File

@ -108,7 +108,7 @@ export class AliyunDeployCertToALB extends AbstractTaskPlugin {
async execute(): Promise<void> {
this.logger.info(`开始部署证书到阿里云(alb)`);
const access = await this.accessService.getById<AliyunAccess>(this.accessId);
const access = await this.getAccess<AliyunAccess>(this.accessId);
const certId = await this.getAliyunCertId(access);
const client = await this.getLBClient(access, this.regionId);
@ -155,7 +155,7 @@ export class AliyunDeployCertToALB extends AbstractTaskPlugin {
if (!this.accessId) {
throw new Error('请选择Access授权');
}
const access = await this.accessService.getById<AliyunAccess>(this.accessId);
const access = await this.getAccess<AliyunAccess>(this.accessId);
const client = await this.getLBClient(access, 'cn-shanghai');
const res = await client.request('DescribeRegions', {});
@ -180,7 +180,7 @@ export class AliyunDeployCertToALB extends AbstractTaskPlugin {
if (!this.regionId) {
throw new Error('请先选择地区');
}
const access = await this.accessService.getById<AliyunAccess>(this.accessId);
const access = await this.getAccess<AliyunAccess>(this.accessId);
const client = await this.getLBClient(access, this.regionId);
const params = {
@ -208,7 +208,7 @@ export class AliyunDeployCertToALB extends AbstractTaskPlugin {
if (!this.regionId) {
throw new Error('请先选择地区');
}
const access = await this.accessService.getById<AliyunAccess>(this.accessId);
const access = await this.getAccess<AliyunAccess>(this.accessId);
const client = await this.getLBClient(access, this.regionId);
const params: any = {

View File

@ -77,7 +77,7 @@ export class DeployCertToAliyunCDN extends AbstractTaskPlugin {
async onInstance() {}
async execute(): Promise<void> {
this.logger.info('开始部署证书到阿里云cdn');
const access = await this.accessService.getById<AliyunAccess>(this.accessId);
const access = await this.getAccess<AliyunAccess>(this.accessId);
const sslClient = new AliyunSslClient({
access,
logger: this.logger,
@ -151,7 +151,7 @@ export class DeployCertToAliyunCDN extends AbstractTaskPlugin {
if (!this.accessId) {
throw new Error('请选择Access授权');
}
const access = await this.accessService.getById<AliyunAccess>(this.accessId);
const access = await this.getAccess<AliyunAccess>(this.accessId);
const client = await this.getClient(access);

View File

@ -57,7 +57,7 @@ export class DeployCertToAliyunDCDN extends AbstractTaskPlugin {
async onInstance() {}
async execute(): Promise<void> {
this.logger.info('开始部署证书到阿里云DCDN');
const access = (await this.accessService.getById(this.accessId)) as AliyunAccess;
const access = (await this.getAccess(this.accessId)) as AliyunAccess;
const client = await this.getClient(access);
const params = await this.buildParams();
await this.doRequest(client, params);

View File

@ -116,7 +116,7 @@ export class AliyunDeployCertToFC extends AbstractPlusTaskPlugin {
async execute(): Promise<void> {
this.logger.info('开始部署证书到阿里云');
const access = await this.accessService.getById<AliyunAccess>(this.accessId);
const access = await this.getAccess<AliyunAccess>(this.accessId);
const client = await this.getClient(access);
@ -177,7 +177,7 @@ export class AliyunDeployCertToFC extends AbstractPlusTaskPlugin {
if (!this.accessId) {
throw new Error('请选择Access授权');
}
const access = await this.accessService.getById<AliyunAccess>(this.accessId);
const access = await this.getAccess<AliyunAccess>(this.accessId);
const client = await this.getClient(access);
const $OpenApi = await import('@alicloud/openapi-client');

View File

@ -108,7 +108,7 @@ export class AliyunDeployCertToNLB extends AbstractTaskPlugin {
async execute(): Promise<void> {
this.logger.info(`开始部署证书到阿里云(nlb)`);
const access = await this.accessService.getById<AliyunAccess>(this.accessId);
const access = await this.getAccess<AliyunAccess>(this.accessId);
const certId = await this.getAliyunCertId(access);
const client = await this.getLBClient(access, this.regionId);
@ -151,7 +151,7 @@ export class AliyunDeployCertToNLB extends AbstractTaskPlugin {
if (!this.accessId) {
throw new Error('请选择Access授权');
}
const access = await this.accessService.getById<AliyunAccess>(this.accessId);
const access = await this.getAccess<AliyunAccess>(this.accessId);
const client = await this.getLBClient(access, 'cn-shanghai');
const res = await client.request('DescribeRegions', {});
@ -176,7 +176,7 @@ export class AliyunDeployCertToNLB extends AbstractTaskPlugin {
if (!this.regionId) {
throw new Error('请先选择地区');
}
const access = await this.accessService.getById<AliyunAccess>(this.accessId);
const access = await this.getAccess<AliyunAccess>(this.accessId);
const client = await this.getLBClient(access, this.regionId);
const params = {
@ -204,7 +204,7 @@ export class AliyunDeployCertToNLB extends AbstractTaskPlugin {
if (!this.regionId) {
throw new Error('请先选择地区');
}
const access = await this.accessService.getById<AliyunAccess>(this.accessId);
const access = await this.getAccess<AliyunAccess>(this.accessId);
const client = await this.getLBClient(access, this.regionId);
const params: any = {

View File

@ -102,7 +102,7 @@ export class DeployCertToAliyunOSS extends AbstractTaskPlugin {
async onInstance() {}
async execute(): Promise<void> {
this.logger.info('开始部署证书到阿里云OSS');
const access = (await this.accessService.getById(this.accessId)) as AliyunAccess;
const access = (await this.getAccess(this.accessId)) as AliyunAccess;
this.logger.info(`bucket: ${this.bucket}, region: ${this.region}, domainName: ${this.domainName}`);
const client = await this.getClient(access);
await this.doRequest(client, {});

View File

@ -107,7 +107,7 @@ export class AliyunDeployCertToSLB extends AbstractTaskPlugin {
async execute(): Promise<void> {
this.logger.info(`开始部署证书到阿里云(slb)`);
const access = await this.accessService.getById<AliyunAccess>(this.accessId);
const access = await this.getAccess<AliyunAccess>(this.accessId);
const client = await this.getLBClient(access, this.regionId);
const aliyunCert = await this.getAliyunCertId(access);
@ -167,7 +167,7 @@ export class AliyunDeployCertToSLB extends AbstractTaskPlugin {
if (!this.accessId) {
throw new Error('请选择Access授权');
}
const access = await this.accessService.getById<AliyunAccess>(this.accessId);
const access = await this.getAccess<AliyunAccess>(this.accessId);
const client = await this.getLBClient(access, 'cn-shanghai');
const res = await client.request('DescribeRegions', {});
@ -192,7 +192,7 @@ export class AliyunDeployCertToSLB extends AbstractTaskPlugin {
if (!this.regionId) {
throw new Error('请先选择地区');
}
const access = await this.accessService.getById<AliyunAccess>(this.accessId);
const access = await this.getAccess<AliyunAccess>(this.accessId);
const client = await this.getLBClient(access, this.regionId);
const params = {
@ -221,7 +221,7 @@ export class AliyunDeployCertToSLB extends AbstractTaskPlugin {
if (!this.regionId) {
throw new Error('请先选择地区');
}
const access = await this.accessService.getById<AliyunAccess>(this.accessId);
const access = await this.getAccess<AliyunAccess>(this.accessId);
const client = await this.getLBClient(access, this.regionId);
const params: any = {

View File

@ -109,7 +109,7 @@ export class AliyunDeployCertToWaf extends AbstractPlusTaskPlugin {
async execute(): Promise<void> {
this.logger.info('开始部署证书到阿里云');
const access = await this.accessService.getById<AliyunAccess>(this.accessId);
const access = await this.getAccess<AliyunAccess>(this.accessId);
let certId: any = this.cert;
if (typeof this.cert === 'object') {
const sslClient = new AliyunSslClient({
@ -163,7 +163,7 @@ export class AliyunDeployCertToWaf extends AbstractPlusTaskPlugin {
if (!this.accessId) {
throw new Error('请选择Access授权');
}
const access = await this.accessService.getById<AliyunAccess>(this.accessId);
const access = await this.getAccess<AliyunAccess>(this.accessId);
const client = await this.getWafClient(access);
const instanceId = await this.getInstanceId(client);

View File

@ -83,7 +83,7 @@ export class UploadCertToAliyun extends AbstractTaskPlugin {
async execute(): Promise<void> {
this.logger.info('开始部署证书到阿里云cdn');
const access: AliyunAccess = await this.accessService.getById(this.accessId);
const access: AliyunAccess = await this.getAccess(this.accessId);
let endpoint = '';
for (const region of regionDict) {

View File

@ -58,7 +58,7 @@ export class AwsUploadToACM extends AbstractTaskPlugin {
async execute(): Promise<void> {
const { cert, accessId, region } = this;
const access = await this.accessService.getById<AwsAccess>(accessId);
const access = await this.getAccess<AwsAccess>(accessId);
const acmClient = new AwsAcmClient({
access,
region,

View File

@ -56,7 +56,7 @@ export class CacheFlyPlugin extends AbstractTaskPlugin {
async execute(): Promise<void> {
const { cert, accessId } = this;
const access = (await this.accessService.getById(accessId)) as CacheflyAccess;
const access = (await this.getAccess(accessId)) as CacheflyAccess;
let otp = null;
if (access.otpkey) {
const response = await this.http.request<any, any>({

View File

@ -140,7 +140,7 @@ export class DemoTest extends AbstractTaskPlugin {
const { select, text, cert, accessId } = this;
try {
const access = await this.accessService.getById(accessId);
const access = await this.getAccess(accessId);
this.logger.debug('access', access);
} catch (e) {
this.logger.error('获取授权失败', e);
@ -177,7 +177,7 @@ export class DemoTest extends AbstractTaskPlugin {
}
// @ts-ignore
const access = await this.accessService.getById(this.accessId);
const access = await this.getAccess(this.accessId);
// const siteRes = await this.ctx.http.request({
// url: '你的服务端获取选项的请求地址',

View File

@ -59,7 +59,7 @@ export class DogeCloudDeployToCDNPlugin extends AbstractTaskPlugin {
dogeClient!: DogeClient;
async onInstance() {
const access = await this.accessService.getById(this.accessId);
const access = await this.getAccess(this.accessId);
this.dogeClient = new DogeClient(access, this.ctx.http);
}
async execute(): Promise<void> {

View File

@ -66,7 +66,7 @@ export class GcoreflushPlugin extends AbstractTaskPlugin {
async execute(): Promise<void> {
const { cert, accessId } = this;
const access = (await this.accessService.getById(accessId)) as GcoreAccess;
const access = (await this.getAccess(accessId)) as GcoreAccess;
let otp = null;
if (access.otpkey) {
const response = await this.http.request<any, any>({

View File

@ -62,7 +62,7 @@ export class GcoreuploadPlugin extends AbstractTaskPlugin {
async execute(): Promise<void> {
const { cert, accessId } = this;
const access = (await this.accessService.getById(accessId)) as GcoreAccess;
const access = (await this.getAccess(accessId)) as GcoreAccess;
let otp = null;
if (access.otpkey) {
const response = await this.http.request<any, any>({

View File

@ -41,7 +41,7 @@ export class HostShellExecutePlugin extends AbstractTaskPlugin {
async onInstance() {}
async execute(): Promise<void> {
const { script, accessId } = this;
const connectConf = await this.accessService.getById(accessId);
const connectConf = await this.getAccess(accessId);
const sshClient = new SshClient(this.logger);
const scripts = script.split('\n');

View File

@ -278,7 +278,7 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
this.logger.error('复制到当前主机功能已迁移到 “复制到本机”插件,请换成复制到本机插件');
return;
}
const connectConf: SshAccess = await this.accessService.getById(accessId);
const connectConf: SshAccess = await this.getAccess(accessId);
const sshClient = new SshClient(this.logger);
if (!accessId) {
@ -370,7 +370,7 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
});
if (this.script && this.script?.trim()) {
const connectConf: SshAccess = await this.accessService.getById(accessId);
const connectConf: SshAccess = await this.getAccess(accessId);
const sshClient = new SshClient(this.logger);
this.logger.info('执行脚本命令');

View File

@ -79,7 +79,7 @@ export class HauweiDeployCertToCDN extends AbstractTaskPlugin {
}
async getCdnClient() {
const access = await this.accessService.getById<HuaweiAccess>(this.accessId);
const access = await this.getAccess<HuaweiAccess>(this.accessId);
const { BasicCredentials } = await import('@huaweicloud/huaweicloud-sdk-core');
const cdn = await import('@huaweicloud/huaweicloud-sdk-cdn/v2/public-api.js');
//恢复华为云把log4j的config改了的问题

View File

@ -61,7 +61,7 @@ export class JDCloudDeployToCDN extends AbstractTaskPlugin {
async execute(): Promise<void> {
this.logger.info("开始部署证书到京东云CDN");
const access = await this.accessService.getById<JDCloudAccess>(this.accessId);
const access = await this.getAccess<JDCloudAccess>(this.accessId);
const service = await this.getClient(access);
let certId = this.cert;
@ -145,7 +145,7 @@ export class JDCloudDeployToCDN extends AbstractTaskPlugin {
if (!this.accessId) {
throw new Error("请选择Access授权");
}
const access = await this.accessService.getById<JDCloudAccess>(this.accessId);
const access = await this.getAccess<JDCloudAccess>(this.accessId);
const service = await this.getClient(access);
/**

View File

@ -60,7 +60,7 @@ export class JDCloudUpdateCert extends AbstractTaskPlugin {
async onInstance() {}
async execute(): Promise<void> {
this.logger.info('开始部署证书到京东云CDN');
const access = await this.accessService.getById<JDCloudAccess>(this.accessId);
const access = await this.getAccess<JDCloudAccess>(this.accessId);
const service = await this.getClient(access)
// let certId = this.cert
@ -119,7 +119,7 @@ export class JDCloudUpdateCert extends AbstractTaskPlugin {
if (!this.accessId) {
throw new Error('请选择Access授权');
}
const access = await this.accessService.getById<JDCloudAccess>(this.accessId);
const access = await this.getAccess<JDCloudAccess>(this.accessId);
const service = await this.getClient(access);
/**

View File

@ -56,7 +56,7 @@ export class JDCloudUploadCert extends AbstractTaskPlugin {
async execute(): Promise<void> {
this.logger.info("开始上传证书到京东云数字证书中心");
const access = await this.accessService.getById<JDCloudAccess>(this.accessId);
const access = await this.getAccess<JDCloudAccess>(this.accessId);
const service = await this.getClient(access);

View File

@ -190,7 +190,7 @@ export class DBBackupPlugin extends AbstractPlusTaskPlugin {
}
private async sshBackup(dbPath: string, backupDir: string, backupPath: string) {
const access: SshAccess = await this.ctx.accessService.getById(this.sshAccessId);
const access: SshAccess = await this.getAccess(this.sshAccessId);
const sshClient = new SshClient(this.logger);
this.logger.info('备份目录:', backupPath);
await sshClient.uploadFiles({

View File

@ -92,7 +92,7 @@ export class ProxmoxUploadCert extends AbstractPlusTaskPlugin {
}
async getClient() {
const access: ProxmoxAccess = await this.accessService.getById<ProxmoxAccess>(this.accessId);
const access: ProxmoxAccess = await this.getAccess<ProxmoxAccess>(this.accessId);
const pve = await import('@corsinvest/cv4pve-api-javascript');
const client = new pve.PveClient(access.host, access.port);
const login = await client.login(access.username, access.password, 'pam');

View File

@ -55,7 +55,7 @@ export class QiniuDeployCertToCDN extends AbstractTaskPlugin {
async onInstance() {}
async execute(): Promise<void> {
this.logger.info('开始部署证书到七牛云cdn');
const access = await this.accessService.getById<QiniuAccess>(this.accessId);
const access = await this.getAccess<QiniuAccess>(this.accessId);
const qiniuClient = new QiniuClient({
http: this.ctx.http,
access,
@ -104,7 +104,7 @@ export class QiniuDeployCertToCDN extends AbstractTaskPlugin {
}
async onGetDomainList() {
const access = await this.accessService.getById<QiniuAccess>(this.accessId);
const access = await this.getAccess<QiniuAccess>(this.accessId);
const qiniuClient = new QiniuClient({
http: this.ctx.http,
access,

View File

@ -51,7 +51,7 @@ export class QiniuCertUpload extends AbstractTaskPlugin {
async onInstance() {}
async execute(): Promise<void> {
this.logger.info('开始上传证书到七牛云');
const access = await this.accessService.getById<QiniuAccess>(this.accessId);
const access = await this.getAccess<QiniuAccess>(this.accessId);
const qiniuClient = new QiniuClient({
http: this.ctx.http,
access,

View File

@ -51,7 +51,7 @@ export class QnapDeploy extends AbstractPlusTaskPlugin {
throw new Error('主机登录授权配置不能为空');
}
const connectConf = await this.ctx.accessService.getById<SshAccess>(accessId);
const connectConf = await this.getAccess<SshAccess>(accessId);
const sshClient = new SshClient(this.logger);
//合并证书
const newCert = cert.key + '\n' + cert.crt;

View File

@ -79,7 +79,7 @@ export class TencentDeleteExpiringCert extends AbstractPlusTaskPlugin {
async onInstance() {}
async execute(): Promise<void> {
const access = await this.accessService.getById<TencentAccess>(this.accessId);
const access = await this.getAccess<TencentAccess>(this.accessId);
const sslClient = new TencentSslClient({
access,
logger: this.logger,

View File

@ -53,7 +53,7 @@ export class DeployCertToTencentAll extends AbstractTaskPlugin {
async onInstance() {}
async execute(): Promise<void> {
const accessProvider = await this.accessService.getById(this.accessId);
const accessProvider = await this.getAccess(this.accessId);
const sdk = await import('tencentcloud-sdk-nodejs/tencentcloud/services/ssl/v20191205/index.js');
const Client = sdk.v20191205.Client;

View File

@ -51,7 +51,7 @@ export class TencentDeployCertToCDNv2 extends AbstractTaskPlugin {
async onInstance() {}
async execute(): Promise<void> {
const access = await this.accessService.getById<TencentAccess>(this.accessId);
const access = await this.getAccess<TencentAccess>(this.accessId);
const sslClient = new TencentSslClient({
access,
logger: this.logger,
@ -82,7 +82,7 @@ export class TencentDeployCertToCDNv2 extends AbstractTaskPlugin {
}
async getCdnClient() {
const accessProvider = await this.accessService.getById<TencentAccess>(this.accessId);
const accessProvider = await this.getAccess<TencentAccess>(this.accessId);
const sdk = await import('tencentcloud-sdk-nodejs/tencentcloud/services/cdn/v20180606/index.js');
const CdnClient = sdk.v20180606.Client;

View File

@ -68,7 +68,7 @@ export class DeployToCdnPlugin extends AbstractTaskPlugin {
}
async getClient() {
const accessProvider: TencentAccess = (await this.accessService.getById(this.accessId)) as TencentAccess;
const accessProvider: TencentAccess = (await this.getAccess(this.accessId)) as TencentAccess;
const CdnClient = this.Client;

View File

@ -108,7 +108,7 @@ export class DeployCertToTencentCLB extends AbstractTaskPlugin {
const sdk = await import('tencentcloud-sdk-nodejs/tencentcloud/services/clb/v20180317/index.js');
const ClbClient = sdk.v20180317.Client;
const accessProvider = (await this.accessService.getById(this.accessId)) as TencentAccess;
const accessProvider = (await this.getAccess(this.accessId)) as TencentAccess;
const region = this.region;
const clientConfig = {

View File

@ -99,7 +99,7 @@ export class DeployCertToTencentCosPlugin extends AbstractTaskPlugin {
async onInstance() {}
async execute(): Promise<void> {
const access = await this.accessService.getById(this.accessId);
const access = await this.getAccess(this.accessId);
const client = new TencentSslClient({
access,
@ -130,7 +130,7 @@ export class DeployCertToTencentCosPlugin extends AbstractTaskPlugin {
}
async onGetDomainList(data: any) {
const access = await this.accessService.getById(this.accessId);
const access = await this.getAccess(this.accessId);
const cosv5 = await import('cos-nodejs-sdk-v5');
const cos = new cosv5.default({

View File

@ -80,7 +80,7 @@ export class DeployCertToTencentEO extends AbstractTaskPlugin {
}
async execute(): Promise<void> {
const accessProvider: TencentAccess = (await this.accessService.getById(this.accessId)) as TencentAccess;
const accessProvider: TencentAccess = (await this.getAccess(this.accessId)) as TencentAccess;
const client = this.getClient(accessProvider);
const params = this.buildParams();
await this.doRequest(client, params);

View File

@ -52,7 +52,7 @@ export class TencentDeployCertToLive extends AbstractPlusTaskPlugin {
async onInstance() {}
async execute(): Promise<void> {
const access = await this.accessService.getById<TencentAccess>(this.accessId);
const access = await this.getAccess<TencentAccess>(this.accessId);
let tencentCertId = this.cert as string;
if (typeof this.cert !== 'string') {
@ -90,7 +90,7 @@ export class TencentDeployCertToLive extends AbstractPlusTaskPlugin {
}
async getLiveClient() {
const accessProvider = await this.accessService.getById<TencentAccess>(this.accessId);
const accessProvider = await this.getAccess<TencentAccess>(this.accessId);
const sdk = await import('tencentcloud-sdk-nodejs/tencentcloud/services/live/v20180801/index.js');
const CssClient = sdk.v20180801.Client;

View File

@ -116,7 +116,7 @@ export class DeployCertToTencentTKEIngressPlugin extends AbstractPlusTaskPlugin
this.K8sClient = k8sSdk.K8sClient;
}
async execute(): Promise<void> {
const accessProvider = await this.accessService.getById(this.accessId);
const accessProvider = await this.getAccess(this.accessId);
const tkeClient = await this.getTkeClient(accessProvider, this.region);
const kubeConfigStr = await this.getTkeKubeConfig(tkeClient, this.clusterId);

View File

@ -135,7 +135,7 @@ export class TencentActionInstancesPlugin extends AbstractTaskPlugin {
}
async getCvmClient() {
const accessProvider = await this.accessService.getById<TencentAccess>(this.accessId);
const accessProvider = await this.getAccess<TencentAccess>(this.accessId);
const sdk = await import('tencentcloud-sdk-nodejs/tencentcloud/services/cvm/v20170312/index.js');
const CvmClient = sdk.v20170312.Client;

View File

@ -52,7 +52,7 @@ export class UploadCertToTencent extends AbstractTaskPlugin {
async execute(): Promise<void> {
const { accessId, name, cert } = this;
const accessProvider = await this.accessService.getById(accessId);
const accessProvider = await this.getAccess(accessId);
const certName = this.appendTimeSuffix(name || cert.domain);
const client = this.getClient(accessProvider);
@ -96,7 +96,7 @@ export class UploadCertToTencent extends AbstractTaskPlugin {
// async rollback({ input }) {
// const { accessId } = input;
// const accessProvider = await this.accessService.getById(accessId);
// const accessProvider = await this.getAccess(accessId);
// const client = this.getClient(accessProvider);
//
// const { tencentCertId } = context;

View File

@ -68,7 +68,7 @@ export class UpyunDeployToCdn extends AbstractPlusTaskPlugin {
//插件执行方法
async execute(): Promise<void> {
const access = await this.accessService.getById<UpyunAccess>(this.accessId);
const access = await this.getAccess<UpyunAccess>(this.accessId);
const upyunClient = new UpyunClient({
access,
@ -101,7 +101,7 @@ export class UpyunDeployToCdn extends AbstractPlusTaskPlugin {
if (!this.accessId) {
throw new Error("accessId不能为空");
}
const access = await this.accessService.getById<UpyunAccess>(this.accessId);
const access = await this.getAccess<UpyunAccess>(this.accessId);
const upyunClient = new UpyunClient({
access,

View File

@ -78,7 +78,7 @@ export class VolcengineDeployToCDN extends AbstractTaskPlugin {
async onInstance() {}
async execute(): Promise<void> {
this.logger.info('开始部署证书到火山引擎CDN');
const access = await this.accessService.getById<VolcengineAccess>(this.accessId);
const access = await this.getAccess<VolcengineAccess>(this.accessId);
const client = await this.getClient(access)
const service = await client.getCdnClient()
@ -117,7 +117,7 @@ export class VolcengineDeployToCDN extends AbstractTaskPlugin {
if (!this.accessId) {
throw new Error('请选择Access授权');
}
const access = await this.accessService.getById<VolcengineAccess>(this.accessId);
const access = await this.getAccess<VolcengineAccess>(this.accessId);
const client = await this.getClient(access);
const service = await client.getCdnClient()

View File

@ -71,7 +71,7 @@ export class WoaiCdnPlugin extends AbstractTaskPlugin {
async execute(): Promise<void> {
const { baseApi, certId, cert, accessId } = this;
const access = (await this.accessService.getById(accessId)) as WoaiAccess;
const access = (await this.getAccess(accessId)) as WoaiAccess;
// 使用默认值或用户输入的值
const apiBase = baseApi || 'https://console.edeg.sxhjgy.cn';
// 登录获取token