feat(itim): Port number validation to check for valid port numbers
!43 #69
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 5.0.7 on 2024-07-20 23:50
|
# Generated by Django 5.0.7 on 2024-07-21 00:05
|
||||||
|
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
# Generated by Django 5.0.7 on 2024-07-20 23:50
|
# Generated by Django 5.0.7 on 2024-07-21 00:05
|
||||||
|
|
||||||
import access.fields
|
import access.fields
|
||||||
import access.models
|
import access.models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
import django.utils.timezone
|
import django.utils.timezone
|
||||||
|
import itim.models.services
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ class Migration(migrations.Migration):
|
|||||||
('is_global', models.BooleanField(default=False)),
|
('is_global', models.BooleanField(default=False)),
|
||||||
('model_notes', models.TextField(blank=True, default=None, null=True, verbose_name='Notes')),
|
('model_notes', models.TextField(blank=True, default=None, null=True, verbose_name='Notes')),
|
||||||
('id', models.AutoField(primary_key=True, serialize=False, unique=True)),
|
('id', models.AutoField(primary_key=True, serialize=False, unique=True)),
|
||||||
('number', models.IntegerField(help_text='The port number', verbose_name='Port Number')),
|
('number', models.IntegerField(help_text='The port number', validators=[itim.models.services.Port.validation_port_number], verbose_name='Port Number')),
|
||||||
('description', models.CharField(blank=True, default=None, help_text='Short description of port', max_length=80, null=True, verbose_name='Description')),
|
('description', models.CharField(blank=True, default=None, help_text='Short description of port', max_length=80, null=True, verbose_name='Description')),
|
||||||
('protocol', models.CharField(choices=[('TCP', 'TCP'), ('UDP', 'UDP')], default='TCP', help_text='Layer 4 Network Protocol', max_length=3, verbose_name='Protocol')),
|
('protocol', models.CharField(choices=[('TCP', 'TCP'), ('UDP', 'UDP')], default='TCP', help_text='Layer 4 Network Protocol', max_length=3, verbose_name='Protocol')),
|
||||||
('created', access.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False)),
|
('created', access.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False)),
|
||||||
|
@ -30,6 +30,12 @@ class Port(TenancyObject):
|
|||||||
TCP = 'TCP', 'TCP'
|
TCP = 'TCP', 'TCP'
|
||||||
UDP = 'UDP', 'UDP'
|
UDP = 'UDP', 'UDP'
|
||||||
|
|
||||||
|
def validation_port_number(number: int):
|
||||||
|
|
||||||
|
if number < 1 or number > 65535:
|
||||||
|
|
||||||
|
raise ValidationError('A Valid port number is between 1-65535')
|
||||||
|
|
||||||
|
|
||||||
id = models.AutoField(
|
id = models.AutoField(
|
||||||
primary_key=True,
|
primary_key=True,
|
||||||
@ -41,6 +47,7 @@ class Port(TenancyObject):
|
|||||||
blank = False,
|
blank = False,
|
||||||
help_text = 'The port number',
|
help_text = 'The port number',
|
||||||
unique = False,
|
unique = False,
|
||||||
|
validators = [ validation_port_number ],
|
||||||
verbose_name = 'Port Number',
|
verbose_name = 'Port Number',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user