示例#1
0
def migrate_analysis_results(self):
    from cripts.services.analysis_result import (AnalysisResult,
                                                 AnalysisConfig,
                                                 EmbeddedAnalysisResultLog)
    old_results = getattr(self.unsupported_attrs, 'analysis', None)
    if old_results:
        for result in old_results:
            ar = AnalysisResult()
            ar.analysis_id = result.get('id')
            if ar.analysis_id:
                del result['id']
            config = result.get('config', {})
            ar.config = AnalysisConfig(**config)
            if 'config' in result:
                del result['config']
            logs = result.get('log', None)
            if logs:
                for l in logs:
                    le = EmbeddedAnalysisResultLog(**l)
                    ar.log.append(le)
                del result['log']
            ar.merge(arg_dict=result)
            ar.object_type = self._meta['cripts_type']
            ar.object_id = str(self.id)
            ar.save()
    try:
        del self.unsupported_attrs['analysis']
    except:
        pass
示例#2
0
def migrate_analysis_results(self):
    from cripts.services.analysis_result import AnalysisResult, AnalysisConfig, EmbeddedAnalysisResultLog

    old_results = getattr(self.unsupported_attrs, "analysis", None)
    if old_results:
        for result in old_results:
            ar = AnalysisResult()
            ar.analysis_id = result.get("id")
            if ar.analysis_id:
                del result["id"]
            config = result.get("config", {})
            ar.config = AnalysisConfig(**config)
            if "config" in result:
                del result["config"]
            logs = result.get("log", None)
            if logs:
                for l in logs:
                    le = EmbeddedAnalysisResultLog(**l)
                    ar.log.append(le)
                del result["log"]
            ar.merge(arg_dict=result)
            ar.object_type = self._meta["cripts_type"]
            ar.object_id = str(self.id)
            ar.save()
    try:
        del self.unsupported_attrs["analysis"]
    except:
        pass
示例#3
0
文件: handlers.py 项目: lakiw/cripts
def insert_analysis_results(task):
    """
    Insert analysis results for this task.
    """

    ar = AnalysisResult()
    tdict = task.to_dict()
    tdict['analysis_id'] = tdict['id']
    del tdict['id']
    ar.merge(arg_dict=tdict)
    ar.save()