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

Need to preserve URL escaped characters in downloaded file #429

Open
opoplawski opened this issue Oct 21, 2022 · 1 comment
Open

Need to preserve URL escaped characters in downloaded file #429

opoplawski opened this issue Oct 21, 2022 · 1 comment

Comments

@opoplawski
Copy link

SUMMARY

BitDefender setupdownloader depends on the filename remaining exactly the same. But it contains '[' and ']' characters that end up URL escaped in the downloaded file.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

win_package

ANSIBLE VERSION
ansible [core 2.12.2]
  config file = /home/orion-admin/ansible-windows/ansible.cfg
  configured module search path = ['/home/orion-admin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  ansible collection location = /home/orion-admin/ansible-windows:/home/orion-admin/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.8.12 (default, Sep 16 2021, 10:46:05) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
  jinja version = 2.10.3
  libyaml = True
COLLECTION VERSION
# /usr/share/ansible/collections/ansible_collections
Collection      Version
--------------- -------
ansible.windows 1.10.0

# /home/orion-admin/ansible-windows/ansible_collections
Collection      Version
--------------- -------
ansible.windows 1.11.1
CONFIGURATION
COLLECTIONS_PATHS(/home/orion-admin/ansible-windows/ansible.cfg) = ['/home/orion-admin/ansible-win>
DEFAULT_FORKS(/home/orion-admin/ansible-windows/ansible.cfg) = 25
DEFAULT_GATHERING(/home/orion-admin/ansible-windows/ansible.cfg) = explicit
DEFAULT_HOST_LIST(/home/orion-admin/ansible-windows/ansible.cfg) = ['/home/orion-admin/ansible-win>
DEFAULT_INVENTORY_PLUGIN_PATH(/home/orion-admin/ansible-windows/ansible.cfg) = ['/home/orion-admin>
DEFAULT_JINJA2_EXTENSIONS(/home/orion-admin/ansible-windows/ansible.cfg) = jinja2.ext.do
DEFAULT_ROLES_PATH(/home/orion-admin/ansible-windows/ansible.cfg) = ['/home/orion-admin/ansible-wi>
DEFAULT_STRATEGY(/home/orion-admin/ansible-windows/ansible.cfg) = mitogen_linear
DEFAULT_STRATEGY_PLUGIN_PATH(/home/orion-admin/ansible-windows/ansible.cfg) = ['/home/orion-admin/>
DEFAULT_TIMEOUT(/home/orion-admin/ansible-windows/ansible.cfg) = 20
PERSISTENT_CONNECT_TIMEOUT(/home/orion-admin/ansible-windows/ansible.cfg) = 30
RETRY_FILES_ENABLED(/home/orion-admin/ansible-windows/ansible.cfg) = False
OS / ENVIRONMENT

RHEL 8.6

STEPS TO REPRODUCE
  tasks:
    - name: Install BitDefender
# This URL escapes the filename which breaks install
      ansible.windows.win_package:
        path: "https://grav1.nwra.com/Packages/BSTWIN/0/setupdownloader_[aHR0cHM6Ly9ncmF2MS5ud3JhLmNvbTo4NDQzL1BhY2thZ2VzL0JTVFdJTi8wL2FxOTBmbC9pbnN0YWxsZXIueG1sP2xhbmc9ZW4tVVM=].exe"
        product_id: Endpoint Security
        arguments: /bdparams /silent silent
        state: present
EXPECTED RESULTS

Install succeeds

ACTUAL RESULTS
TASK [Install BitDefender] ************************************************************************
task path: /home/orion-admin/ansible-windows/install-bitdefender-package.yml:6
fatal: [prn-bld01.ad.nwra.com]: FAILED! => {"changed": false, "elapsed": 3.0165842, "msg": "unexpected rc from 'C:\\Users\\orion-admin\\AppData\\Local\\Temp\\ansible-moduletmp-133108513167669159-771566920\\setupdownloader_%5BaHR0cHM6Ly9ncmF2MS5ud3JhLmNvbTo4NDQzL1BhY2thZ2VzL0JTVFdJTi8wL2FxOTBmbC9pbnN0YWxsZXIueG1sP2xhbmc9ZW4tVVM=%5D.exe /bdparams /silent silent': see rc, stdout, and stderr for more details", "rc": 3, "reboot_required": false, "status_code": 200, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
@jborean93
Copy link
Collaborator

This might be hard to achieve, we currently use the response URL segment to derive the file name as per

$tempPath = Join-Path -Path $module.Tmpdir -ChildPath $Response.ResponseUri.Segments[-1]
. At this point in time the URL has already been changed by dotnet. We could use [Uri]::UnescapeDataString(...) to get the raw value back but I'm unsure whether this might cause more problems down the line with invalid file path characters.

As a workaround for now you can use win_get_url to download the package manually with the chars you filename needed until we figure out the best way forward here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants