Skip to content

Commit

Permalink
[Sources] fix github url check (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
benlorenz authored Jan 31, 2023
1 parent ccfc219 commit 35a86ff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Sources.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ function check_github_archive(url::String)
# * https://github.com/spack/spack/issues/35250
# Note: according to
# <https://github.com/bazel-contrib/SIG-rules-authors/issues/11#issuecomment-1029861300>
# the `/archive/refs/tag` should be more stable, but that didn't happen in the incident
# the `/archive/refs/tags` should be more stable, but that didn't happen in the incident
# on 2023-01-30, so it's unclear whether we can trust them.
if contains(url, r"github.com/[^/]+/[^/]+/archive/(refs/tag/)?[^/]+\.(tar\.gz|zip)$")
if contains(url, r"github.com/[^/]+/[^/]+/archive/(refs/tags/)?[^/]+\.(tar\.gz|zip)$")
throw(ArgumentError("""
The archive automatically generated by GitHub
$(url)
Expand Down
4 changes: 2 additions & 2 deletions test/sources.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ using JSON
@test FileSource("https://curl.haxx.se/ca/cacert-2020-01-01.pem", "adf770dfd574a0d6026bfaa270cb6879b063957177a991d453ff1d302c02081f"; filename="cacert.pem").filename == "cacert.pem"
# GitHub-generated archives are banned
@test_throws ArgumentError ArchiveSource("https://github.com/ralna/ARCHDefs/archive/v2.0.3x.tar.gz", "6583e27f84338447767bbdf4335514c8836ae4ad54f5e66280307e8b57189cff")
@test_throws ArgumentError ArchiveSource("https://github.com/ralna/ARCHDefs/archive/refs/tag/v2.0.3x.tar.gz", "6583e27f84338447767bbdf4335514c8836ae4ad54f5e66280307e8b57189cff")
@test_throws ArgumentError ArchiveSource("https://github.com/ralna/ARCHDefs/archive/refs/tags/v2.0.3x.tar.gz", "6583e27f84338447767bbdf4335514c8836ae4ad54f5e66280307e8b57189cff")
@test_throws ArgumentError FileSource("https://github.com/ralna/ARCHDefs/archive/v2.0.3x.tar.gz", "6583e27f84338447767bbdf4335514c8836ae4ad54f5e66280307e8b57189cff")
@test_throws ArgumentError FileSource("https://github.com/ralna/ARCHDefs/archive/refs/tag/v2.0.3x.tar.gz", "6583e27f84338447767bbdf4335514c8836ae4ad54f5e66280307e8b57189cff")
@test_throws ArgumentError FileSource("https://github.com/ralna/ARCHDefs/archive/refs/tags/v2.0.3x.tar.gz", "6583e27f84338447767bbdf4335514c8836ae4ad54f5e66280307e8b57189cff")

@test SetupSource("https://ftp.gnu.org/gnu/wget/wget-1.20.3.tar.gz", "wget-1.20.3.tar.gz", "", "") isa SetupSource{ArchiveSource}
@test SetupSource("https://ftp.gnu.org/gnu/wget/wget-1.20.3.zip", "wget-1.20.3.zip", "", "") isa SetupSource{ArchiveSource}
Expand Down

0 comments on commit 35a86ff

Please sign in to comment.