Commit graph

27 commits

Author SHA1 Message Date
Babak K. Shandiz
0f32f2ac46
refactor(run download): extract zip extraction func into a separate package
Signed-off-by: Babak K. Shandiz <babakks@github.com>

Co-authored-by: Kynan Ware <bagtoad@github.com>
Co-authored-by: Devraj Mehta <devm33@github.com>
2026-01-19 10:38:21 +00:00
Babak K. Shandiz
3ad3fcdce9
fix: resolve gocritic issue
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-11-03 20:05:26 +00:00
William Martin
9bd8f09774 Use safepaths for run download 2024-12-04 22:12:58 +01:00
William Martin
a47b4c9f1d Use consistent slice ordering in run download tests 2024-12-04 13:02:25 +01:00
Andy Feller
8720479b0b Consolidate logic for isolating artifacts 2024-12-03 13:33:00 -05:00
Andy Feller
cdfc12caf5 Expand logic and tests to handle edge cases
This commit expands filepathDescendsFrom(string, string) to handle edge cases such as mixing absolute and relative paths or artifact name edge cases.

Additionally, tests for filepathDescendsFrom() and downloadrun() have been expanded to verify additional use cases.
2024-11-22 15:26:11 -05:00
Andy Feller
e7c5706336 Refactor download testing, simpler file descends
This incorporates the work done by @williammartin to improve reasoning about `gh run download` behavior through testing while verifying a simpler solution to checking if a path is contained within a directory.
2024-11-21 17:07:27 -05:00
Tyler McGoffin
83cf411556 Improve test names so there is no repetition 2024-11-19 16:08:31 -08:00
Andy Feller
8da27d2c8a Second attempt to address exploit
This builds off suggestion to reuse logic used already within `gh run download` for detecting path traversals.

This largely works but runs into an issue where detection logic doesn't handle non-separated traversal.
2024-11-19 17:55:18 -05:00
Junichi Sato
330a385f9e
Document that gh run download downloads the latest artifact by default
This commit addresses the documentation issue.

The discussion at #7018 has confirmed that it is undocumented that
the current behavior of `gh run download` with `-n` and no `run-id`
downloads the latest artifact.

Although the behavior has not been created intentionally, it is the one
that should be documented and the future releases should warn before
a breaking change.
2024-08-08 19:35:16 +09:00
Yukai Chou
d7b8ecf33d Unify use of tab indent in non-test source files
Found with
    rg '(^ | \t|\t )' -g '*.go' -g '!*_test.go'

Mixed indent exceptions:
- wrapped long list items with extra 2-space indent
- code snippets using space indent
- commented code lines having "\t*// \t+" prefix
2024-08-03 00:35:30 +08:00
vilmibm
5597139df3 switch to []int return for multiselect 2023-05-23 00:12:44 -07:00
nate smith
c536114de0 use new prompter in run download 2023-04-10 17:38:30 -07:00
Sam Coe
39805fa9b1
Properly handle closing files that have been writen to (#7199) 2023-03-23 01:17:47 +00:00
vilmibm
41385477c3 fix linting 2022-07-27 14:15:27 -05:00
ffalor
3fb8579419
Add --pattern field to run download (#5539) 2022-05-23 08:57:57 +00:00
Håvard Anda Estensen
58cb773e09
Replace ioutil with io and os (#5498) 2022-04-26 13:07:44 +02:00
Mislav Marohnić
a315e6865c run download: fix extracting to root path
Our rudimentary check for whether a file path is entirely contained
under a directory had a false negative when the parent directory is "/".
2022-02-18 20:27:40 +01:00
Mislav Marohnić
11fbb60ae7 Rename the module to "github.com/cli/cli/v2" 2021-08-25 12:41:30 +02:00
Mislav Marohnić
f8c7fd1d28 Fix extracting workflow artifact to a relative path
To prevent zipslip, we verify that each extracted file would fall
strictly under the prefix of the path to extract to. However, this
yielded a false positive when extracting to `.`, which is the default
for downloading a single archive.
2021-04-13 19:15:14 +02:00
vilmibm
878bdb8d50 add an example 2021-04-07 14:48:28 -05:00
vilmibm
9b5e92e64a make test windows friendly 2021-04-07 14:47:12 -05:00
Mislav Marohnić
6ce12c07f6 Move Artifact to the "shared" package 2021-04-07 20:26:12 +02:00
Mislav Marohnić
0e94de1ce6 Address run download feedback
- With no arguments in TTY mode, prompt which artifacts to download
- Change `--pattern` argument to be just `--name` and only do exact
  matching
- For multi-archive downloads, prefix the destination path with the name
  of the artifact
- Add tests exercising HTTP functionality
- Avoid "zipslip" path injection when extracting ZIP files
- Add tests for ZIP extraction
2021-04-07 19:56:28 +02:00
Mislav Marohnić
b41681cbb7 Restore Go < 1.16 compatibility 2021-04-02 20:54:56 +02:00
Mislav Marohnić
51a0a27a6f Add ARTIFACTS information to run view 2021-04-02 20:52:41 +02:00
Mislav Marohnić
c54e3c9ca8 Add run download command for downloading workflow artifacts 2021-04-02 20:42:18 +02:00