tenable / pyTenable

Python Library for interfacing into Tenable's platform APIs
https://pytenable.readthedocs.io
MIT License
354 stars 173 forks source link

pyTenable returns an empty iterable even when using the exact code from the instructions #681

Closed Argonomics closed 1 year ago

Argonomics commented 1 year ago

Describe the bug An empty iterable is returned when using tio.tags.list() with or without filters

To Reproduce

Using Python 3.8, wth pyTenable 1.4.12 (or any older version), try to output a list of tags as shown in the documentation

for category in tio.tags.list_categories(): print(category['name'])

Connectors Agent Groups Testing

print(tio.tags.list())

<tenable.io.tags.TagsIterator object at 0x0000022D6F6AA7F0>

for tag in tio.tags.list(): print('found a TAG!') print(tag)

Output: Nothing

for tag in tio.tags.list(('category_name', 'eq', 'Connectors')): print('found a TAG!') print(tag)

Output: Nothing

Expected behavior A list of tags would be printed. For the Connectors category example above, this should be "All", "Azure", and "AWS"

System Information (please complete the following information):

Additional context Support case 01567717

I have tried this with varying levels of permission on the API keys used, including some with full admin access to everything in t.io to rule out permissions as the problem

aseemsavio commented 1 year ago

@Argonomics I could not reproduce your issue. Could you try this?

from tenable.io import TenableIO

tio = TenableIO(access_key="ACCESS_KEY", secret_key="SECRET_KEY")

for category in tio.tags.list_categories():
    print('found a TAG!')
    print(category["name"])

for tag in tio.tags.list():
    print('found a TAG!')
    print(tag)
Argonomics commented 1 year ago

It works, thank you! The issue seemed to be with the TenableIO line syntax. Using the same keys but changing from

tio = TenableIO("ACCESS_KEY", "SECRET_KEY")

to

tio = TenableIO(access_key="ACCESS_KEY", secret_key="SECRET_KEY")

It's strange that it worked partially before, rather than not at all