You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

119 lines
3.4 KiB

#!/usr/bin/env python3
import datetime
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime
DatabaseBase = declarative_base()
class VaultEvidence(DatabaseBase):
'''Used to store evidence files.'''
__tablename__ = 'Evidence'
id = Column('id', Integer, primary_key=True)
name = Column('name', String(32), unique=True)
path = Column('path', String(260), unique=True)
def __init__(self, name, path):
self.name = name
self.path = path
def __str__(self):
return '%s, %s, %s' % (self.id, self.name, self.path)
class VaultComparison(DatabaseBase):
'''Used to store comparison files.'''
__tablename__ = 'Comparison'
id = Column('id', Integer, primary_key=True)
name = Column('name', String(32), unique=True)
path = Column('path', String(260), unique=True)
def __init__(self, name, path):
self.name = name
self.path = path
def __str__(self):
return '%s, %s, %s' % (self.id, self.name, self.path)
class VaultTest(DatabaseBase):
'''Used to store comparison files.'''
__tablename__ = 'Test'
id = Column('id', Integer, primary_key=True)
evidence_id = Column('evidence_id', ForeignKey('Evidence.id'))
comparison_id = Column('comparison_id', ForeignKey('Comparison.id'))
def __init__(self, name, path):
self.evidence_id = name
self.comparison_id = path
def __str__(self):
return '%s, %s, %s' % (self.id, self.evidence_id, self.comparison_id)
class VaultEvent(DatabaseBase):
'''Used to identify which set that a result belongs to.'''
__tablename__ = 'Event'
id = Column('id', Integer, primary_key=True)
name = Column('name', String(32), unique=True)
def __init__(self, name):
self.name = name
def __str__(self):
return '%s, %s' % (self.id, self.name)
class VaultJob(DatabaseBase):
'''Used to store comparison files.'''
__tablename__ = 'Job'
id = Column('id', Integer, primary_key=True)
test_id = Column('test_id', ForeignKey('Test.id'))
event_id = Column('event_id', ForeignKey('Event.id'), default=1)
batch_id = Column('batch_id', ForeignKey('Batch.id'))
timestamp = Column('timestamp', DateTime, default=datetime.datetime.utcnow)
def __init__(self, test_id, batch_id):
self.test_id = test_id
self.batch_id = batch_id
class VaultBatch(DatabaseBase):
'''Used to identify which set that a result belongs to.'''
__tablename__ = 'Batch'
id = Column('id', Integer, primary_key=True)
name = Column('name', String(32), unique=True)
def __init__(self, name):
self.name = name
def __str__(self):
return '%s, %s' % (self.id, self.name)
class VaultResult(DatabaseBase):
'''Used to store output files from completed jobs.'''
__tablename__ = 'Result'
id = Column('id', Integer, primary_key=True)
name = Column('name', String(32))
path = Column('path', String(260))
processing_time = Column('processing_time', Integer())
batch_id = Column('batch_id', ForeignKey('Batch.id'))
def __init__(self, name, path, batch_id, time):
self.name = name
self.path = path
self.batch_id = batch_id
self.processing_time = time
def __str__(self):
return '%s, %s, %s' % (self.id, self.name, self.path, self.time)