ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
13.97k stars 3.41k forks source link

KeyError querying 'Address' key out of the CyberArk object using CyberArk Central Credential Provider Lookup #14606

Open nielskroon opened 11 months ago

nielskroon commented 11 months ago

Please confirm the following

Bug Summary

Using AWX 23.3.0 and trying to fetch a credential (account) 'Address' from CyberARK PAM using Central Credential Provider version 12.6 we encounter a KeyError.

Fetching object property '' ('Content') or 'UserName' works flawlessly and using PowerShell the same query works and Address field in the JSON response is there and has the proper value.

related #13411 related #13402 related #5743

AWX version

23.3.0

Select the relevant components

Installation method

kubernetes

Modifications

no

Ansible version

core 2.12.5.post0

Operating system

CentOS Stream release 8

Web browser

Chrome

Steps to reproduce

Reproduceable with a CyberARK PAM account that has the Address field populated and an AWX credential of Credential Type "VMware vCenter" passing through the lookup of the 'VCenter Host' details using AIM (External Secret Management System) to a self managed safe using this data:

{
  "reason": "no particular",
  "object_query": "Safe=XXXXXX_Self;Object=awx-vcenter-test",
  "object_property": "Address",
  "object_query_format": "Exact"
}

Expected results

env var VMWARE_HOST set with the value in the Address field of the CyberArk credential

Actual results

Test button in Credential Edit->External Secret Management System->Metadata page will show a KeyError pop up, and playbook in debug mode using this credential fails with these messages:

Traceback (most recent call last):
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/tasks/jobs.py", line 528, in run
    credential.credential_type.inject_credential(credential, env, self.safe_cred_env, args, private_data_dir)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/models/credential/__init__.py", line 455, in inject_credential
    getattr(builtin_injectors, credential.credential_type.namespace)(credential, injected_env, private_data_dir)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/models/credential/injectors.py", line 71, in vmware
    env['VMWARE_HOST'] = cred.get_input('host', default='')
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/models/credential/__init__.py", line 279, in get_input
    return self._get_dynamic_input(field_name)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/models/credential/__init__.py", line 313, in _get_dynamic_input
    return input_source.get_input_value()
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/models/credential/__init__.py", line 1258, in get_input_value
    return backend(**backend_kwargs)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/credential_plugins/aim.py", line 115, in aim_backend
    raise KeyError('Property {} not found in object'.format(object_property))
KeyError: 'Property Address not found in object'

Additional information

Using another instance (same versions AWX and CCP) we can reproduce this error.

Nenodema commented 11 months ago

I am encountering the same issue (CCP v13.x, AWX 23.1.0). When I retrieve the object from the CCP using PowerShell, I can confirm the existence of the 'Address' property. However, I am unable to utilize it within AWX, and I am also receiving the same error message.

@infamousjoeg could you assist with this issue?