Onemind-Services-LLC/netbox-secrets

[Bug]: Unable to search secrets by name or assigned device (UI and API)

uedvt359 opened this issue · 3 comments

NetBox Secrets plugin version

v1.7.6

NetBox version

v3.4.8

Steps to Reproduce

  1. add some secrets
  2. try to search for a secret by attribute name with /plugins/netbox_secrets/secrets/?name=My+Secret (or /api/...)
  3. try to search for a secret by attribute device with /plugins/netbox_secrets/secrets/?device=my-server.com (or /api/...)

Expected Behavior

only secrets matching name or device, respecively, exactly should be returned. this worked in DanSheps' netbox_secretstore plugin

Observed Behavior

for name:

  • UI: the parameter is ignored and all secrets are returned
  • API: HTTP/1.1 400 Bad Request => {"name":["“My Secret” is not a valid value."]}

for device:

  • UI: the parameter is ignored and all secrets are returned
  • API: the parameter is ignored and all secrets are returned

This makes it impossible to retrieve secrets precisely, for example in automation. interestingly, querying by ?role= works correctly in both old and new plugins.

name can be fixed by simply removing these lines: https://github.com/Onemind-Services-LLC/netbox-secrets/blob/master/netbox_secrets/filtersets.py#L91-L95

for device (and device_id, virtual_machine, virtual_machine_id) i tried adding the following lines, but that resulted in 500 internal server error failures when calling get-session-key: https://github.com/DanSheps/netbox-secretstore/blob/4ad3bdd24d40b3f7f822e72b4fea76819df0ae9a/netbox_secretstore/filtersets.py#L53-L58

ImportError: Module "netbox_secrets.urls" does not define a "urlpatterns" attribute/class

@uedvt359 You can filter the device or virtual machine using the content type, and I added a new feature here that you can perform a quick search by the assigned object name.

@uedvt359

You can also see these filters in the Rest API documentation on your NetBox instance at: /api/docs/

/plugins/netbox_secrets/secrets/?assigned_object_type=dcim.device&assigned_object_id=1