Skip to content

Classify executables by magic bytes instead of the extensionless heuristic #325

Description

@bobtista

Problem

Executable classification currently relies on an extensionless-file heuristic. That heuristic will misfire on ordinary extensionless files — README, LICENSE and similar — treating them as executables.

Proposed approach

Replace the heuristic with magic-byte sniffing:

  • Mach-O (macOS)
  • ELF (Linux)
  • MZ (Windows)

Classify on file content rather than on the absence of an extension.

Acceptance criteria

  • Extensionless non-executables (README, LICENSE) are not classified as executables.
  • Mach-O, ELF and MZ binaries are correctly identified on all platforms.
  • Classification does not depend on file extension.

Notes

Worth landing before the current heuristic trips on real content in the wild.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions