Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

Commit

Permalink
(GH-599) Restrict calls to choco.org to https
Browse files Browse the repository at this point in the history
This proved the changes required to ensure that client communicates with
chocolatey.org using HTTPS.
  • Loading branch information
ferventcoder committed Nov 2, 2014
1 parent 372a262 commit 3d2ee3e
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 38 deletions.
10 changes: 5 additions & 5 deletions chocolateyInstall/InstallChocolatey.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ==============================================================================
#
# Fervent Coder Copyright 2011 - Released under the Apache 2.0 License
# Fervent Coder Copyright 2011 - Present - Released under the Apache 2.0 License
#
# Copyright 2007-2008 The Apache Software Foundation.
#
Expand All @@ -17,9 +17,9 @@
# ==============================================================================

# variables
#$url = "http://chocolatey.org/packages/chocolatey/DownloadPackage"
$url = "http://chocolatey.org/api/v2/package/chocolatey/"
#$url = "http://chocolatey.org/api/v1/package/chocolatey"
#$url = "https://chocolatey.org/packages/chocolatey/DownloadPackage"
$url = "https://chocolatey.org/api/v2/package/chocolatey/"
#$url = "https://chocolatey.org/api/v1/package/chocolatey"
$chocTempDir = Join-Path $env:TEMP "chocolatey"
$tempDir = Join-Path $chocTempDir "chocInstall"
if (![System.IO.Directory]::Exists($tempDir)) {[System.IO.Directory]::CreateDirectory($tempDir)}
Expand Down Expand Up @@ -47,7 +47,7 @@ $chocInstallPS1 = Join-Path $toolsFolder "chocolateyInstall.ps1"
write-host 'Ensuring chocolatey commands are on the path'
$chocInstallVariableName = "ChocolateyInstall"
$nuGetPath = [Environment]::GetEnvironmentVariable($chocInstallVariableName, [System.EnvironmentVariableTarget]::User)
$nugetExePath = 'C:\NuGet\bin'
$nugetExePath = 'C:\ProgramData\Chocolatey\bin'
if ($nuGetPath -ne $null) {
$nugetExePath = Join-Path $nuGetPath 'bin'
}
Expand Down
2 changes: 1 addition & 1 deletion nuget/chocolatey.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ See all - https://github.com/chocolatey/chocolatey/blob/master/CHANGELOG.md
* Update to Nuget.exe 2.8.2 - https://github.com/chocolatey/chocolatey/issues/379

</releaseNotes>
<projectUrl>http://chocolatey.org</projectUrl>
<projectUrl>https://chocolatey.org</projectUrl>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<copyright>RealDimensions Software, LLC - 2011-Present</copyright>
Expand Down
2 changes: 1 addition & 1 deletion readme.markdown
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Chocolatey NuGet (like apt-get, but for Windows) [![](http://img.shields.io/gittip/Chocolatey.svg)](https://www.gittip.com/Chocolatey/) [![](http://img.shields.io/chocolatey/dt/chocolatey.svg)](http://chocolatey.org/packages/chocolatey) [![](http://img.shields.io/chocolatey/v/chocolatey.svg)](http://chocolatey.org/packages/chocolatey) [![Build status](https://ci.appveyor.com/api/projects/status/jj9h1tobakhpbiwx/branch/master)](https://ci.appveyor.com/project/ferventcoder/chocolatey/branch/master) [![](http://img.shields.io/teamcity/codebetter/bt802.svg)](http://teamcity.codebetter.com/viewType.html?buildTypeId=bt802)
Chocolatey NuGet (like apt-get, but for Windows) [![](http://img.shields.io/gittip/Chocolatey.svg)](https://www.gittip.com/Chocolatey/) [![](http://img.shields.io/chocolatey/dt/chocolatey.svg)](https://chocolatey.org/packages/chocolatey) [![](http://img.shields.io/chocolatey/v/chocolatey.svg)](https://chocolatey.org/packages/chocolatey) [![Build status](https://ci.appveyor.com/api/projects/status/jj9h1tobakhpbiwx/branch/master)](https://ci.appveyor.com/project/ferventcoder/chocolatey/branch/master) [![](http://img.shields.io/teamcity/codebetter/bt802.svg)](http://teamcity.codebetter.com/viewType.html?buildTypeId=bt802)
=======
![Chocolatey Logo](https://github.com/chocolatey/chocolatey/raw/master/docs/logo/chocolateyicon.gif "Chocolatey")

Expand Down
27 changes: 0 additions & 27 deletions src/chocolatey.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -122,37 +122,10 @@ The default install location has been changed to '$newChocoPath'.
"@ | Write-Host -ForegroundColor $Warning -BackgroundColor Black
}

# Win2003/XP do not support SNI
if ([Environment]::OSVersion.Version -lt (new-object 'Version' 6,0)){
$originalSource = $source
Write-Debug 'This version of Windows does not support SNI, so configuring chocolatey to use Http automatically'
$chocoHttpExists = $false
$chocoHttpId = 'chocolateyHttp'
$sources = Chocolatey-Sources 'list'
Write-Debug 'Checking sources to see if chocolatey http is configured'
foreach ($sourceConfig in $sources) {
if ($sourceConfig.ID -eq "$chocoHttpId") {
Write-Debug 'ChocolateyHttp found'
$chocoHttpExists = $true
break
}
}

if (!$chocoHttpExists) {
Write-Debug 'Removing https version of chocolatey and re-adding as http'
Chocolatey-Sources 'disable' 'chocolatey'
Chocolatey-Sources 'add' "$chocoHttpId" 'http://chocolatey.org/api/v2/'
}

#this command fixes a small change somewhere that messes up the original source specified
$source = $originalSource
}

# bump installarguments back to quotes
$installArguments = $installArguments.Replace("'","""")
$packageParameters = $packageParameters.Replace("'","""")


#main entry point
Append-Log

Expand Down
2 changes: 1 addition & 1 deletion src/functions/Chocolatey-InstallAll.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ param(

Write-Debug "Running 'Chocolatey-InstallAll' with source:`'$source`'";

if ($source -eq '' -or $source -eq 'https://go.microsoft.com/fwlink/?LinkID=230477' -or $source -eq 'http://chocolatey.org/api/v2/') {
if ($source -eq '' -or $source -eq 'https://go.microsoft.com/fwlink/?LinkID=230477' -or $source -eq 'https://chocolatey.org/api/v2/') {
write-host 'Source must be specified and cannot be nuget.org/chocolatey.org'
return
}
Expand Down
4 changes: 2 additions & 2 deletions src/functions/Chocolatey-Push.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
function Chocolatey-Push {
param(
[string] $packageName,
[string] $source = 'http://chocolatey.org/'
[string] $source = 'https://chocolatey.org/'
)
Write-Debug "Running 'Chocolatey-Push' for $packageName with source:`'$source`'";

$srcArgs = "-source $source"
if ($source -like '') {
$srcArgs = '-source http://chocolatey.org/'
$srcArgs = '-source https://chocolatey.org/'
Write-Debug "Setting source to `'$srcArgs`'"
}

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Get-ConfigValue.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Describe "Get-ConfigValue" {
<?xml version="1.0"?>
<chocolatey>
<sources>
<source id="chocolatey" value="http://chocolatey.org/api/v2/" />
<source id="chocolatey" value="https://chocolatey.org/api/v2/" />
<source id="nuget" value="https://go.microsoft.com/fwlink/?LinkID=230477" />
</sources>
</chocolatey>
Expand Down

0 comments on commit 3d2ee3e

Please sign in to comment.