tenable / pyTenable

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

"error_msg":"Valid orgID is required." #294

Closed gig3r closed 3 years ago

gig3r commented 3 years ago

Describe the bug Hi. I have an error when i try use sc.access_lists.details()

To Reproduce

from tenable.sc import TenableSC
sc = TenableSC('ip_address')
sc.login('login', 'password')
for asset_list in sc.asset_lists.list():
    print(asset_list)

Print result: {'id': '39', 'name': 'Test', 'description': '', 'type': 'dynamic', 'status': '0'}

asset_list_detail = sc.asset_lists.details(39)
print(asset_list_detail)

Print result: GET https://ip_address/rest/asset/39 >> None:403 {"type":"regular","response":"","error_code":15,"error_msg":"Valid orgID is required.\n","warnings":[],"timestamp":1617952970}

Traceback (most recent call last): File "C:/Users/admin/PycharmProjects/Lesson/Tenable/SC_test.py", line 57, in asset_list_detail = sc.asset_lists.details(39) File "C:\Program Files\Python38\lib\site-packages\tenable\sc\asset_lists.py", line 464, in details return self._api.get('asset/{}'.format(self._check('id', id, int)), File "C:\Program Files\Python38\lib\site-packages\tenable\base\v1.py", line 574, in get return self._request('GET', path, **kwargs) File "C:\Program Files\Python38\lib\site-packages\tenable\base\v1.py", line 545, in _request raise self._error_codesstatus tenable.errors.APIError: None:403 {"type":"regular","response":"","error_code":15,"error_msg":"Valid orgID is required.\n","warnings":[],"timestamp":1617952970}

System Information (please complete the following information):

Additional context I want to download the asset details, for, example list of ips. In general i want to update the asset by new ips. maybe i do something wrong, could you help me?

levwais commented 3 years ago

based on the API documentation, seems like if you are an administrator the /asset/{id} API requires an org_id query param that is not supported in PyTenable. https://docs.tenable.com/tenablesc/api/Asset.htm

Parameters must be passed in as query string (as opposed to JSON) in the format of: /asset/{id}?orgID={orgID}

@mvalliammal - can you please add this to our backlog to fix?

mvalliammal commented 3 years ago

@gig3r,

Please verify

gig3r commented 3 years ago

@mvalliammal Hi! Great, now the script is working, thanks!

starblast commented 2 years ago

This is breaking my code now. Shouldn't orgID be an optional parameter given that it is optional if not being accessed as an administrator?