Repository navigation
Read a requirements.txt line longer than 64 KiB instead of failing the scan with "bufio.Scanner: token too long" (#50) - #52
Merged
Conversation
…e scan with "bufio.Scanner: token too long" (#50) The requirements.txt reader, which both the dependency parser and the unread-lines reader use, read the file with a bufio.Scanner and its default token limit of 64 KiB. A longer line stopped it with "bufio.Scanner: token too long", the parser returned that error, and the file was refused as a whole: a directory whose requirements.txt has a first line of "cryptography==42.0.0 " followed by 70,000 "x" characters failed analyze --offline with "found 1 manifest file(s) but none could be read" and exit code 2. pip 26.0's requirements reader reads that 70,021-character line and the lines after it. The scanner's token limit is now math.MaxInt. With "pycryptodome==3.20.0" and "-r extra.txt" after the long line, analyze --offline now reports 2 dependencies, lists line 3 as an include it did not follow, and exits 1. The x characters stay in the version cryptography is reported with (cryptography@42.0.0 xxx...), as trailing text on a short line does before and after this change. For testdata/fixtures/python-project the table output and stderr are the same before and after, the JSON output differs only in timestamps, and the exit code is 1 for both. Fixes #50
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.
This pull request lands 1 commit in
internal/manifestandCHANGELOG.md.Included
Verified on this exact tree
go build ./...: exit 0go vet ./...: exit 0gofmt -l cmd internal pkg: no files listedgolangci-lint run ./...(golangci-lint 2.12.2): exit 3,can't load config: unsupported version of the configuration: ""golangci-lint run -c <copy of .golangci.yml converted by golangci-lint migrate> ./...: 8 issues (staticcheck: 8); the same command onorigin/main(09d9c66): 8 issues (staticcheck: 8), the same 8 check IDs in the same filesgo test -json -race -p 4 -count=1 -coverprofile=<temporary file> ./...: exit 0; 16 packages, 13okand 3 with no test filesTestIntegration_FetchPyPIPackage(internal/analyzer/source), outputpip not available, skipping testNot included
None
Closes
Fixes #50
How to merge
Rebase and merge, so that each change stays its own commit on
main.