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

Function buildOutput

worker/src/components/security/dnsx.ts:672–814  ·  view source on GitHub ↗
(params: {
      records: z.infer<typeof dnsxLineSchema>[];
      rawOutput: string;
      domainCount: number;
      recordCount: number;
      recordTypes: string[];
      resolvers: string[];
      errors?: string[];
    })

Source from the content-addressed store, hash-verified

670 }
671
672 const buildOutput = (params: {
673 records: z.infer<typeof dnsxLineSchema>[];
674 rawOutput: string;
675 domainCount: number;
676 recordCount: number;
677 recordTypes: string[];
678 resolvers: string[];
679 errors?: string[];
680 }): Output => {
681 const normalisedRecords: DnsxRecord[] = params.records.map((record) => {
682 const answers: Record<string, string[]> = {};
683 const candidateKeys = [
684 'a',
685 'aaaa',
686 'cname',
687 'mx',
688 'ns',
689 'txt',
690 'ptr',
691 'srv',
692 'soa',
693 'caa',
694 'any',
695 'axfr',
696 'all',
697 ];
698
699 candidateKeys.forEach((key: string) => {
700 const value = (record as Record<string, unknown>)[key];
701 if (Array.isArray(value) && value.length > 0) {
702 answers[key] = value.map((entry: unknown) => String(entry));
703 }
704 });
705
706 const ttlValue = (record as Record<string, unknown>).ttl;
707 const ttl =
708 typeof ttlValue === 'number'
709 ? ttlValue
710 : typeof ttlValue === 'string' && ttlValue.trim().length > 0
711 ? Number.parseInt(ttlValue, 10)
712 : undefined;
713
714 return {
715 host: record.host,
716 statusCode:
717 typeof (record as Record<string, unknown>).status_code === 'string'
718 ? ((record as Record<string, unknown>).status_code as string)
719 : undefined,
720 ttl: Number.isFinite(ttl) ? ttl : undefined,
721 resolver: Array.isArray(record.resolver)
722 ? record.resolver.map((entry: unknown) => String(entry))
723 : undefined,
724 answers,
725 timestamp: record.timestamp,
726 };
727 });
728
729 const derivedResolvers = ensureUnique(

Callers 2

buildSilentOutputFunction · 0.85
executeFunction · 0.85

Calls 3

generateFindingHashFunction · 0.90
ensureUniqueFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected