tenable / pyTenable

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

TenableSC Plugins JSON Output #222

Closed bedchr closed 4 years ago

bedchr commented 4 years ago

I’m having trouble getting a normal JSON output when running the plugins API. Is there a way to fix this?

SteveMcGrath commented 4 years ago

which method?

bedchr commented 4 years ago

I modified the sample script that provides the Crit numbers for TenableSC. I just don’t get the regular JSON output I get when using cURL. I get each pluginid with the fields below enclosed in their own {} but not a typical JSON format. It won’t even format as a JSON when I try in vscode after the fact. Here’s what I have: Plugins = sc.plugin.list( Fields([‘id’,’name’,’description’,’pluginPubDate’])) For plugin in plugins: Print(plugin)

SteveMcGrath commented 4 years ago

The docs and code clearly detail that its an iterable thats returned. The iterable handles all of the pagination for you. Each item returned is a python dict already. I'm also confused as to your use of a field object. that technically should't work. I just ran this before posting:

>>> for p in sc.plugins.list(fields=['id', 'name', 'description', 'pluginPubDate']):
...     print(p['id'])