Skip to content

Add is_binary_data flag to detect binary data files in text form - #5571

Open
sujalgiriiitp-source wants to merge 1 commit into
aboutcode-org:developfrom
sujalgiriiitp-source:gsoc-602-binary-data-flag
Open

sujalgiriiitp-source wants to merge 1 commit into
aboutcode-org:developfrom
sujalgiriiitp-source:gsoc-602-binary-data-flag

Conversation

@sujalgiriiitp-source

Copy link
Copy Markdown

Detect common binary data files in hex form as a new informational is_binary_data flag in the --info scan, as suggested in #602. Intel HEX files are detected by validating the record structure (byte count, record type 00-05) and checksum of each line. Pure hex/number data files (long lists of hex digits and numbers) are detected when all sampled lines consist only of hex digits, digits, X, punctuation or whitespace. Only the first 200 non-empty lines are read, so large data files stay cheap to check. This is detection only: flagged files are still scanned, since hex firmwares are known to carry unusual licenses. Skipping the scan of such files is left for later work, as is certificate detection (#620). Fixes #602 (partial: implements TODO item 1, the is_binary_data flag; skipping is explicitly out of scope). Tests: new TestBinaryData tests in tests/textcode/test_analysis.py and get_file_info coverage in tests/scancode/test_api.py (39 passed). A false-positive check over 64,815 existing source/test-data files flagged only the new fixtures. AI use disclosure (per AboutCode's draft AI-policy direction — Sujal to confirm wording before submitting): this change was drafted with AI assistance and reviewed/verified by me (Sujal Giri) before submission.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not scan certain data-only data file

1 participant