mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Enable using multiple macho parsers
This commit is contained in:
parent
6bebb57e58
commit
dda7623fda
2 changed files with 42 additions and 2 deletions
|
|
@ -4,8 +4,8 @@ import prettyBytes from 'pretty-bytes'
|
||||||
// import zip from '@zip.js/zip.js'
|
// import zip from '@zip.js/zip.js'
|
||||||
import FileApi, { File } from 'file-api'
|
import FileApi, { File } from 'file-api'
|
||||||
|
|
||||||
import parseMacho from '~/helpers/macho/index.js'
|
|
||||||
import { isString } from '~/helpers/check-types.js'
|
import { isString } from '~/helpers/check-types.js'
|
||||||
|
import { extraMachoMeta } from '~/helpers/scanner/parsers/macho.js'
|
||||||
|
|
||||||
// For some reason inline 'import()' works better than 'import from'
|
// For some reason inline 'import()' works better than 'import from'
|
||||||
// https://gildas-lormeau.github.io/zip.js/
|
// https://gildas-lormeau.github.io/zip.js/
|
||||||
|
|
@ -290,7 +290,7 @@ export class AppScan {
|
||||||
buffer: bundleExecutableBlob,
|
buffer: bundleExecutableBlob,
|
||||||
})
|
})
|
||||||
|
|
||||||
this.machoMeta = await parseMacho( machoFileInstance, FileApi ) //await this.parseMachOBlob( bundleExecutableBlob, file.name )
|
this.machoMeta = await extraMachoMeta({ machoFileInstance, FileApi }) //await this.parseMachOBlob( bundleExecutableBlob, file.name )
|
||||||
// console.log( 'this.machoMeta', this.machoMeta )
|
// console.log( 'this.machoMeta', this.machoMeta )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
40
helpers/scanner/parsers/macho.js
Normal file
40
helpers/scanner/parsers/macho.js
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
|
||||||
|
|
||||||
|
export class MachoManiac {
|
||||||
|
constructor ({ machoFileInstance, FileApi }) {
|
||||||
|
this.machoFileInstance = machoFileInstance
|
||||||
|
this.FileApi = FileApi
|
||||||
|
}
|
||||||
|
|
||||||
|
async run () {
|
||||||
|
// import parseMacho from '~/helpers/macho/index.js'
|
||||||
|
const { default: parseMacho } = await import( '~/helpers/macho/index.js' )
|
||||||
|
|
||||||
|
return await parseMacho( this.machoFileInstance, this.FileApi )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export async function extraMachoMeta ({ machoFileInstance, FileApi = null }) {
|
||||||
|
const parsers = [
|
||||||
|
MachoManiac
|
||||||
|
]
|
||||||
|
|
||||||
|
// Run through each parser
|
||||||
|
for ( const Parser of parsers ) {
|
||||||
|
try {
|
||||||
|
// Run the parser
|
||||||
|
const parserInstance = new Parser({
|
||||||
|
machoFileInstance,
|
||||||
|
FileApi
|
||||||
|
})
|
||||||
|
const meta = await parserInstance.run()
|
||||||
|
|
||||||
|
return meta
|
||||||
|
} catch ( err ) {
|
||||||
|
// console.log( 'err', err )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue