11
11
from cve_bin_tool .async_utils import FileIO , run_coroutine
12
12
13
13
14
- async def aio_is_binary (filename ) :
14
+ async def aio_is_binary (filename : str ) -> bool :
15
15
"""Read the magic bytes from a file and determine if it is an executable
16
16
binary."""
17
- signature = await read_signature (filename )
17
+ signature : bytes = await read_signature (filename )
18
18
for name , method in inspect .getmembers (
19
19
sys .modules [__name__ ], predicate = inspect .isfunction
20
20
):
@@ -24,26 +24,26 @@ async def aio_is_binary(filename):
24
24
return False
25
25
26
26
27
- def is_binary (filename ) :
27
+ def is_binary (filename : str ) -> bool :
28
28
return run_coroutine (aio_is_binary (filename ))
29
29
30
30
31
- async def read_signature (filename , length = 4 ) :
31
+ async def read_signature (filename : str , length : int = 4 ) -> bytes :
32
32
"""Read the signature, first length bytes, from filename."""
33
33
async with FileIO (filename , "rb" ) as file_handle :
34
34
return await file_handle .read (length )
35
35
36
36
37
- def check_elf (_filename , signature ) :
37
+ def check_elf (_filename : str , signature : bytes ) -> bool :
38
38
"""Check for an ELF signature."""
39
39
return signature == b"\x7f \x45 \x4c \x46 "
40
40
41
41
42
- def check_pe (_filename , signature ) :
42
+ def check_pe (_filename : str , signature : bytes ) -> bool :
43
43
"""Check for windows/dos PE signature, aka 0x5a4d."""
44
44
return signature [:4 ] == b"\x4d \x5a "
45
45
46
46
47
- def check_fake_test (_filename , signature ) :
47
+ def check_fake_test (_filename : str , signature : bytes ) -> bool :
48
48
"""check for fake tests under windows."""
49
49
return signature == b"MZ\x90 \x00 "
0 commit comments