removed legacy fields from endpoint (ip, server_name, domain)

parent 62e3b645
......@@ -45,7 +45,7 @@ class UrlIpAdmin(admin.ModelAdmin):
class EndpointAdmin(admin.ModelAdmin):
list_display = ('id', 'url', 'discovered_on', 'ip_version', 'port', 'protocol', 'is_dead', 'is_dead_since',
'tls_scans', 'generic_scans')
search_fields = ('url__url', 'server_name', 'ip_version', 'port', 'protocol', 'is_dead',
search_fields = ('url__url', 'ip_version', 'port', 'protocol', 'is_dead',
'is_dead_since', 'is_dead_reason')
list_filter = ('ip_version', 'port', 'protocol', 'is_dead')
fieldsets = (
......@@ -57,7 +57,6 @@ class EndpointAdmin(admin.ModelAdmin):
}),
)
exclude = ('server_name', 'ip', 'domain')
readonly_fields = ['discovered_on']
@staticmethod
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-11-13 12:03
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('scanners', '0027_auto_20171113_1028'),
]
operations = [
migrations.RemoveField(
model_name='endpoint',
name='domain',
),
migrations.RemoveField(
model_name='endpoint',
name='ip',
),
migrations.RemoveField(
model_name='endpoint',
name='server_name',
),
migrations.AlterField(
model_name='endpoint',
name='ip_version',
field=models.IntegerField(default=4, help_text="Either 4: IPv4 or 6: IPv6. There are basically two possibilities to reach the endpoint, which due to immaturity often look very different. The old way is using IPv4addresses (4) and the newer method is uing IPv6 (6). The internet looks a whole lotdifferent between IPv4 or IPv6. That shouldn't be the case, but it is."),
),
migrations.AlterField(
model_name='endpoint',
name='is_dead',
field=models.BooleanField(default=False, help_text="Use the 'declare dead' button to autofill the date. If the port is closed, or the endpoint is otherwisenot reachable over the specified protocol, then markit as dead. A scanner for this port/protocol can alsodeclare it dead. This port is closed on this protocol."),
),
migrations.AlterField(
model_name='endpoint',
name='protocol',
field=models.CharField(
help_text='Lowercase. Mostly application layer protocols, such as HTTP, FTP,SSH and so on. For more, read here: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol', max_length=20),
),
]
......@@ -28,31 +28,10 @@ class Endpoint(models.Model):
Additionally it's easier for humans to understand a "url", much more than that there are
ports, protocols, ip-addresses and more of that.
"""
# There was duplication between URL.URL and endpoint.domain. This resulted on both
# places the same data was stored (increase in database size). Additionally there was no
# django way to travel between endpoints and urls, which made it impossible to main
# database independence. Which would then result in the solution being harder to maintain.
# Therefore we've dropped the domain field and added a foreign key to URL.
# todo-cancelled: drop domain at the next possible option.
# We want, for some reason, to also save scans that don't have a URL.
domain = models.CharField(
max_length=255,
help_text="This is a legacy field, "
"used by the scanner. Will be obsoleted "
"after the incorrectly migrated domains"
"have been fixed manually in production"
"and the scanner is ready.")
url = models.ForeignKey(
Url, null=True, blank=True)
# server information
server_name = models.CharField(
max_length=255,
help_text="Deprecated. Don't fill.",
blank=True,
null=True
)
ip_version = models.IntegerField(
help_text="Either 4: IPv4 or 6: IPv6. There are basically two possibilities to reach the endpoint, "
"which due to immaturity often look very different. The old way is using IPv4"
......@@ -61,15 +40,9 @@ class Endpoint(models.Model):
default=4
)
ip = models.CharField(
max_length=255,
help_text="Deprecated. Don't fill.",
blank=True,
null=True,
)
port = models.IntegerField(default=443,
help_text="Ports range from 1 to 65535.") # 1 to 65535
port = models.IntegerField(
default=443,
help_text="Ports range from 1 to 65535.") # 1 to 65535
protocol = models.CharField(
max_length=20,
......@@ -78,17 +51,32 @@ class Endpoint(models.Model):
"https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol",
)
discovered_on = models.DateTimeField(blank=True, null=True)
discovered_on = models.DateTimeField(
blank=True,
null=True
)
# Till when the endpoint existed and why it was deleted (or didn't exist at all).
is_dead = models.BooleanField(default=False,
help_text="If the port is closed, or the endpoint is otherwise"
"not reachable over the specified protocol, then mark"
"it as dead. A scanner for this port/protocol can also"
"declare it dead. This port is closed on this protocol."
"")
is_dead_since = models.DateTimeField(blank=True, null=True)
is_dead_reason = models.CharField(max_length=255, blank=True, null=True)
is_dead = models.BooleanField(
default=False,
help_text="Use the 'declare dead' button to autofill the date. "
"If the port is closed, or the endpoint is otherwise"
"not reachable over the specified protocol, then mark"
"it as dead. A scanner for this port/protocol can also"
"declare it dead. This port is closed on this protocol."
""
)
is_dead_since = models.DateTimeField(
blank=True,
null=True
)
is_dead_reason = models.CharField(
max_length=255,
blank=True,
null=True
)
def __str__(self):
if self.is_dead:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment