refactor(core): Port nodes config (no-changelog) (#10140)

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Iván Ovejero
2024-07-23 13:32:50 +02:00
committed by GitHub
parent d2a3a4a080
commit 95b85dd5c1
14 changed files with 95 additions and 65 deletions

View File

@@ -88,15 +88,17 @@ export class InstanceRiskReporter implements RiskReporter {
const settings: Record<string, unknown> = {};
settings.features = {
communityPackagesEnabled: config.getEnv('nodes.communityPackages.enabled'),
communityPackagesEnabled: this.globalConfig.nodes.communityPackages.enabled,
versionNotificationsEnabled: this.globalConfig.versionNotifications.enabled,
templatesEnabled: this.globalConfig.templates.enabled,
publicApiEnabled: isApiEnabled(),
};
const { exclude, include } = this.globalConfig.nodes;
settings.nodes = {
nodesExclude: config.getEnv('nodes.exclude') ?? 'none',
nodesInclude: config.getEnv('nodes.include') ?? 'none',
nodesExclude: exclude.length === 0 ? 'none' : exclude.join(', '),
nodesInclude: include.length === 0 ? 'none' : include.join(', '),
};
settings.telemetry = {

View File

@@ -1,7 +1,6 @@
import * as path from 'path';
import glob from 'fast-glob';
import { Service } from 'typedi';
import config from '@/config';
import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials';
import { getNodeTypes } from '@/security-audit/utils';
import {
@@ -14,12 +13,14 @@ import {
import type { WorkflowEntity } from '@db/entities/WorkflowEntity';
import type { Risk, RiskReporter } from '@/security-audit/types';
import { CommunityPackagesService } from '@/services/communityPackages.service';
import { GlobalConfig } from '@n8n/config';
@Service()
export class NodesRiskReporter implements RiskReporter {
constructor(
private readonly loadNodesAndCredentials: LoadNodesAndCredentials,
private readonly communityPackagesService: CommunityPackagesService,
private readonly globalConfig: GlobalConfig,
) {}
async report(workflows: WorkflowEntity[]) {
@@ -85,7 +86,7 @@ export class NodesRiskReporter implements RiskReporter {
}
private async getCommunityNodeDetails() {
if (!config.getEnv('nodes.communityPackages.enabled')) return [];
if (!this.globalConfig.nodes.communityPackages.enabled) return [];
const installedPackages = await this.communityPackagesService.getAllInstalledPackages();