Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mcrit/config/StorageConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@dataclass
class StorageConfig(ConfigInterface):
# storage configuration, use "memory" for local testing or "alchemy" when working with larger data
# storage configuration, use "memory" for local testing or "mongodb" when working with larger data
# STORAGE_METHOD = StorageFactory.STORAGE_METHOD_MEMORY
STORAGE_METHOD: ... = StorageFactory.STORAGE_METHOD_MONGODB
# Use this as endpoint for our server
Expand Down
22 changes: 0 additions & 22 deletions mcrit/storage/FunctionEntry.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
# constructor -> .fromSmdaFunction
# assume sample_entry, smda_function always available

# TODO remove (everywhere) from alchemy function


class FunctionEntry(object):
# MCRIT specific
function_id: int
Expand Down Expand Up @@ -123,25 +120,6 @@ def fromDict(cls, entry_dict):
function_entry.xcfg = entry_dict["xcfg"] if "xcfg" in entry_dict else None
return function_entry

@classmethod
def fromAlchemyFunction(cls, function):
function_entry = cls(None, None) # type:ignore
function_entry.binweight = function.binweight
function_entry.function_id = function.id
function_entry.family_id = function.family.id
function_entry.sample_id = function.sample.id
function_entry.architecture = function.architecture.name
function_entry.function_name = function.function_name
if function.pichash:
function_entry.pichash = function.pichash.pichash
if function.minhash:
function_entry.minhash = function.minhash.minhash
function_entry.num_blocks = function.num_blocks
function_entry.num_instructions = function.num_instructions
function_entry.offset = function.offset
function_entry.xcfg = function.xcfg
return function_entry

def __str__(self):
return "Family: {} Sample: {} Function: {} @ 0x{:08x} - {} blocks ({} hashes), {} instructions - pichash: {}".format(
self.family_id,
Expand Down
21 changes: 0 additions & 21 deletions mcrit/storage/SampleEntry.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,6 @@ def fromDict(cls, entry_dict):
sample_entry.timestamp = datetime.datetime.strptime(entry_dict["timestamp"], "%Y-%m-%dT%H-%M-%S")
return sample_entry

@classmethod
def fromAlchemySample(cls, sample):
sample_entry = cls(None) #type:ignore
sample_entry.sample_id = sample.id
sample_entry.family_id = sample.family.id
sample_entry.family = sample.family.name
sample_entry.architecture = sample.architecture.name
sample_entry.base_addr = sample.base_addr
sample_entry.binary_size = sample.binary_size
sample_entry.component = sample.component
sample_entry.binweight = sample.binweight
sample_entry.bitness = sample.bitness.name
sample_entry.version = sample.version
sample_entry.is_library = sample.is_library
sample_entry.filename = sample.filename
sample_entry.sha256 = sample.sha256
sample_entry.smda_version = sample.smda_version
sample_entry.statistics = sample.statistics
sample_entry.timestamp = sample.timestamp
return sample_entry

def __str__(self):
return "Sample {} ({}, {} bit) - {} ({}): ".format(
self.sample_id, self.architecture, self.bitness, self.filename, self.family
Expand Down
5 changes: 0 additions & 5 deletions mcrit/storage/StorageFactory.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
# from mcrit.storage.alchemy.AlchemyStorage import AlchemyStorage
from mcrit.storage.MemoryStorage import MemoryStorage
from mcrit.storage.MongoDbStorage import MongoDbStorage


class StorageFactory:

STORAGE_METHOD_MEMORY = "memory"
STORAGE_METHOD_ALCHEMY = "alchemy"
STORAGE_METHOD_MONGODB = "mongodb"

@staticmethod
def getStorage(mcrit_config):
if mcrit_config.STORAGE_CONFIG.STORAGE_METHOD == StorageFactory.STORAGE_METHOD_MONGODB:
return MongoDbStorage(mcrit_config)
# Alchemy not supported right now
# if storage_config.STORAGE_METHOD == StorageFactory.STORAGE_METHOD_ALCHEMY:
# return AlchemyStorage(storage_config)
return MemoryStorage(mcrit_config)
Loading