1111from cve_bin_tool .async_utils import FileIO , run_coroutine
1212
1313
14- async def aio_is_binary (filename ) :
14+ async def aio_is_binary (filename : str ) -> bool :
1515 """Read the magic bytes from a file and determine if it is an executable
1616 binary."""
17- signature = await read_signature (filename )
17+ signature : bytes = await read_signature (filename )
1818 for name , method in inspect .getmembers (
1919 sys .modules [__name__ ], predicate = inspect .isfunction
2020 ):
@@ -24,26 +24,26 @@ async def aio_is_binary(filename):
2424 return False
2525
2626
27- def is_binary (filename ) :
27+ def is_binary (filename : str ) -> bool :
2828 return run_coroutine (aio_is_binary (filename ))
2929
3030
31- async def read_signature (filename , length = 4 ) :
31+ async def read_signature (filename : str , length : int = 4 ) -> bytes :
3232 """Read the signature, first length bytes, from filename."""
3333 async with FileIO (filename , "rb" ) as file_handle :
3434 return await file_handle .read (length )
3535
3636
37- def check_elf (_filename , signature ) :
37+ def check_elf (_filename : str , signature : bytes ) -> bool :
3838 """Check for an ELF signature."""
3939 return signature == b"\x7f \x45 \x4c \x46 "
4040
4141
42- def check_pe (_filename , signature ) :
42+ def check_pe (_filename : str , signature : bytes ) -> bool :
4343 """Check for windows/dos PE signature, aka 0x5a4d."""
4444 return signature [:4 ] == b"\x4d \x5a "
4545
4646
47- def check_fake_test (_filename , signature ) :
47+ def check_fake_test (_filename : str , signature : bytes ) -> bool :
4848 """check for fake tests under windows."""
4949 return signature == b"MZ\x90 \x00 "
0 commit comments