From 86448324a1617b87e015d2c2e51f40b757eeeba8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Jul 2023 02:32:08 +0000 Subject: [PATCH 01/12] Bump github.com/essentialkaos/ek/v12 from 12.68.0 to 12.69.0 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.68.0 to 12.69.0. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.68.0...v12.69.0) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 67fdabc..62473e5 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/essentialkaos/check v1.4.0 - github.com/essentialkaos/ek/v12 v12.68.0 + github.com/essentialkaos/ek/v12 v12.69.0 github.com/klauspost/compress v1.16.7 github.com/pierrec/lz4/v4 v4.1.18 github.com/ulikunitz/xz v0.5.11 @@ -14,5 +14,5 @@ require ( github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/rogpeppe/go-internal v1.10.0 // indirect - golang.org/x/sys v0.9.0 // indirect + golang.org/x/sys v0.10.0 // indirect ) diff --git a/go.sum b/go.sum index d7e3b3a..5cc5a3b 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= github.com/essentialkaos/check v1.4.0/go.mod h1:LMKPZ2H+9PXe7Y2gEoKyVAwUqXVgx7KtgibfsHJPus0= -github.com/essentialkaos/ek/v12 v12.68.0 h1:/tNqKHfGypPUUu+aQ8LcmmWWEOO8itJZoJgOCPOZFY8= -github.com/essentialkaos/ek/v12 v12.68.0/go.mod h1:CAPhbYcAiQsCP7CMyBlkgD/MgvuLcbr4EXjCIKn3DIk= +github.com/essentialkaos/ek/v12 v12.69.0 h1:UxDZdFLgA15BVelpR3IpkY3RPc/EdY7sXJHbT4T7J90= +github.com/essentialkaos/ek/v12 v12.69.0/go.mod h1:juDcZWOWaj1QmYShZkT9RzdqJ3n0tmeP/iq4sw5fQF0= github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -17,5 +17,5 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= -golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= -golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= From 10bff030133604a835a0636ec9392122f8a0acb7 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Sat, 15 Jul 2023 00:05:57 +0300 Subject: [PATCH 02/12] Improve CI workflow --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d03863d..c0598c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -82,4 +82,5 @@ jobs: uses: actions/checkout@v3 - name: Check spelling + continue-on-error: true uses: crate-ci/typos@master From b15b8e879b09f0b1e732871d743dd61eb0bbd022 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jul 2023 02:14:12 +0000 Subject: [PATCH 03/12] Bump github.com/essentialkaos/ek/v12 from 12.69.0 to 12.70.0 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.69.0 to 12.70.0. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.69.0...v12.70.0) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 62473e5..de772df 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/essentialkaos/check v1.4.0 - github.com/essentialkaos/ek/v12 v12.69.0 + github.com/essentialkaos/ek/v12 v12.70.0 github.com/klauspost/compress v1.16.7 github.com/pierrec/lz4/v4 v4.1.18 github.com/ulikunitz/xz v0.5.11 diff --git a/go.sum b/go.sum index 5cc5a3b..79d82d8 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= github.com/essentialkaos/check v1.4.0/go.mod h1:LMKPZ2H+9PXe7Y2gEoKyVAwUqXVgx7KtgibfsHJPus0= -github.com/essentialkaos/ek/v12 v12.69.0 h1:UxDZdFLgA15BVelpR3IpkY3RPc/EdY7sXJHbT4T7J90= -github.com/essentialkaos/ek/v12 v12.69.0/go.mod h1:juDcZWOWaj1QmYShZkT9RzdqJ3n0tmeP/iq4sw5fQF0= +github.com/essentialkaos/ek/v12 v12.70.0 h1:3LzRvWparTSaU/SWe5CLB+YwntNHBktkk1RQA7UGzYI= +github.com/essentialkaos/ek/v12 v12.70.0/go.mod h1:juDcZWOWaj1QmYShZkT9RzdqJ3n0tmeP/iq4sw5fQF0= github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= From e07d7e7fadad775fb9a6729fe7c4f402866f21a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Jul 2023 02:32:35 +0000 Subject: [PATCH 04/12] Bump github.com/essentialkaos/ek/v12 from 12.70.0 to 12.72.0 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.70.0 to 12.72.0. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.70.0...v12.72.0) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index de772df..08f23ac 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/essentialkaos/check v1.4.0 - github.com/essentialkaos/ek/v12 v12.70.0 + github.com/essentialkaos/ek/v12 v12.72.0 github.com/klauspost/compress v1.16.7 github.com/pierrec/lz4/v4 v4.1.18 github.com/ulikunitz/xz v0.5.11 diff --git a/go.sum b/go.sum index 79d82d8..5616cbf 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= github.com/essentialkaos/check v1.4.0/go.mod h1:LMKPZ2H+9PXe7Y2gEoKyVAwUqXVgx7KtgibfsHJPus0= -github.com/essentialkaos/ek/v12 v12.70.0 h1:3LzRvWparTSaU/SWe5CLB+YwntNHBktkk1RQA7UGzYI= -github.com/essentialkaos/ek/v12 v12.70.0/go.mod h1:juDcZWOWaj1QmYShZkT9RzdqJ3n0tmeP/iq4sw5fQF0= +github.com/essentialkaos/ek/v12 v12.72.0 h1:KG80+kFzNYnArbwaqlUHCe3UpNvRV6uCIdMUKhCBCEA= +github.com/essentialkaos/ek/v12 v12.72.0/go.mod h1:juDcZWOWaj1QmYShZkT9RzdqJ3n0tmeP/iq4sw5fQF0= github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= From 74809f5a50a8a754846b3dbb30ca210eccc47e12 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Jul 2023 02:57:03 +0000 Subject: [PATCH 05/12] Bump github.com/essentialkaos/ek/v12 from 12.72.0 to 12.73.1 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.72.0 to 12.73.1. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.72.0...v12.73.1) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 08f23ac..dcc44db 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/essentialkaos/check v1.4.0 - github.com/essentialkaos/ek/v12 v12.72.0 + github.com/essentialkaos/ek/v12 v12.73.1 github.com/klauspost/compress v1.16.7 github.com/pierrec/lz4/v4 v4.1.18 github.com/ulikunitz/xz v0.5.11 diff --git a/go.sum b/go.sum index 5616cbf..91ea1c4 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= github.com/essentialkaos/check v1.4.0/go.mod h1:LMKPZ2H+9PXe7Y2gEoKyVAwUqXVgx7KtgibfsHJPus0= -github.com/essentialkaos/ek/v12 v12.72.0 h1:KG80+kFzNYnArbwaqlUHCe3UpNvRV6uCIdMUKhCBCEA= -github.com/essentialkaos/ek/v12 v12.72.0/go.mod h1:juDcZWOWaj1QmYShZkT9RzdqJ3n0tmeP/iq4sw5fQF0= +github.com/essentialkaos/ek/v12 v12.73.1 h1:hRx+l4AOawq5Z6u9IH0Ylcw2hMlLznhRFeucjaGfurM= +github.com/essentialkaos/ek/v12 v12.73.1/go.mod h1:juDcZWOWaj1QmYShZkT9RzdqJ3n0tmeP/iq4sw5fQF0= github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= From fb65d1a416fa659f43f45d5fa02aa4d57cb9c4ee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 02:41:11 +0000 Subject: [PATCH 06/12] Bump github.com/essentialkaos/ek/v12 from 12.73.1 to 12.73.2 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.73.1 to 12.73.2. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.73.1...v12.73.2) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index dcc44db..669fc65 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/essentialkaos/check v1.4.0 - github.com/essentialkaos/ek/v12 v12.73.1 + github.com/essentialkaos/ek/v12 v12.73.2 github.com/klauspost/compress v1.16.7 github.com/pierrec/lz4/v4 v4.1.18 github.com/ulikunitz/xz v0.5.11 diff --git a/go.sum b/go.sum index 91ea1c4..260e78e 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= github.com/essentialkaos/check v1.4.0/go.mod h1:LMKPZ2H+9PXe7Y2gEoKyVAwUqXVgx7KtgibfsHJPus0= -github.com/essentialkaos/ek/v12 v12.73.1 h1:hRx+l4AOawq5Z6u9IH0Ylcw2hMlLznhRFeucjaGfurM= -github.com/essentialkaos/ek/v12 v12.73.1/go.mod h1:juDcZWOWaj1QmYShZkT9RzdqJ3n0tmeP/iq4sw5fQF0= +github.com/essentialkaos/ek/v12 v12.73.2 h1:MrHHcH1/qOmeMGruRdtcyWTxHQh85QEvxc8aUmjY07c= +github.com/essentialkaos/ek/v12 v12.73.2/go.mod h1:juDcZWOWaj1QmYShZkT9RzdqJ3n0tmeP/iq4sw5fQF0= github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= From d992e9e58929626386667c832cad31c7b40c34fc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Aug 2023 03:05:10 +0000 Subject: [PATCH 07/12] Bump github.com/essentialkaos/ek/v12 from 12.73.2 to 12.75.1 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.73.2 to 12.75.1. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.73.2...v12.75.1) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 669fc65..f048bbd 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/essentialkaos/check v1.4.0 - github.com/essentialkaos/ek/v12 v12.73.2 + github.com/essentialkaos/ek/v12 v12.75.1 github.com/klauspost/compress v1.16.7 github.com/pierrec/lz4/v4 v4.1.18 github.com/ulikunitz/xz v0.5.11 diff --git a/go.sum b/go.sum index 260e78e..58ee905 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= github.com/essentialkaos/check v1.4.0/go.mod h1:LMKPZ2H+9PXe7Y2gEoKyVAwUqXVgx7KtgibfsHJPus0= -github.com/essentialkaos/ek/v12 v12.73.2 h1:MrHHcH1/qOmeMGruRdtcyWTxHQh85QEvxc8aUmjY07c= -github.com/essentialkaos/ek/v12 v12.73.2/go.mod h1:juDcZWOWaj1QmYShZkT9RzdqJ3n0tmeP/iq4sw5fQF0= +github.com/essentialkaos/ek/v12 v12.75.1 h1:HE8/uWED+QgyT6HIcRULqjMYWKhqQ1rkfa/ozcva1eQ= +github.com/essentialkaos/ek/v12 v12.75.1/go.mod h1:juDcZWOWaj1QmYShZkT9RzdqJ3n0tmeP/iq4sw5fQF0= github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= From 5f6b53a708342a14459e08c5880f791977c30f3f Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Sun, 13 Aug 2023 23:37:36 +0300 Subject: [PATCH 08/12] Improve check for external link --- tar/tar.go | 23 ++++++++++------------- tar/tar_test.go | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/tar/tar.go b/tar/tar.go index 80a73d5..f39aba9 100644 --- a/tar/tar.go +++ b/tar/tar.go @@ -158,8 +158,8 @@ func createFile(h *tar.Header, r io.Reader, path string) error { // createSymlink creates symbolic link func createSymlink(h *tar.Header, dir, path string) error { - if !AllowExternalLinks && isExternalLink(h.Linkname, dir) { - return fmt.Errorf("Symbolic link %s points to target outside of target directory (%s)", h.Name, h.Linkname) + if !AllowExternalLinks && isExternalLink(h.Linkname, path, dir) { + return fmt.Errorf("Symbolic link %s points to object outside of target directory (%s)", h.Name, h.Linkname) } return os.Symlink(h.Linkname, path) @@ -167,8 +167,8 @@ func createSymlink(h *tar.Header, dir, path string) error { // createHardlink creates hard link func createHardlink(h *tar.Header, dir, path string) error { - if !AllowExternalLinks && isExternalLink(h.Linkname, dir) { - return fmt.Errorf("Hard link %s points to target outside of target directory (%s)", h.Name, h.Linkname) + if !AllowExternalLinks && isExternalLink(h.Linkname, path, dir) { + return fmt.Errorf("Hard link %s points to object outside of target directory (%s)", h.Name, h.Linkname) } return os.Link(h.Linkname, path) @@ -198,16 +198,13 @@ func updateAttrs(h *tar.Header, path string) error { } // isExternalLink checks if link leads to object outside target directory -func isExternalLink(path, dir string) bool { - if filepath.IsAbs(path) && !strings.HasPrefix(path, dir) { +func isExternalLink(linkPath, objPath, targetDir string) bool { + if filepath.IsAbs(linkPath) && !strings.HasPrefix(linkPath, targetDir) { return true } - realPath, err := utils.Join(dir, path) - - if err != nil { - return true - } - - return !strings.HasPrefix(realPath, dir) + return !strings.HasPrefix( + filepath.Clean(filepath.Dir(objPath)+"/"+linkPath), + targetDir, + ) } diff --git a/tar/tar_test.go b/tar/tar_test.go index 0ecad9c..b8d5504 100644 --- a/tar/tar_test.go +++ b/tar/tar_test.go @@ -104,5 +104,5 @@ func (s *TarSuite) TestErrors(c *C) { err = createHardlink(&tar.Header{Linkname: "/root/test"}, "/unknown", "/_unknown") c.Assert(err, NotNil) - c.Assert(isExternalLink("../unknown", "/root"), Equals, true) + c.Assert(isExternalLink("../../unknown", "/root/test", "/root"), Equals, true) } From ca26959a681c31fb413e94e72392314fc255b874 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Sun, 13 Aug 2023 23:38:06 +0300 Subject: [PATCH 09/12] Improve CI workflow --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0598c7..1a31f8a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: strategy: matrix: - go: [ '1.18.x', '1.19.x', '1.20.x' ] + go: [ '1.18.x', '1.19.x', '1.20.x', '1.21.x' ] steps: - name: Checkout From cca3eca85e957ffd11ed6f762a12901fc3d38c68 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Sun, 13 Aug 2023 23:39:50 +0300 Subject: [PATCH 10/12] Improve usage example --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2f609c1..ae369b0 100644 --- a/README.md +++ b/README.md @@ -47,13 +47,15 @@ import ( ) func main() { - err := npck.Unpack("file.tar.gz", "/home/john") + file := "file.tar.gz" + err := npck.Unpack(file, "/home/john") if err != nil { - panic("Can't unpack file: %v", err) + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return } - fmt.Printf("File %s successfully unpacked!\n") + fmt.Printf("File %s successfully unpacked!\n", file) } ``` From f1c87f2c000193c4b0d8fa684d8c3a39131e0c91 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Sun, 13 Aug 2023 23:50:30 +0300 Subject: [PATCH 11/12] Improve tests --- tar/tar_test.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tar/tar_test.go b/tar/tar_test.go index b8d5504..93be7ab 100644 --- a/tar/tar_test.go +++ b/tar/tar_test.go @@ -12,6 +12,7 @@ import ( "os" "strings" "testing" + "time" "github.com/essentialkaos/ek/v12/fsutil" "github.com/essentialkaos/ek/v12/hash" @@ -89,11 +90,19 @@ func (s *TarSuite) TestErrors(c *C) { c.Assert(err, NotNil) UpdateTimes, UpdateOwner = true, false - err = updateAttrs(&tar.Header{Linkname: "/__unknown"}, "/_unknown") + err = updateAttrs(&tar.Header{ + Linkname: "/__unknown", + AccessTime: time.Now(), + ModTime: time.Now(), + }, "/_unknown") c.Assert(err, NotNil) UpdateTimes, UpdateOwner = false, true - err = updateAttrs(&tar.Header{Linkname: "/__unknown"}, "/_unknown") + err = updateAttrs(&tar.Header{ + Linkname: "/__unknown", + AccessTime: time.Now(), + ModTime: time.Now(), + }, "/_unknown") c.Assert(err, NotNil) UpdateTimes, UpdateOwner = true, false From a3c784596f1ce5d032599cf5e8b894ba2bf8f289 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Mon, 14 Aug 2023 00:20:01 +0300 Subject: [PATCH 12/12] Add usage examples --- bz2/example_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++++ example_test.go | 26 +++++++++++++++++++++++++ gz/example_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++++ lz4/example_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++++ tar/example_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++++ tbz2/example_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++++ tgz/example_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++++ tlz4/example_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++++ txz/example_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++++ tzst/example_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++++ xz/example_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++++ zip/example_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++++ zst/example_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++++ 13 files changed, 578 insertions(+) create mode 100644 bz2/example_test.go create mode 100644 example_test.go create mode 100644 gz/example_test.go create mode 100644 lz4/example_test.go create mode 100644 tar/example_test.go create mode 100644 tbz2/example_test.go create mode 100644 tgz/example_test.go create mode 100644 tlz4/example_test.go create mode 100644 txz/example_test.go create mode 100644 tzst/example_test.go create mode 100644 xz/example_test.go create mode 100644 zip/example_test.go create mode 100644 zst/example_test.go diff --git a/bz2/example_test.go b/bz2/example_test.go new file mode 100644 index 0000000..a2d06a5 --- /dev/null +++ b/bz2/example_test.go @@ -0,0 +1,46 @@ +package bz2 + +// ////////////////////////////////////////////////////////////////////////////////// // +// // +// Copyright (c) 2023 ESSENTIAL KAOS // +// Apache License, Version 2.0 // +// // +// ////////////////////////////////////////////////////////////////////////////////// // + +import ( + "fmt" + "os" +) + +// ////////////////////////////////////////////////////////////////////////////////// // + +func ExampleUnpack() { + file := "file.bz2" + err := Unpack(file, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} + +func ExampleRead() { + file := "file.bz2" + fd, err := os.OpenFile(file, os.O_RDONLY, 0) + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + err = Read(fd, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} diff --git a/example_test.go b/example_test.go new file mode 100644 index 0000000..7ef6d65 --- /dev/null +++ b/example_test.go @@ -0,0 +1,26 @@ +package npck + +// ////////////////////////////////////////////////////////////////////////////////// // +// // +// Copyright (c) 2023 ESSENTIAL KAOS // +// Apache License, Version 2.0 // +// // +// ////////////////////////////////////////////////////////////////////////////////// // + +import ( + "fmt" +) + +// ////////////////////////////////////////////////////////////////////////////////// // + +func ExampleUnpack() { + file := "file.tzg" + err := Unpack(file, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} diff --git a/gz/example_test.go b/gz/example_test.go new file mode 100644 index 0000000..c77e304 --- /dev/null +++ b/gz/example_test.go @@ -0,0 +1,46 @@ +package gz + +// ////////////////////////////////////////////////////////////////////////////////// // +// // +// Copyright (c) 2023 ESSENTIAL KAOS // +// Apache License, Version 2.0 // +// // +// ////////////////////////////////////////////////////////////////////////////////// // + +import ( + "fmt" + "os" +) + +// ////////////////////////////////////////////////////////////////////////////////// // + +func ExampleUnpack() { + file := "file.gz" + err := Unpack(file, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} + +func ExampleRead() { + file := "file.gz" + fd, err := os.OpenFile(file, os.O_RDONLY, 0) + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + err = Read(fd, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} diff --git a/lz4/example_test.go b/lz4/example_test.go new file mode 100644 index 0000000..3b2ea68 --- /dev/null +++ b/lz4/example_test.go @@ -0,0 +1,46 @@ +package lz4 + +// ////////////////////////////////////////////////////////////////////////////////// // +// // +// Copyright (c) 2023 ESSENTIAL KAOS // +// Apache License, Version 2.0 // +// // +// ////////////////////////////////////////////////////////////////////////////////// // + +import ( + "fmt" + "os" +) + +// ////////////////////////////////////////////////////////////////////////////////// // + +func ExampleUnpack() { + file := "file.lz4" + err := Unpack(file, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} + +func ExampleRead() { + file := "file.lz4" + fd, err := os.OpenFile(file, os.O_RDONLY, 0) + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + err = Read(fd, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} diff --git a/tar/example_test.go b/tar/example_test.go new file mode 100644 index 0000000..7692b47 --- /dev/null +++ b/tar/example_test.go @@ -0,0 +1,46 @@ +package tar + +// ////////////////////////////////////////////////////////////////////////////////// // +// // +// Copyright (c) 2023 ESSENTIAL KAOS // +// Apache License, Version 2.0 // +// // +// ////////////////////////////////////////////////////////////////////////////////// // + +import ( + "fmt" + "os" +) + +// ////////////////////////////////////////////////////////////////////////////////// // + +func ExampleUnpack() { + file := "file.tar" + err := Unpack(file, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} + +func ExampleRead() { + file := "file.tar" + fd, err := os.OpenFile(file, os.O_RDONLY, 0) + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + err = Read(fd, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} diff --git a/tbz2/example_test.go b/tbz2/example_test.go new file mode 100644 index 0000000..bd12e2b --- /dev/null +++ b/tbz2/example_test.go @@ -0,0 +1,46 @@ +package tbz2 + +// ////////////////////////////////////////////////////////////////////////////////// // +// // +// Copyright (c) 2023 ESSENTIAL KAOS // +// Apache License, Version 2.0 // +// // +// ////////////////////////////////////////////////////////////////////////////////// // + +import ( + "fmt" + "os" +) + +// ////////////////////////////////////////////////////////////////////////////////// // + +func ExampleUnpack() { + file := "file.tbz2" + err := Unpack(file, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} + +func ExampleRead() { + file := "file.tbz2" + fd, err := os.OpenFile(file, os.O_RDONLY, 0) + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + err = Read(fd, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} diff --git a/tgz/example_test.go b/tgz/example_test.go new file mode 100644 index 0000000..0f1a7ed --- /dev/null +++ b/tgz/example_test.go @@ -0,0 +1,46 @@ +package tgz + +// ////////////////////////////////////////////////////////////////////////////////// // +// // +// Copyright (c) 2023 ESSENTIAL KAOS // +// Apache License, Version 2.0 // +// // +// ////////////////////////////////////////////////////////////////////////////////// // + +import ( + "fmt" + "os" +) + +// ////////////////////////////////////////////////////////////////////////////////// // + +func ExampleUnpack() { + file := "file.tgz" + err := Unpack(file, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} + +func ExampleRead() { + file := "file.tgz" + fd, err := os.OpenFile(file, os.O_RDONLY, 0) + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + err = Read(fd, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} diff --git a/tlz4/example_test.go b/tlz4/example_test.go new file mode 100644 index 0000000..5c6491c --- /dev/null +++ b/tlz4/example_test.go @@ -0,0 +1,46 @@ +package tlz4 + +// ////////////////////////////////////////////////////////////////////////////////// // +// // +// Copyright (c) 2023 ESSENTIAL KAOS // +// Apache License, Version 2.0 // +// // +// ////////////////////////////////////////////////////////////////////////////////// // + +import ( + "fmt" + "os" +) + +// ////////////////////////////////////////////////////////////////////////////////// // + +func ExampleUnpack() { + file := "file.tlz4" + err := Unpack(file, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} + +func ExampleRead() { + file := "file.tlz4" + fd, err := os.OpenFile(file, os.O_RDONLY, 0) + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + err = Read(fd, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} diff --git a/txz/example_test.go b/txz/example_test.go new file mode 100644 index 0000000..1c1ab22 --- /dev/null +++ b/txz/example_test.go @@ -0,0 +1,46 @@ +package txz + +// ////////////////////////////////////////////////////////////////////////////////// // +// // +// Copyright (c) 2023 ESSENTIAL KAOS // +// Apache License, Version 2.0 // +// // +// ////////////////////////////////////////////////////////////////////////////////// // + +import ( + "fmt" + "os" +) + +// ////////////////////////////////////////////////////////////////////////////////// // + +func ExampleUnpack() { + file := "file.txz" + err := Unpack(file, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} + +func ExampleRead() { + file := "file.txz" + fd, err := os.OpenFile(file, os.O_RDONLY, 0) + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + err = Read(fd, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} diff --git a/tzst/example_test.go b/tzst/example_test.go new file mode 100644 index 0000000..956f452 --- /dev/null +++ b/tzst/example_test.go @@ -0,0 +1,46 @@ +package tzst + +// ////////////////////////////////////////////////////////////////////////////////// // +// // +// Copyright (c) 2023 ESSENTIAL KAOS // +// Apache License, Version 2.0 // +// // +// ////////////////////////////////////////////////////////////////////////////////// // + +import ( + "fmt" + "os" +) + +// ////////////////////////////////////////////////////////////////////////////////// // + +func ExampleUnpack() { + file := "file.tzst" + err := Unpack(file, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} + +func ExampleRead() { + file := "file.tzst" + fd, err := os.OpenFile(file, os.O_RDONLY, 0) + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + err = Read(fd, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} diff --git a/xz/example_test.go b/xz/example_test.go new file mode 100644 index 0000000..2e62aff --- /dev/null +++ b/xz/example_test.go @@ -0,0 +1,46 @@ +package xz + +// ////////////////////////////////////////////////////////////////////////////////// // +// // +// Copyright (c) 2023 ESSENTIAL KAOS // +// Apache License, Version 2.0 // +// // +// ////////////////////////////////////////////////////////////////////////////////// // + +import ( + "fmt" + "os" +) + +// ////////////////////////////////////////////////////////////////////////////////// // + +func ExampleUnpack() { + file := "file.xz" + err := Unpack(file, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} + +func ExampleRead() { + file := "file.xz" + fd, err := os.OpenFile(file, os.O_RDONLY, 0) + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + err = Read(fd, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} diff --git a/zip/example_test.go b/zip/example_test.go new file mode 100644 index 0000000..0e127fb --- /dev/null +++ b/zip/example_test.go @@ -0,0 +1,46 @@ +package zip + +// ////////////////////////////////////////////////////////////////////////////////// // +// // +// Copyright (c) 2023 ESSENTIAL KAOS // +// Apache License, Version 2.0 // +// // +// ////////////////////////////////////////////////////////////////////////////////// // + +import ( + "fmt" + "os" +) + +// ////////////////////////////////////////////////////////////////////////////////// // + +func ExampleUnpack() { + file := "file.zip" + err := Unpack(file, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} + +func ExampleRead() { + file := "file.zip" + fd, err := os.OpenFile(file, os.O_RDONLY, 0) + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + err = Read(fd, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} diff --git a/zst/example_test.go b/zst/example_test.go new file mode 100644 index 0000000..2b2cd15 --- /dev/null +++ b/zst/example_test.go @@ -0,0 +1,46 @@ +package zst + +// ////////////////////////////////////////////////////////////////////////////////// // +// // +// Copyright (c) 2023 ESSENTIAL KAOS // +// Apache License, Version 2.0 // +// // +// ////////////////////////////////////////////////////////////////////////////////// // + +import ( + "fmt" + "os" +) + +// ////////////////////////////////////////////////////////////////////////////////// // + +func ExampleUnpack() { + file := "file.zst" + err := Unpack(file, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +} + +func ExampleRead() { + file := "file.zst" + fd, err := os.OpenFile(file, os.O_RDONLY, 0) + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + err = Read(fd, "/home/bob/data") + + if err != nil { + fmt.Printf("Error: Can't unpack %s: %v\n", file, err) + return + } + + fmt.Printf("File %s successfully unpacked!\n", file) +}