Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent converting NUL characters in strings read by licensecheck #6

Closed
wants to merge 1 commit into from

Conversation

giordano
Copy link
Contributor

@giordano giordano commented Feb 16, 2021

Ref JuliaEcosystem/PackageAnalyzer.jl#14.

I don't have the time to add tests now, if you have a good idea how to do that,
please go ahead! (Edit: I have a couple of ideas for how to test this, but I'll have the time to do it only tomorrow night)

@codecov
Copy link

codecov bot commented Feb 16, 2021

Codecov Report

Merging #6 (61d5b7b) into main (23ce74b) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main        #6   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         2    +1     
  Lines            5        35   +30     
=========================================
+ Hits             5        35   +30     
Impacted Files Coverage Δ
src/LicenseCheck.jl 100.00% <100.00%> (ø)
src/find_licenses.jl 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d1bc603...61d5b7b. Read the comment docs.

@ericphanson
Copy link
Owner

ericphanson commented Feb 16, 2021

Thanks @giordano, this seems great. I think for a test we could just generate a test file by something like

using Random
str = randstring(100);
str_bytes = Vector{UInt8}(str);
str_bytes[10] = 0;
str2 = String(str_bytes);
write("test/malformed_file_dir/malformed_file.txt", str2)

and then do license_check("test/malformed_file_dir") or something like that. We could also put an actual license in that directory and check that it finds the license (and doesn't throw on seeing the bad file).

@ericphanson ericphanson mentioned this pull request Feb 16, 2021
@giordano giordano deleted the mg/safer-string branch February 17, 2021 00:22
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.

None yet

2 participants