🐛 Limit Binary Artifact file reads to first 1024 bytes - #3923
Merged
Conversation
Signed-off-by: Spencer Schrock <sschrock@google.com>
Signed-off-by: Spencer Schrock <sschrock@google.com>
spencerschrock
requested review from
laurentsimon and
naveensrinivasan
and removed request for
a team
March 5, 2024 21:30
spencerschrock
temporarily deployed
to
integration-test
March 5, 2024 21:30 — with
GitHub Actions
Inactive
Codecov Report
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 |
Member
Author
|
/scdiff generate Binary-Artifact |
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. |
Member
Author
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. |
laurentsimon
approved these changes
Mar 6, 2024
spencerschrock
enabled auto-merge (squash)
March 6, 2024 21:31
spencerschrock
temporarily deployed
to
integration-test
March 6, 2024 21:31 — with
GitHub Actions
Inactive
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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.)