/// <summary> /// metodo que devuelve la vista con los detalles del malware /// </summary> /// <param name="id">md5 del malware</param> /// <returns>vista</returns> public IActionResult Index(string id) { try { //revisamos que el parametro no este vacio if (id != null) { //desde el parametro obetenmos el malware asociaso var malware = malwareManager.GetByMd5(id); malId = malware.Id; if (malware != null) { if (malware.MalwareStatus != CORE.Status.Finalizado) { return(RedirectToAction("Status", malware)); } //creamos el modelo de datos de la vista AnalysisIndexViewModel model = new AnalysisIndexViewModel { Malware = malwareManager.GetAll().Where(p => p.MD5 == id).Select(e => new CORE.Malware { Id = malware.Id, User_Id = malware.User_Id, Date = malware.Date, MD5 = malware.MD5, SHA256 = malware.SHA256, FileName = malware.FileName, FilePath = malware.FilePath, Name = malware.Name, MalwareLevel = malware.MalwareLevel, MalwareStatus = malware.MalwareStatus, Url = malware.Url }).FirstOrDefault(), Screenshots = screenShotManager.GetAll().Where(p => p.Malware_Id == malware.Id).Select(e => new CORE.ScreenShot { Id = e.Id, Malware_Id = e.Malware_Id, PathFile = e.PathFile, }).ToList(), Comments = commentManager.GetAll().Where(c => c.Malware_Id == malware.Id).Select(e => new CORE.Comment { Id = e.Id, User = e.User, User_Id = e.User_Id, Malware_Id = e.Malware_Id, TextComment = e.TextComment, }).ToList(), VTInfo = virusTotalManager.GetAll().Where(v => v.Malware_Id == malware.Id).Select(e => new CORE.VirusTotal.VirusTotalInfo { Id = e.Id, Malware_Id = e.Malware_Id, Positives = e.Positives, Total = e.Total, MD5 = e.MD5 }).SingleOrDefault(), CuckooInfo = cuckooInfoManager.GetAll().Where(v => v.Malware_Id == malware.Id).Select(e => new CORE.Cuckoo.CuckooInfo { Id = e.Id, Malware = e.Malware, Malware_Id = e.Malware_Id, Score = e.Score, Package = e.Package, Category = e.Category, MD5 = e.MD5 }).SingleOrDefault(), TCInfo = threatCrowdInfoManager.GetAll().Where(v => v.Malware_Id == malware.Id).Select(e => new CORE.ThreatCrowd.ThreatCrowdInfo { Id = e.Id, Malware_Id = e.Malware_Id, Type = e.Type, Votes = e.Votes, Permalink = e.Permalink }).SingleOrDefault(), }; // devolvemos la vista con el modelo de datos return(View(model)); } else { // return(RedirectToAction("Error")); } } else { //TODO return(RedirectToAction("Index", "Malware")); } } catch (Exception ex) { //guardamso log si se produce una excepcion _log.LogError(ex.Message, ex); return(RedirectToAction("Index", "Malware")); } }
public IActionResult Edit(string id) { try { //verificamos que el id no este vacio if (id != null) { //obtenemos el malware var malware = malwareManager.GetByMd5(id); //si elmalware no esta vacio generamos el model if (malware != null) { //Obtenemos los usuarios y los pasamos a una lista var users = usrManager.GetAll().Select(e => new UserList { Id = e.Id.ToString(), UserName = e.UserName }).ToList(); var userList = new List <SelectListItem>(); foreach (var item in users) { userList.Add(new SelectListItem { Text = item.UserName, Value = item.Id }); } var model = new MalwareEditViewModel { UserList = userList, Malware = new Malware { Id = malware.Id, Name = malware.Name, Date = malware.Date, User = malware.User, User_Id = malware.User_Id, MalwareStatus = malware.MalwareStatus, MalwareLevel = malware.MalwareLevel, MD5 = malware.MD5 }, }; return(View(model)); } //si el malware no existe redirigimos a index else { return(RedirectToAction("Index")); } } else { return(RedirectToAction("Index")); } } catch (Exception ex) { _log.LogError(ex.Message, ex); return(RedirectToAction("Index")); } }