-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fix read_tar_magic to properly return an array when a file has less than 264 characters #30
Merged
Conversation
This file contains 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
With Failingrequire 'mixlib/archive'
def tempdir
@tmpdir ||= Dir.mktmpdir("chef-dk")
File.realpath(@tmpdir)
end
working_dir = ::File.join(tempdir, 'policyfile_services_test_working_dir')
archive_file_path = ::File.join('example-policy-abc123.tgz')
Zlib::GzipWriter.open(archive_file_path) do |gz_file|
gz_file << "lol this isn't a tar file"
end
def read_tar_magic(io)
io.rewind
magic = io.read(512).bytes[257..264].pack("C*")
io.rewind
magic
end
def is_tar_archive?(io)
!(read_tar_magic(io) =~ /ustar\s{0,2}\x00/).nil?
end
raw = ::File.open(archive_file_path, 'rb')
is_tar_archive?(raw) Passing (Cast as Array)require 'mixlib/archive'
def tempdir
@tmpdir ||= Dir.mktmpdir("chef-dk")
File.realpath(@tmpdir)
end
working_dir = ::File.join(tempdir, 'policyfile_services_test_working_dir')
archive_file_path = ::File.join('example-policy-abc123.tgz')
Zlib::GzipWriter.open(archive_file_path) do |gz_file|
gz_file << "lol this isn't a tar file"
end
def read_tar_magic(io)
io.rewind
magic = Array(io.read(512).bytes[257..264]).pack("C*")
io.rewind
magic
end
def is_tar_archive?(io)
!(read_tar_magic(io) =~ /ustar\s{0,2}\x00/).nil?
end
raw = ::File.open(archive_file_path, 'rb')
is_tar_archive?(raw) |
bdwyertech
force-pushed
the
fix_dk_test
branch
from
August 28, 2018 02:36
279fff9
to
61b12ff
Compare
bdwyertech
force-pushed
the
fix_dk_test
branch
from
August 28, 2018 02:40
61b12ff
to
f7b7755
Compare
Signed-off-by: Brian Dwyer <brian.dwyer@broadridge.com>
bdwyertech
force-pushed
the
fix_dk_test
branch
from
August 28, 2018 02:50
ac6eb00
to
8446b32
Compare
tas50
changed the title
Fix read_tar_magic
Fix read_tar_magic to properly return an array when a file has less than 264 characters
Aug 28, 2018
tas50
approved these changes
Aug 28, 2018
stuartpreston
approved these changes
Aug 28, 2018
Thanks for working this out and explaining it so well in the PR @bdwyertech |
You are welcome @tas50 -- Also I updated the PR on ChefDK to 0.4.16 so once this gets released, that should hopefully pass... |
netbsd-srcmastr
pushed a commit
to NetBSD/pkgsrc
that referenced
this pull request
Sep 23, 2018
## [v0.4.16](https://github.com/chef/mixlib-archive/tree/v0.4.16) (2018-08-28) #### Merged Pull Requests - Fix read_tar_magic to properly return an array when a file has less than 264 characters [#30](chef/mixlib-archive#30) ([bdwyertech](https://github.com/bdwyertech)) <!-- latest_release --> <!-- release_rollup since=0.4.13 --> ### Changes not yet released to rubygems.org #### Merged Pull Requests - Fix read_tar_magic to properly return an array when a file has less than 264 characters [#30](chef/mixlib-archive#30) ([bdwyertech](https://github.com/bdwyertech)) <!-- 0.4.16 --> - Fix mixlib-archive on Windows, add Appveyor [#31](chef/mixlib-archive#31) ([stuartpreston](https://github.com/stuartpreston)) <!-- 0.4.15 --> - Ensure that paths like foo..bar.baz aren't ignored [#9](chef/mixlib-archive#9) ([thommay](https://github.com/thommay)) <!-- 0.4.14 --> <!-- release_rollup --> <!-- latest_stable_release --> ## [v0.4.13](https://github.com/chef/mixlib-archive/tree/v0.4.13) (2018-08-03) #### Merged Pull Requests - add codeowners [#24](chef/mixlib-archive#24) ([thommay](https://github.com/thommay)) - Move deps to the Gemfile and expand Rake tasks [#25](chef/mixlib-archive#25) ([tas50](https://github.com/tas50)) - Add github issue template & standardize expeditor config [#26](chef/mixlib-archive#26) ([tas50](https://github.com/tas50)) - Update codeowners and add PR template [#27](chef/mixlib-archive#27) ([tas50](https://github.com/tas50)) - bugfix to make dir.chdir threadsafe [#29](chef/mixlib-archive#29) ([stevenoneill](https://github.com/stevenoneill)) <!-- latest_stable_release --> ## [v0.4.8](https://github.com/chef/mixlib-archive/tree/v0.4.8) (2018-06-21) #### Merged Pull Requests - Use the correct entry size for content with multi-byte characters. [#23](chef/mixlib-archive#23) ([coderanger](https://github.com/coderanger)) <!-- latest_release --> <!-- release_rollup since=0.4.7 --> ### Changes not yet released to rubygems.org #### Merged Pull Requests - Use the correct entry size for content with multi-byte characters. [#23](chef/mixlib-archive#23) ([coderanger](https://github.com/coderanger)) <!-- 0.4.8 --> <!-- release_rollup --> <!-- latest_stable_release --> ## [v0.4.7](https://github.com/chef/mixlib-archive/tree/v0.4.7) (2018-06-07) #### Merged Pull Requests - fixup strange edge case around tar magic reading [#22](chef/mixlib-archive#22) ([spion06](https://github.com/spion06)) <!-- latest_stable_release --> ## [v0.4.6](https://github.com/chef/mixlib-archive/tree/v0.4.6) (2018-05-08) #### Merged Pull Requests - update tar magic to identify oldgnu style tar headers [#21](chef/mixlib-archive#21) ([spion06](https://github.com/spion06)) ## [v0.4.5](https://github.com/chef/mixlib-archive/tree/v0.4.5) (2018-05-04) #### Merged Pull Requests - Fix up creating archives [#18](chef/mixlib-archive#18) ([thommay](https://github.com/thommay)) - Fix up writing tar archives with the rubygems tar [#19](chef/mixlib-archive#19) ([thommay](https://github.com/thommay)) ## [v0.4.2](https://github.com/chef/mixlib-archive/tree/v0.4.2) (2018-04-25) #### Merged Pull Requests - use libarchive by preference [#17](chef/mixlib-archive#17) ([thommay](https://github.com/thommay))
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.
Description
In the case that a file is smaller than 264 characters, nil is returned rather than an array, alas the pack method is not available.
This is what is causing the AppVeyor build failure on ChefDK.
Issues Resolved
Hopefully this allows us to bump
mixlib-archive
to address chef-boneyard/chef-dk#1663 via chef-boneyard/chef-dk#1664Check List