Пример #1
0
        public async Task AnalyzeAsync(DumpMetainfo dumpInfo, string dumpFilePath, string analysisWorkingDir)
        {
            await BlockIfBundleRepoNotReady($"AnalysisService.Analyze for {dumpInfo.Id}");

            try {
                dumpRepo.SetDumpStatus(dumpInfo.Id, DumpStatus.Analyzing);

                if (new FileInfo(dumpFilePath).Length == 0)
                {
                    dumpRepo.SetDumpStatus(dumpInfo.Id, DumpStatus.Failed, "The primary dump file is empty!");
                    return;
                }

                if (dumpInfo.DumpType == DumpType.WindowsDump)
                {
                    await AnalyzeWindows(dumpInfo, new DirectoryInfo(analysisWorkingDir), dumpFilePath);
                }
                else if (dumpInfo.DumpType == DumpType.LinuxCoreDump)
                {
                    await LinuxAnalyzationAsync(dumpInfo, new DirectoryInfo(analysisWorkingDir), dumpFilePath);
                }
                else
                {
                    throw new Exception("unknown dumptype. here be dragons");
                }

                // Re-fetch dump info as it was updated
                dumpInfo = dumpRepo.Get(dumpInfo.Id);

                SDResult result = await dumpRepo.GetResultAndThrow(dumpInfo.Id);

                if (result != null)
                {
                    dumpRepo.WriteResult(dumpInfo.Id, result);
                    dumpRepo.SetDumpStatus(dumpInfo.Id, DumpStatus.Finished);

                    var bundle = bundleRepo.Get(dumpInfo.BundleId);
                    await elasticSearch.PushResultAsync(result, bundle, dumpInfo);
                }
            } catch (Exception e) {
                Console.WriteLine(e.Message);
                dumpRepo.SetDumpStatus(dumpInfo.Id, DumpStatus.Failed, e.ToString());
            } finally {
                if (settings.Value.DeleteDumpAfterAnalysis)
                {
                    dumpStorage.DeleteDumpFile(dumpInfo.Id);
                }
                await notifications.NotifyDumpAnalysisFinished(dumpInfo);

                similarityService.ScheduleSimilarityAnalysis(dumpInfo, false, DateTime.Now - TimeSpan.FromDays(settings.Value.SimilarityDetectionMaxDays));
            }
        }
Пример #2
0
        public async Task Analyze(DumpMetainfo dumpInfo, string dumpFilePath, string analysisWorkingDir)
        {
            try {
                dumpRepo.SetDumpStatus(dumpInfo.BundleId, dumpInfo.DumpId, DumpStatus.Analyzing);

                if (dumpInfo.DumpType == DumpType.WindowsDump)
                {
                    await AnalyzeWindows(dumpInfo, new DirectoryInfo(analysisWorkingDir), dumpFilePath);
                }
                else if (dumpInfo.DumpType == DumpType.LinuxCoreDump)
                {
                    await LinuxAnalyzationAsync(dumpInfo, new DirectoryInfo(analysisWorkingDir), dumpFilePath);
                }
                else
                {
                    throw new Exception("unknown dumptype. here be dragons");
                }
                dumpRepo.SetDumpStatus(dumpInfo.BundleId, dumpInfo.DumpId, DumpStatus.Finished);

                // Re-fetch dump info as it was updated
                dumpInfo = dumpRepo.Get(dumpInfo.BundleId, dumpInfo.DumpId);

                SDResult result = await dumpRepo.GetResult(dumpInfo.BundleId, dumpInfo.DumpId);

                if (result != null)
                {
                    var bundle = bundleRepo.Get(dumpInfo.BundleId);
                    await elasticSearch.PushResultAsync(result, bundle, dumpInfo);
                }
            } catch (Exception e) {
                Console.WriteLine(e.Message);
                dumpRepo.SetDumpStatus(dumpInfo.BundleId, dumpInfo.DumpId, DumpStatus.Failed, e.ToString());
            } finally {
                if (settings.Value.DeleteDumpAfterAnalysis)
                {
                    dumpStorage.DeleteDumpFile(dumpInfo.BundleId, dumpInfo.DumpId);
                }
                await notifications.NotifyDumpAnalysisFinished(dumpInfo);

                similarityService.ScheduleSimilarityAnalysis(dumpInfo, false, DateTime.Now - TimeSpan.FromDays(90));                 // last 90 days.
            }
        }
Пример #3
0
        public async Task Analyze(DumpMetainfo dumpInfo, string dumpFilePath, string analysisWorkingDir)
        {
            try {
                dumpRepo.SetDumpStatus(dumpInfo.BundleId, dumpInfo.DumpId, DumpStatus.Analyzing);

                if (dumpInfo.DumpType == DumpType.WindowsDump)
                {
                    await AnalyzeWindows(dumpInfo, new DirectoryInfo(analysisWorkingDir), dumpFilePath);
                }
                else if (dumpInfo.DumpType == DumpType.LinuxCoreDump)
                {
                    await LinuxAnalyzationAsync(dumpInfo, new DirectoryInfo(analysisWorkingDir), dumpFilePath);
                }
                else
                {
                    throw new Exception("unknown dumptype. here be dragons");
                }
                dumpRepo.SetDumpStatus(dumpInfo.BundleId, dumpInfo.DumpId, DumpStatus.Finished);

                SDResult result = dumpRepo.GetResult(dumpInfo.BundleId, dumpInfo.DumpId, out string err);
                if (result != null)
                {
                    var bundle = bundleRepo.Get(dumpInfo.BundleId);
                    await elasticSearch.PushResultAsync(result, bundle, dumpInfo);
                }
            } catch (Exception e) {
                Console.WriteLine(e.Message);
                dumpRepo.SetDumpStatus(dumpInfo.BundleId, dumpInfo.DumpId, DumpStatus.Failed, e.ToString());
            } finally {
                if (settings.Value.DeleteDumpAfterAnalysis)
                {
                    dumpStorage.DeleteDumpFile(dumpInfo.BundleId, dumpInfo.DumpId);
                }
                await notifications.NotifyDumpAnalysisFinished(dumpInfo);
            }
        }