Skip to content

Sanitize input for properties that are lists #1609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@
<Compile Include="Models\PSApplicationGatewaySku.cs" />
<Compile Include="Models\PSApplicationGatewaySslCertificate.cs" />
<Compile Include="Models\PSApplicationGatewayUrlPathMap.cs" />
<Compile Include="Models\PSInboundRule.cs" />
<Compile Include="Models\PSInboundNatPool.cs" />
<Compile Include="Models\PSExpressRouteServiveProvider.cs" />
<Compile Include="Models\PSExpressRouteCircuitArpTable.cs" />
Expand Down Expand Up @@ -319,10 +320,10 @@
<Compile Include="VirtualNetworkGateway\NewAzureVirtualNetworkGatewayCommand.cs" />
<Compile Include="VirtualNetworkGateway\GetAzureVpnClientRootCertificateCommand.cs" />
<Compile Include="VirtualNetworkGateway\GetAzureVpnClientRevokedCertificateCommand.cs" />
<Compile Include="VirtualNetworkGateway\AddAzureVpnClientRootCertificateCommand.cs" />
<Compile Include="VirtualNetworkGateway\AddAzureVpnClientRevokedCertificateCommand.cs" />
<Compile Include="VirtualNetworkGateway\AddAzureVpnClientRootCertificateCommand.cs" />
<Compile Include="VirtualNetworkGateway\AddAzureVpnClientRevokedCertificateCommand.cs" />
<Compile Include="VirtualNetworkGateway\NewAzureVpnClientRootCertificateCommand.cs" />
<Compile Include="VirtualNetworkGateway\NewAzureVpnClientRevokedCertificateCommand.cs" />
<Compile Include="VirtualNetworkGateway\NewAzureVpnClientRevokedCertificateCommand.cs" />
<Compile Include="VirtualNetworkGateway\ResizeAzureVirtualNetworkGatewayCommand.cs" />
<Compile Include="VirtualNetworkGateway\RemoveAzureVpnClientRevokedCertificateCommand.cs" />
<Compile Include="VirtualNetworkGateway\RemoveAzureVpnClientRootCertificateCommand.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@
</ListItem>
<ListItem>
<Label>FrontendIPConfigurations</Label>
<PropertyName>FrontendIPConfigurationsText</PropertyName>
<PropertyName>FrontendIpConfigurationsText</PropertyName>
</ListItem>
<ListItem>
<Label>BackendAddressPools</Label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,15 @@ public string LoadBalancingRulesText
{
get { return JsonConvert.SerializeObject(LoadBalancingRules, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

public bool ShouldSerializeBackendIpConfigurations()
{
return !string.IsNullOrEmpty(this.Name);
}

public bool ShouldSerializeLoadBalancingRules()
{
return !string.IsNullOrEmpty(this.Name);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,19 @@ public string InboundNatPoolsText
get { return JsonConvert.SerializeObject(InboundNatPools, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

public bool ShouldSerializeInboundNatRules()
{
return !string.IsNullOrEmpty(this.Name);
}

public bool ShouldSerializeLoadBalancingRules()
{
return !string.IsNullOrEmpty(this.Name);
}

public bool ShouldSerializeInboundNatPools()
{
return !string.IsNullOrEmpty(this.Name);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,12 @@ namespace Microsoft.Azure.Commands.Network.Models
{
using Newtonsoft.Json;

public class PSInboundNatPool : PSChildResource
public class PSInboundNatPool : PSInboundRule
{
[JsonProperty(Order = 1)]
public PSResourceId FrontendIPConfiguration { get; set; }

[JsonProperty(Order = 1)]
public int FrontendPortRangeStart { get; set; }

[JsonProperty(Order = 1)]
public int FrontendPortRangeEnd { get; set; }

[JsonProperty(Order = 1)]
public int BackendPort { get; set; }

[JsonProperty(Order = 1)]
public string Protocol { get; set; }

[JsonProperty(Order = 1)]
public string ProvisioningState { get; set; }

[JsonIgnore]
public string FrontendIPConfigurationText
{
get { return JsonConvert.SerializeObject(FrontendIPConfiguration, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,29 @@ namespace Microsoft.Azure.Commands.Network.Models
{
using Newtonsoft.Json;

public class PSInboundNatRule : PSChildResource
public class PSInboundNatRule : PSInboundRule
{
[JsonProperty(Order = 1)]
public PSResourceId FrontendIPConfiguration { get; set; }

[JsonProperty(Order = 1)]
public string Protocol { get; set; }

[JsonProperty(Order = 1)]
public int? FrontendPort { get; set; }

[JsonProperty(Order = 1)]
public int? BackendPort { get; set; }
public int FrontendPort { get; set; }

[JsonProperty(Order = 1)]
public int? IdleTimeoutInMinutes { get; set; }

[JsonProperty(Order = 1)]
public bool? EnableFloatingIP { get; set; }

[JsonProperty(Order = 1)]
public string ProvisioningState { get; set; }

[JsonProperty(Order = 1)]
public PSNetworkInterfaceIPConfiguration BackendIPConfiguration { get; set; }

[JsonIgnore]
public string FrontendIPConfigurationText
public string BackendIPConfigurationText
{
get { return JsonConvert.SerializeObject(FrontendIPConfiguration, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
get { return JsonConvert.SerializeObject(BackendIPConfiguration, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

[JsonIgnore]
public string BackendIPConfigurationText
public bool ShouldSerializeFrontendPort()
{
get { return JsonConvert.SerializeObject(BackendIPConfiguration, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
return !string.IsNullOrEmpty(this.Name);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// Copyright (c) Microsoft. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

namespace Microsoft.Azure.Commands.Network.Models
{
using Newtonsoft.Json;

public class PSInboundRule : PSChildResource
{
[JsonProperty(Order = 1)]
public PSResourceId FrontendIPConfiguration { get; set; }

[JsonProperty(Order = 1)]
public int BackendPort { get; set; }

[JsonProperty(Order = 1)]
public string Protocol { get; set; }

[JsonProperty(Order = 1)]
public string ProvisioningState { get; set; }

[JsonIgnore]
public string FrontendIPConfigurationText
{
get { return JsonConvert.SerializeObject(FrontendIPConfiguration, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

public bool ShouldSerializeBackendPort()
{
return !string.IsNullOrEmpty(this.Name);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,16 @@ namespace Microsoft.Azure.Commands.Network.Models
{
using Newtonsoft.Json;

public class PSLoadBalancingRule : PSChildResource
public class PSLoadBalancingRule : PSInboundRule
{
[JsonProperty(Order = 1)]
public PSResourceId FrontendIPConfiguration { get; set; }

[JsonProperty(Order = 1)]
public PSResourceId BackendAddressPool { get; set; }

[JsonProperty(Order = 1)]
public PSResourceId Probe { get; set; }

[JsonProperty(Order = 1)]
public string Protocol { get; set; }

[JsonProperty(Order = 1)]
public int? FrontendPort { get; set; }

[JsonProperty(Order = 1)]
public int? BackendPort { get; set; }
public int FrontendPort { get; set; }

[JsonProperty(Order = 1)]
public int? IdleTimeoutInMinutes { get; set; }
Expand All @@ -46,15 +37,6 @@ public class PSLoadBalancingRule : PSChildResource
[JsonProperty(Order = 1)]
public bool? EnableFloatingIP { get; set; }

[JsonProperty(Order = 1)]
public string ProvisioningState { get; set; }

[JsonIgnore]
public string FrontendIPConfigurationText
{
get { return JsonConvert.SerializeObject(FrontendIPConfiguration, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

[JsonIgnore]
public string BackendAddressPoolText
{
Expand All @@ -67,5 +49,9 @@ public string ProbeText
get { return JsonConvert.SerializeObject(Probe, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

public bool ShouldSerializeFrontendPort()
{
return !string.IsNullOrEmpty(this.Name);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,10 @@ public string NetworkSecurityGroupText
{
get { return JsonConvert.SerializeObject(NetworkSecurityGroup, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

public bool ShouldSerializeIpConfigurations()
{
return !string.IsNullOrEmpty(this.Name);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,15 @@ public string LoadBalancerInboundNatRulesText
{
get { return JsonConvert.SerializeObject(LoadBalancerInboundNatRules, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

public bool ShouldSerializeLoadBalancerBackendAddressPools()
{
return !string.IsNullOrEmpty(this.Name);
}

public bool ShouldSerializeLoadBalancerInboundNatRules()
{
return !string.IsNullOrEmpty(this.Name);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,25 @@ public string SubnetsText
{
get { return JsonConvert.SerializeObject(Subnets, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

public bool ShouldSerializeSecurityRules()
{
return !string.IsNullOrEmpty(this.Name);
}

public bool ShouldSerializeDefaultSecurityRules()
{
return !string.IsNullOrEmpty(this.Name);
}

public bool ShouldSerializeNetworkInterfaces()
{
return !string.IsNullOrEmpty(this.Name);
}

public bool ShouldSerializeSubnets()
{
return !string.IsNullOrEmpty(this.Name);
}
}
}
15 changes: 15 additions & 0 deletions src/ResourceManager/Network/Commands.Network/Models/PSProbe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,20 @@ public string LoadBalancingRulesText
{
get { return JsonConvert.SerializeObject(LoadBalancingRules, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

public bool ShouldSerializePort()
{
return !string.IsNullOrEmpty(this.Name);
}

public bool ShouldSerializeIntervalInSeconds()
{
return !string.IsNullOrEmpty(this.Name);
}

public bool ShouldSerializeNumberOfProbes()
{
return !string.IsNullOrEmpty(this.Name);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,15 @@ public string SubnetsText
{
get { return JsonConvert.SerializeObject(Subnets, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

public bool ShouldSerializeSubnets()
{
return !string.IsNullOrEmpty(this.Name);
}

public bool ShouldSerializeRoutes()
{
return !string.IsNullOrEmpty(this.Name);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Microsoft.Azure.Commands.Network.Models
{
using System.Collections.Generic;
using System.Runtime.CompilerServices;

using Newtonsoft.Json;

Expand Down Expand Up @@ -52,5 +53,10 @@ public string RouteTableText
{
get { return JsonConvert.SerializeObject(RouteTable, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

public bool ShouldSerializeIpConfigurations()
{
return !string.IsNullOrEmpty(this.Name);
}
}
}