Skip to content

🐛 Limit Binary Artifact file reads to first 1024 bytes - #3923

Merged
spencerschrock merged 3 commits into
ossf:mainfrom
spencerschrock:binary-artifact-reader
Mar 6, 2024
Merged

🐛 Limit Binary Artifact file reads to first 1024 bytes#3923
spencerschrock merged 3 commits into
ossf:mainfrom
spencerschrock:binary-artifact-reader

Conversation

@spencerschrock

Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

bug fix

What is the current behavior?

The whole file is read, even though we only use 1024 bytes when determining if a file is text or binary

What is the new behavior (if this is a feature change)?**

Only up to the first 1024 bytes are read.

  • Tests for the changes have been added (for bug fixes/features)

Which issue(s) this PR fixes

Part 1 of 2 to address #3831

Special notes for your reviewer

Does this PR introduce a user-facing change?

For user-facing changes, please add a concise, human-readable release note to
the release-note

(In particular, describe what changes users might need to make in their
application as a result of this pull request.)

NONE

Signed-off-by: Spencer Schrock <sschrock@google.com>
Signed-off-by: Spencer Schrock <sschrock@google.com>
@spencerschrock
spencerschrock requested a review from a team as a code owner March 5, 2024 21:30
@spencerschrock
spencerschrock requested review from laurentsimon and naveensrinivasan and removed request for a team March 5, 2024 21:30
@codecov

codecov Bot commented Mar 5, 2024

Copy link
Copy Markdown

Codecov Report

Merging #3923 (5c9220f) into main (0a6b06a) will decrease coverage by 6.53%.
The diff coverage is 64.51%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3923      +/-   ##
==========================================
- Coverage   75.11%   68.58%   -6.53%     
==========================================
  Files         234      234              
  Lines       15859    15877      +18     
==========================================
- Hits        11912    10890    -1022     
- Misses       3187     4294    +1107     
+ Partials      760      693      -67     

@spencerschrock

Copy link
Copy Markdown
Member Author

/scdiff generate Binary-Artifact

@github-actions

github-actions Bot commented Mar 5, 2024

Copy link
Copy Markdown

@pnacht

pnacht commented Mar 5, 2024

Copy link
Copy Markdown
Contributor

This is already a big improvement, but why 1024 bytes? From what I understood (described in #3831), h2non/filetype (the package Scorecard uses to determine the filetype) only needs the first 262 bytes.

@spencerschrock

Copy link
Copy Markdown
Member Author

This is already a big improvement, but why 1024 bytes

Getting the file type is just one part, we also check some of the file for false positives. You can read a bit more here: #2412.

@spencerschrock
spencerschrock enabled auto-merge (squash) March 6, 2024 21:31
@spencerschrock
spencerschrock merged commit c779392 into ossf:main Mar 6, 2024
@spencerschrock
spencerschrock deleted the binary-artifact-reader branch March 6, 2024 21:39
fhoeborn pushed a commit to fhoeborn/scorecard that referenced this pull request Apr 1, 2024
* add OnMatchingFileReaderDo

Signed-off-by: Spencer Schrock <sschrock@google.com>

* switch binary artifact to using reader

Signed-off-by: Spencer Schrock <sschrock@google.com>

---------

Signed-off-by: Spencer Schrock <sschrock@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants