kaisero / fireREST

Python library for interacting with Cisco Firepower Management Center REST API
GNU General Public License v3.0
70 stars 49 forks source link

Issue with Get_audit_records #24

Closed mortiz-code closed 4 years ago

mortiz-code commented 4 years ago

Hi there. First, thanks for your time and this helpful tool. Next, I have an issue when I use the get_audit_records method.

FMC 6.5 Python 3.8.3

Source:

from fireREST import Client
client = Client(hostname='fmc ip', username='user', password='pass')
client.get_audit_records()

Debug from ipython:

In [18]:  client.get_audit_records()
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
~/github/devnet/firepower/fmc_audit/venv/lib/python3.8/site-packages/fireREST/utils.py in wrapper(*args, **kwargs)
    151             response = f(*args, **kwargs)
--> 152             response.raise_for_status()
    153         except HTTPError:

~/github/devnet/firepower/fmc_audit/venv/lib/python3.8/site-packages/requests/models.py in raise_for_status(self)
    940         if http_error_msg:
--> 941             raise HTTPError(http_error_msg, response=self)
    942

HTTPError: 404 Client Error: Not Found for url: https://192.168.10.195/api/fmc_platform/v1/audit/auditrecords?limit=1000&expanded=True

During handling of the above exception, another exception occurred:

HTTPError                                 Traceback (most recent call last)
<ipython-input-18-80541365c4d5> in <module>
----> 1 client.get_audit_records()

~/github/devnet/firepower/fmc_audit/venv/lib/python3.8/site-packages/fireREST/utils.py in wrapper(*args, **kwargs)
    109                     f'{f.__name__} requires fmc software version {minimum_version}. Installed version: {installed_version}',
    110                 )
--> 111             return f(*args, **kwargs)
    112
    113         return wrapper

~/github/devnet/firepower/fmc_audit/venv/lib/python3.8/site-packages/fireREST/__init__.py in get_audit_records(self)
    390     def get_audit_records(self):
    391         url = self._url('platform', '/audit/auditrecords')
--> 392         return self._get(url)
    393
    394     @utils.minimum_version_required('6.1.0')

~/github/devnet/firepower/fmc_audit/venv/lib/python3.8/site-packages/fireREST/__init__.py in _get(self, url, params, items)
    124             params['expanded'] = defaults.API_EXPANSION_MODE
    125
--> 126         response = self._request('get', url, params)
    127         payload = response.json()
    128

~/github/devnet/firepower/fmc_audit/venv/lib/python3.8/site-packages/fireREST/utils.py in wrapper(*args, **kwargs)
    156                 client._refresh()
    157             else:
--> 158                 raise_for_status(response)
    159         return response
    160

~/github/devnet/firepower/fmc_audit/venv/lib/python3.8/site-packages/fireREST/utils.py in raise_for_status(response)
    186             if error['msg'] in response.text:
    187                 raise error['exception']
--> 188     raise exceptions.get(status_code, HTTPError)

HTTPError:

Thanks!

mortiz-code commented 4 years ago

I am a newbie with this but is it possible that the problem is here?

HTTPError: 404 Client Error: Not Found for url: https://192.168.10.195/api/fmc_platform/v1/audit/auditrecords?limit=1000&expanded=True

From FMC API doc the requests should be:

URL: /api/fmc_config/v1/domain/{domain_UUID}/audit/auditrecords

https://www.cisco.com/c/en/us/td/docs/security/firepower/650/api/REST/Firepower_Management_Center_REST_API_Quick_Start_Guide_650/objects_in_the_rest_api.html#concept_t4j_gw3_bcb

Thank you!

kaisero commented 4 years ago

Thanks for the report, fixed in v0.1.3