feat: implement Entry.asBytes() method for single file extraction #89
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 PR implements the requested functionality from issue #58 to extract single files from tar archives without extracting the entire archive.
Problem
Users need to inspect specific files within tar archives (like Docker OCI images) without extracting the entire archive. The existing API only allowed full archive extraction via
unpack()
or iterating through entries to get paths and headers, but not the actual file content.Solution
Added a new
asBytes()
method to theEntry
class that reads the entire content of a tar entry and returns it as a Buffer. This provides functionality equivalent to:API Changes
Rust (src/entry.rs)
TypeScript (index.d.ts)
Usage Example
Testing
Added comprehensive tests covering:
All existing tests continue to pass, ensuring backward compatibility.
Benefits
Closes #58
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com
/usr/lib/apt/methods/https
(dns block)global.endpoint.security.microsoft.com
curl --cacert /tmp/tmp.b1hd5CK3bB.pem -s -S -X POST -d { "client": { "appVersion": "101.25062.0003", "hostname": "pkrvmsl9tci6h6u", "platform": "Linux", "machineGuid": "b5acfbb6-e614-7644-bd1a-b173b20ed7d7", "orgId": "", "releaseRing": "Production", "productGuid":"c65eac3e-401e-4a0c-82e3-f106f693222f" }, "reports":[ { "$type":"installationReport", "timestamp": "1754837115.898366504", "correlation_id": "0ad349b9-4330-45e7-a502-f0d19b7dc380", "version": "101.25062.0003", "distro": "ubuntu 24.04", "scenario": "Install", "severity": "I", "stage": "preinstall", "code": "preinstStarted", "text": "" } ] } --max-time 5 --connect-timeout 1 REDACTED -o /dev/null -w %{http_code}
(dns block)curl --cacert /tmp/tmp.A2ntptLO7b.pem -s -S -X POST -d { "client": { "appVersion": "101.25062.0003", "hostname": "pkrvmsl9tci6h6u", "platform": "Linux", "machineGuid": "b5acfbb6-e614-7644-bd1a-b173b20ed7d7", "orgId": "", "releaseRing": "Production", "productGuid":"c65eac3e-401e-4a0c-82e3-f106f693222f" }, "reports":[ { "$type":"installationReport", "timestamp": "1754837139.615479953", "correlation_id": "0ad349b9-4330-45e7-a502-f0d19b7dc380", "version": "101.25062.0003", "distro": " ", "scenario": "Install", "severity": "I", "stage": "postinstall", "code": "postinstStarted", "text": "" } ] } --max-time 5 --connect-timeout 1 REDACTED -o /dev/null -w %{http_code}
(dns block)curl --cacert /tmp/tmp.7nLLpvqTjl.pem -s -S -X POST -d { "client": { "appVersion": "101.25062.0003", "hostname": "pkrvmsl9tci6h6u", "platform": "Linux", "machineGuid": "b5acfbb6-e614-7644-bd1a-b173b20ed7d7", "orgId": "", "releaseRing": "Production", "productGuid":"c65eac3e-401e-4a0c-82e3-f106f693222f" }, "reports":[ { "$type":"installationReport", "timestamp": "1754837140.631181139", "correlation_id": "0ad349b9-4330-45e7-a502-f0d19b7dc380", "version": "101.25062.0003", "distro": " ", "scenario": "", "severity": "W", "stage": "postinstall", "code": "LogTelemetryFailed", "text": "error_code=1, lineno=625, command='return $result', func='LogTelemetry'" } ] } --max-time 5 --connect-timeout 1 REDACTED -o /dev/null -w %{http_code}
(dns block)go.microsoft.com
/opt/microsoft/mdatp/sbin/wdavdaemon
(dns block)metadata.google.internal
/opt/microsoft/mdatp/sbin/wdavdaemon
(dns block)unitedstates.cp.wd.microsoft.com
/opt/microsoft/mdatp/sbin/wdavdaemon
(dns block)unitedstates.x.cp.wd.microsoft.com
/opt/microsoft/mdatp/sbin/wdavdaemon
(dns block)wdcp.microsoft.com
/opt/microsoft/mdatp/sbin/wdavdaemon
(dns block)winatp-gw-cus.microsoft.com
/opt/microsoft/mdatp/sbin/wdavdaemon edr 16 15 --log_level info
(dns block)x.cp.wd.microsoft.com
curl -s -S -d { "client": { "appVersion": "101.25062.0003", "hostname": "pkrvmsl9tci6h6u", "platform": "Linux", "machineGuid": "b5acfbb6-e614-7644-bd1a-b173b20ed7d7", "orgId": "", "releaseRing": "Production", "productGuid":"c65eac3e-401e-4a0c-82e3-f106f693222f" }, "reports":[ { "$type":"installationReport", "timestamp": "1754837115.898366504", "correlation_id": "0ad349b9-4330-45e7-a502-f0d19b7dc380", "version": "101.25062.0003", "distro": "ubuntu 24.04", "scenario": "Install", "severity": "I", "stage": "preinstall", "code": "preinstStarted", "text": "" } ] } -X POST --max-time 5 --connect-timeout 1 REDACTED
(dns block)curl -s -S -d { "client": { "appVersion": "101.25062.0003", "hostname": "pkrvmsl9tci6h6u", "platform": "Linux", "machineGuid": "b5acfbb6-e614-7644-bd1a-b173b20ed7d7", "orgId": "", "releaseRing": "Production", "productGuid":"c65eac3e-401e-4a0c-82e3-f106f693222f" }, "reports":[ { "$type":"installationReport", "timestamp": "1754837117.959222181", "correlation_id": "0ad349b9-4330-45e7-a502-f0d19b7dc380", "version": "101.25062.0003", "distro": "ubuntu 24.04", "scenario": "Install", "severity": "C", "stage": "preinstall", "code": "InstallStarted", "text": "is_new_install='1', bundle_version='101.25062.0003', branch='release/linux/2506-2', package=''" } ] } -X POST --max-time 5 --connect-timeout 1 REDACTED
(dns block)curl -s -S -d { "client": { "appVersion": "101.25062.0003", "hostname": "pkrvmsl9tci6h6u", "platform": "Linux", "machineGuid": "b5acfbb6-e614-7644-bd1a-b173b20ed7d7", "orgId": "", "releaseRing": "Production", "productGuid":"c65eac3e-401e-4a0c-82e3-f106f693222f" }, "reports":[ { "$type":"installationReport", "timestamp": "1754837119.000644555", "correlation_id": "0ad349b9-4330-45e7-a502-f0d19b7dc380", "version": "101.25062.0003", "distro": "ubuntu 24.04", "scenario": "Install", "severity": "I", "stage": "preinstall", "code": "machineInformation", "text": "distro='ubuntu 24.04', cpu_name='AMD EPYC 7763 64-Core Processor AMD EPYC 7763 64-Core Processor None CPU @ 2.4GHz', cpu_architecture='x86_64', cpu_cores='4', threads_per_core='2', logical_cores='8', available_ram='14Gi', free_ram='10Gi', free_swap='4.0Gi', free_disk='26G', kernel_version='6.11.0-1018-azure', kernel_cmdline='BOOT_IMAGE=/vmlinuz-6.11.0-1018-azure root=PARTUUID=b64e0d51-c5e6-43a0-adab-9d3434918512 ro console=tty1 console=ttyS0 earlyprintk=ttyS0 nvme_core.io_timeout=240 panic=-1', locale_info='LANG=REDACTED,LANGUAGE=,LC_CTYPE='REDACTED',LC_NUMERIC='REDACTED',LC_TIME='REDACTED',LC_COLLATE='REDACTED',LC_MONETARY='REDACTED',LC_MESSAGES='REDACTED',LC_PAPER='REDACTED',LC_NAME='REDACTED',LC_ADDRESS='REDACTED',LC_TELEPHONE='REDACTED',LC_MEASUREMENT='REDACTED',LC_IDENTIFICATION='REDACTED',LC_ALL=,'" } ] } -X POST --max-time 5 --connect-timeout 1 REDACTED
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.