pyTenable 1.4.3 - marshmallow.exceptions.ValidationError
Describe the bug Running Tenable asset export using pyTenable library with version 1.4.3 is raising marshmallow.exceptions.ValidationError.
To Reproduce Steps to reproduce the behavior:
- Execute the script to export Tenable assets.
- Script runs export_assets method.
def export_assets(self, sources=None):
for asset in self._api.exports.assets(sources=sources, is_deleted=False, is_terminated=False):
asset['network_interfaces'] = [NetworkInterface(**i) for i in asset['network_interfaces']]
asset['tags'] = [Tag(**i) for i in asset['tags']]
asset['sources'] = [AssetSource(**i) for i in asset['sources']]
yield ExportedAsset(**asset)
- marshmallow.exceptions.ValidationError is thrown.
Expected behavior Assets are properly exported as in older version 1.3.3.
Screenshots
Traceback (most recent call last):
File "sync.py", line 82, in <module>
main(
File "/opt/tenable-integrations/aws/here_integration/__init__.py", line 505, in main
existing_assets: Iterable[ExportedAsset] = list(tenable.get_existing_assets(host_export_back_days=configuration.host_export_back_days))
File "/opt/tenable-integrations/aws/here_integration/lib/nice_tenable.py", line 335, in export_assets
for asset in self._api.exports.assets(sources=sources, is_deleted=False, is_terminated=False):
File "/opt/tenable-integrations/aws/.venv/lib/python3.8/site-packages/tenable/io/exports/api.py", line 280, in assets
return self._export('assets', AssetExportSchema(), **kwargs)
File "/opt/tenable-integrations/aws/.venv/lib/python3.8/site-packages/tenable/io/exports/api.py", line 177, in _export
payload = schema.dump(schema.load(kwargs))
File "/opt/tenable-integrations/aws/.venv/lib/python3.8/site-packages/marshmallow/schema.py", line 719, in load
return self._do_load(
File "/opt/tenable-integrations/aws/.venv/lib/python3.8/site-packages/marshmallow/schema.py", line 904, in _do_load
raise exc
marshmallow.exceptions.ValidationError: {'sources': ['Field may not be null.'], 'is_deleted': ['Unknown field.']}
System Information (please complete the following information):
- OS: Ubuntu 20.04.3 LTS
- Architecture x86_64
- Version 5.11.0-46-generic
- Memory 12GB
Additional context Issue might be related to file schema.py that seems to be refactored and boolean flag 'is_deleted' is missing. Either versions 1.4.2 and 1.4.3 are affected by this.
PR open with the fixing change.
@SteveMcGrath Thanks for the prompt PR. Is it also solving the problem with 'sources': ['Field may not be null.']?
How are you passing sources?
Issue was on our side. We are passing sources argument to the export, but never filled it with real data. It always stays on default sources=None value.
After I changed:
self._api.exports.assets(sources=sources, is_deleted=False, is_terminated=False)
to
self._api.exports.assets(is_deleted=False, is_terminated=False)
and implemented your change from PR, export is running successfully.
Thanks for the hint in your previous comment, it was helpful.
Closing as this is fixed with #523.