prevent device_by_id_cache from adding unneeded array elements to $device #3785

merged 1 commit into from Jul 6, 2016


None yet

3 participants

brandune commented Jul 6, 2016

I was attempting to use the get_device endpoint to determine whether a device existed in LibreNMS as the endpoint is written to return a 404 if the device doesn't exist. But I found that no matter what hostname you gave it a 200 would be returned along with this:

{ "status": "ok", "devices": [ { "vrf_lite_cisco": [], "ip": "" } ] }

get_device depends on device_by_id_cache for a device object, which hits the DB for the device table info and vrf_lite_cisco table info. However, the index 'vrf_lite_cisco' is added to the device object before validating that anything was returned from the DB. 'ip' gets added by processing it with inet6_pton whether or not an IP was returned from the DB.

This commit moves the addition of 'vrf_lite_cisco' in to the block that validates that any vrf rows exist, and adds the same kind of validation to the IP element.

@brandune brandune prevent device_by_id_cache from adding unneeded array elements to $de…
@laf laf added the Bug label Jul 6, 2016
@laf laf merged commit 614a2dc into librenms:master Jul 6, 2016

2 checks passed

Auto-Deploy Build finished.
continuous-integration/travis-ci/pr The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment