Esempio n. 1
0
        private void CheckSqlInjection(string query, IDbLog log)
        {
            if (checkQuery(query))
            {
                bool ok = true;
                // no permitir comentarios ni algunas instrucciones maliciosas
                if (query.IndexOf("--") > -1)
                {
                    log.end(null, "No se admiten comentarios de SQL en la cadena de selección\n" + this.rutaDDBB);

                    throw new ArgumentException("No se admiten comentarios de SQL en la cadena de selección. SQL: " + query);
                }
                else if (query.ToUpper().IndexOf("DROP TABLE ") > -1)
                {
                    log.end(null, "La cadena debe ser SELECT campos FROM tabla, no DROP y otros comandos no adecuados...\n" + this.rutaDDBB);

                    throw new ArgumentException("La cadena debe ser SELECT campos FROM tabla, no DROP y otros comandos no adecuados... SQL: " + query);
                }
                else if (query.ToUpper().IndexOf("DROP PROCEDURE ") > -1)
                {
                    log.end(null, "La cadena debe ser SELECT campos FROM tabla, no DROP y otros comandos no adecuados...\n" + this.rutaDDBB);

                    throw new ArgumentException("La cadena debe ser SELECT campos FROM tabla, no DROP y otros comandos no adecuados... SQL: " + query);
                }
                else if (query.ToUpper().IndexOf("DROP FUNCTION ") > -1)
                {
                    log.end(null, "La cadena debe ser SELECT campos FROM tabla, no DROP y otros comandos no adecuados...\n" + this.rutaDDBB);

                    throw new ArgumentException("La cadena debe ser SELECT campos FROM tabla, no DROP y otros comandos no adecuados... SQL: " + query);
                }
                else
                {
                    ok = true;
                }

                // Comprobar que realmente se use SELECT, o EXEC
                if (query.ToUpper().IndexOf("EXEC") < 0)
                {
                    ok = false;
                }
                // Comprobar que realmente se use SELECT, o EXEC
                if (query.ToUpper().IndexOf("SELECT") < 0 && ok == false)
                {
                    log.end(null, "La cadena debe ser SELECT campos FROM tabla / EXEC Storage Proces and variables\n" + this.rutaDDBB);

                    throw new ArgumentException("Query must be SELECT fields FROM table / EXEC Storage Process and variables. SQL: " + query);
                }
                else
                {
                    log.end(null, "Ha superado la prueba de comando correcto.\n" + this.rutaDDBB);
                }
            }
            else
            {
                log.end(null, "No ha superado la prueba de comando correcto.\n" + this.rutaDDBB);
                throw new ArgumentException("Query must be SELECT fields FROM table / EXEC Storage Process and variables. SQL: " + query);
            }
        }
Esempio n. 2
0
        protected void Application_Start(object sender, EventArgs e)
        {
            Dbl = DBController.DbLog;
            MigrationHandler.Perform();
            StartBackgroundWorkers();
#if debug
            ExcelHelper.Perform(DBController);
#endif
        }
            public static void Test()
            {
                IFactory kit     = new LogFactory();
                IFileLog fileLog = (IFileLog)kit.CreateLog(LogCategory.File);
                IDbLog   dbLog   = (IDbLog)kit.CreateLog(LogCategory.DB);

                fileLog.WriteToFile();
                dbLog.WriteToDb();
            }
Esempio n. 4
0
 public void SetLogger(IDbLog logger)
 {
     if (logger == null)
     {
         log = new defLog(this.FolderLog);
     }
     else
     {
         log = logger;
     }
 }
            public static void Test()
            {
                ILogFactory2 kit     = new LogFactory2 <FileLog, DbLog>();
                IFileLog     fileLog = kit.CreateFileLog();
                IDbLog       dbLog   = kit.CreateDbLog();

                fileLog.WriteToFile();
                dbLog.WriteToDb();

                IOtherLog otherLog = kit.CreateOtherLog <OtherLog>();

                otherLog.WriteToOther();
            }
 protected void Application_Start(object sender, EventArgs e)
 {
     Dbl = DBController.DbLog;
 }