From fbcec973289ea9a4ebb22f28dabdbcb33f9cdaed Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 6 May 2024 15:28:43 -0400 Subject: [PATCH 01/34] PRVB --- docs/release-notes/version-4.0.md | 4 ++++ netbox/netbox/settings.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/version-4.0.md b/docs/release-notes/version-4.0.md index 4f8b0f29a00..a0a4fad8476 100644 --- a/docs/release-notes/version-4.0.md +++ b/docs/release-notes/version-4.0.md @@ -1,5 +1,9 @@ # NetBox v4.0 +## v4.0.1 (FUTURE) + +--- + ## v4.0.0 (2024-05-06) !!! tip "Plugin Maintainers" diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 7c4c400beea..53eaffed510 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -25,7 +25,7 @@ # Environment setup # -VERSION = '4.0.0' +VERSION = '4.0.1-dev' HOSTNAME = platform.node() # Set the base directory two levels up BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) From d7592744d461e054d55587dee9d85c029cd84e41 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 6 May 2024 16:41:16 -0400 Subject: [PATCH 02/34] Update supported Python versions for v4.0 --- .github/ISSUE_TEMPLATE/bug_report.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 5140a0743b1..e5cbc2ece9f 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -34,10 +34,9 @@ body: label: Python Version description: What version of Python are you currently running? options: - - "3.8" - - "3.9" - "3.10" - "3.11" + - "3.12" validations: required: true - type: textarea From b4486b4d30c7b241204ac80a5f682e5c2cc9b391 Mon Sep 17 00:00:00 2001 From: Tobias Genannt Date: Tue, 7 May 2024 14:37:38 +0200 Subject: [PATCH 03/34] Fix #15992: Removed integrations for sentry-sdk According to the Sentry Python SDK documentation setting the integrations manually is only needed when the integration configuration needs to be changed. See: https://docs.sentry.io/platforms/python/integrations/django/#options --- netbox/netbox/settings.py | 1 - 1 file changed, 1 deletion(-) diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 53eaffed510..38df1655108 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -522,7 +522,6 @@ def _setting(name, default=None): sentry_sdk.init( dsn=SENTRY_DSN, release=VERSION, - integrations=[sentry_sdk.integrations.django.DjangoIntegration()], sample_rate=SENTRY_SAMPLE_RATE, traces_sample_rate=SENTRY_TRACES_SAMPLE_RATE, send_default_pii=True, From acc2add84586fb6f29381247e4f4038cc539b872 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 7 May 2024 10:37:42 -0400 Subject: [PATCH 04/34] Fixes #15977: Hide all admin menu items for non-authenticated users (#15978) * Fixes #15977: Hide all admin menu items for non-authenticated users * Account for absence of auth_required on PluginMenuItem --- netbox/netbox/navigation/__init__.py | 1 + netbox/netbox/navigation/menu.py | 11 +++++++++-- netbox/utilities/templatetags/navigation.py | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/netbox/netbox/navigation/__init__.py b/netbox/netbox/navigation/__init__.py index d13282f7ecf..b4f7dbd9f58 100644 --- a/netbox/netbox/navigation/__init__.py +++ b/netbox/netbox/navigation/__init__.py @@ -32,6 +32,7 @@ class MenuItem: link: str link_text: str permissions: Optional[Sequence[str]] = () + auth_required: Optional[bool] = False staff_only: Optional[bool] = False buttons: Optional[Sequence[MenuItemButton]] = () diff --git a/netbox/netbox/navigation/menu.py b/netbox/netbox/navigation/menu.py index 4fe16e773a4..2a58b277e76 100644 --- a/netbox/netbox/navigation/menu.py +++ b/netbox/netbox/navigation/menu.py @@ -371,6 +371,7 @@ MenuItem( link=f'users:user_list', link_text=_('Users'), + auth_required=True, permissions=[f'auth.view_user'], buttons=( MenuItemButton( @@ -390,6 +391,7 @@ MenuItem( link=f'users:group_list', link_text=_('Groups'), + auth_required=True, permissions=[f'auth.view_group'], buttons=( MenuItemButton( @@ -409,12 +411,14 @@ MenuItem( link=f'users:token_list', link_text=_('API Tokens'), + auth_required=True, permissions=[f'users.view_token'], buttons=get_model_buttons('users', 'token') ), MenuItem( link=f'users:objectpermission_list', link_text=_('Permissions'), + auth_required=True, permissions=[f'users.view_objectpermission'], buttons=get_model_buttons('users', 'objectpermission', actions=['add']) ), @@ -425,16 +429,19 @@ items=( MenuItem( link='core:system', - link_text=_('System') + link_text=_('System'), + auth_required=True ), MenuItem( link='core:configrevision_list', link_text=_('Configuration History'), + auth_required=True, permissions=['core.view_configrevision'] ), MenuItem( link='core:background_queue_list', - link_text=_('Background Tasks') + link_text=_('Background Tasks'), + auth_required=True ), ), ), diff --git a/netbox/utilities/templatetags/navigation.py b/netbox/utilities/templatetags/navigation.py index fd492db2225..176996aa13c 100644 --- a/netbox/utilities/templatetags/navigation.py +++ b/netbox/utilities/templatetags/navigation.py @@ -26,6 +26,8 @@ def nav(context): for group in menu.groups: items = [] for item in group.items: + if getattr(item, 'auth_required', False) and not user.is_authenticated: + continue if not user.has_perms(item.permissions): continue if item.staff_only and not user.is_staff: From 9316f48a20f2ff2ceaa51c0e9d8eb99b413c5be1 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 7 May 2024 10:27:20 -0400 Subject: [PATCH 05/34] Fixes #15982: Restore the "assign IP" tab --- netbox/ipam/views.py | 1 + .../ipam/inc/ipaddress_edit_header.html | 33 ++++------- netbox/templates/ipam/ipaddress_assign.html | 56 +++++++++---------- netbox/templates/ipam/ipaddress_edit.html | 5 ++ 4 files changed, 44 insertions(+), 51 deletions(-) create mode 100644 netbox/templates/ipam/ipaddress_edit.html diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index 24d82d18680..044474ec4eb 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -781,6 +781,7 @@ def get_extra_context(self, request, instance): class IPAddressEditView(generic.ObjectEditView): queryset = IPAddress.objects.all() form = forms.IPAddressForm + template_name = 'ipam/ipaddress_edit.html' def alter_object(self, obj, request, url_args, url_kwargs): diff --git a/netbox/templates/ipam/inc/ipaddress_edit_header.html b/netbox/templates/ipam/inc/ipaddress_edit_header.html index a635fbd8b38..c7fbffee7c4 100644 --- a/netbox/templates/ipam/inc/ipaddress_edit_header.html +++ b/netbox/templates/ipam/inc/ipaddress_edit_header.html @@ -3,30 +3,21 @@ diff --git a/netbox/templates/ipam/ipaddress_assign.html b/netbox/templates/ipam/ipaddress_assign.html index 4ddd1994193..3001bffc7bd 100644 --- a/netbox/templates/ipam/ipaddress_assign.html +++ b/netbox/templates/ipam/ipaddress_assign.html @@ -12,37 +12,33 @@ {% endblock %} {% block form %} -
- {% csrf_token %} - {% for field in form.hidden_fields %} - {{ field }} - {% endfor %} -
-
-
-
{% trans "Select IP Address" %}
- {% render_field form.vrf_id %} - {% render_field form.q %} -
-
+ + {% csrf_token %} + {% for field in form.hidden_fields %} + {{ field }} + {% endfor %} +
+
+
{% trans "Select IP Address" %}
+
+ {% render_field form.vrf_id %} + {% render_field form.q %} +
+
+ {% trans "Cancel" %} + +
+ + {% if table %} +
+
+

{% trans "Search Results" %}

+
+ {% render_table table 'inc/table.html' %}
-
-
- {% trans "Cancel" %} - -
-
- - {% if table %} -
-
-

{% trans "Search Results" %}

-
- {% render_table table 'inc/table.html' %} -
-
-
- {% endif %} +
+
+ {% endif %} {% endblock form %} {% block buttons %} diff --git a/netbox/templates/ipam/ipaddress_edit.html b/netbox/templates/ipam/ipaddress_edit.html new file mode 100644 index 00000000000..48acde3349b --- /dev/null +++ b/netbox/templates/ipam/ipaddress_edit.html @@ -0,0 +1,5 @@ +{% extends 'generic/object_edit.html' %} + +{% block tabs %} + {% include 'ipam/inc/ipaddress_edit_header.html' with active_tab='add' %} +{% endblock %} From ccf32244d3dc2adb4edd432057e2bbc29b945d71 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 7 May 2024 10:42:50 -0400 Subject: [PATCH 06/34] Fixes #16003: Enable cache busting on upgrade for setmode.js --- netbox/templates/base/base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/templates/base/base.html b/netbox/templates/base/base.html index f7fa3fa50f1..7a7a4fe993d 100644 --- a/netbox/templates/base/base.html +++ b/netbox/templates/base/base.html @@ -20,7 +20,7 @@ {# Initialize color mode #}