Add timeout for Macho Parsers

This commit is contained in:
Sam Carlton 2022-07-18 19:33:22 -05:00
parent b8a3b8e5d9
commit 4c92f61fd5

View file

@ -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 )