Get-ChocolateyWebFile should pass the Options parameter to Get-WebFileName and Get-WebHeaders
- Dominant language
- C#
- Stars
- 11.5k
- Forks
- 960
- PR merge metrics
- No merged PRs in 30d
Description
### Checklist
- [X] I have verified this is the correct repository for opening this issue.
- [X] I have verified no other issues exist related to my problem.
- [X] I have verified this is not an issue for a specific package.
- [X] I have verified this issue is not security related.
### What You Are Seeing?
We use chocolatey on an Air-gapped network for which we upload the nuget packages to our Artifactory server. This server requires basic authentication to access any resources.
We modify the nuget packages install scripts so that calls to `Install-Chocolateypackage` use the `Options` parameter in which we add an Authorization Headers.
This works fine and downloads the packages correctly, however it triggers errors which could be avoided.
### What is Expected?
No errors are generated when download packages using Authorization headers.
### How Did You Get This To Happen?
1. Modify a package to add the 'Options' parameter with and Authorization header
2. Upload this package to a repository requiring basic auth
3. `choco install `
### System Details
* Operating System: 10.0.19045.0
* Windows PowerShell version: 5.1.19041.2673
* Chocolatey CLI Version: 2.0.0
* Chocolatey Licensed Extension version: N/A
* Chocolatey License type: N/A
* Terminal/Emulator: Microsoft Terminal
### Installed Packages
```bash
N/A
```
### Output Log
```bash
- Running Get-WebFileName -url -defaultName
- Url request/response fialed - file name will be : Exception calling "GetResponse" with "0" argument(s): "The remote servier returned an error: (401) Unauthorized."
- Running Get-WebHeaders -url -ErrorAction 'Stop'
- Setting the UserAgent to 'chocolatey command line'
- Request Header:
- 'Accept':'*/*'
- 'User-Agent':'chocolatey command line'
- Attempt to get header for failed.
The remote file tierh doesn't exist, is unauthorized, or is forbidden for url . Exception calling "GetResponse" with "0" argument(s): "The remote servier returned an error: (401) Unauthorized."
```
### Additional Context
The following should allow receiving `Options`
- Get-WebHeaders
- Get-WebFileName
The following should be changed to pass the `Options`
- https://github.com/chocolatey/choco/blob/master/src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1#L304
- https://github.com/chocolatey/choco/blob/master/src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1#L327
- https://github.com/chocolatey/choco/blob/master/src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1#L336
Contributor guide
Research direction
Start in src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1 at the referenced lines 304, 327, and 336. Review how Get-WebFileName and Get-WebHeaders accept Options, then trace the calls from Get-ChocolateyWebFile. Done means authorization headers supplied through Options are received by those helpers without the 401-related download errors described.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100