private string ExtractNetFrameworkVersion(NetFrameworkVersion version) { switch (version) { case NetFrameworkVersion.NoManagedCode: return(""); case NetFrameworkVersion.Net1_0: return("v1.0"); case NetFrameworkVersion.Net1_1: return("v1.1"); case NetFrameworkVersion.Net2_0: return("v2.0"); case NetFrameworkVersion.Net4_0: return("v4.0"); case NetFrameworkVersion.Net5_0: return("v5.0"); default: throw new ConDepUnknowNetFrameworkException("Framework version unknown to ConDep."); } }
/// <summary> /// Gets the dot net version that the application runs on. /// </summary> /// <param name="appInfo">The application info structure.</param> /// <returns>The .net version supported by the application</returns> private DotNetVersion GetAppVersion(ApplicationInfo appInfo) { this.startupLogger.Info(Strings.DeterminingApplication); string[] allAssemblies = Directory.GetFiles(appInfo.Path, "*.dll", SearchOption.AllDirectories); DotNetVersion version = DotNetVersion.Two; if (allAssemblies.Length == 0) { version = NetFrameworkVersion.GetFrameworkFromConfig(Path.Combine(appInfo.Path, "web.config")); } foreach (string assembly in allAssemblies) { if (NetFrameworkVersion.GetVersion(assembly) == DotNetVersion.Four) { version = DotNetVersion.Four; break; } } this.startupLogger.Info(Strings.DetectedNet + GetAspDotNetVersion(version)); return(version); }
public void XmlExternalEntityShouldNotBeParsed_XmlDocument(NetFrameworkVersion version, string testFilePath) => Verifier.VerifyAnalyzer(testFilePath, new XmlExternalEntityShouldNotBeParsed(GetVersionProviderMock(version)), additionalReferences: MetadataReferenceFacade.GetSystemXml() .Concat(MetadataReferenceFacade.GetSystemData()) .Concat(MetadataReferenceFacade.GetSystemXmlLinq()) .Concat(NuGetMetadataReference.MicrosoftWebXdt()) .ToArray());
private static void VerifyRule(NetFrameworkVersion version, string testFilePath, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary, IEnumerable <ParseOptions> options = null) => Verifier.VerifyAnalyzer(testFilePath, new XmlExternalEntityShouldNotBeParsed(GetVersionProviderMock(version)), additionalReferences: MetadataReferenceFacade.GetSystemXml() .Concat(MetadataReferenceFacade.GetSystemData()) .Concat(MetadataReferenceFacade.GetSystemXmlLinq()) .ToArray(), outputKind: outputKind, options: options);
private static void VerifyRule(NetFrameworkVersion version, string testFilePath) { var rule = new XmlExternalEntityShouldNotBeParsed(GetVersionProviderMock(version)); Verifier.VerifyAnalyzer(testFilePath, rule, additionalReferences: FrameworkMetadataReference.SystemXml .Concat(FrameworkMetadataReference.SystemData) .Concat(FrameworkMetadataReference.SystemXmlLinq) .ToArray()); }
private static INetFrameworkVersionProvider GetVersionProviderMock(NetFrameworkVersion version) { var versionProviderMock = new Mock <INetFrameworkVersionProvider>(); versionProviderMock .Setup(vp => vp.GetDotNetFrameworkVersion(It.IsAny <Compilation>())) .Returns(version); return(versionProviderMock.Object); }
private static void VerifyRule(NetFrameworkVersion version, string testFilePath, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary, IEnumerable <ParseOptions> options = null) => Verifier.VerifyAnalyzer(testFilePath, new CS.XmlExternalEntityShouldNotBeParsed(GetVersionProviderMock(version)), options, CompilationErrorBehavior.Default, outputKind, MetadataReferenceFacade.SystemXml .Concat(MetadataReferenceFacade.SystemData) .Concat(MetadataReferenceFacade.SystemXmlLinq) .ToArray());
public void XmlExternalEntityShouldNotBeParsed_XmlTextReader(NetFrameworkVersion version, string testFilePath) { // setup var rule = new XmlExternalEntityShouldNotBeParsed(GetVersionProviderMock(version)); // act & verify Verifier.VerifyAnalyzer(testFilePath, rule, additionalReferences: FrameworkMetadataReference.SystemXml.ToArray(), options: ParseOptionsHelper.FromCSharp8); }
public void XmlExternalEntityShouldNotBeParsed_XmlDocument(NetFrameworkVersion version, string testFilePath) { // setup var rule = new XmlExternalEntityShouldNotBeParsed(GetVersionProviderMock(version)); // act & verify Verifier.VerifyAnalyzer(testFilePath, rule, additionalReferences: FrameworkMetadataReference.SystemXml .Concat(FrameworkMetadataReference.SystemData) .Concat(FrameworkMetadataReference.SystemXmlLinq) .Concat(NuGetMetadataReference.MicrosoftWebXdt()) .ToArray(), options: ParseOptionsHelper.FromCSharp8); }
public static string FriendlyName(NetFrameworkVersion value) { var fieldInfo = value.GetType().GetField(value.ToString()); object[] attributes = fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false); if (attributes.Length <= 0) { return(value.ToString()); } var descriptionAttribute = (DescriptionAttribute)attributes[0]; return(descriptionAttribute.Description); }
private static void PopulateWinformsSection() { if (NetFrameworkVersion.CompareTo(featureSupportedMinimumFrameworkVersion) >= 0) { try { applicationConfigOptions = ConfigurationManager.GetSection(ConfigurationStringConstants.WinformsApplicationConfigurationSectionName) as NameValueCollection; } catch (Exception ex) { Debug.WriteLine("Exception while reading" + ConfigurationStringConstants.WinformsApplicationConfigurationSectionName + " from app.config file " + " " + ex.ToString()); } } }
public async ValueTask <IWebApp> CreateWebAppAsync( string webAppName, string databaseConnectionString, IAppServicePlan plan, IResourceGroup resourceGroup) { return(await this.azure.AppServices.WebApps .Define(webAppName) .WithExistingWindowsPlan(plan) .WithExistingResourceGroup(resourceGroup) .WithNetFrameworkVersion(NetFrameworkVersion.Parse("v6.0")) .WithConnectionString( name: "DefaultConnect", value: databaseConnectionString, type: ConnectionStringType.SQLAzure) .CreateAsync()); }
private string ExtractNetFrameworkVersion(NetFrameworkVersion version) { switch (version) { case NetFrameworkVersion.NoManagedCode: return ""; case NetFrameworkVersion.Net1_0: return "v1.0"; case NetFrameworkVersion.Net1_1: return "v1.1"; case NetFrameworkVersion.Net2_0: return "v2.0"; case NetFrameworkVersion.Net4_0: return "v4.0"; case NetFrameworkVersion.Net5_0: return "v5.0"; default: throw new ConDepUnknowNetFrameworkException("Framework version unknown to ConDep."); } }
IOfferIisAppPoolOptions IOfferIisAppPoolOptions.NetFrameworkVersion(NetFrameworkVersion version) { _values.NetFrameworkVersion = ExtractNetFrameworkVersion(version); return this; }
public static bool IsFrameworkVersionSupported(NetFrameworkVersion targetedVersion) { return((int)targetedVersion <= (int)NewestFrameworkVersion); }
public XmlReaderSettingsValidator(SemanticModel semanticModel, NetFrameworkVersion version) { this.semanticModel = semanticModel; isXmlResolverSafeByDefault = IsXmlResolverPropertySafeByDefault(version); }
// The XmlDocument and XmlTextReader constructors were made safe-by-default in .NET 4.5.2 private static bool ConstructorIsSafe(NetFrameworkVersion version) => version switch {
private static bool IsXPathDocumentSecureByDefault(NetFrameworkVersion version) => // XPathDocument is secure by default starting with .Net 4.5.2 version == NetFrameworkVersion.After452 || version == NetFrameworkVersion.Unknown;
public void XmlExternalEntityShouldNotBeParsed_XPathDocument(NetFrameworkVersion version, string testFilePath) => VerifyRule(version, testFilePath);
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); WebsitesClient = WebsitesClient ?? new WebsitesClient(CurrentSubscription, WriteDebug); string suffix = WebsitesClient.GetWebsiteDnsSuffix(); Site website = null; SiteConfig websiteConfig = null; InvokeInOperationContext(() => { try { website = RetryCall(s => Channel.GetSite(s, Name, null)); websiteConfig = RetryCall(s => Channel.GetSiteConfig(s, website.WebSpace, Name)); } catch (CommunicationException ex) { WriteErrorDetails(ex); } }); if (website == null) { throw new Exception(string.Format(Resources.InvalidWebsite, Name)); } bool changes = false; SiteWithConfig websiteConfigUpdate = new SiteWithConfig(website, websiteConfig); if (SiteWithConfig != null) { websiteConfigUpdate = SiteWithConfig; changes = true; } if (NumberOfWorkers != null && !NumberOfWorkers.Equals(websiteConfig.NumberOfWorkers)) { changes = true; websiteConfigUpdate.NumberOfWorkers = NumberOfWorkers; } if (DefaultDocuments != null && !DefaultDocuments.Equals(websiteConfig.DefaultDocuments)) { changes = true; websiteConfigUpdate.DefaultDocuments = DefaultDocuments; } if (NetFrameworkVersion != null && !NetFrameworkVersion.Equals(websiteConfig.NetFrameworkVersion)) { changes = true; websiteConfigUpdate.NetFrameworkVersion = NetFrameworkVersion; } if (PhpVersion != null && !PhpVersion.Equals(websiteConfig.PhpVersion)) { changes = true; websiteConfigUpdate.PhpVersion = PhpVersion; } if (RequestTracingEnabled != null && !RequestTracingEnabled.Equals(websiteConfig.RequestTracingEnabled)) { changes = true; websiteConfigUpdate.RequestTracingEnabled = RequestTracingEnabled; } if (HttpLoggingEnabled != null && !HttpLoggingEnabled.Equals(websiteConfig.HttpLoggingEnabled)) { changes = true; websiteConfigUpdate.HttpLoggingEnabled = HttpLoggingEnabled; } if (DetailedErrorLoggingEnabled != null && !DetailedErrorLoggingEnabled.Equals(websiteConfig.DetailedErrorLoggingEnabled)) { changes = true; websiteConfigUpdate.DetailedErrorLoggingEnabled = DetailedErrorLoggingEnabled; } if (AppSettings != null && !AppSettings.Equals(websiteConfig.AppSettings)) { changes = true; websiteConfigUpdate.AppSettings = AppSettings; } if (Metadata != null && !Metadata.Equals(websiteConfig.Metadata)) { changes = true; websiteConfigUpdate.Metadata = Metadata; } if (ConnectionStrings != null && !ConnectionStrings.Equals(websiteConfig.ConnectionStrings)) { changes = true; websiteConfigUpdate.ConnectionStrings = ConnectionStrings; } if (HandlerMappings != null && !HandlerMappings.Equals(websiteConfig.HandlerMappings)) { changes = true; websiteConfigUpdate.HandlerMappings = HandlerMappings; } bool siteChanges = false; Site websiteUpdate = new Site { Name = Name, HostNames = new[] { string.Format("{0}.{1}", Name, suffix) } }; if (HostNames != null) { siteChanges = true; List <string> newHostNames = new List <string> { string.Format("{0}.{1}", Name, suffix) }; newHostNames.AddRange(HostNames); websiteUpdate.HostNames = newHostNames.ToArray(); } if (changes) { InvokeInOperationContext(() => { try { RetryCall(s => Channel.UpdateSiteConfig(s, website.WebSpace, Name, websiteConfigUpdate.GetSiteConfig())); } catch (CommunicationException ex) { WriteErrorDetails(ex); } }); } if (siteChanges) { InvokeInOperationContext(() => { try { RetryCall(s => Channel.UpdateSite(s, website.WebSpace, Name, websiteUpdate)); } catch (CommunicationException ex) { WriteErrorDetails(ex); } }); } if (PassThru.IsPresent) { WriteObject(true); } }
IOfferIisAppPoolOptions IOfferIisAppPoolOptions.NetFrameworkVersion(NetFrameworkVersion version) { _values.NetFrameworkVersion = ExtractNetFrameworkVersion(version); return(this); }
public void XmlExternalEntityShouldNotBeParsed_XmlTextReader(NetFrameworkVersion version, string testFilePath) => Verifier.VerifyAnalyzer(testFilePath, new XmlExternalEntityShouldNotBeParsed(GetVersionProviderMock(version)), ParseOptionsHelper.FromCSharp8, additionalReferences: MetadataReferenceFacade.GetSystemXml().ToArray());