MCPcopy Create free account
hub / github.com/ShipSecAI/studio / normaliseFindings

Function normaliseFindings

worker/src/components/security/prowler-scan.ts:810–835  ·  view source on GitHub ↗
(
  rawSegments: string[],
  runId: string,
)

Source from the content-addressed store, hash-verified

808}
809
810function normaliseFindings(
811 rawSegments: string[],
812 runId: string,
813): {
814 findings: NormalisedFinding[];
815 errors: string[];
816} {
817 const findings: NormalisedFinding[] = [];
818 const errors: string[] = [];
819
820 rawSegments.forEach((segment, segmentIndex) => {
821 const candidates = parseSegment(segment, segmentIndex, errors);
822 candidates.forEach((candidate, candidateIndex) => {
823 const parsed = prowlerFindingSchema.safeParse(candidate);
824 if (!parsed.success) {
825 errors.push(
826 `Segment ${segmentIndex + 1} item ${candidateIndex + 1}: ${parsed.error.message}`,
827 );
828 return;
829 }
830 findings.push(toNormalisedFinding(parsed.data, findings.length, runId));
831 });
832 });
833
834 return { findings, errors };
835}
836
837function parseSegment(segment: string, segmentIndex: number, errors: string[]): unknown[] {
838 const trimmed = (segment ?? '').trim();

Callers 1

executeFunction · 0.85

Calls 3

parseSegmentFunction · 0.85
toNormalisedFindingFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected