From 8c300de023a48753c34fe4d1f01f6ac0c57cd5e1 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 2 Jun 2021 16:12:11 -0400 Subject: [PATCH] Fixes #6217: Disallow passing of string values for integer custom fields --- docs/release-notes/version-2.11.md | 1 + netbox/extras/models/customfields.py | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/release-notes/version-2.11.md b/docs/release-notes/version-2.11.md index 112b62a64..461293cac 100644 --- a/docs/release-notes/version-2.11.md +++ b/docs/release-notes/version-2.11.md @@ -11,6 +11,7 @@ ### Bug Fixes * [#6064](https://github.com/netbox-community/netbox/issues/6064) - Fix object permission assignments for user and group models +* [#6217](https://github.com/netbox-community/netbox/issues/6217) - Disallow passing of string values for integer custom fields * [#6284](https://github.com/netbox-community/netbox/issues/6284) - Avoid sending redundant webhooks when adding/removing tags * [#6496](https://github.com/netbox-community/netbox/issues/6496) - Fix upgrade script when Python installed in nonstandard path * [#6502](https://github.com/netbox-community/netbox/issues/6502) - Correct permissions evaluation for running a report via the REST API diff --git a/netbox/extras/models/customfields.py b/netbox/extras/models/customfields.py index 2360da739..b88c73531 100644 --- a/netbox/extras/models/customfields.py +++ b/netbox/extras/models/customfields.py @@ -286,9 +286,7 @@ class CustomField(BigIDModel): # Validate integer if self.type == CustomFieldTypeChoices.TYPE_INTEGER: - try: - int(value) - except ValueError: + if type(value) is not int: raise ValidationError("Value must be an integer.") if self.validation_minimum is not None and value < self.validation_minimum: raise ValidationError(f"Value must be at least {self.validation_minimum}")