mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-14 16:44:07 -08:00
b2ca050031
Also converting to service. Followup to https://github.com/n8n-io/n8n/pull/7663
27 lines
842 B
TypeScript
27 lines
842 B
TypeScript
import type { WorkflowEntity as Workflow } from '@db/entities/WorkflowEntity';
|
|
import type { Risk } from '@/security-audit/types';
|
|
|
|
type Node = Workflow['nodes'][number];
|
|
|
|
export const toFlaggedNode = ({ node, workflow }: { node: Node; workflow: Workflow }) => ({
|
|
kind: 'node' as const,
|
|
workflowId: workflow.id,
|
|
workflowName: workflow.name,
|
|
nodeId: node.id,
|
|
nodeName: node.name,
|
|
nodeType: node.type,
|
|
});
|
|
|
|
export const toReportTitle = (riskCategory: Risk.Category) =>
|
|
riskCategory.charAt(0).toUpperCase() + riskCategory.slice(1) + ' Risk Report';
|
|
|
|
export function getNodeTypes(workflows: Workflow[], test: (element: Node) => boolean) {
|
|
return workflows.reduce<Risk.NodeLocation[]>((acc, workflow) => {
|
|
workflow.nodes.forEach((node) => {
|
|
if (test(node)) acc.push(toFlaggedNode({ node, workflow }));
|
|
});
|
|
|
|
return acc;
|
|
}, []);
|
|
}
|