Model for storing secure files and reports for scripts and plugins #10102

Closed
opened 2025-12-29 21:26:53 +01:00 by adam · 1 comment
Owner

Originally created by @jchambers2012 on GitHub (Aug 15, 2024).

NetBox version

v4.0.8

Feature type

New functionality

Proposed functionality

I am seeing if a new API can be developed that can be used by custom scripts and plugins to “publish” files in a protected and secure way. This new model should support the ability to store reports and could expire or overwrite based on the Scripts/Plugin Needs.

Use case

Today I have several scripts that generates CSV reports. One script uses complex scripts and multiple models to virtually build a new green field site so that the project team can validate the device requirements for the new site for procurement , IPAM/ASN layout for management and user networks and cabling matrix before it is committed to the database for config generation. The script today just pushes them to the “/opt/netbox/netbox/media/random uuid-security key/report name.csv” and generates a link for the script runner to go to. A separate script needs to come around every so often to clean these files up.

Database changes

A new model that supports, but is not limited to:

  • pk
  • uuid – a random UUID that could be used to “bypass” the View permission if the requesting user does not have access to view all reports generated.
  • file_name
  • generated by - link to the script that ran it
  • requesting user that generated the report
  • request ID
  • File data –or—file path to the file in question
  • expire date/time – None for never – default new configuration setting maybe matching CHANGELOG_RETENTION of 90 days

The model should also include the PrimaryModel so it has access to ChangeLoggingMixin, JournalingMixin and TagsMixin for reports that do not expire. The model will also need a maintenance job to purge the expired reports from the database

The model might also need a new protected storage folder if the files should not be stored in the database and the media folder is deemed not secure enough for this operation.

External dependencies

Unknown if a Django app exists today to meet this need and work seamlessly with NetBox

Originally created by @jchambers2012 on GitHub (Aug 15, 2024). ### NetBox version v4.0.8 ### Feature type New functionality ### Proposed functionality I am seeing if a new API can be developed that can be used by custom scripts and plugins to “publish” files in a protected and secure way. This new model should support the ability to store reports and could expire or overwrite based on the Scripts/Plugin Needs. ### Use case Today I have several scripts that generates CSV reports. One script uses complex scripts and multiple models to virtually build a new green field site so that the project team can validate the device requirements for the new site for procurement , IPAM/ASN layout for management and user networks and cabling matrix before it is committed to the database for config generation. The script today just pushes them to the “/opt/netbox/netbox/media/`random uuid-security key`/`report name`.csv” and generates a link for the script runner to go to. A separate script needs to come around every so often to clean these files up. ### Database changes A new model that supports, but is not limited to: - pk - uuid – a random UUID that could be used to “bypass” the `View` permission if the requesting user does not have access to `view` all reports generated. - file_name - generated by - link to the script that ran it - requesting user that generated the report - request ID - File data –or—file path to the file in question - expire date/time – None for never – default new configuration setting maybe matching CHANGELOG_RETENTION of 90 days The model should also include the `PrimaryModel` so it has access to `ChangeLoggingMixin`, `JournalingMixin` and `TagsMixin` for reports that do not expire. The model will also need a maintenance job to purge the expired reports from the database The model might also need a new protected storage folder if the files should not be stored in the database and the media folder is deemed not secure enough for this operation. ### External dependencies Unknown if a Django app exists today to meet this need and work seamlessly with NetBox
adam closed this issue 2025-12-29 21:26:53 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 15, 2024):

It sounds like you have the beginnings of a feature request in mind, but this needs quite a bit of refinement and expansion before it can be considered for work. It's also likely better served by a custom plugin, depending on the probable additional requirements for your specific use case.

I'm converting this to a discussion; maybe others in the community can help piece together a detailed implementation proposal that serves a generic use case.

@jeremystretch commented on GitHub (Aug 15, 2024): It sounds like you have the beginnings of a feature request in mind, but this needs quite a bit of refinement and expansion before it can be considered for work. It's also likely better served by a custom plugin, depending on the probable additional requirements for your specific use case. I'm converting this to a discussion; maybe others in the community can help piece together a detailed implementation proposal that serves a generic use case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10102