Date: Thu, 11 Nov 2021 12:10:47 -0500
Subject: [PATCH 07/14] Fixes #7654: Fix assignment of members to virtual
chassis with initial position of zero
---
docs/release-notes/version-3.0.md | 1 +
netbox/dcim/forms/object_create.py | 10 ++++++++--
netbox/templates/dcim/virtualchassis.html | 2 +-
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md
index c8d188e3d..fdbf58908 100644
--- a/docs/release-notes/version-3.0.md
+++ b/docs/release-notes/version-3.0.md
@@ -9,6 +9,7 @@
### Bug Fixes
+* [#7564](https://github.com/netbox-community/netbox/issues/7564) - Fix assignment of members to virtual chassis with initial position of zero
* [#7701](https://github.com/netbox-community/netbox/issues/7701) - Fix conflation of assigned IP status & role in interface tables
* [#7741](https://github.com/netbox-community/netbox/issues/7741) - Fix 404 when attaching multiple images in succession
* [#7752](https://github.com/netbox-community/netbox/issues/7752) - Fix minimum version check under Python v3.10
diff --git a/netbox/dcim/forms/object_create.py b/netbox/dcim/forms/object_create.py
index 7577ad355..ea797335d 100644
--- a/netbox/dcim/forms/object_create.py
+++ b/netbox/dcim/forms/object_create.py
@@ -117,12 +117,18 @@ class VirtualChassisCreateForm(BootstrapMixin, CustomFieldModelForm):
'name', 'domain', 'region', 'site_group', 'site', 'rack', 'members', 'initial_position', 'tags',
]
+ def clean(self):
+ if self.cleaned_data['members'] and self.cleaned_data['initial_position'] is None:
+ raise forms.ValidationError({
+ 'initial_position': "A position must be specified for the first VC member."
+ })
+
def save(self, *args, **kwargs):
instance = super().save(*args, **kwargs)
# Assign VC members
- if instance.pk:
- initial_position = self.cleaned_data.get('initial_position') or 1
+ if instance.pk and self.cleaned_data['members']:
+ initial_position = self.cleaned_data.get('initial_position', 1)
for i, member in enumerate(self.cleaned_data['members'], start=initial_position):
member.virtual_chassis = instance
member.vc_position = i
diff --git a/netbox/templates/dcim/virtualchassis.html b/netbox/templates/dcim/virtualchassis.html
index 12088e892..60c20a5dc 100644
--- a/netbox/templates/dcim/virtualchassis.html
+++ b/netbox/templates/dcim/virtualchassis.html
@@ -61,7 +61,7 @@
{{ vc_member }}
- {% badge vc_member.vc_position %}
+ {% badge vc_member.vc_position show_empty=True %}
|
{% if object.master == vc_member %}
From 2f064cdfd1429ee835062cdb9d88ffc64f3ddf9a Mon Sep 17 00:00:00 2001
From: jeremystretch
Date: Thu, 11 Nov 2021 12:30:28 -0500
Subject: [PATCH 08/14] Changelog for #7767
---
docs/release-notes/version-3.0.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md
index fdbf58908..366f0bca0 100644
--- a/docs/release-notes/version-3.0.md
+++ b/docs/release-notes/version-3.0.md
@@ -6,6 +6,7 @@
* [#7740](https://github.com/netbox-community/netbox/issues/7740) - Add mini-DIN 8 console port type
* [#7760](https://github.com/netbox-community/netbox/issues/7760) - Add `vid` filter field to VLANs list
+* [#7767](https://github.com/netbox-community/netbox/issues/7767) - Add visual aids to interfaces table for type, enabled status
### Bug Fixes
From a7990942276f125694e7fa33f6d5c58925574aee Mon Sep 17 00:00:00 2001
From: jeremystretch
Date: Thu, 11 Nov 2021 15:38:34 -0500
Subject: [PATCH 09/14] Fixes #7788: Improve XSS mitigation in Markdown
renderer
---
docs/release-notes/version-3.0.md | 1 +
netbox/utilities/templatetags/helpers.py | 9 +++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md
index 366f0bca0..5ba2ac35f 100644
--- a/docs/release-notes/version-3.0.md
+++ b/docs/release-notes/version-3.0.md
@@ -17,6 +17,7 @@
* [#7766](https://github.com/netbox-community/netbox/issues/7766) - Add missing outer dimension columns to rack table
* [#7780](https://github.com/netbox-community/netbox/issues/7780) - Preserve multi-line values during CSV file import
* [#7783](https://github.com/netbox-community/netbox/issues/7783) - Fix indentation of locations under site view
+* [#7788](https://github.com/netbox-community/netbox/issues/7788) - Improve XSS mitigation in Markdown renderer
* [#7791](https://github.com/netbox-community/netbox/issues/7791) - Enable sorting device bays table by installed device status
* [#7802](https://github.com/netbox-community/netbox/issues/7802) - Differentiate ID and VID columns in VLANs table
diff --git a/netbox/utilities/templatetags/helpers.py b/netbox/utilities/templatetags/helpers.py
index 5b5534321..b047bb698 100644
--- a/netbox/utilities/templatetags/helpers.py
+++ b/netbox/utilities/templatetags/helpers.py
@@ -40,14 +40,19 @@ def render_markdown(value):
"""
Render text as Markdown
"""
+ schemes = '|'.join(settings.ALLOWED_URL_SCHEMES)
+
# Strip HTML tags
value = strip_tags(value)
# Sanitize Markdown links
- schemes = '|'.join(settings.ALLOWED_URL_SCHEMES)
- pattern = fr'\[(.+)\]\((?!({schemes})).*:(.+)\)'
+ pattern = fr'\[([^\]]+)\]\((?!({schemes})).*:(.+)\)'
value = re.sub(pattern, '[\\1](\\3)', value, flags=re.IGNORECASE)
+ # Sanitize Markdown reference links
+ pattern = fr'\[(.+)\]:\w?(?!({schemes})).*:(.+)'
+ value = re.sub(pattern, '[\\1]: \\3', value, flags=re.IGNORECASE)
+
# Render Markdown
html = markdown(value, extensions=['fenced_code', 'tables'])
From 0b705553a565edbd03c808fc8376f109b2c653fb Mon Sep 17 00:00:00 2001
From: jeremystretch
Date: Thu, 11 Nov 2021 16:16:54 -0500
Subject: [PATCH 10/14] Fixes #7809: Add missing export template support for
various models
---
docs/release-notes/version-3.0.md | 1 +
netbox/extras/forms/models.py | 2 +-
netbox/extras/models/customfields.py | 2 +-
netbox/extras/models/models.py | 8 ++++----
netbox/extras/models/tags.py | 2 +-
5 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md
index 5ba2ac35f..27c8fffad 100644
--- a/docs/release-notes/version-3.0.md
+++ b/docs/release-notes/version-3.0.md
@@ -20,6 +20,7 @@
* [#7788](https://github.com/netbox-community/netbox/issues/7788) - Improve XSS mitigation in Markdown renderer
* [#7791](https://github.com/netbox-community/netbox/issues/7791) - Enable sorting device bays table by installed device status
* [#7802](https://github.com/netbox-community/netbox/issues/7802) - Differentiate ID and VID columns in VLANs table
+* [#7809](https://github.com/netbox-community/netbox/issues/7809) - Add missing export template support for various models
---
diff --git a/netbox/extras/forms/models.py b/netbox/extras/forms/models.py
index 7e462e62b..61c341334 100644
--- a/netbox/extras/forms/models.py
+++ b/netbox/extras/forms/models.py
@@ -70,7 +70,7 @@ class CustomLinkForm(BootstrapMixin, forms.ModelForm):
class ExportTemplateForm(BootstrapMixin, forms.ModelForm):
content_type = ContentTypeChoiceField(
queryset=ContentType.objects.all(),
- limit_choices_to=FeatureQuery('custom_links')
+ limit_choices_to=FeatureQuery('export_templates')
)
class Meta:
diff --git a/netbox/extras/models/customfields.py b/netbox/extras/models/customfields.py
index c74bb0cde..245079863 100644
--- a/netbox/extras/models/customfields.py
+++ b/netbox/extras/models/customfields.py
@@ -31,7 +31,7 @@ class CustomFieldManager(models.Manager.from_queryset(RestrictedQuerySet)):
return self.get_queryset().filter(content_types=content_type)
-@extras_features('webhooks')
+@extras_features('webhooks', 'export_templates')
class CustomField(ChangeLoggedModel):
content_types = models.ManyToManyField(
to=ContentType,
diff --git a/netbox/extras/models/models.py b/netbox/extras/models/models.py
index 2c56f2f0f..1b20cc79c 100644
--- a/netbox/extras/models/models.py
+++ b/netbox/extras/models/models.py
@@ -9,7 +9,7 @@ from django.db import models
from django.http import HttpResponse
from django.urls import reverse
from django.utils import timezone
-from django.utils.formats import date_format, time_format
+from django.utils.formats import date_format
from rest_framework.utils.encoders import JSONEncoder
from extras.choices import *
@@ -36,7 +36,7 @@ __all__ = (
# Webhooks
#
-@extras_features('webhooks')
+@extras_features('webhooks', 'export_templates')
class Webhook(ChangeLoggedModel):
"""
A Webhook defines a request that will be sent to a remote application when an object is created, updated, and/or
@@ -175,7 +175,7 @@ class Webhook(ChangeLoggedModel):
# Custom links
#
-@extras_features('webhooks')
+@extras_features('webhooks', 'export_templates')
class CustomLink(ChangeLoggedModel):
"""
A custom link to an external representation of a NetBox object. The link text and URL fields accept Jinja2 template
@@ -234,7 +234,7 @@ class CustomLink(ChangeLoggedModel):
# Export templates
#
-@extras_features('webhooks')
+@extras_features('webhooks', 'export_templates')
class ExportTemplate(ChangeLoggedModel):
content_type = models.ForeignKey(
to=ContentType,
diff --git a/netbox/extras/models/tags.py b/netbox/extras/models/tags.py
index afeeee53d..da2016875 100644
--- a/netbox/extras/models/tags.py
+++ b/netbox/extras/models/tags.py
@@ -14,7 +14,7 @@ from utilities.querysets import RestrictedQuerySet
# Tags
#
-@extras_features('webhooks')
+@extras_features('webhooks', 'export_templates')
class Tag(ChangeLoggedModel, TagBase):
color = ColorField(
default=ColorChoices.COLOR_GREY
From 9f8068e8d12da7ac9399e622fa2c4ec5d74fe452 Mon Sep 17 00:00:00 2001
From: jeremystretch
Date: Thu, 11 Nov 2021 16:21:27 -0500
Subject: [PATCH 11/14] Fixes #7808: Fix reference values for content type
under custom field import form
---
docs/release-notes/version-3.0.md | 1 +
netbox/utilities/forms/fields.py | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md
index 27c8fffad..03a4d3a59 100644
--- a/docs/release-notes/version-3.0.md
+++ b/docs/release-notes/version-3.0.md
@@ -20,6 +20,7 @@
* [#7788](https://github.com/netbox-community/netbox/issues/7788) - Improve XSS mitigation in Markdown renderer
* [#7791](https://github.com/netbox-community/netbox/issues/7791) - Enable sorting device bays table by installed device status
* [#7802](https://github.com/netbox-community/netbox/issues/7802) - Differentiate ID and VID columns in VLANs table
+* [#7808](https://github.com/netbox-community/netbox/issues/7808) - Fix reference values for content type under custom field import form
* [#7809](https://github.com/netbox-community/netbox/issues/7809) - Add missing export template support for various models
---
diff --git a/netbox/utilities/forms/fields.py b/netbox/utilities/forms/fields.py
index d9f1719ec..bca293b0b 100644
--- a/netbox/utilities/forms/fields.py
+++ b/netbox/utilities/forms/fields.py
@@ -304,7 +304,7 @@ class CSVMultipleContentTypeField(forms.ModelMultipleChoiceField):
app_label, model = name.split('.')
ct_filter |= Q(app_label=app_label, model=model)
return list(ContentType.objects.filter(ct_filter).values_list('pk', flat=True))
- return super().prepare_value(value)
+ return f'{value.app_label}.{value.model}'
#
From daf6c8e327ff3128449a3add684a76bd7fef4268 Mon Sep 17 00:00:00 2001
From: jeremystretch
Date: Fri, 12 Nov 2021 08:23:58 -0500
Subject: [PATCH 12/14] Fixes #7814: Fix restriction of user & group objects in
GraphQL API queries
---
docs/release-notes/version-3.0.md | 1 +
netbox/users/graphql/types.py | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md
index 03a4d3a59..324cda952 100644
--- a/docs/release-notes/version-3.0.md
+++ b/docs/release-notes/version-3.0.md
@@ -22,6 +22,7 @@
* [#7802](https://github.com/netbox-community/netbox/issues/7802) - Differentiate ID and VID columns in VLANs table
* [#7808](https://github.com/netbox-community/netbox/issues/7808) - Fix reference values for content type under custom field import form
* [#7809](https://github.com/netbox-community/netbox/issues/7809) - Add missing export template support for various models
+* [#7814](https://github.com/netbox-community/netbox/issues/7814) - Fix restriction of user & group objects in GraphQL API queries
---
diff --git a/netbox/users/graphql/types.py b/netbox/users/graphql/types.py
index 3315744b9..d948686c6 100644
--- a/netbox/users/graphql/types.py
+++ b/netbox/users/graphql/types.py
@@ -19,7 +19,7 @@ class GroupType(DjangoObjectType):
@classmethod
def get_queryset(cls, queryset, info):
- return RestrictedQuerySet(model=Group)
+ return RestrictedQuerySet(model=Group).restrict(info.context.user, 'view')
class UserType(DjangoObjectType):
@@ -34,4 +34,4 @@ class UserType(DjangoObjectType):
@classmethod
def get_queryset(cls, queryset, info):
- return RestrictedQuerySet(model=User)
+ return RestrictedQuerySet(model=User).restrict(info.context.user, 'view')
From 49e77841e06f47f29294c9b69dca97c87285a2d7 Mon Sep 17 00:00:00 2001
From: jeremystretch
Date: Fri, 12 Nov 2021 08:36:33 -0500
Subject: [PATCH 13/14] Release v3.0.10
---
.github/ISSUE_TEMPLATE/bug_report.yaml | 2 +-
.github/ISSUE_TEMPLATE/feature_request.yaml | 2 +-
docs/release-notes/version-3.0.md | 2 +-
netbox/netbox/settings.py | 2 +-
requirements.txt | 4 ++--
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml
index fa773eb13..79fb0e334 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yaml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yaml
@@ -14,7 +14,7 @@ body:
attributes:
label: NetBox version
description: What version of NetBox are you currently running?
- placeholder: v3.0.9
+ placeholder: v3.0.10
validations:
required: true
- type: dropdown
diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml
index a6fc342be..76944eecb 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.yaml
+++ b/.github/ISSUE_TEMPLATE/feature_request.yaml
@@ -14,7 +14,7 @@ body:
attributes:
label: NetBox version
description: What version of NetBox are you currently running?
- placeholder: v3.0.9
+ placeholder: v3.0.10
validations:
required: true
- type: dropdown
diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md
index 324cda952..4c263e78f 100644
--- a/docs/release-notes/version-3.0.md
+++ b/docs/release-notes/version-3.0.md
@@ -1,6 +1,6 @@
# NetBox v3.0
-## v3.0.10 (FUTURE)
+## v3.0.10 (2021-11-12)
### Enhancements
diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py
index b0c996141..83655d0c5 100644
--- a/netbox/netbox/settings.py
+++ b/netbox/netbox/settings.py
@@ -17,7 +17,7 @@ from django.core.validators import URLValidator
# Environment setup
#
-VERSION = '3.0.10-dev'
+VERSION = '3.0.10'
# Hostname
HOSTNAME = platform.node()
diff --git a/requirements.txt b/requirements.txt
index c537a39c3..84ad0c398 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -15,13 +15,13 @@ djangorestframework==3.12.4
drf-yasg[validation]==1.20.0
graphene_django==2.15.0
gunicorn==20.1.0
-Jinja2==3.0.2
+Jinja2==3.0.3
Markdown==3.3.4
markdown-include==0.6.0
mkdocs-material==7.3.6
netaddr==0.8.0
Pillow==8.4.0
-psycopg2-binary==2.9.1
+psycopg2-binary==2.9.2
PyYAML==6.0
svgwrite==1.4.1
tablib==3.1.0
From c0ca1eaf9044ace9d4b7933d6ff75a9d53e55bb1 Mon Sep 17 00:00:00 2001
From: jeremystretch
Date: Fri, 12 Nov 2021 08:54:08 -0500
Subject: [PATCH 14/14] PRVB
---
docs/release-notes/version-3.0.md | 4 ++++
netbox/netbox/settings.py | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md
index 4c263e78f..4e7ead79c 100644
--- a/docs/release-notes/version-3.0.md
+++ b/docs/release-notes/version-3.0.md
@@ -1,5 +1,9 @@
# NetBox v3.0
+## v3.0.11 (FUTURE)
+
+---
+
## v3.0.10 (2021-11-12)
### Enhancements
diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py
index 83655d0c5..b7886b23c 100644
--- a/netbox/netbox/settings.py
+++ b/netbox/netbox/settings.py
@@ -17,7 +17,7 @@ from django.core.validators import URLValidator
# Environment setup
#
-VERSION = '3.0.10'
+VERSION = '3.0.11-dev'
# Hostname
HOSTNAME = platform.node()
|