packetchaos / navi

A Command-line tool which leverages the Tenable.io API to reduce the time it takes to get information that is common during remediation or a troubleshooting event
GNU General Public License v3.0
72 stars 26 forks source link

"navi export vulns" errors with UnicodeEncodeError #22

Closed AndyJanes closed 2 years ago

AndyJanes commented 2 years ago

Hi,

Loving navi but I've come across an error with the "navi export vulns" and "navi display scans" which may be related as I've just clean installed Python and Navi on my lab Windows 10 machine.

The errors are:

PS C:\Users\andy> navi export vulns

Exporting your data now. Saving vuln_data.csv now...

I'm exporting vuln_data.csv with your requested data
Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python310\Scripts\navi.exe\__main__.py", line 7, in <module>
  File "C:\Users\andy\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\andy\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "C:\Users\andy\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\andy\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\andy\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\andy\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "C:\Program Files\Python310\lib\site-packages\navi\plugins\export.py", line 171, in vulns
    query_export(asset_query, file)
  File "C:\Program Files\Python310\lib\site-packages\navi\plugins\query_export.py", line 39, in query_export
    agent_writer.writerow(assets)
  File "C:\Program Files\Python310\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u015a' in position 65944: character maps to <undefined>

and

PS C:\Users\andy> navi display scans

Scan Name                                                    Scan ID    Status                         UUID
------------------------------------------------------------------------------------------------------------------------------------------------------
<redacted>                                  84         completed                      a09b3200-f583-4489-bcd8-0871f6f750b8
<redacted>                                  76         completed                      bc7dfa94-4a85-482f-a531-9facb9bcda3f
...
...
...
<redacted>                                  65         completed                      a82f2360-eabe-43e3-a2df-0761e48a4313
<redacted>                                  32         canceled                       c2becc4c-5c62-4f56-900a-ebf360ad77f8
Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python310\Scripts\navi.exe\__main__.py", line 7, in <module>
  File "C:\Users\andy\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\andy\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "C:\Users\andy\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\andy\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\andy\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\andy\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "C:\Program Files\Python310\lib\site-packages\navi\plugins\display.py", line 110, in scans
    str(scan['uuid'])))
KeyError: 'uuid' 

The first error suggests an invalid character in the scan name, but I can't locate one either on the Tenable.io portal or in the equivalent JSON results when calling it via Postman. I've done several "navi update full" commands as suggested in other issue threads, but the error remains.

Python install is 3.10.1 navi-pro (from pip3) is 6.7.3

packetchaos commented 2 years ago

Sorry for the issues you are having. I believe both are fixed now in the code on github. I will be releasing it to pip after some testing and a few more bug fixes in another week.

if you pull the new version down, 6.7.9, and still have issues please report them and will continue to iterate until the issue is resolved.

packetchaos commented 2 years ago

I believe this issue was resolved in the latest version. Please re-open it if you are still having issues. Thanks