refactor(core): Decouple community packages from security audit (#17818)

This commit is contained in:
Iván Ovejero
2025-08-05 15:55:31 +02:00
committed by GitHub
parent bac61a7e0d
commit 3eb9367add
3 changed files with 21 additions and 10 deletions

View File

@@ -7,6 +7,7 @@ import { v4 as uuid } from 'uuid';
import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials';
import { NodeTypes } from '@/node-types';
import { OFFICIAL_RISKY_NODE_TYPES, NODES_REPORT } from '@/security-audit/constants';
import { PackagesRepository } from '@/security-audit/security-audit.repository';
import { SecurityAuditService } from '@/security-audit/security-audit.service';
import { toReportTitle } from '@/security-audit/utils';
import { CommunityPackagesService } from '@/community-packages/community-packages.service';
@@ -18,6 +19,7 @@ nodesAndCredentials.getCustomDirectories.mockReturnValue([]);
mockInstance(NodeTypes);
const communityPackagesService = mockInstance(CommunityPackagesService);
Container.set(CommunityPackagesService, communityPackagesService);
const packagesRepository = mockInstance(PackagesRepository);
let securityAuditService: SecurityAuditService;
@@ -37,7 +39,7 @@ afterAll(async () => {
});
test('should report risky official nodes', async () => {
communityPackagesService.getAllInstalledPackages.mockResolvedValue(MOCK_PACKAGE);
packagesRepository.find.mockResolvedValue(MOCK_PACKAGE);
const map = [...OFFICIAL_RISKY_NODE_TYPES].reduce<{ [nodeType: string]: string }>((acc, cur) => {
return (acc[cur] = uuid()), acc;
}, {});
@@ -82,7 +84,7 @@ test('should report risky official nodes', async () => {
});
test('should not report non-risky official nodes', async () => {
communityPackagesService.getAllInstalledPackages.mockResolvedValue(MOCK_PACKAGE);
packagesRepository.find.mockResolvedValue(MOCK_PACKAGE);
await saveManualTriggerWorkflow();
const testAudit = await securityAuditService.run(['nodes']);
@@ -99,7 +101,7 @@ test('should not report non-risky official nodes', async () => {
});
test('should report community nodes', async () => {
communityPackagesService.getAllInstalledPackages.mockResolvedValue(MOCK_PACKAGE);
packagesRepository.find.mockResolvedValue(MOCK_PACKAGE);
const testAudit = await securityAuditService.run(['nodes']);