From fcb36548de8fa56b6c0fd99622d5f7fa3b805515 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Mon, 18 Jul 2022 19:33:22 -0500 Subject: [PATCH] Add timeout for Macho Parsers --- helpers/scanner/parsers/macho.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/helpers/scanner/parsers/macho.js b/helpers/scanner/parsers/macho.js index 56e17db..8c8d26a 100644 --- a/helpers/scanner/parsers/macho.js +++ b/helpers/scanner/parsers/macho.js @@ -102,6 +102,10 @@ export async function extractMachoMeta ({ machoFileInstance, FileApi = null }) { // Run through each parser for ( const Parser of parsers ) { try { + const parserTimeout = setTimeout(() => { + throw new Error( 'Timed out' ) + }, 60 * 1000 ) + // Run the parser const parserInstance = new Parser({ machoFileInstance, @@ -109,6 +113,9 @@ export async function extractMachoMeta ({ machoFileInstance, FileApi = null }) { }) const meta = await parserInstance.run() + // Clear the timeout + clearTimeout( parserTimeout ) + return meta } catch ( err ) { console.log( 'Macho parser failed', Parser )