Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(MODULES-6652) Fix download 7z behind proxy #94

Merged
merged 1 commit into from
Mar 11, 2019

Conversation

helge000
Copy link

Adds a local file '7za.exe' witch is copied to $::system32 in case unzip
method is '7zip'.
7za - source: https://chocolatey.org/7za.exe, witch was originally used
in the template.

@helge000 helge000 changed the title Fixes MODULES-6652 (MODULES-6652) Fix download 7z behind proxy Feb 16, 2018
@helge000 helge000 force-pushed the MODULES-6652 branch 4 times, most recently from 6c414ed to 50f1b38 Compare February 16, 2018 11:12
@ferventcoder
Copy link

A few things:

  • Find a temp location, don't use system32.
  • Make sure this is 32-bit 7za.exe.
  • Ensure it is at least 18.1 to get past all current CVEs.

@ferventcoder
Copy link

We are pushing the latest 7za up to https://chocolatey.org, so if you want to use that as a source, hold until we have it up there.

@helge000
Copy link
Author

A few things:

  • Find a temp location, don't use system32.

Do you have something specific in mind here?

I did not use a temp location on purpose to avoid recreating 7za.exe unnecessarily. However, it might be ok since we only call install on installs and updates? If I use a temp location, I only see C:\Windows\temp; I would need to access it quite ugly via $::system32\\..\\temp.

  • Make sure this is 32-bit 7za.exe.

Should be the case already since I used the one from chocolatey.org

  • Ensure it is at least 18.1 to get past all current CVEs.

I could only find 18.0.1; so I'll just wait until you tell me to redownload.

@ferventcoder
Copy link

@helge000 https://chocolatey.org/7za.exe is now 18.1. (it shows 18.0.1 as product version).

$unzip_type = $::chocolatey::use_7zip ? {
true => '7zip',
default => 'windows'
$sevenzip_exe = "${::system32}\\chocolatey_temp_7za.exe"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't mind code style, we could use something like

$sevenzip_exe = inline_template('"#{ENV['TEMP']}\\7za.exe"')

Witch is basically the current behavior.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could work, but I wonder what the Puppet style guide says about that.

@jpogran
Copy link

jpogran commented Feb 20, 2018

I am not OK with vendoring in a binary in our module, or writing it to system32

@ferventcoder
Copy link

I am not OK with vendoring in a binary in our module, or writing it to system32

@jpogran I replied at https://tickets.puppetlabs.com/browse/MODULES-6652. Let me know if you want to keep the discussion here or if that location is more appropriate?

@Iristyle
Copy link

I can understand the appeal of vendoring 7za.exe inside the module to solve this problem. There are a few downsides from a maintainers perspective however that we have to consider:

  • Licensing for 7-zip is GNU LGPL per http://www.7-zip.org/license.txt. IANAL, but I'm not sure that redistributing 7-zip would be compatible with our Apache 2 license (also see https://www.apache.org/licenses/GPL-compatibility.html). In any event, it's a complicated subject.
  • Including other projects that are not Puppet maintained incurs an additional ongoing cost from a security perspective. To even add 7-zip requires approval by the release team, which means evaluating a number of criteria, including the disclosure practices of 7-zip. If approved, active security triage is then required going forward, which could result in unscheduled releases.
  • While the 7-zip source code is available as a 7-zip package, it's not available in a public repository like GitHub. This does make it a bit more difficult if there's ever a need to build custom binaries, for instance in response to a critical vulnerability that doesn't yet have a release.

Given the above complexity, is there another way we could address the hardcoded URI? For instance, would it be enough to make it configurable, so that users can stage their own copy (for instance by placing it in a Code Manager control repo), and using a file:// style URI?

@helge000 helge000 force-pushed the MODULES-6652 branch 2 times, most recently from 9491105 to de1d97f Compare February 22, 2018 10:41
@helge000
Copy link
Author

@Iristyle, thanks for elaborating; makes much more sense to me now.

@@ -62,6 +66,7 @@
class chocolatey (
$choco_install_location = $::chocolatey::params::install_location,
$use_7zip = $::chocolatey::params::use_7zip,
$binary_7zip = $::chocolatey::params::binary_7zip,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ferventcoder, are you ok with this new param name?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't self document what it is. Needs something like 7zip_download_url to make it consistent with the other params.

Copy link
Author

@helge000 helge000 Feb 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly, though I cannot start a var name with a number. What about:
$download_url_7zip

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch. How about seven_zip_download_url? Although both would probably work, just weird workaround that folks may not immediately understand.

@helge000
Copy link
Author

@ferventcoder, I refactored to use a new parameter. I also tried to find the relevant docs. I feel I should also add a spec for the new file?

@ferventcoder
Copy link

@Iristyle way ahead of you on that (see JIRA) - but thank you for elaborating on the reasoning.

@@ -793,6 +793,10 @@ If you override the default installation directory you need to set appropriate p

Specifies whether to use the built-in shell or allow the installer to download 7zip to extract `chocolatey.nupkg` during installation. Valid options: `true`, `false`. Default: `false`.

##### `seven_zip_download_url`

Specifies the source file for `7za.exe`. Supports all sources supported by Puppet's `file {}` resource. You should use a 32bit binary for compatibility. Defaults to `https://chocolatey.org/7za.exe`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: perhaps instead of file {} use [file](<url to file resource>)

@michaeltlombardi michaeltlombardi force-pushed the MODULES-6652 branch 7 times, most recently from c37317e to d6db7cd Compare March 8, 2019 22:02
ThoughtCrhyme
ThoughtCrhyme previously approved these changes Mar 8, 2019
Facter.clear_messages
end

context "on Windows", :if => Puppet::Util::Platform.windows? do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should maybe replace with skips in the It blocks? CC @ThoughtCrhyme

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Prior to this commit the 7zip executable, a requirement for the
installation of Chocolatey, was hardcoded for download from a
single internet URL. This caused failures when pointed through
a proxy.

This commit adds a new parameter, `$seven_zip_download_url` to
the Chocolatey class. This is used to specify the path to the
`7za.exe` binary, which can live anywhere that the Puppet File
resource can retrieve it for the target machine. It uses such
a file declaration in the `install.pp` manifest to handle cases
where the use of 7zip is required. This parameter defaults to
the previously hardcoded URL, `https://chocolatey.org/7za.exe`.

This commit also adds a new fact, `choco_temp_dir`, to discover
the appropriate temporary folder on disk in which to place the
7zip binary. It follows the pattern for using/testing facts as
the `choco_install_path` fact already used in this module, by
adding the logic for the fact in helper code.

This commit therefore also includes new tests to the module for
the helper code, the fact, the parameter, and the expected change
in behavior. It also includes updated documentation per the new
parameter.
@ThoughtCrhyme ThoughtCrhyme merged commit e743906 into puppetlabs:master Mar 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants