Homebrew / brew

🍺 The missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
41.2k stars 9.68k forks source link

New Cask Formula with Cookie encoding requirements fails #6148

Closed giovannidegani closed 5 years ago

giovannidegani commented 5 years ago

Please note that we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you repeatedly fail to use the issue template, we will block you from ever submitting issues to Homebrew again.

What you were trying to do (and why)

I'm writing a new formula for Cask to download and install SAP Cloud Platform Neo SDK CLI tool from https://tools.hana.ondemand.com/sdk/neo-java-web-sdk-3.80.13.zip

This download link has a EULA step that can be bypassed by providing the following cookie: eula_3_1_agreed=tools.hana.ondemand.com/developer-license-3_1.txt

cask 'sap-cloud-platform-neo-enviroment-sdk' do
  version "3.80.13"
  sha256 "cb75e6b55ee65d45b115d2eed3dfa04d58877464630346e36ad9c9d511383a8e"

  url "https://tools.hana.ondemand.com/sdk/neo-java-web-sdk-#{version}.zip",
      cookies: {
                 'eula_3_1_agreed' => 'tools.hana.ondemand.com/developer-license-3_1.txt',
               }
  name 'SAP Cloud Platform Neo Environment SDK'
  homepage 'https://tools.hana.ondemand.com/#cloud'

  binary 'tools/neo.sh', target: 'neo'

  artifact 'api', target: "#{HOMEBREW_PREFIX}/sap-cloud-platform-neo-enviroment-sdk-#{version}/api"
  artifact 'javadoc', target: "#{HOMEBREW_PREFIX}/sap-cloud-platform-neo-enviroment-sdk-#{version}/javadoc"
  artifact 'license', target: "#{HOMEBREW_PREFIX}/sap-cloud-platform-neo-enviroment-sdk-#{version}/license"
  artifact 'repository', target: "#{HOMEBREW_PREFIX}/sap-cloud-platform-neo-enviroment-sdk-#{version}/repository"
  artifact 'samples', target: "#{HOMEBREW_PREFIX}/sap-cloud-platform-neo-enviroment-sdk-#{version}/samples"
  artifact 'sdk.version', target: "#{HOMEBREW_PREFIX}/nsap-cloud-platform-neo-enviroment-sdk-#{version}/sdk.version"
  artifact 'tools', target: "#{HOMEBREW_PREFIX}/sap-cloud-platform-neo-enviroment-sdk-#{version}/tools"

  preflight do
    system_command '/bin/mkdir', args: ['-p', "#{HOMEBREW_PREFIX}/sap-cloud-platform-neo-enviroment-sdk-#{version}"], sudo: true
  end

end

What happened (include command output)

The cookie encoding that happens in download_strategy.rb wrongly encodes the cookie value, and the download fails.

Command output

brew cask install --debug --verbose sap-cloud-platform-neo-enviroment-sdk.rb
==> Cask::Installer#install
==> Printing caveats
==> Cask::Installer#fetch
==> Satisfying dependencies
==> Downloading
==> Downloading https://tools.hana.ondemand.com/sdk/neo-java-web-sdk-3.80.13.zip
/usr/bin/curl -q --show-error --user-agent Homebrew/2.1.2-66-g099b047\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 10.14.5\)\ curl/7.54.0 -b eula_3_1_agreed=tools.hana.ondemand.com\%2Fdeveloper-license-3_1.txt --location --silent --head --request GET https://tools.hana.ondemand.com/sdk/neo-java-web-sdk-3.80.13.zip
Already downloaded: /Users/dkgiodeg/Library/Caches/Homebrew/downloads/9b0bfbcc83992d54b3add15f5691c080d7fe11a8b7207eb754478fe8ef1c16bd--neo-java-web-sdk-3.80.13.zip
==> Checking quarantine support
/usr/bin/xattr
/usr/bin/swift /usr/local/Homebrew/Library/Homebrew/cask/utils/quarantine.swift
==> Quarantine is available.
==> Verifying Gatekeeper status of /Users/dkgiodeg/Library/Caches/Homebrew/downloads/9b0bfbcc83992d54b3add15f5691c080d7fe11a8b7207eb754478fe8ef1c16bd--neo-java-web-sdk-3.80.13.zip
/usr/bin/xattr -p com.apple.quarantine /Users/dkgiodeg/Library/Caches/Homebrew/downloads/9b0bfbcc83992d54b3add15f5691c080d7fe11a8b7207eb754478fe8ef1c16bd--neo-java-web-sdk-3.80.13.zip
==> /Users/dkgiodeg/Library/Caches/Homebrew/downloads/9b0bfbcc83992d54b3add15f5691c080d7fe11a8b7207eb754478fe8ef1c16bd--neo-java-web-sdk-3.80.13.zip is quarantined
==> Downloaded to -> /Users/dkgiodeg/Library/Caches/Homebrew/downloads/9b0bfbcc83992d54b3add15f5691c080d7fe11a8b7207eb754478fe8ef1c16bd--neo-java-web-sdk-3.80.13.zip
==> Verifying SHA-256 checksum for Cask 'sap-cloud-platform-neo-enviroment-sdk'.
==> Note: Running `brew update` may fix SHA-256 checksum errors.
Error: Checksum for Cask 'sap-cloud-platform-neo-enviroment-sdk' does not match.
Expected: cb75e6b55ee65d45b115d2eed3dfa04d58877464630346e36ad9c9d511383a8e
  Actual: 53d4e2857c317a63aefcbccc72639b2bf6af59d7aac00ef8b6b15a2055ad8fcc
    File: /Users/dkgiodeg/Library/Caches/Homebrew/downloads/9b0bfbcc83992d54b3add15f5691c080d7fe11a8b7207eb754478fe8ef1c16bd--neo-java-web-sdk-3.80.13.zip
To retry an incomplete download, remove the file above.
If the issue persists, visit:
  https://github.com/Homebrew/homebrew-cask/blob/master/doc/reporting_bugs/checksum_does_not_match_error.md
/usr/local/Homebrew/Library/Homebrew/cask/verify.rb:23:in `all'
/usr/local/Homebrew/Library/Homebrew/cask/installer.rb:162:in `verify'
/usr/local/Homebrew/Library/Homebrew/cask/installer.rb:67:in `fetch'
/usr/local/Homebrew/Library/Homebrew/cask/installer.rb:94:in `install'
/usr/local/Homebrew/Library/Homebrew/cask/cmd/install.rb:23:in `block in run'
/usr/local/Homebrew/Library/Homebrew/cask/cmd/install.rb:16:in `each'
/usr/local/Homebrew/Library/Homebrew/cask/cmd/install.rb:16:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/cmd/abstract_command.rb:36:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/cmd.rb:92:in `run_command'
/usr/local/Homebrew/Library/Homebrew/cask/cmd.rb:158:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/cmd.rb:123:in `run'
/usr/local/Homebrew/Library/Homebrew/cmd/cask.rb:9:in `cask'
/usr/local/Homebrew/Library/Homebrew/brew.rb:102:in `
' Error: Kernel.exit /usr/local/Homebrew/Library/Homebrew/cask/cmd.rb:162:in `exit' /usr/local/Homebrew/Library/Homebrew/cask/cmd.rb:162:in `rescue in run' /usr/local/Homebrew/Library/Homebrew/cask/cmd.rb:146:in `run' /usr/local/Homebrew/Library/Homebrew/cask/cmd.rb:123:in `run' /usr/local/Homebrew/Library/Homebrew/cmd/cask.rb:9:in `cask' /usr/local/Homebrew/Library/Homebrew/brew.rb:102:in `
'

What you expected to happen

I expect the following curl command to be generated, as this one works: /usr/bin/curl -q --show-error --user-agent Homebrew/2.1.2-64-gbcc5f04\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 10.14.5\)\ curl/7.54.0 -b "eula_3_1_agreed=tools.hana.ondemand.com/developer-license-3_1.txt" --location --silent --head --request GET https://tools.hana.ondemand.com/sdk/neo-java-web-sdk-3.80.13.zip

Also, encoding cookies is not part of the RFC, even though is common, is not always required mozilla cookie directives

A can optionally be set in double quotes and any US-ASCII characters excluding CTLs, whitespace, double quotes, comma, semicolon, and backslash are allowed. Encoding: Many implementations perform URL encoding on cookie values, however it is not required per the RFC specification. It does help satisfying the requirements about which characters are allowed for though.

Step-by-step reproduction instructions (by running brew commands)

  1. Create a new cask formula with the above code
  2. Run the formula. eg. brew cask install sap-cloud-platform-neo-enviroment-sdk.rb
MikeMcQuaid commented 5 years ago

CC @Homebrew/cask