Exemple #1
0
        public void ItShouldDetectFileWithMarkOfTheWeb()
        {
            var testFile = Path.Combine(TestAssets.CreateTestDirectory().FullName, Path.GetRandomFileName());

            File.WriteAllText(testFile, string.Empty);
            AlternateStream.WriteAlternateStream(
                testFile,
                "Zone.Identifier",
                "[ZoneTransfer]\r\nZoneId=3\r\nReferrerUrl=C:\\Users\\test.zip\r\n");

            new DangerousFileDetector().IsDangerous(testFile).Should().BeTrue();
        }
        public void ItShouldDetectFileWithMarkOfTheWeb()
        {
            var testFile = Path.Combine(_testAssetsManager.CreateTestDirectory().Path, Path.GetRandomFileName());

            File.WriteAllText(testFile, string.Empty);
            AlternateStream.WriteAlternateStream(
                testFile,
                "Zone.Identifier",
                "[ZoneTransfer]\r\nZoneId=3\r\nReferrerUrl=C:\\Users\\test.zip\r\n");

            bool isTestFileDangerous = new DangerousFileDetector().IsDangerous(testFile);

            if (!HasInternetSecurityManagerNativeApi())
            {
                isTestFileDangerous.Should().BeFalse("Locked down version of Windows does not have IE to download files");
            }
            else
            {
                isTestFileDangerous.Should().BeTrue();
            }
        }