saltstack / saltstack/salt

[BUG] file.manage doen't download redirected url with basic authentication

Open
#66,885 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description
file.manage doen't download redirected url with basic authentication like : https://USERNAME:PASSWORD@someurl.com/file.tar.gz

If the URL is used with curl -L URL we see a redirect: HTTP/1.1 302 and file is downloaded
It works with curl either with credentials or without .

Same state is working if it is used without Basic Authentication

It fails with :
Comment: Error: HTTP 400: Bad Request reading

----------
          ID: install_template_install_pkg
    Function: archive.extracted
        Name: /tmp
      Result: False
     Comment: Error: HTTP 400: Bad Request reading /artifactory/packages/pyr_pbis-open-9.1.0.551.tar.gz
     Started: 20:05:50.276210
    Duration: 819.146 ms
     Changes:

Setup
(Please provide relevant configs and/or SLS files (be sure to remove sensitive info. There is no general set-up of Salt.)

Please be as specific as possible and give set-up details.

  • on-prem machine
  • VM (Virtualbox, KVM, etc. please specify)
  • VM running on a cloud service, please be explicit and add details
  • container (Kubernetes, Docker, containerd, etc. please specify)
  • or a combination, please be explicit
  • jails if it is FreeBSD
  • classic packaging
  • onedir packaging
  • used bootstrap to install

Steps to Reproduce the behavior
(Include debug logs if possible and relevant)

install_template_install_pkg:
archive.extracted:
- name: /tmp
- source: https://USERNAME:PASSWORD@someurl.com/file.tar.gz
- archive_format: tar
- skip_verify: True
- tar_options: xvf
- user: root
- group: root

Expected behavior
dearchive file in /tmp

Screenshots
If applicable, add screenshots to help explain your problem.

Versions Report

[root@boyadboz-alma8 ~]# salt-minion --versions-report
Salt Version:
Salt: 3007.1

Python Version:
Python: 3.10.14 (main, Apr 3 2024, 21:30:09) [GCC 11.2.0]

Dependency Versions:
cffi: 1.16.0
cherrypy: 18.8.0
dateutil: 2.8.0
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.4
libgit2: Not Installed
looseversion: 1.3.0
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.7
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 23.1
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.19.1
pygit2: Not Installed
python-gnupg: 0.5.2
PyYAML: 6.0.1
PyZMQ: 25.1.2
relenv: 0.16.0
smmap: Not Installed
timelib: 0.2.4
Tornado: 6.3.3
ZMQ: 4.3.4

Salt Package Information:
Package Type: onedir

System Versions:
dist: almalinux 8.10 Cerulean Leopard
locale: utf-8
machine: x86_64
release: 4.18.0-513.24.1.el8_9.x86_64
system: Linux
version: AlmaLinux 8.10 Cerulean Leopard

Additional context

  1. Same URL works if there is no basic authentication
  2. It is working with different URL when there is not redirection

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the archive.extracted state using the reported source URL, then trace how file.manage handles redirects and Basic Authentication. Compare the failing redirected request with the working curl -L behavior and the non-redirected authenticated URL. Done means the archive downloads and extracts to /tmp without the HTTP 400 error, with regression coverage for the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.