Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# That way we do not try to identify bytes that don't exist
matches = list()
for magic_row in magic_header_array:
start = magic_row.offset
end = magic_row.offset + len(magic_row.byte_match)
if end > len(header):
continue
if header[start:end] == magic_row.byte_match:
matches.append(magic_row)
for magic_row in magic_footer_array:
start = magic_row.offset
if footer[start:] == magic_row.byte_match:
matches.append(magic_row)
if not matches:
raise PureError("Could not identify file")
return _confidence(matches, ext)