Ejemplo n.º 1
0
        public List <ScanMasterDTO> GetPreviousScanResult(string userId, string scanId = "")
        {
            List <ScanMasterDTO> scanMasterList;

            try
            {
                using (var context = new WebParser.DAL.DataModel.WebParserEntities())
                {
                    scanMasterList = (from item1 in context.ScanMasters
                                      where item1.UserId == userId
                                      select item1).ToList().Select(item => new ScanMasterDTO()
                    {
                        Id         = item.Id,
                        ClientName = item.ClientName,
                        ScanDate   = item.ScanDate.ToString(),
                        ScanID     = item.ScanId,
                        ScanName   = item.ScanName,
                        SubScanID  = item.SubScanId
                    }).ToList();
                }
            }
            catch (Exception)
            {
                throw new Exception("Failed to Get Previous Scan results");
            }

            return(scanMasterList);
        }
Ejemplo n.º 2
0
        public LoginDTO DoRegister(LoginDTO item)
        {
            LoginDTO    dto     = new LoginDTO();
            UserProfile profile = new UserProfile();

            profile.Admin    = item.IsAdmin;
            profile.Password = item.Password;
            profile.UserId   = item.UserId;

            using (var context = new WebParser.DAL.DataModel.WebParserEntities())
            {
                bool isUserIDExist = context.UserProfiles.Any(c => c.UserId == profile.UserId);
                if (isUserIDExist)
                {
                    return(null);
                }
                else
                {
                    context.UserProfiles.Add(profile);
                    int value = context.SaveChanges();
                    dto = context.UserProfiles.Where(c => c.UserId == profile.UserId && c.Password == profile.Password).Select(v => new LoginDTO()
                    {
                        IsAdmin = v.Admin,
                        UserId  = v.UserId,
                    }).FirstOrDefault();
                }
            }
            return(dto);
        }
Ejemplo n.º 3
0
        public List <CurrScanDTO> NewPluginOutputVarianceSecond(int scanId)
        {
            List <CurrScanDTO> datalist = new List <CurrScanDTO>();

            try
            {
                using (var context = new WebParser.DAL.DataModel.WebParserEntities())
                {
                    List <MasterPlugin> masterPlugindata = context.MasterPlugins.Where(v => v.PluginOutputReportable == true).ToList();
                    List <int>          plgIds           = masterPlugindata.Select(c => c.PluginID).ToList();
                    List <CurrScan>     crsData          = context.CurrScans.Where(c => plgIds.Contains(c.PluginID) && c.Compliance == false && c.ScanID == scanId).ToList();

                    datalist = (from item in crsData
                                join plg in masterPlugindata on item.PluginID equals plg.PluginID
                                where item.PluginOutput != (plg.PluginOutPut == null ? string.Empty : plg.PluginOutPut)
                                orderby item.PluginID
                                select new CurrScanDTO()
                    {
                        Description = item.Description,
                        PluginId = item.PluginID,
                        PluginOutput = item.PluginOutput,
                        ComplianceCheckID = item.ComplianceCheckID
                    }).ToList();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(datalist);
        }
Ejemplo n.º 4
0
        public List <ScanMasterDTO> GetScanIds()
        {
            List <ScanMasterDTO> scanMasterList;

            using (var context = new WebParser.DAL.DataModel.WebParserEntities())
            {
                scanMasterList = (from item1 in context.ScanMasters
                                  select item1).ToList().Select(item => new ScanMasterDTO()
                {
                    Id         = item.Id,
                    ClientName = item.ClientName,
                    ScanDate   = item.ScanDate.ToString(),
                    ScanID     = item.ScanId,
                    ScanName   = item.ScanName,
                    SubScanID  = item.SubScanId
                }).ToList();
            }
            return(scanMasterList);
        }
Ejemplo n.º 5
0
        public List <NewPluginDataDTO> NewRegularScan(int scanId)
        {
            List <NewPluginDataDTO> datalist = new List <NewPluginDataDTO>();

            using (var context = new WebParser.DAL.DataModel.WebParserEntities())
            {
                List <int> plugins = context.MasterPlugins.Select(x => x.PluginID).ToList();
                try
                {
                    datalist = (from item in context.CurrScans.Where(c => plugins.Contains(c.PluginID) == false && c.Compliance == false && c.ScanID == scanId)
                                orderby item.PluginID
                                select new NewPluginDataDTO()
                    {
                        PluginId = item.PluginID,
                        Synopsis = item.Synopsis,
                        UpdatedSynopsis = "",
                        Description = item.Description,
                        ExploitAvailable = item.ExploitAvailable,
                        ExploitabilityEase = item.ExploitabilityEase,
                        ExploitedByMalware = item.ExploitedByMalware,
                        UpdatedDescription = "",
                        Reportable = "",
                        RiskFactor = item.RiskFactor,
                        UpdatedRiskFactor = "",
                        PluginOutput = item.PluginOutput,
                        Solution = item.Solution,
                        SeeAlso = item.SeeAlso,
                        PluginOutPutReportable = "",
                        UpdatedCategory1 = "",
                        UpdatedCategory2 = "",
                        UpdatedCategory3 = "",
                    }).ToList();
                    var plgIds = datalist.Select(c => c.PluginId).Distinct().ToList();
                    datalist = datalist.Where(c => plgIds.Contains(c.PluginId)).GroupBy(v => v.PluginId).Select(b => b.First()).ToList();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(datalist);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Login to web parser
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public LoginDTO DoLogin(string userId, string password)
        {
            LoginDTO itemDTO = new LoginDTO();

            using (var context = new WebParser.DAL.DataModel.WebParserEntities())
            {
                var userProfileObj = context.UserProfiles.FirstOrDefault(item => item.UserId == userId);
                if (userProfileObj != null)
                {
                    itemDTO.IsValidLogin = true;
                    itemDTO.IsAdmin      = userProfileObj.Admin;
                    itemDTO.UserId       = userProfileObj.UserId;
                }
                else
                {
                    return(null);
                }
            }
            return(itemDTO);
        }
Ejemplo n.º 7
0
        public List <ScanMasterDTO> GetsScanResultByScanId(string userId, int scanId)
        {
            List <ScanMasterDTO> scanMasterList;

            using (var context = new WebParser.DAL.DataModel.WebParserEntities())
            {
                scanMasterList = (from item1 in context.ScanMasters
                                  where item1.UserId == userId && item1.ScanId == scanId
                                  select item1).ToList().Select(item => new ScanMasterDTO()
                {
                    Id         = item.Id,
                    ClientName = item.ClientName,
                    ScanDate   = item.ScanDate.ToString(),
                    ScanID     = item.ScanId,
                    ScanName   = item.ScanName,
                    SubScanID  = item.SubScanId
                }).ToList();
            }
            return(scanMasterList);
        }
Ejemplo n.º 8
0
        public List <NewComplianceDataDTO> NewComplianceData(int scanId)
        {
            List <NewComplianceDataDTO> datalist = new List <NewComplianceDataDTO>();

            try
            {
                using (var context = new WebParser.DAL.DataModel.WebParserEntities())
                {
                    List <string> complianceCheckIDList = context.ComplianceMasters.Select(c => c.ComplianceCheckID).Distinct().ToList();

                    datalist = (from item in context.CurrScans.Where(c => complianceCheckIDList.Contains(c.ComplianceCheckID) == false && c.Compliance == true && c.ScanID == scanId)
                                orderby item.PluginID, item.ComplianceCheckID
                                select new NewComplianceDataDTO()
                    {
                        PluginId = item.PluginID,
                        Description = item.Description,
                        UpdatedDescription = "",
                        Reportable = "",
                        RiskFactor = item.RiskFactor,
                        UpdatedRiskFactor = "",
                        PluginOutput = item.PluginOutput,

                        ComplianceCheckID = item.ComplianceCheckID,
                        ComplianceCheckName = item.ComplianceCheckName,
                        Complianceinfo = item.Complianceinfo,
                        ComplianceSeeAlso = item.ComplianceSeeAlso,
                        ComplianceSolution = item.ComplianceSolution,
                        UpdatedPluginOutput = "",
                        UpdatedCategory1 = "",
                        UpdatedCategory2 = "",
                        UpdatedCategory3 = "",
                    }).ToList();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(datalist);
        }
Ejemplo n.º 9
0
        public ReturnResultDTO ImportXmlData(List <ImportXMLDataDTO> inputDTOList)
        {
            int             scanId    = 0;
            int             subScnaID = 0;
            ReturnResultDTO dtoItem;

            if (inputDTOList.Any(c => c.IsAdditionalScan))
            {
                //Generate New ScanID;
                scanId    = inputDTOList.First().ScanId;
                subScnaID = inputDTOList.First().SubScanId + 1;
            }

            //Create MasterScan
            ScanMaster master = CreateScanMaster(scanId, subScnaID, inputDTOList.First().UserId, inputDTOList.First().ClientName, inputDTOList.First().ScanDate, inputDTOList.First().ScanName);


            using (var context = new WebParser.DAL.DataModel.WebParserEntities())
            {
                if (!inputDTOList.Any(c => c.IsAdditionalScan))
                {
                    ScanNumber newNumber = new ScanNumber()
                    {
                        UserId = inputDTOList.First().UserId
                    };
                    context.ScanNumbers.Add(newNumber);
                    context.SaveChanges();

                    var userID     = inputDTOList.First().UserId;
                    var listOfScan = context.ScanNumbers.Where(c => c.UserId == userID).ToList();
                    scanId        = listOfScan.Last().ScanId;
                    master.ScanId = scanId;
                }
                foreach (var item in inputDTOList)
                {
                    CurrScan newItem = CreateCurrentScan(item, scanId, subScnaID);
                    master.CurrScans.Add(newItem);
                    //context.CurrScans.Add(newItem);
                }
                context.ScanMasters.Add(master);
                int value = 0;
                try
                {
                    using (TransactionScope trans = new TransactionScope())
                    {
                        value = context.SaveChanges();
                        if (value > 0)
                        {
                            dtoItem           = CheckExistingData(scanId);
                            dtoItem.IsSuccess = true;
                            trans.Complete();
                        }
                        else
                        {
                            dtoItem           = new ReturnResultDTO();
                            dtoItem.IsSuccess = false;
                            trans.Dispose();
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(dtoItem);
        }