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)); } }
public void DeleteDumpFile(DumpIdentifier id) { storage.DeleteDumpFile(id); }