Example #1
0
        public void TestApplicationBlacklists()
        {
            DefaultPolicyConfiguration configuration = setupConfiguration();

            AppListCheck alc = new AppListCheck(configuration);

            Func <string, bool> isAppInBlacklist = (path) => alc.IsAppInBlacklist(path, System.IO.Path.GetFileName(path));

            Assert.IsTrue(alc.IsAppInBlacklist(@"C:\Program Files\Google\Chrome\chrome.exe", "chrome.exe"));
            Assert.IsTrue(alc.IsAppInBlacklist(@"C:\Program Files (x86)\Google\Chrome\chrome.exe", "chrome.exe"));

            Assert.IsTrue(alc.IsAppInBlacklist(@"C:\testme.exe", "testme.exe"));

            Assert.IsTrue(alc.IsAppInBlacklist(@"C:\Program Files\java\jre.exe", "jre.exe"));
            Assert.IsFalse(isAppInBlacklist(@"C:\Program Files\eclipse\java\jre.exe"));
            Assert.IsFalse(isAppInBlacklist(@"C:\Apps\java\jre.exe"));

            Assert.IsTrue(isAppInBlacklist(@"C:\Windows\MicrosoftEdge.exe"));
            Assert.IsFalse(isAppInBlacklist(@"C:\Program Files\MicrosoftEdge.exe"));

            Assert.IsTrue(isAppInBlacklist(@"c:\windows\microsoftedge.exe"));
            Assert.IsTrue(isAppInBlacklist(@"C:\WINDOWS\MICROSOFTEDGE.EXE"));
            Assert.IsTrue(isAppInBlacklist(@"C:\PROGRAM FILES\GOOGLE\CHROME\CHROME.EXE"));
            Assert.IsTrue(isAppInBlacklist(@"C:\PROGRAM FILES\JAVA\JRE.EXE"));

            Assert.IsTrue(isAppInBlacklist(@"c:\program files (x86)\java\JRE.EXE"));
        }
Example #2
0
        public void TestNullBehavior()
        {
            DefaultPolicyConfiguration configuration = setupConfiguration(true);

            AppListCheck alc = new AppListCheck(configuration);

            Func <string, bool> isAppInBlacklist = (path) => alc.IsAppInBlacklist(path, System.IO.Path.GetFileName(path));

            bool blacklistVal = isAppInBlacklist(@"C:\Program Files\Google\Chrome\chrome.exe");
            bool whitelistVal = alc.IsAppInWhitelist(@"C:\Program Files\Google\Chrome\chrome.exe", "chrome.exe");

            // The result doesn't matter, we just don't want any NullReferenceExceptions occurring.
        }
Example #3
0
        private DefaultPolicyConfiguration setupConfiguration(bool useInvalidJson = false)
        {
            string configFileText = useInvalidJson ? "404 Some nasty error has occurred" : provideConfigurationJsonForApplicationLists();

            DefaultPolicyConfiguration configuration = new DefaultPolicyConfiguration(null, NLog.LogManager.GetCurrentClassLogger(), new System.Threading.ReaderWriterLockSlim());

            using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(configFileText)))
            {
                Assert.AreEqual(!useInvalidJson, configuration.LoadConfiguration(ms), "LoadConfiguration delivered unexpected result for the circumstances.");
            }

            return(configuration);
        }
Example #4
0
        public void TestApplicationWhitelists()
        {
            DefaultPolicyConfiguration configuration = setupConfiguration();

            AppListCheck alc = new AppListCheck(configuration);

            Func <string, bool> isAppInWhitelist = (path) => alc.IsAppInWhitelist(path, System.IO.Path.GetFileName(path));

            Assert.IsTrue(isAppInWhitelist(@"C:\Program Files\Dropbox\dropbox.exe"));
            Assert.IsTrue(isAppInWhitelist(@"C:\Program Files\eclipse\java\jre.exe"));
            Assert.IsTrue(isAppInWhitelist(@"C:\Program Files\IDrive\backup-v300.exe"));

            Assert.IsFalse(isAppInWhitelist(@"C:\Program Files\IDrive\backup\invalid.exe"));

            Assert.IsTrue(isAppInWhitelist(@"d:\program files\dropbox\dropbox.exe"));
            Assert.IsTrue(isAppInWhitelist(@"D:\PROGRAM FILES (X86)\DROPBOX\DROPBOX.EXE"));

            Assert.IsTrue(isAppInWhitelist(@"D:\PROGRAM FILES (X86)\IDRIVE\BACKUP-V301.EXE"));

            Assert.IsFalse(isAppInWhitelist(@"D:\PROGRAM FILES (X86)\IDRIVE\BACKUP-V301.EXE\trick.exe"));
        }