Skip to content

fix: use file mode to distinguish executable binaries from non-executable ones#256

Merged
jmeridth merged 1 commit intomainfrom
jm_fix_binary_detection
Mar 4, 2026
Merged

fix: use file mode to distinguish executable binaries from non-executable ones#256
jmeridth merged 1 commit intomainfrom
jm_fix_binary_detection

Conversation

@jmeridth
Copy link
Member

@jmeridth jmeridth commented Mar 4, 2026

Fixes #255

What

Added the Mode field from GitHub's GraphQL TreeEntry to the repo tree struct and updated the binary check to use Unix execute permission bits (mode & 0111) to determine if a binary file is actually executable.

Why

OSPS-QA-05.01 targets "generated executable artifacts," not all binary files. Non-executable binaries like PNGs and PDFs were being incorrectly flagged, causing false failures for documentation-heavy repositories.

Notes

  • The bitwise check (mode & 0111) is used instead of exact mode comparison (== 33261) for robustness against non-standard Git implementations, though standard Git only uses 100755 for executables.
  • This changes behavior for the checkViaPartialFetch fallback path: when isBinaryPtr is nil and the file is fetched via HTTP, the mode check is NOT applied. That path lacks the GraphQL mode data, so it retains the existing MIME-based heuristic. Reviewers should consider whether this is acceptable.

…able ones

Fixes #255

## What

Added the Mode field from GitHub's GraphQL TreeEntry to the repo tree struct and updated the binary check to use Unix execute permission bits (mode & 0111) to determine if a binary file is actually executable.

## Why

OSPS-QA-05.01 targets "generated executable artifacts," not all binary files. Non-executable binaries like PNGs and PDFs were being incorrectly flagged, causing false failures for documentation-heavy repositories.

## Notes

- The bitwise check (`mode & 0111`) is used instead of exact mode comparison (`== 33261`) for robustness against non-standard Git implementations, though standard Git only uses 100755 for executables.
- This changes behavior for the `checkViaPartialFetch` fallback path: when `isBinaryPtr` is nil and the file is fetched via HTTP, the mode check is NOT applied. That path lacks the GraphQL mode data, so it retains the existing MIME-based heuristic. Reviewers should consider whether this is acceptable.

Signed-off-by: jmeridth <jmeridth@gmail.com>
@jmeridth jmeridth self-assigned this Mar 4, 2026
@jmeridth jmeridth requested a review from a team as a code owner March 4, 2026 16:12
@github-actions github-actions bot added the fix label Mar 4, 2026
Copy link

@tuminoid tuminoid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with question.

@jmeridth jmeridth merged commit 268f1a5 into main Mar 4, 2026
8 checks passed
@jmeridth jmeridth deleted the jm_fix_binary_detection branch March 4, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PNG files counted as binaries and OSPS-QA-05.01 fails

3 participants