<filename>malware_crawl/models.py
from django.db import models
from django_extensions.db.models import TitleSlugDescriptionModel

# Create your models here.

"""
abstract models.
"""


class DiscoveredModel(models.Model):
    discovered = models.DateTimeField(help_text="When the item was discovered")

    class Meta:
        abstract = True


class SourceModel(TitleSlugDescriptionModel):
    url = models.URLField(help_text="The url representing the source of a model")

    class Meta:
        abstract = True

"""
concrete models
"""


class TopicSet(DiscoveredModel):
    source = models.CharField(max_length=255)


class Topic(models.Model):
    """
    A particular trending item. Eg "Hail Obama", "#8ReasonsWhyImOnTwitter"
    """
    keyword = models.CharField(max_length=255)
    topicset = models.ForeignKey("TopicSet")


class Search(DiscoveredModel):
    source = models.CharField(max_length=255)
    topic = models.ForeignKey("Topic")


class Result(models.Model):
    url = models.URLField()
    search = models.ForeignKey("Search")


class MalwareReport(models.Model):
    result = models.ForeignKey("Result")
    reporter = models.CharField(max_length=255)


class Opinion(models.Model):
    type = models.CharField(max_length=255)
    confidence = models.DecimalField(max_digits=2, decimal_places=1)
    malware_report = models.ForeignKey("MalwareReport")


class Keywords(models.Model):
    word = models.CharField(max_length=255)


class Malicouse_sites(models.Model):
    """
        The table which is going to be used for classification
    """
    url = models.CharField(max_length=255)
    malware = models.BooleanField()

# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
#     * Rearrange models' order
#     * Make sure each model has one field with primary_key=True
# Feel free to rename the models, but don't rename db_table values or field names.
#
# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [appname]'
# into your database.
"""
class Clientprogram(models.Model):
    clientprogram_id = models.BigIntegerField(unique=True)
    name = models.CharField(max_length=300, blank=True)
    class Meta:
        db_table = u'clientprogram'

class Error(models.Model):
    url_id = models.IntegerField(primary_key=True)
    operation_id = models.IntegerField(primary_key=True)
    majorerror = models.CharField(max_length=150, blank=True)
    minorerror = models.CharField(max_length=150, blank=True)
    class Meta:
        db_table = u'error'

class Event(models.Model):
    event_id = models.BigIntegerField(unique=True)
    url_id = models.IntegerField(null=True, blank=True)
    operation_id = models.IntegerField(null=True, blank=True)
    type = models.CharField(max_length=150, blank=True)
    time = models.CharField(max_length=69, blank=True)
    process = models.CharField(max_length=1500, blank=True)
    action = models.CharField(max_length=150, blank=True)
    object1 = models.CharField(max_length=1500, blank=True)
    object2 = models.CharField(max_length=1500, blank=True)
    class Meta:
        db_table = u'event'

class File(models.Model):
    url_id = models.IntegerField(primary_key=True)
    operation_id = models.IntegerField(primary_key=True)
    filename = models.CharField(max_length=1500, primary_key=True)
    content = models.TextField(blank=True)
    class Meta:
        db_table = u'file'

class Honeypot(models.Model):
    honeypot_id = models.BigIntegerField(unique=True)
    ipaddress = models.CharField(max_length=45, blank=True)
    port = models.IntegerField(null=True, blank=True)
    status = models.CharField(max_length=3, blank=True)
    description = models.CharField(max_length=1500, db_column='Description', blank=True) # Field name made lowercase.
    class Meta:
        db_table = u'honeypot'

class Operation(models.Model):
    operation_id = models.BigIntegerField(unique=True)
    description = models.CharField(max_length=1500, blank=True)
    visitstarttime = models.CharField(max_length=69, blank=True)
    visitfinishtime = models.CharField(max_length=69, blank=True)
    honeypot_id = models.IntegerField(null=True, blank=True)
    class Meta:
        db_table = u'operation'

class Status(models.Model):
    status_id = models.CharField(max_length=3, primary_key=True)
    name = models.CharField(max_length=300, blank=True)
    class Meta:
        db_table = u'status'
"""
class CaptureUrl(models.Model):
    url_id = models.BigIntegerField(unique=True, primary_key=True)
    url = models.CharField(max_length=6249)
    currentstatus = models.CharField(max_length=3, blank=True)
    lastvisittime = models.CharField(max_length=69, blank=True)
    operation_id = models.IntegerField(null=True, blank=True)
    class Meta:
        db_table = u'url'
"""
class UrlOperation(models.Model):
    url_id = models.IntegerField(primary_key=True)
    operation_id = models.IntegerField(primary_key=True)
    clientprogram_id = models.IntegerField(null=True, blank=True)
    visitstarttime = models.CharField(max_length=69, blank=True)
    visitfinishtime = models.CharField(max_length=69, blank=True)
    status_id = models.CharField(max_length=3, blank=True)
    webserverip = models.CharField(max_length=45, blank=True)
    class Meta:
        db_table = u'url_operation'
"""
