Commit Graph

15397 Commits

Author SHA1 Message Date
Jeremy Stretch 5359ad8ee4 Fixes 22512: Restrict queryset when fetching custom field objects 2026-06-23 11:57:52 -04:00
bctiemann bf78a45204
Merge pull request #22491 from JCWasmx86/22442-cache-serializers
chore(netbox): Cache serializers
2026-06-22 20:28:57 -04:00
Jason Novinger 8c73f46cc9
Fixes #22507: Check is_active in restrict() and IsSuperuser superuser bypass (#22508)
RestrictedQuerySet.restrict() and IsSuperuser short-circuited on is_superuser
without checking is_active, so a deactivated superuser was granted the full
superuser bypass. restrict() in particular fails open, returning the
unrestricted queryset. Both now also require is_active, matching the existing
guard in ObjectPermissionMixin.has_perm.
2026-06-22 22:03:33 +02:00
Jeremy Stretch a5974ee265
Fixes #21310: Fix IntegrityError exception when `AUTH_LDAP_MIRROR_GROUPS` is enabled (#22492) 2026-06-22 05:35:38 -05:00
github-actions 78d4f4765e Update source translation strings 2026-06-20 06:28:34 +00:00
Arthur Hanson 626e1ef1f8
Fixes #22439: Enforce view permissions for Custom Links (#22469)
Filter custom links by the current user's view permissions before rendering
them on object detail views and table columns.
2026-06-19 09:38:47 +02:00
Jeremy Stretch 83439ba00f
Fixes #22440: Remove errant changelog filter from OpenAPI spec (#22494) 2026-06-18 23:09:33 +02:00
Jeremy Stretch e92367b3f6
Fixes #22480: Revert forced handling of image attachments as downloads (#22493) 2026-06-18 14:09:04 -07:00
mburggraf d217acdc85
Closes #22487: Remove release notes for NetBox v2.x (#22490) 2026-06-18 14:55:59 -04:00
JCWasmx86 4e1e7e9e2e chore(netbox): Cache serializers 2026-06-18 19:41:09 +02:00
mburggraf f9ce0a6741
Closes #22464: Update Documentation to use v2 Tokens in examples (#22477) 2026-06-17 13:44:29 -07:00
Martin Hauser 0e9c99ec7a test(graphql): Add GraphQL schema coverage test framework
Introduce GraphQLSchemaCoverageTestCase to verify every model-backed
GraphQL type exposed as a root query field is covered by a test. Add
type_class and graphql_test_exempt attributes to GraphQLTestCase for
explicit type declaration and coverage exclusion. Include
graphql_object_permission_assertions flag to gate permission checks for
types not enforcing object permissions.

Fixes #22089
2026-06-17 09:34:56 -04:00
Jeremy Stretch 0c26f973ff Release v4.6.3 2026-06-16 11:59:12 -04:00
Jeremy Stretch 086b1cf34d Fixes #22466: Fix test failure against SSL-enabled PosgtreSQL 2026-06-16 11:03:14 -04:00
Brian Tiemann 61696c8633 Closes #22427: Validate JSONFilter.path; add JSONStringLookup with regex
- Add _validate_json_path(): each __-separated path segment must match
  [A-Za-z0-9_][A-Za-z0-9_-]* (allows leading underscores per Jeremy's
  suggestion; ORM operator names like 'date'/'regex' are valid JSON keys
  and are not blocked — the trailing __ JSONFilter appends makes them
  key traversal steps, not ORM transforms)
- Add JSONStringLookup: explicit string-filter type for JSONLookup.
  regex/i_regex are included (they offer no additional oracle power
  beyond starts_with, which is also present, per Jeremy's observation)
- JSONFilter.filter() validates self.path and returns empty Q() on
  invalid input rather than passing untrusted user input to the ORM
- 19 unit tests for path validation and JSONStringLookup field presence

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-16 09:25:09 -04:00
Martin Hauser f46090076d refactor(graphql): Update filter lookups for strawberry-django 0.86
Update strawberry-graphql-django to 0.86.1 and remove redundant type
parameters from StrFilterLookup, DateFilterLookup, TimeFilterLookup, and
DatetimeFilterLookup annotations across model-backed GraphQL filters.

Add NetBox-local JSON date, time, and datetime lookup input types to
preserve the previous string-backed JSON filter schema without relying
on deprecated upstream generic lookup annotations. These local types
keep the legacy GraphQL type names and date/time sub-lookup fields
intact.

Fixes #22353
2026-06-16 08:50:03 -04:00
Jeremy Stretch 16c70c3657
Fixes #22448: Ensure all objects are escaped under handle_protectederror() (#22449) 2026-06-16 13:43:52 +02:00
Jeremy Stretch 0994ce9f0c
Closes #22457: Use `hmac.compare_digest()` to authenticate API tokens (#22458) 2026-06-16 04:51:36 -05:00
Martin Hauser 025074c390
Closes #22280: Set 91% test coverage threshold and exclude non-testable paths (#22450) 2026-06-16 04:38:21 -05:00
github-actions 1264797fa6 Update source translation strings 2026-06-16 06:47:17 +00:00
bctiemann 2d496ca069
Merge pull request #22455 from netbox-community/22451-pass-strawberry-graphql-extension-factories-instead-of
Closes #22451: Use factories for GraphQL schema extension initialization
2026-06-15 19:02:11 -04:00
Jeremy Stretch 9bfdea4787
Fixes #22454: Fix serialization of decimal custom field values (#22460) 2026-06-15 22:24:10 +02:00
Jason Novinger b7de62610f Fixes #22395: Remove unused save() override on ManagedFileForm
The method wrote uploaded files to disk via a raw open(), but no code
path reached it. Its only subclass, ScriptFileForm, overrode save() to
write through django-storages and explicitly skipped the base via
super(ManagedFileForm, self).save(). With the override gone, that call
simplifies back to a plain super().save(). A leftover from #18680, which
moved both upload paths onto django-storages but left the form-level
write in place.
2026-06-15 14:07:46 -04:00
Martin Hauser eaed2a7f8e
refactor(graphql): Use factories for schema extension initialization
Change `get_schema_extensions()` to return extension factories instead
of instances. This defers extension initialization and prevents stale
references to settings captured at import time.

Lambdas capture settings values when extensions are constructed, and
tests now instantiate extensions from factories to verify configuration.

Fixes #22451
2026-06-15 15:34:22 +02:00
Martin Hauser d7de863681
Closes #17598: Add bulk creation for VLANs (#22377) 2026-06-15 08:22:58 -05:00
Jeremy Stretch 8afbfc42d5
Fixes #22346: Return a clean error message & redirect on SSO auth failure (#22420) 2026-06-15 07:51:06 -05:00
github-actions c889e58bee Update source translation strings 2026-06-15 06:46:14 +00:00
Fabi bf1a27b89c
Fixes #22397: Fix AttributeError exception for unauthentictaed users during bulk export 2026-06-14 10:34:51 -04:00
github-actions 850aae2d35 Update source translation strings 2026-06-14 06:31:05 +00:00
Jeremy Stretch 8ff56032b9
Fixes #22444: Fix KeyError exception on device view with non-English locale (#22445) 2026-06-14 02:10:29 +02:00
Tobias Genannt b4fdd6f209 Closes #22333: Use lowercase username for testing
The test failures arises from unstable sorting of the usernames
depending on the collation used in the PostgreSQL database used for
testing. When a case-insensitive collation is used 'testuser' is sorted
before 'User*' and because this user has permissions assigned and
additional query is issued resulting in 12 queries. When a
case-sensitive collation is used the sorting is inverted. Because the
'User*' don't have permissions only 11 queries are sent to the database.

Using only testusers with lowercase names enforces stable sorting
across collations.
2026-06-13 19:42:21 -04:00
Martin Hauser 8f974e3cc8 perf(ipam): Optimize Prefix availability calculations
Replace IPSet-heavy Prefix availability and utilization logic with
indexed host lookups, distinct host counts, and interval-based
availability calculation.

This adds mask-insensitive host-bound filtering for IP addresses and
ranges, moves availability/counting behavior onto QuerySet and model
methods, and uses merged occupied intervals to find available addresses
without materializing large address sets in Python.

Prefix utilization remains on a cheap utilization-only path for list
views, while Prefix detail views can use a shared usage summary when
both utilization and available IP count are needed. Usable IP bounds now
live on the Prefix model, since the logic depends on Prefix-specific
state such as is_pool.

This also adds host expression indexes for IP Ranges, fixes zero-address
preparation, fixes child IP matching across differing mask lengths,
keeps Prefix hierarchy rebuilding scoped to the existing VRF/global API,
and preserves IPRange.first_available_ip as a cached compatibility
wrapper.

Fixes #21870
2026-06-13 18:02:51 -04:00
bctiemann bc7ed0e9bb
Merge pull request #22434 from netbox-community/22303-openapi-fields-omit
Fixes #22303: Annotate fields & omit parameters in OpenAPI schema
2026-06-12 08:38:34 -04:00
github-actions acef3ac112 Update source translation strings 2026-06-12 06:31:01 +00:00
bctiemann d1919627ce
Closes #22429: Enforce ObjectPermission constraints on grant_token (#22424) 2026-06-11 13:30:27 -07:00
github-actions 65454d30db Update source translation strings 2026-06-11 06:32:06 +00:00
Jeremy Stretch d59f5f4381 Fixes #22303: Annotate fields & omit parameters in OpenAPI schema 2026-06-10 13:55:29 -04:00
Brian Tiemann 97a1375a82 Security: replace random.choice with secrets.choice in Token.generate()
Token.generate() used Python's random module (Mersenne Twister PRNG).
Mersenne Twister is not a CSPRNG: observing ~624 outputs from the same
worker process allows full state recovery and prediction of subsequent
outputs. Any token minted in the same worker within that window becomes
predictable, including tokens for privileged accounts.

Fix: replace random.choice with secrets.choice. secrets is backed by
os.urandom() / getrandom() which provides OS-level CSPRNG entropy and
is immune to state-recovery attacks.

The import of the now-unused random module is removed.

Regression tests:
- test_generate_uses_csprng: patches secrets.choice with wraps= to
  confirm it is called exactly TOKEN_DEFAULT_LENGTH times per generate().
- test_generate_length_parameter: verifies length= is respected and
  output is drawn only from TOKEN_CHARSET.

Ref: SR-001 / VM-317 (internal security review, R1-F07 / R3-F1)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 13:16:12 -04:00
Jeremy Stretch c63e3a8b80
Fixes #22421: GraphQLTestCase should support relative imports (#22422) 2026-06-10 09:48:35 -07:00
mburggraf b4116f2532
Fixes #22273: Fix migration failure when a service has thousands of ports defined 2026-06-10 12:27:50 -04:00
github-actions 34f2ca6f84 Update source translation strings 2026-06-10 06:35:05 +00:00
mburggraf f732a8e878
Fixes #22376: Remove files from request for script action event rules 2026-06-09 13:55:20 -04:00
github-actions c81bd39f7d Update source translation strings 2026-06-09 06:21:09 +00:00
Jeremy Stretch 70391e5a0b
Closes #22392: Deprecate support for Redis 5.x (#22405) 2026-06-08 09:28:31 -07:00
Jeremy Stretch 87c53aaaeb
Fixes #22399: Enforce object permissions for relevant static media (#22400) 2026-06-08 16:05:39 +02:00
bctiemann 6121418f5a
Merge pull request #22391 from netbox-community/22349-minimum-redis-version
Closes #22349: Correct documentation to reflect minimum Redis version of 5.0
2026-06-08 08:40:21 -04:00
github-actions 22d0b22fc9 Update source translation strings 2026-06-05 06:29:27 +00:00
bctiemann f4d95e6e9d
Merge pull request #22384 from netbox-community/15569-add-better-tests-for-graphql-filtering-and-lookup
Closes #15569: Auto-generate GraphQL filter tests for API test cases
2026-06-04 19:17:17 -04:00
Martin Hauser 86ea67d640 fix(extras): Prevent direct access to TableConfig create view
Add GET handler to TableConfigEditView that redirects users to home with
a warning if they attempt to access the create form directly without
required object_type and table parameters from a source list view.

Fixes #22237
2026-06-04 15:58:58 -04:00
Alex Houlton b905e99e63
Closes #22375: Fix VLAN filter_interface_id performance: use UNION instead of OR across M2M joins (#22387) 2026-06-04 15:50:39 -04:00