tenable.errors.ConnectionError: Invalid Tenable.sc Instance error on pytenable 1.4.6
I am trying to use pytenable for some tenable.sc automation via API. I am using examples from the pytenable 'getting started' but run into this error "tenable.errors.ConnectionError: Invalid Tenable.sc Instance". Am I missing something? I have used both user/pass and API keys. I validated that the I can login manually with the user account and that if a do a curl get request with the API keys I get the info I want. It just seems like pytenable keeps coming back with this error.
for the address I've used these combinations
- https://the-sc-svraddress.domainname/,
- sc-svr-address.domainname,
- ip address of sc svr
To Reproduce example code 1:
from tenable.sc import TenableSC sc = TenableSC('[redacted]') sc.login('[redacted username]', '[redacted password]') for vuln in sc.analysis.vulns(): print('{ip}:{pluginID}:{pluginName}'.format(**vuln))
example code 2: from tenable.sc import TenableSC sc = TenableSC('[redacted]') sc.login(access_key = '[redacted]', secret_key = '[redacted]') for vuln in sc.analysis.vulns(): print('{ip}:{pluginID}:{pluginName}'.format(**vuln))
example code 3: from tenable.sc import TenableSC sc = TenableSC('[redacted]')
Expected behavior my curl with API keys works fine but the pytenable code above doesnt work
Error I am seeing:
DEBUG:tenable.sc.TenableSC:{"method": "GET", "url": "https://SERVERIP:443/rest/system", "params": {}, "body": {}} DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): SERVERIP:443 DEBUG:urllib3.connectionpool:https://SERVERIP:443 "GET /rest/system HTTP/1.1" 200 None ERROR:tenable.errors.ConnectionError:Invalid Tenable.sc Instance Traceback (most recent call last): File "C:\Users...\AppData\Local\Programs\Python\Python310\lib\tenable\sc_init_.py", line 249, in init self.version = self.info['version'] KeyError: 'version'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users......\Tenable\Code\TenableHelloWorld.py", line 6, in
I am running pytenable 1.4.6, python 3.10.3 on Windows 10 64-bit. My IDE is VSCode.
Tenable instance is tenable.sc 5.21.0 on tenable core
Additional context This functionality used to work until my system upgraded several months ago to 5.21.0. that was the only change.
I think you may have a dirty update. Try uninstalling the python package and re-installing it. That error was corrected some time ago and related to SC 5.20 no longer passing the version before auth.
May I also suggest that you may want to refactor to use API keys instead as they dont consume user sessions.
Closing due to inactivity.