You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/test/integration
Adrian Likins 9c58827410
Better handling of malformed vault data envelope (#32515)
* Better handling of malformed vault data envelope

If an embedded vaulted variable ('!vault' in yaml)
had an invalid format, it would eventually cause
an error for seemingly unrelated reasons.
"Invalid" meaning not valid hexlify (extra chars,
non-hex chars, etc).

For ex, if a host_vars file had invalid vault format
variables, on py2, it would cause an error like:

  'ansible.vars.hostvars.HostVars object' has no
  attribute u'broken.example.com'

Depending on where the invalid vault is, it could
also cause "VARIABLE IS NOT DEFINED!". The behavior
can also change if ansible-playbook is py2 or py3.

Root cause is errors from binascii.unhexlify() not
being handled consistently.

Fix is to add a AnsibleVaultFormatError exception and
raise it on any unhexlify() errors and to handle it
properly elsewhere.

Add a _unhexlify() that try/excepts around a binascii.unhexlify()
and raises an AnsibleVaultFormatError on invalid vault data.
This is so the same exception type is always raised for this
case. Previous it was different between py2 and py3.

binascii.unhexlify() raises a binascii.Error if the hexlified
blobs in a vault data blob are invalid.

On py2, binascii.Error is a subclass of Exception.
On py3, binascii.Error is a subclass of TypeError

When decrypting content of vault encrypted variables,
if a binascii.Error is raised it propagates up to
playbook.base.Base.post_validate(). post_validate()
handles exceptions for TypeErrors but not for
base Exception subclasses (like py2 binascii.Error).

* Add a display.warning on vault format errors
* Unit tests for _unhexlify, parse_vaulttext*
* Add intg test cases for invalid vault formats

Fixes #28038
8 years ago
..
targets Better handling of malformed vault data envelope (#32515) 8 years ago
asa.yaml Fix trailing space in ec2_vol example, fix 'the the' typos (#28440) 8 years ago
cloud-config-aws.yml.template Add region to ansible-test AWS cloud config. (#30733) 8 years ago
cloud-config-azure.yml.template Fix Azure config template. 8 years ago
cloud-config-cs.ini.template Add support for cloud tests to ansible-test. (#24315) 9 years ago
dellos6.yaml Migrate Network Tests into ansible/ansible (#18233) 9 years ago
dellos9.yaml Migrate Network Tests into ansible/ansible (#18233) 9 years ago
dellos10.yaml Migrate Network Tests into ansible/ansible (#18233) 9 years ago
eos.yaml eos_static_route DI module (#32587) 8 years ago
integration.cfg Fix ansible-test config management. 8 years ago
integration_config.yml Fix cosmetic problems in YAML source 9 years ago
inventory Fix fact failures cause by ordering of collectors (#30777) 8 years ago
inventory.network Add VyOS integration tests for net_linkagg (#26478) 9 years ago
inventory.networking.template Increase python version coverage for tests. (#24762) 9 years ago
inventory.remote.template Add support for OS X CI on Shippable. (#17160) 9 years ago
inventory.winrm.template Increase python version coverage for tests. (#24762) 9 years ago
ios.yaml IOS Ping: Add new module to support ping tests from IOS devices (#28557) 8 years ago
iosxr.yaml Fix trailing space in ec2_vol example, fix 'the the' typos (#28440) 8 years ago
junos.yaml Fix trailing space in ec2_vol example, fix 'the the' typos (#28440) 8 years ago
network-all.yaml New module: management of the Nuage Networks VSP SDN solution (network/nuage/nuage_vspk) (#24895) 9 years ago
network-integration.cfg Increase socket connect retry timeout for integration test (#30681) 8 years ago
nxos.yaml Integration Tests only: add static route, snmp_user, snapshot and hsrp it cases (#28933) 8 years ago
ops.yaml Fix trailing space in ec2_vol example, fix 'the the' typos (#28440) 8 years ago
platform_agnostic.yaml remove net_command (#28525) 8 years ago
target-prefixes.network openvswitch targets via network-integration (#27295) 9 years ago
vyos.yaml Add vyos_vlan DI module (#32072) 8 years ago
windows-integration.cfg Fix ansible-test config management. 8 years ago