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

Function buildSilentOutput

worker/src/components/security/dnsx.ts:816–949  ·  view source on GitHub ↗
(payload: unknown)

Source from the content-addressed store, hash-verified

814 };
815
816 const buildSilentOutput = (payload: unknown): Output => {
817 let rawOutput: string;
818 if (typeof payload === 'string') {
819 rawOutput = payload;
820 } else {
821 try {
822 rawOutput = JSON.stringify(payload ?? '');
823 } catch {
824 rawOutput = '';
825 }
826 }
827
828 const trimmed = rawOutput.trim();
829
830 if (trimmed.length === 0) {
831 return {
832 dnsRecords: [],
833 results: [],
834 rawOutput,
835 domainCount: domainCount,
836 recordCount: 0,
837 recordTypes,
838 resolvers: resolverList,
839 resolvedHosts: [],
840 };
841 }
842
843 try {
844 const maybeJson = JSON.parse(trimmed);
845 if (maybeJson && typeof maybeJson === 'object' && !Array.isArray(maybeJson)) {
846 const record = maybeJson as Record<string, unknown>;
847 if (record.__error__ === true) {
848 const message =
849 typeof record.message === 'string'
850 ? (record.message as string)
851 : 'dnsx returned an error.';
852 const errorDomainCount =
853 typeof record.domainCount === 'number' && Number.isFinite(record.domainCount)
854 ? (record.domainCount as number)
855 : domainCount;
856 return {
857 dnsRecords: [],
858 results: [],
859 rawOutput: trimmed,
860 domainCount: errorDomainCount,
861 recordCount: 0,
862 recordTypes,
863 resolvers: resolverList,
864 resolvedHosts: [],
865 errors: [message],
866 };
867 }
868
869 const validated = outputSchema.safeParse(record);
870 if (validated.success) {
871 return buildOutput({
872 records: validated.data.dnsRecords as z.infer<typeof dnsxLineSchema>[],
873 rawOutput: validated.data.rawOutput ?? rawOutput,

Callers 1

executeFunction · 0.85

Calls 5

generateFindingHashFunction · 0.90
buildOutputFunction · 0.85
ensureUniqueFunction · 0.85
parseMethod · 0.80
fromMethod · 0.80

Tested by

no test coverage detected