コード例 #1
0
        public static void verify_using_NoSql_objfuscator_and_quoted_string_in_sql_that_GetObfuscatedSql_returns_null()
        {
            SqlObfuscator ob  = SqlObfuscator.GetSqlObfuscator(true, "off");
            string        sql = "Select * from users where name = 'dude'";

            Assert.IsNull(ob.GetObfuscatedSql(sql));
        }
コード例 #2
0
        public static void verify_using_raw_obfuscator_and_quoted_string_in_sql_that_GetObfuscatedSql_returns_sql_passed_in()
        {
            SqlObfuscator ob  = SqlObfuscator.GetSqlObfuscator(true, "raw");
            string        sql = "Select * from users where name = 'dude'";

            Assert.AreEqual(sql, ob.GetObfuscatedSql(sql));
        }
コード例 #3
0
        public static void verify_using_NoSql_objfuscator_that_GetObfuscatedSql_returns_null()
        {
            SqlObfuscator ob  = SqlObfuscator.GetSqlObfuscator(true, "off");
            string        sql = "Select * from users where ssn = 433871122";

            Assert.IsNull(ob.GetObfuscatedSql(sql));
        }
コード例 #4
0
        public static void verify_using_raw_obfuscator_that_GetObfuscatedSql_returns_sql_passed_in()
        {
            SqlObfuscator ob  = SqlObfuscator.GetSqlObfuscator(true, "raw");
            string        sql = "Select * from users where ssn = 433871122";

            Assert.AreEqual(sql, ob.GetObfuscatedSql(sql));
        }
コード例 #5
0
        protected override void OnConfigurationUpdated(ConfigurationUpdateSource configurationUpdateSource)
        {
            // It is *CRITICAL* that this method never do anything more complicated than clearing data and starting and ending subscriptions.
            // If this method ends up trying to send data synchronously (even indirectly via the EventBus or RequestBus) then the user's application will deadlock (!!!).

            _sqlObfuscator = SqlObfuscator.GetSqlObfuscator(_configuration.TransactionTracerEnabled, _configuration.TransactionTracerRecordSql);
            _cache.SetCapacity(_configuration.DatabaseStatementCacheCapcity);
        }
コード例 #6
0
        /// <summary>
        /// SQL obfuscation is expensive. It is performed when a transaction has ended in the creation of SQL traces and transaction traces.
        /// Whether we obfuscate SQL for traces depends on configuration. We reduce the number of times SQL obfuscation is performed by caching
        /// results.
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        private string GetObfuscatedSqlFromCache(string sql, DatastoreVendor vendor)
        {
            return(_cache.GetOrAdd(vendor, sql, ObfuscateSql));

            string ObfuscateSql()
            {
                return(SqlObfuscator.GetObfuscatingSqlObfuscator().GetObfuscatedSql(sql, vendor));
            }
        }
コード例 #7
0
 /// <summary>
 /// If the SQL obfuscation settings are set to obfuscate, this will return the obfuscated SQL using the cache. Otherwise, it just returns
 /// the value returned from the SQL obfuscator defined by the configuration because there is no need to cache the value of the no sql and raw sql obfuscators.
 /// </summary>
 /// <param name="sql"></param>
 /// <returns></returns>
 public string GetObfuscatedSql(string sql, DatastoreVendor vendor)
 {
     return(_sqlObfuscator != SqlObfuscator.GetObfuscatingSqlObfuscator()
         ? _sqlObfuscator.GetObfuscatedSql(sql, vendor)
         : GetObfuscatedSqlFromCache(sql, vendor));
 }
コード例 #8
0
 public DatabaseService(ICacheStatsReporter cacheStatsReporter)
 {
     _sqlObfuscator = SqlObfuscator.GetSqlObfuscator(_configuration.TransactionTracerEnabled, _configuration.TransactionTracerRecordSql);
     _cache         = new CacheByDatastoreVendor <string, string>("SqlObfuscationCache", cacheStatsReporter);
 }