コード例 #1
0
        public void UseCase_SuppressExistingPast_Test()
        {
            string        testString = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore DS126858,DS168931 until 1980-07-15";
            SuppressionEx sup        = new SuppressionEx(testString, "csharp");

            Assert.IsFalse(sup.IsIssueSuppressed("DS126858"), "Is suppressed DS126858 should be True");
            Assert.IsFalse(sup.IsIssueSuppressed("DS168931"), "Is suppressed DS168931 should be True");

            // Suppress multiple
            string suppressedString = sup.SuppressIssue("DS196098");
            string expected         = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore DS126858,DS168931,DS196098 until 1980-07-15";

            Assert.AreEqual(expected, suppressedString, "Suppress multiple failed");

            // Suppress multiple new date
            DateTime expirationDate = DateTime.Now.AddDays(10);

            suppressedString = sup.SuppressIssue("DS196098", expirationDate);
            expected         = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore DS126858,DS168931,DS196098 until 1980-07-15";
            Assert.AreEqual(string.Format(expected, expirationDate), suppressedString, "Suppress multiple new date failed");

            // Suppress multiple to all
            suppressedString = sup.SuppressAll();
            expected         = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore all until 1980-07-15";
            Assert.AreEqual(string.Format(expected, expirationDate), suppressedString, "Suppress multiple to all failed");

            // Suppress multiple to all new date
            suppressedString = sup.SuppressAll(expirationDate);
            expected         = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore all until 1980-07-15";
            Assert.AreEqual(string.Format(expected, expirationDate), suppressedString, "Suppress multiple to all new date failed");
        }
コード例 #2
0
        public void Suppress_Test()
        {
            // Is supressed test
            string        testString = "md5.new()";
            SuppressionEx sup        = new SuppressionEx(testString, "python");

            Assert.IsTrue(sup.Index < 0, "Suppression should not be flagged");

            // Suppress Rule test
            string ruleId           = "DS196098";
            string suppressedString = sup.SuppressIssue(ruleId);
            string expected         = "md5.new() #DevSkim: ignore DS196098";

            Assert.AreEqual(expected, suppressedString, "Supress Rule failed ");

            // Suppress Rule Until test
            DateTime expirationDate = DateTime.Now.AddDays(5);

            suppressedString = sup.SuppressIssue(ruleId, expirationDate);
            expected         = string.Format("md5.new() #DevSkim: ignore DS196098 until {0:yyyy}-{0:MM}-{0:dd}", expirationDate);
            Assert.AreEqual(expected, suppressedString, "Supress Rule Until failed ");

            // Suppress All test
            suppressedString = sup.SuppressAll();
            expected         = "md5.new() #DevSkim: ignore all";
            Assert.AreEqual(expected, suppressedString, "Supress All failed");

            // Suppress All Until test
            suppressedString = sup.SuppressAll(expirationDate);
            expected         = string.Format("md5.new() #DevSkim: ignore all until {0:yyyy}-{0:MM}-{0:dd}", expirationDate);
            Assert.AreEqual(expected, suppressedString, "Supress All Until failed ");
        }
コード例 #3
0
        public void SuppressExisting_Test()
        {
            string   testString     = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore DS126858,DS168931 until {0:yyyy}-{0:MM}-{0:dd}";
            DateTime expirationDate = DateTime.Now.AddDays(5);

            SuppressionEx sup = new SuppressionEx(string.Format(testString, expirationDate), "csharp");

            Assert.IsTrue(sup.IsIssueSuppressed("DS126858"), "Is suppressed DS126858 should be True");
            Assert.IsTrue(sup.IsIssueSuppressed("DS168931"), "Is suppressed DS168931 should be True");

            // Suppress multiple
            string suppressedString = sup.SuppressIssue("DS196098");
            string expected         = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore DS126858,DS168931,DS196098 until {0:yyyy}-{0:MM}-{0:dd}";

            Assert.AreEqual(string.Format(expected, expirationDate), suppressedString, "Suppress multiple failed");

            // Suppress multiple to all
            suppressedString = sup.SuppressAll();
            expected         = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore all until {0:yyyy}-{0:MM}-{0:dd}";
            Assert.AreEqual(string.Format(expected, expirationDate), suppressedString, "Suppress multiple to all failed");

            // Suppress multiple new date
            expected         = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore DS126858,DS168931,DS196098 until {0:yyyy}-{0:MM}-{0:dd}";
            suppressedString = sup.SuppressIssue("DS196098", DateTime.Now.AddDays(100));
            Assert.AreEqual(string.Format(expected, expirationDate), suppressedString, "Suppress multiple new date failed");

            // Suppress multiple to all new date
            suppressedString = sup.SuppressAll(DateTime.Now.AddDays(10));
            expected         = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore all until {0:yyyy}-{0:MM}-{0:dd}";
            Assert.AreEqual(string.Format(expected, expirationDate), suppressedString, "Suppress multiple to all new date failed");
        }
コード例 #4
0
        public void IsSuppress_Test()
        {
            // Is supressed test
            string        testString = "md5.new()";
            SuppressionEx sup        = new SuppressionEx(testString, "python");

            Assert.IsTrue(sup.Index < 0, "Suppression should not be flagged");
        }
コード例 #5
0
        public void Multiline_IsSuppress_Test()
        {
            // Is supressed test
            string        testString = "var hash=MD5.Create();";
            SuppressionEx sup        = new SuppressionEx(testString, "csharp");

            Assert.IsTrue(sup.Index < 0, "Suppression should not be flagged");
        }
コード例 #6
0
        public void UseCase_SuppressExistingPast_Test()
        {
            string          testString = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore DS126858,DS168931 until 1980-07-15";
            SuppressionEx   sup        = new SuppressionEx(testString, "csharp");
            SuppressedIssue iss        = sup.GetSuppressedIssue("DS126858");

            Assert.IsNull(sup.GetSuppressedIssue("DS126858"), "Is suppressed DS126858 should be Null");
            Assert.IsNull(sup.GetSuppressedIssue("DS168931"), "Is suppressed DS168931 should be Null");
        }
コード例 #7
0
        public void UseCase_SuppressMultiple_Test()
        {
            string        testString = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore DS126858,DS168931 until 1980-07-15";
            SuppressionEx sup        = new SuppressionEx(testString, "csharp");
            // Suppress multiple
            string suppressedString = sup.SuppressIssue("DS196098");
            string expected         = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore DS126858,DS168931,DS196098 until 1980-07-15";

            Assert.AreEqual(expected, suppressedString, "Suppress multiple failed");
        }
コード例 #8
0
        public void Multiline_SuppressAll_Test()
        {
            string        testString = "var hash=MD5.Create();";
            SuppressionEx sup        = new SuppressionEx(testString, "csharp");
            // Suppress All test
            string suppressedString = sup.SuppressAll();
            string expected         = "var hash=MD5.Create(); /*DevSkim: ignore all*/";

            Assert.AreEqual(expected, suppressedString, "Supress All failed");
        }
コード例 #9
0
        public void SuppressExisting_Test()
        {
            string   testString     = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore DS126858,DS168931 until {0:yyyy}-{0:MM}-{0:dd}";
            DateTime expirationDate = DateTime.Now.AddDays(5);

            SuppressionEx sup = new SuppressionEx(string.Format(testString, expirationDate), "csharp");

            Assert.IsNotNull(sup.GetSuppressedIssue("DS126858"), "Is suppressed DS126858 should be True");
            Assert.IsNotNull(sup.GetSuppressedIssue("DS168931"), "Is suppressed DS168931 should be True");
        }
コード例 #10
0
        public void SuppressRule_Test()
        {
            // Suppress Rule test
            string        testString       = "md5.new()";
            SuppressionEx sup              = new SuppressionEx(testString, "python");
            string        ruleId           = "DS196098";
            string        suppressedString = sup.SuppressIssue(ruleId);
            string        expected         = "md5.new() #DevSkim: ignore DS196098\n";

            Assert.AreEqual(expected, suppressedString, "Supress Rule failed ");
        }
コード例 #11
0
        public void Multiline_SuppressRule_Test()
        {
            string        testString = "var hash=MD5.Create();";
            SuppressionEx sup        = new SuppressionEx(testString, "csharp");
            // Suppress Rule test
            string ruleId           = "DS126858";
            string suppressedString = sup.SuppressIssue(ruleId);
            string expected         = "var hash=MD5.Create(); /*DevSkim: ignore DS126858*/";

            Assert.AreEqual(expected, suppressedString, "Supress Rule failed ");
        }
コード例 #12
0
        public void SuppressAll_Test()
        {
            string        testString = "md5.new()";
            SuppressionEx sup        = new SuppressionEx(testString, "python");

            // Suppress All test
            string suppressedString = sup.SuppressAll();
            string expected         = "md5.new() #DevSkim: ignore all\n";

            Assert.AreEqual(expected, suppressedString, "Supress All failed");
        }
コード例 #13
0
        public void UseCase_SuppressMultipleToAllNewDate_Test()
        {
            string        testString     = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore DS126858,DS168931 until 1980-07-15";
            SuppressionEx sup            = new SuppressionEx(testString, "csharp");
            DateTime      expirationDate = DateTime.Now.AddDays(10);
            // Suppress multiple to all new date
            string suppressedString = sup.SuppressAll(expirationDate);
            string expected         = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore all until 1980-07-15";

            Assert.AreEqual(string.Format(expected, expirationDate), suppressedString, "Suppress multiple to all new date failed");
        }
コード例 #14
0
        public void Multiline_SuppressAllUntil_Test()
        {
            string        testString     = "var hash=MD5.Create();";
            SuppressionEx sup            = new SuppressionEx(testString, "csharp");
            DateTime      expirationDate = DateTime.Now.AddDays(5);
            // Suppress All Until test
            string suppressedString = sup.SuppressAll(expirationDate);
            string expected         = string.Format("var hash=MD5.Create(); /*DevSkim: ignore all until {0:yyyy}-{0:MM}-{0:dd}*/", expirationDate);

            Assert.AreEqual(expected, suppressedString, "Supress All Until failed ");
        }
コード例 #15
0
        public void SuppressAllUntil_Test()
        {
            string        testString     = "md5.new()";
            SuppressionEx sup            = new SuppressionEx(testString, "python");
            DateTime      expirationDate = DateTime.Now.AddDays(5);

            // Suppress All Until test
            string suppressedString = sup.SuppressAll(expirationDate);
            string expected         = string.Format("md5.new() #DevSkim: ignore all until {0:yyyy}-{0:MM}-{0:dd}\n", expirationDate);

            Assert.AreEqual(expected, suppressedString, "Supress All Until failed ");
        }
コード例 #16
0
        public void SuppressMultipleNewDate_Test()
        {
            string        testString     = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore DS126858,DS168931 until {0:yyyy}-{0:MM}-{0:dd}";
            DateTime      expirationDate = DateTime.Now.AddDays(5);
            SuppressionEx sup            = new SuppressionEx(string.Format(testString, expirationDate), "csharp");

            // Suppress multiple new date
            string expected         = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore DS126858,DS168931,DS196098 until {0:yyyy}-{0:MM}-{0:dd}";
            string suppressedString = sup.SuppressIssue("DS196098", DateTime.Now.AddDays(100));

            Assert.AreEqual(string.Format(expected, expirationDate), suppressedString, "Suppress multiple new date failed");
        }
コード例 #17
0
        public void SuppressMultipleToAll_Test()
        {
            string        testString     = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore DS126858,DS168931 until {0:yyyy}-{0:MM}-{0:dd}";
            DateTime      expirationDate = DateTime.Now.AddDays(5);
            SuppressionEx sup            = new SuppressionEx(string.Format(testString, expirationDate), "csharp");

            // Suppress multiple to all
            string suppressedString = sup.SuppressAll();
            string expected         = "MD5 hash = new MD5CryptoServiceProvider(); //DevSkim: ignore all until {0:yyyy}-{0:MM}-{0:dd}";

            Assert.AreEqual(string.Format(expected, expirationDate), suppressedString, "Suppress multiple to all failed");
        }