|
8 | 8 | # - Each path component must begin with [\w], or a more restrictive character set. |
9 | 9 | # - Percent (`%`) shall not be allowed to avoid any percent encoding. |
10 | 10 | WINDOWS_VERSIONS_URLS_REGEXPS = [ |
11 | | - %r{^https://github\.com/oneclick/rubyinstaller2?/releases/download/\w[\w.-]*/\w[\w.-]*$}, |
12 | | - %r{^https://github\.com/MSP-Greg/ruby-loco/releases/download/\w[\w.-]*/\w[\w.-]*$} |
| 11 | + %r{\Ahttps://github\.com/oneclick/rubyinstaller2?/releases/download/\w[\w.-]*/\w[\w.-]*\z}, |
| 12 | + %r{\Ahttps://github\.com/MSP-Greg/ruby-loco/releases/download/\w[\w.-]*/\w[\w.-]*\z} |
13 | 13 | ].freeze |
14 | 14 |
|
15 | 15 | WINDOWS_TOOLCHAIN_VERSIONS_URLS_REGEXPS = [ |
16 | | - %r{^https://github\.com/oneclick/rubyinstaller/releases/download/devkit-4\.7\.2/DevKit-mingw64-64-4\.7\.2-20130224-1432-sfx\.exe$}, |
17 | | - %r{^https://github\.com/ruby/setup-msys2-gcc/releases/download/\w[\w.-]*/\w[\w@.-]*$}, |
18 | | - %r{^https://github\.com/ruby/setup-msys2-gcc/releases/latest/download/\w[\w@.-]*$} |
| 16 | + %r{\Ahttps://github\.com/oneclick/rubyinstaller/releases/download/devkit-4\.7\.2/DevKit-mingw64-64-4\.7\.2-20130224-1432-sfx\.exe\z}, |
| 17 | + %r{\Ahttps://github\.com/ruby/setup-msys2-gcc/releases/download/\w[\w.-]*/\w[\w@.-]*\z}, |
| 18 | + %r{\Ahttps://github\.com/ruby/setup-msys2-gcc/releases/latest/download/\w[\w@.-]*\z} |
19 | 19 | ].freeze |
20 | 20 |
|
21 | 21 | # Validate all the URLs in the versions json |
22 | 22 | def validate(versions, allowed_urls_regexps) |
23 | 23 | versions.values.flat_map(&:values).each do |url| |
24 | | - if allowed_urls_regexps.none? { |regexp| regexp =~ url } |
| 24 | + if allowed_urls_regexps.none? { |regexp| regexp.match? url } |
25 | 25 | raise SecurityError, "Unexpected URL: #{url}" |
26 | 26 | end |
27 | 27 | end |
|
0 commit comments