Compare commits

...

16 Commits
v4.4.0 ... main

Author SHA1 Message Date
github-actions
c9f823167c Update source translation strings
Some checks are pending
CodeQL / Analyze (${{ matrix.language }}) (none, actions) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, python) (push) Waiting to run
2025-09-06 05:02:29 +00:00
jetomit
5ca2cea016
Closes #20222: Enable HttpOnly flag for the CSRF cookie (#20262)
Some checks are pending
CI / build (20.x, 3.10) (push) Waiting to run
CI / build (20.x, 3.11) (push) Waiting to run
CI / build (20.x, 3.12) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, actions) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, python) (push) Waiting to run
2025-09-05 15:04:02 -07:00
Jason Novinger
026737b62b
Fixes #19851: Fix WirelessLANImportForm has no field scope, improve validation (#20273) 2025-09-05 14:59:38 -07:00
Jeremy Stretch
94faf58c27
Closes #19408: Enable export templates for circuit terminations (#20251) 2025-09-05 14:23:07 -07:00
Jeremy Stretch
de499ca686
Fixes #20282: Fix styling of warning for missing prerequisite objects (#20283) 2025-09-05 15:26:11 -05:00
Martin Hauser
f04a2b965f
Fixes #20252: Remove generic AddObject from ObjectChildrenView (#20279) 2025-09-05 15:10:24 -05:00
Jason Novinger
fcb380b5c5 Fixes #20221: JSON CustomField does not coerce {} to null
Some checks are pending
CI / build (20.x, 3.10) (push) Waiting to run
CI / build (20.x, 3.11) (push) Waiting to run
CI / build (20.x, 3.12) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, actions) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, python) (push) Waiting to run
This fix actually fixes this for all valid JSON values that evaluate to
`False` in Python when loaded and cast to bool:
`bool(json.loads(<val>))`.

- `{}`
- `[]`
- `0`
- `False`

This does not change the behavior of `()` or `""` which are both
explicitly cited as "empty" values on `JSONField`.
2025-09-05 15:54:25 -04:00
Martin Hauser
8311f457b5
Fixes #20258: Correct typographical errors in labels (#20278) 2025-09-05 14:07:12 -05:00
Martin Hauser
47e4947ca0
Fixes #20234: Correct add_button return_url (#20268) 2025-09-05 08:01:28 -05:00
Jeremy Stretch
545773e221
Fixes #20227: Fix paragraph spacing in rendered Markdown content (#20256) 2025-09-05 07:05:36 -05:00
github-actions
2ddec1ef48 Update source translation strings
Some checks are pending
CodeQL / Analyze (${{ matrix.language }}) (none, actions) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, python) (push) Waiting to run
2025-09-05 05:03:32 +00:00
Jonathan Ramstedt
309e434064
Fixes #19896: cf minmax mustbe int (#20207)
Some checks are pending
CI / build (20.x, 3.10) (push) Waiting to run
CI / build (20.x, 3.11) (push) Waiting to run
CI / build (20.x, 3.12) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, actions) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, python) (push) Waiting to run
2025-09-04 16:10:05 -07:00
Jeremy Stretch
8a1db81111
Closes #20203: Add a pre-commit check for OpenAPI schema changes (#20230) 2025-09-04 16:02:12 -07:00
Martin Hauser
399d51b466 fix(vpn): Update to_field_name in bulk import form
Changes the value of `to_field_name` from `name` to `address` in the
VPN bulk import form. This ensures proper mapping and validation for
IP address selection during the bulk import process.

Closes #20238
2025-09-04 16:42:13 -04:00
Martin Hauser
6135fb8cd7 feat(vpn): Add search index for TunnelGroup
Introduces `TunnelGroupIndex` for enabling search functionality on
Tunnel Groups. Includes searchable fields for `name` and `description`
with respective weights and display attributes.

Closes #20237
2025-09-04 16:33:39 -04:00
github-actions
ea50786b5c Update source translation strings
Some checks failed
CodeQL / Analyze (${{ matrix.language }}) (none, actions) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, python) (push) Has been cancelled
2025-09-03 05:02:17 +00:00
26 changed files with 259264 additions and 2393 deletions

View File

@ -21,6 +21,14 @@ repos:
language: system
pass_filenames: false
types: [python]
- id: openapi-check
name: "Validate OpenAPI schema"
description: "Check for any unexpected changes to the OpenAPI schema"
files: api/.*\.py$
entry: scripts/verify-openapi.sh
language: system
pass_filenames: false
types: [python]
- id: mkdocs-build
name: "Build documentation"
description: "Build the documentation with mkdocs"

256546
contrib/openapi.json Normal file

File diff suppressed because one or more lines are too long

View File

@ -123,16 +123,6 @@ $ node bundle.js
Done in 1.00s.
```
### Rebuild the Device Type Definition Schema
Run the following command to update the device type definition validation schema:
```nohighlight
./manage.py buildschema --write
```
This will automatically update the schema file at `contrib/generated_schema.json`.
### Update & Compile Translations
Updated language translations should be pulled from [Transifex](https://app.transifex.com/netbox-community/netbox/dashboard/) and re-compiled for each new release. First, retrieve any updated translation files using the Transifex CLI client:
@ -160,6 +150,24 @@ Then, compile these portable (`.po`) files for use in the application:
!!! tip
Put yourself in the shoes of the user when recording change notes. Focus on the effect that each change has for the end user, rather than the specific bits of code that were modified in a PR. Ensure that each message conveys meaning absent context of the initial feature request or bug report. Remember to include keywords or phrases (such as exception names) that can be easily searched.
### Rebuild the Device Type Definition Schema
Run the following command to update the device type definition validation schema:
```nohighlight
./manage.py buildschema --write
```
This will automatically update the schema file at `contrib/generated_schema.json`.
### Update the OpenAPI Schema
Update the static OpenAPI schema definition at `contrib/openapi.json` with the management command below. If the schema file is up-to-date, only the NetBox version will be changed.
```nohighlight
./manage.py spectacular --format openapi-json > ../contrib/openapi.json
```
### Submit a Pull Request
Commit the above changes and submit a pull request titled **"Release vX.Y.Z"** to merge the current release branch (e.g. `release-vX.Y.Z`) into `main`. Copy the documented release notes into the pull request's body.

View File

@ -6,7 +6,6 @@ from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from circuits.choices import *
from circuits.constants import *
from dcim.models import CabledObjectModel
from netbox.models import ChangeLoggedModel, OrganizationalModel, PrimaryModel
from netbox.models.mixins import DistanceMixin
@ -231,6 +230,7 @@ class CircuitGroupAssignment(CustomFieldsMixin, ExportTemplatesMixin, TagsMixin,
class CircuitTermination(
CustomFieldsMixin,
CustomLinksMixin,
ExportTemplatesMixin,
TagsMixin,
ChangeLoggedModel,
CabledObjectModel

View File

@ -8,7 +8,7 @@ from django.utils.translation import gettext_lazy as _
from circuits.choices import *
from netbox.models import ChangeLoggedModel, PrimaryModel
from netbox.models.features import CustomFieldsMixin, CustomLinksMixin, TagsMixin
from netbox.models.features import CustomFieldsMixin, CustomLinksMixin, ExportTemplatesMixin, TagsMixin
from .base import BaseCircuitType
__all__ = (
@ -121,6 +121,7 @@ class VirtualCircuit(PrimaryModel):
class VirtualCircuitTermination(
CustomFieldsMixin,
CustomLinksMixin,
ExportTemplatesMixin,
TagsMixin,
ChangeLoggedModel
):

View File

@ -1181,7 +1181,7 @@ class InventoryItemImportForm(NetBoxModelImportForm):
help_text=_('Component Type')
)
component_name = forms.CharField(
label=_('Compnent name'),
label=_('Component name'),
required=False,
help_text=_('Component Name')
)

View File

@ -1,6 +1,6 @@
from django import forms
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ObjectDoesNotExist
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.utils.translation import gettext_lazy as _
from dcim.constants import LOCATION_SCOPE_TYPES
@ -48,8 +48,17 @@ class ScopedForm(forms.Form):
def clean(self):
super().clean()
scope = self.cleaned_data.get('scope')
scope_type = self.cleaned_data.get('scope_type')
if scope_type and not scope:
raise ValidationError({
'scope': _(
"Please select a {scope_type}."
).format(scope_type=scope_type.model_class()._meta.model_name)
})
# Assign the selected scope (if any)
self.instance.scope = self.cleaned_data.get('scope')
self.instance.scope = scope
def _set_scoped_values(self):
if scope_type_id := get_field_value(self, 'scope_type'):
@ -107,3 +116,15 @@ class ScopedImportForm(forms.Form):
required=False,
label=_('Scope type (app & model)')
)
def clean(self):
super().clean()
scope_id = self.cleaned_data.get('scope_id')
scope_type = self.cleaned_data.get('scope_type')
if scope_type and not scope_id:
raise ValidationError({
'scope_id': _(
"Please select a {scope_type}."
).format(scope_type=scope_type.model_class()._meta.model_name)
})

View File

@ -87,11 +87,9 @@ class CachedScopeMixin(models.Model):
def clean(self):
if self.scope_type and not (self.scope or self.scope_id):
scope_type = self.scope_type.model_class()
raise ValidationError({
'scope': _(
"Please select a {scope_type}."
).format(scope_type=scope_type._meta.model_name)
})
raise ValidationError(
_("Please select a {scope_type}.").format(scope_type=scope_type._meta.model_name)
)
super().clean()
def save(self, *args, **kwargs):

View File

@ -76,11 +76,11 @@ class CustomFieldBulkEditForm(ChangelogMessageMixin, BulkEditForm):
required=False,
widget=BulkEditNullBooleanSelect()
)
validation_minimum = forms.IntegerField(
validation_minimum = forms.DecimalField(
label=_('Minimum value'),
required=False,
)
validation_maximum = forms.IntegerField(
validation_maximum = forms.DecimalField(
label=_('Maximum value'),
required=False,
)

View File

@ -103,11 +103,11 @@ class CustomFieldFilterForm(SavedFiltersMixin, FilterForm):
choices=BOOLEAN_WITH_BLANK_CHOICES
)
)
validation_minimum = forms.IntegerField(
validation_minimum = forms.DecimalField(
label=_('Minimum value'),
required=False
)
validation_maximum = forms.IntegerField(
validation_maximum = forms.DecimalField(
label=_('Maximum value'),
required=False
)

View File

@ -17,7 +17,7 @@ if TYPE_CHECKING:
)
from tenancy.graphql.filters import TenantFilter, TenantGroupFilter
from netbox.graphql.enums import ColorEnum
from netbox.graphql.filter_lookups import IntegerLookup, JSONFilter, StringArrayLookup, TreeNodeFilter
from netbox.graphql.filter_lookups import FloatLookup, IntegerLookup, JSONFilter, StringArrayLookup, TreeNodeFilter
from users.graphql.filters import GroupFilter, UserFilter
from virtualization.graphql.filters import ClusterFilter, ClusterGroupFilter, ClusterTypeFilter
from .enums import *
@ -151,10 +151,10 @@ class CustomFieldFilter(BaseObjectTypeFilterMixin, ChangeLogFilterMixin):
weight: Annotated['IntegerLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
strawberry_django.filter_field()
)
validation_minimum: Annotated['IntegerLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
validation_minimum: Annotated['FloatLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
strawberry_django.filter_field()
)
validation_maximum: Annotated['IntegerLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
validation_maximum: Annotated['FloatLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
strawberry_django.filter_field()
)
validation_regex: FilterLookup[str] | None = strawberry_django.filter_field()

View File

@ -0,0 +1,21 @@
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('extras', '0132_configcontextprofile'),
]
operations = [
migrations.AlterField(
model_name='customfield',
name='validation_maximum',
field=models.DecimalField(blank=True, decimal_places=4, max_digits=16, null=True),
),
migrations.AlterField(
model_name='customfield',
name='validation_minimum',
field=models.DecimalField(blank=True, decimal_places=4, max_digits=16, null=True),
),
]

View File

@ -174,13 +174,17 @@ class CustomField(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel):
verbose_name=_('display weight'),
help_text=_('Fields with higher weights appear lower in a form.')
)
validation_minimum = models.BigIntegerField(
validation_minimum = models.DecimalField(
max_digits=16,
decimal_places=4,
blank=True,
null=True,
verbose_name=_('minimum value'),
help_text=_('Minimum allowed value (for numeric fields)')
)
validation_maximum = models.BigIntegerField(
validation_maximum = models.DecimalField(
max_digits=16,
decimal_places=4,
blank=True,
null=True,
verbose_name=_('maximum value'),
@ -471,7 +475,7 @@ class CustomField(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel):
field = forms.DecimalField(
required=required,
initial=initial,
max_digits=12,
max_digits=16,
decimal_places=4,
min_value=self.validation_minimum,
max_value=self.validation_maximum
@ -534,7 +538,7 @@ class CustomField(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel):
# JSON
elif self.type == CustomFieldTypeChoices.TYPE_JSON:
field = JSONField(required=required, initial=json.dumps(initial) if initial else None)
field = JSONField(required=required, initial=json.dumps(initial) if initial is not None else None)
# Object
elif self.type == CustomFieldTypeChoices.TYPE_OBJECT:

View File

@ -1,7 +1,9 @@
import datetime
import json
from decimal import Decimal
from django.core.exceptions import ValidationError
from django.test import tag
from django.urls import reverse
from rest_framework import status
@ -269,6 +271,60 @@ class CustomFieldTest(TestCase):
instance.refresh_from_db()
self.assertIsNone(instance.custom_field_data.get(cf.name))
@tag('regression')
def test_json_field_falsy_defaults(self):
"""Test that falsy JSON default values are properly handled"""
falsy_test_cases = [
({}, 'empty_dict'),
([], 'empty_array'),
(0, 'zero'),
(False, 'false_bool'),
("", 'empty_string'),
]
for default, suffix in falsy_test_cases:
with self.subTest(default=default, suffix=suffix):
cf = CustomField.objects.create(
name=f'json_falsy_{suffix}',
type=CustomFieldTypeChoices.TYPE_JSON,
default=default,
required=False
)
cf.object_types.set([self.object_type])
instance = Site.objects.create(name=f'Test Site {suffix}', slug=f'test-site-{suffix}')
self.assertIsNotNone(instance.custom_field_data)
self.assertIn(cf.name, instance.custom_field_data)
instance.refresh_from_db()
stored = instance.custom_field_data[cf.name]
self.assertEqual(stored, default)
@tag('regression')
def test_json_field_falsy_to_form_field(self):
"""Test form field generation preserves falsy defaults"""
falsy_test_cases = (
({}, json.dumps({}), 'empty_dict'),
([], json.dumps([]), 'empty_array'),
(0, json.dumps(0), 'zero'),
(False, json.dumps(False), 'false_bool'),
("", '""', 'empty_string'),
)
for default, expected, suffix in falsy_test_cases:
with self.subTest(default=default, expected=expected, suffix=suffix):
cf = CustomField.objects.create(
name=f'json_falsy_{suffix}',
type=CustomFieldTypeChoices.TYPE_JSON,
default=default,
required=False
)
cf.object_types.set([self.object_type])
form_field = cf.to_form_field(set_initial=True)
self.assertEqual(form_field.initial, expected)
def test_select_field(self):
CHOICES = (
('a', 'Option A'),

View File

@ -84,6 +84,7 @@ CORS_ORIGIN_REGEX_WHITELIST = getattr(configuration, 'CORS_ORIGIN_REGEX_WHITELIS
CORS_ORIGIN_WHITELIST = getattr(configuration, 'CORS_ORIGIN_WHITELIST', [])
CSRF_COOKIE_NAME = getattr(configuration, 'CSRF_COOKIE_NAME', 'csrftoken')
CSRF_COOKIE_PATH = f'/{BASE_PATH.rstrip("/")}'
CSRF_COOKIE_HTTPONLY = True
CSRF_COOKIE_SECURE = getattr(configuration, 'CSRF_COOKIE_SECURE', False)
CSRF_TRUSTED_ORIGINS = getattr(configuration, 'CSRF_TRUSTED_ORIGINS', [])
DATA_UPLOAD_MAX_MEMORY_SIZE = getattr(configuration, 'DATA_UPLOAD_MAX_MEMORY_SIZE', 2621440)

View File

@ -15,7 +15,7 @@ from django.utils.translation import gettext as _
from core.signals import clear_events
from netbox.object_actions import (
AddObject, BulkDelete, BulkEdit, BulkExport, BulkImport, CloneObject, DeleteObject, EditObject,
BulkDelete, BulkEdit, BulkExport, BulkImport, CloneObject, DeleteObject, EditObject,
)
from utilities.error_handlers import handle_protectederror
from utilities.exceptions import AbortRequest, PermissionsViolation
@ -103,7 +103,7 @@ class ObjectChildrenView(ObjectView, ActionsMixin, TableMixin):
table = None
filterset = None
filterset_form = None
actions = (AddObject, BulkImport, BulkEdit, BulkExport, BulkDelete)
actions = (BulkImport, BulkEdit, BulkExport, BulkDelete)
template_name = 'generic/object_children.html'
def get_children(self, request, parent):

Binary file not shown.

View File

@ -30,7 +30,7 @@
// Remove the bottom margin of the last <p> elements in markdown
.rendered-markdown {
p:last-of-type {
p:last-child {
margin-bottom: 0;
}
}

View File

@ -60,7 +60,7 @@
<td>{{ worker.pid|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Curent Job" %}</th>
<th scope="row">{% trans "Current Job" %}</th>
<td>{{ job.func_name|placeholder }}</td>
</tr>
<tr>

View File

@ -1,16 +1,14 @@
{% load buttons %}
{% load i18n %}
<div class="alert alert-warning" role="alert">
<div class="d-flex justify-content-between">
<div>
<i class="mdi mdi-alert p-2"></i>
{% blocktrans trimmed with model=model|meta:"verbose_name" prerequisite_model=prerequisite_model|meta:"verbose_name" %}
Before you can add a {{ model }} you must first create a <strong>{{ prerequisite_model }}</strong>.
{% endblocktrans %}
</div>
<div>
{% add_button prerequisite_model request.path %}
</div>
</div>
<div class="alert alert-warning d-flex align-items-center" role="alert">
<span class="text-warning fs-1">
<i class="mdi mdi-alert"></i>
</span>
<span class="flex-fill">
{% blocktrans trimmed with model=model|meta:"verbose_name" prerequisite_model=prerequisite_model|meta:"verbose_name" %}
Before you can add a {{ model }} you must first create a <strong>{{ prerequisite_model }}</strong>.
{% endblocktrans %}
</span>
{% add_button prerequisite_model return_url=request.path %}
</div>

View File

@ -69,7 +69,7 @@ class ContactGroupBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
description = forms.CharField(
label=_('Desciption'),
label=_('Description'),
max_length=200,
required=False
)

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@
{{ value|isodatetime }}
{% elif customfield.type == 'url' and value %}
<a href="{{ value }}">{{ value|truncatechars:70 }}</a>
{% elif customfield.type == 'json' and value %}
{% elif customfield.type == 'json' and value is not None %}
<pre>{{ value|json }}</pre>
{% elif customfield.type == 'multiselect' and value %}
{{ value|join:", " }}

View File

@ -107,7 +107,7 @@ class TunnelTerminationImportForm(NetBoxModelImportForm):
label=_('Outside IP'),
queryset=IPAddress.objects.all(),
required=False,
to_field_name='name'
to_field_name='address'
)
class Meta:

View File

@ -14,6 +14,17 @@ class TunnelIndex(SearchIndex):
display_attrs = ('group', 'status', 'encapsulation', 'tenant', 'tunnel_id', 'description')
@register_search
class TunnelGroupIndex(SearchIndex):
model = models.TunnelGroup
fields = (
('name', 100),
('slug', 110),
('description', 500),
)
display_attrs = ('description',)
@register_search
class IKEProposalIndex(SearchIndex):
model = models.IKEProposal

22
scripts/verify-openapi.sh Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env bash
# This script checks for differences between the generated OpenAPI schema and the static definition
# saved at contrib/openapi.json. If the two are not identical, the script returns an error.
PROJECT_ROOT="$PWD"
CMD="python $PROJECT_ROOT/netbox/manage.py spectacular --format openapi-json"
SCHEMA_FILE="$PROJECT_ROOT/contrib/openapi.json"
# Generate the OpenAPI schema & save it to a temporary file
TEMP_FILE=$(mktemp)
trap 'rm -f "$TEMP_FILE"' EXIT
eval "$CMD > $TEMP_FILE"
# Run a diff between the original & generated schemas
if diff -u "$SCHEMA_FILE" "$TEMP_FILE"; then
echo "✅ No changes found."
exit 0
else
echo "❌ Change(s) to OpenAPI schema detected."
exit 1
fi