示例#1
0
        public static List <Log> GetHpkpWarnings()
        {
            var seContext = new SeContext();

            return(seContext.Log
                   .Where(a => a.Level == "Warning" && a.Message.StartsWith("Http Public Key Pinning Violation")).ToList());
        }
示例#2
0
        public static List <Log> GetCspWarnings()
        {
            var seContext = new SeContext();

            return(seContext.Log
                   .Where(a => a.Level == "Warning" && a.Message.StartsWith("Content Security Policy Violation")).ToList());
        }
示例#3
0
        public static void SetUserRoles(List <UserRole> userRoles)
        {
            var seContext = new SeContext();

            userRoles.ForEach(a => seContext.UserRole.Add(a));
            seContext.SaveChanges();
        }
示例#4
0
        public static void SetLookupItems(List <LookupItem> lookupItems)
        {
            var seContext = new SeContext();

            lookupItems.ForEach(a => seContext.LookupItem.Add(a));
            seContext.SaveChanges();
        }
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            // Set the initializer here
            Database.SetInitializer(new SeDbInitializer());

            var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
            json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            var jsonFormatter = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
            jsonFormatter.Indent = true;

            GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();


            // Now initialize it
            using (var context = new SeContext())
            {
                context.Database.Initialize(false);

                var cnt = context.Sessions.Count();

            }
        }
        public static void SetLookupTypes(List <LookupType> lookupTypes)
        {
            SeContext seContext = new SeContext();

            lookupTypes.ForEach(a => seContext.LookupType.Add(a));
            seContext.SaveChanges();
        }
示例#7
0
        protected void Application_Start()
        {
            DependencyInjection.Configure();
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();
            AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.Name;
            // SECURE: Remove automatic XFrame option header so we can add it in filters to entire site
            AntiForgeryConfig.SuppressXFrameOptionsHeader = true;

            // SECURE: Remove server information disclosure
            MvcHandler.DisableMvcResponseHeader = true;

            using (var context = new SeContext())
            {
                context.Database.Initialize(true);
            }
            Log.Logger = new LoggerConfiguration()
                         .WriteTo.MSSqlServer(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString(), "Logs", batchPostingLimit: int.Parse(ConfigurationManager.AppSettings["LoggingBatchPostingLimit"]))
                         .MinimumLevel.Debug()
                         .CreateLogger();
            Log.Information("Application started");
        }
        public static void SetUsers(List <User> users)
        {
            SeContext seContext = new SeContext();

            users.ForEach(a => seContext.User.Add(a));
            seContext.SaveChanges();
        }
        public static void SetLogs(List <Log> logs)
        {
            SeContext seContext = new SeContext();

            logs.ForEach(a => seContext.Log.Add(a));
            seContext.SaveChanges();
        }
        public static void SetRoles(List <Role> roles)
        {
            SeContext seContext = new SeContext();

            roles.ForEach(a => seContext.Role.Add(a));
            seContext.SaveChanges();
        }
示例#11
0
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            // Set the initializer here
            Database.SetInitializer(new SeDbInitializer());

            var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;

            json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            var jsonFormatter = GlobalConfiguration.Configuration.Formatters.JsonFormatter;

            jsonFormatter.Indent = true;

            GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();


            // Now initialize it
            using (var context = new SeContext())
            {
                context.Database.Initialize(false);

                var cnt = context.Sessions.Count();
            }
        }
    public SeContext se()
    {
        SeContext _localctx = new SeContext(Context, State);

        EnterRule(_localctx, 16, RULE_se);
        try {
            EnterOuterAlt(_localctx, 1);
            {
                State = 88; Match(T__3);
                State = 89; Match(T_APARENT);
                State = 90; exp_relacional();
                State = 91; Match(T_FPARENT);
                State = 92; Match(T__4);
                State = 93; blococomando();
                State = 97;
                ErrorHandler.Sync(this);
                switch (Interpreter.AdaptivePredict(TokenStream, 6, Context))
                {
                case 1:
                {
                    State = 94; Match(T__5);
                    State = 95; Match(T__4);
                    State = 96; blococomando();
                }
                break;
                }
            }
        }
        catch (RecognitionException re) {
            _localctx.exception = re;
            ErrorHandler.ReportError(this, re);
            ErrorHandler.Recover(this, re);
        }
        finally {
            ExitRule();
        }
        return(_localctx);
    }
        public static void ClearDatabase()
        {
            SeContext seContext     = new SeContext();
            var       existingUsers = seContext.User
                                      .Include("PreviousPasswords")
                                      .Include("UserLogs")
                                      .Include("UserRoles")
                                      .ToList();

            existingUsers.ForEach(a => { a.PreviousPasswords.ToList().ForEach(b => seContext.SetDeleted(b)); });
            existingUsers.ForEach(a => { a.UserLogs.ToList().ForEach(b => seContext.SetDeleted(b)); });
            existingUsers.ForEach(a => { a.UserRoles.ToList().ForEach(b => seContext.SetDeleted(b)); });
            seContext.SaveChanges();
            existingUsers.ForEach(a => { seContext.SetDeleted(a); });
            var lookupItems = seContext.LookupItem.ToList();

            foreach (var lookupItem in lookupItems)
            {
                seContext.SetDeleted(lookupItem);
            }
            seContext.SaveChanges();
            var lookupTypes = seContext.LookupType.ToList();

            foreach (var lookupType in lookupTypes)
            {
                seContext.SetDeleted(lookupType);
            }
            seContext.SaveChanges();
            var logs = seContext.Log.ToList();

            foreach (var log in logs)
            {
                seContext.SetDeleted(log);
            }
            seContext.SaveChanges();
        }
        public static List <Log> GetAppSensorErrors()
        {
            SeContext seContext = new SeContext();

            return(seContext.Log.Where(a => a.Level == "Information" && a.Message.StartsWith("AppSensor")).ToList());
        }
        public static List <Log> GetSystemErrors()
        {
            SeContext seContext = new SeContext();

            return(seContext.Log.Where(a => a.Level == "Error").ToList());
        }
        public static Role GetRoleByName(string description)
        {
            SeContext seContext = new SeContext();

            return(seContext.Role.SingleOrDefault(a => a.Description == description));
        }
        public static List <PreviousPassword> GetPreviousPasswords()
        {
            SeContext seContext = new SeContext();

            return(seContext.PreviousPassword.ToList());
        }
        public static LookupItem GetLookupItemByLookupTypeAndDescription(int lookupTypeId, string description)
        {
            SeContext seContext = new SeContext();

            return(seContext.LookupItem.Single(a => a.LookupTypeId == lookupTypeId && a.Description == description));
        }
示例#19
0
        public static List <Log> GetCtWarnings()
        {
            SeContext seContext = new SeContext();

            return(seContext.Log.Where(a => a.Level == "Warning" && a.Message.StartsWith("Certificate Transparency Violation")).ToList());
        }
示例#20
0
        public static List <UserLog> GetUserLogs()
        {
            var seContext = new SeContext();

            return(seContext.UserLog.ToList());
        }
        public static List <User> GetUsers()
        {
            SeContext seContext = new SeContext();

            return(seContext.User.ToList());
        }
        public static User GetUserByUserName(string userName)
        {
            SeContext seContext = new SeContext();

            return(seContext.User.Single(a => a.UserName == userName));
        }
        public static List <LookupItem> GetLookupItemsByLookupType(int lookupTypeId)
        {
            SeContext seContext = new SeContext();

            return(seContext.LookupItem.Where(a => a.LookupTypeId == lookupTypeId).ToList());
        }
示例#24
0
        public static List <Log> GetLogs()
        {
            SeContext seContext = new SeContext();

            return(seContext.Log.ToList());
        }