Skip to content

Commit 94df2f0

Browse files
author
Hovsep
committed
Merge pull request Azure#1609 from DeepakRajendranMsft/SanitizeOutput
Sanitize input for properties that are lists
2 parents 8bae464 + 09c735a commit 94df2f0

14 files changed

+153
-62
lines changed

src/ResourceManager/Network/Commands.Network/Commands.Network.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@
280280
<Compile Include="Models\PSApplicationGatewaySku.cs" />
281281
<Compile Include="Models\PSApplicationGatewaySslCertificate.cs" />
282282
<Compile Include="Models\PSApplicationGatewayUrlPathMap.cs" />
283+
<Compile Include="Models\PSInboundRule.cs" />
283284
<Compile Include="Models\PSInboundNatPool.cs" />
284285
<Compile Include="Models\PSExpressRouteServiveProvider.cs" />
285286
<Compile Include="Models\PSExpressRouteCircuitArpTable.cs" />
@@ -319,10 +320,10 @@
319320
<Compile Include="VirtualNetworkGateway\NewAzureVirtualNetworkGatewayCommand.cs" />
320321
<Compile Include="VirtualNetworkGateway\GetAzureVpnClientRootCertificateCommand.cs" />
321322
<Compile Include="VirtualNetworkGateway\GetAzureVpnClientRevokedCertificateCommand.cs" />
322-
<Compile Include="VirtualNetworkGateway\AddAzureVpnClientRootCertificateCommand.cs" />
323-
<Compile Include="VirtualNetworkGateway\AddAzureVpnClientRevokedCertificateCommand.cs" />
323+
<Compile Include="VirtualNetworkGateway\AddAzureVpnClientRootCertificateCommand.cs" />
324+
<Compile Include="VirtualNetworkGateway\AddAzureVpnClientRevokedCertificateCommand.cs" />
324325
<Compile Include="VirtualNetworkGateway\NewAzureVpnClientRootCertificateCommand.cs" />
325-
<Compile Include="VirtualNetworkGateway\NewAzureVpnClientRevokedCertificateCommand.cs" />
326+
<Compile Include="VirtualNetworkGateway\NewAzureVpnClientRevokedCertificateCommand.cs" />
326327
<Compile Include="VirtualNetworkGateway\ResizeAzureVirtualNetworkGatewayCommand.cs" />
327328
<Compile Include="VirtualNetworkGateway\RemoveAzureVpnClientRevokedCertificateCommand.cs" />
328329
<Compile Include="VirtualNetworkGateway\RemoveAzureVpnClientRootCertificateCommand.cs" />

src/ResourceManager/Network/Commands.Network/Microsoft.Azure.Commands.Network.format.ps1xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@
512512
</ListItem>
513513
<ListItem>
514514
<Label>FrontendIPConfigurations</Label>
515-
<PropertyName>FrontendIPConfigurationsText</PropertyName>
515+
<PropertyName>FrontendIpConfigurationsText</PropertyName>
516516
</ListItem>
517517
<ListItem>
518518
<Label>BackendAddressPools</Label>

src/ResourceManager/Network/Commands.Network/Models/PSBackendAddressPool.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,15 @@ public string LoadBalancingRulesText
4141
{
4242
get { return JsonConvert.SerializeObject(LoadBalancingRules, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
4343
}
44+
45+
public bool ShouldSerializeBackendIpConfigurations()
46+
{
47+
return !string.IsNullOrEmpty(this.Name);
48+
}
49+
50+
public bool ShouldSerializeLoadBalancingRules()
51+
{
52+
return !string.IsNullOrEmpty(this.Name);
53+
}
4454
}
4555
}

src/ResourceManager/Network/Commands.Network/Models/PSFrontendIpConfiguration.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,19 @@ public string InboundNatPoolsText
4848
get { return JsonConvert.SerializeObject(InboundNatPools, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
4949
}
5050

51+
public bool ShouldSerializeInboundNatRules()
52+
{
53+
return !string.IsNullOrEmpty(this.Name);
54+
}
55+
56+
public bool ShouldSerializeLoadBalancingRules()
57+
{
58+
return !string.IsNullOrEmpty(this.Name);
59+
}
60+
61+
public bool ShouldSerializeInboundNatPools()
62+
{
63+
return !string.IsNullOrEmpty(this.Name);
64+
}
5165
}
5266
}

src/ResourceManager/Network/Commands.Network/Models/PSInboundNatPool.cs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,12 @@ namespace Microsoft.Azure.Commands.Network.Models
1717
{
1818
using Newtonsoft.Json;
1919

20-
public class PSInboundNatPool : PSChildResource
20+
public class PSInboundNatPool : PSInboundRule
2121
{
22-
[JsonProperty(Order = 1)]
23-
public PSResourceId FrontendIPConfiguration { get; set; }
24-
2522
[JsonProperty(Order = 1)]
2623
public int FrontendPortRangeStart { get; set; }
2724

2825
[JsonProperty(Order = 1)]
2926
public int FrontendPortRangeEnd { get; set; }
30-
31-
[JsonProperty(Order = 1)]
32-
public int BackendPort { get; set; }
33-
34-
[JsonProperty(Order = 1)]
35-
public string Protocol { get; set; }
36-
37-
[JsonProperty(Order = 1)]
38-
public string ProvisioningState { get; set; }
39-
40-
[JsonIgnore]
41-
public string FrontendIPConfigurationText
42-
{
43-
get { return JsonConvert.SerializeObject(FrontendIPConfiguration, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
44-
}
4527
}
4628
}

src/ResourceManager/Network/Commands.Network/Models/PSInboundNatRule.cs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,29 @@ namespace Microsoft.Azure.Commands.Network.Models
1717
{
1818
using Newtonsoft.Json;
1919

20-
public class PSInboundNatRule : PSChildResource
20+
public class PSInboundNatRule : PSInboundRule
2121
{
2222
[JsonProperty(Order = 1)]
23-
public PSResourceId FrontendIPConfiguration { get; set; }
24-
25-
[JsonProperty(Order = 1)]
26-
public string Protocol { get; set; }
27-
28-
[JsonProperty(Order = 1)]
29-
public int? FrontendPort { get; set; }
30-
31-
[JsonProperty(Order = 1)]
32-
public int? BackendPort { get; set; }
23+
public int FrontendPort { get; set; }
3324

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

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

40-
[JsonProperty(Order = 1)]
41-
public string ProvisioningState { get; set; }
42-
4331
[JsonProperty(Order = 1)]
4432
public PSNetworkInterfaceIPConfiguration BackendIPConfiguration { get; set; }
4533

4634
[JsonIgnore]
47-
public string FrontendIPConfigurationText
35+
public string BackendIPConfigurationText
4836
{
49-
get { return JsonConvert.SerializeObject(FrontendIPConfiguration, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
37+
get { return JsonConvert.SerializeObject(BackendIPConfiguration, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
5038
}
5139

52-
[JsonIgnore]
53-
public string BackendIPConfigurationText
40+
public bool ShouldSerializeFrontendPort()
5441
{
55-
get { return JsonConvert.SerializeObject(BackendIPConfiguration, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
42+
return !string.IsNullOrEmpty(this.Name);
5643
}
5744
}
5845
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// Copyright (c) Microsoft. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
16+
namespace Microsoft.Azure.Commands.Network.Models
17+
{
18+
using Newtonsoft.Json;
19+
20+
public class PSInboundRule : PSChildResource
21+
{
22+
[JsonProperty(Order = 1)]
23+
public PSResourceId FrontendIPConfiguration { get; set; }
24+
25+
[JsonProperty(Order = 1)]
26+
public int BackendPort { get; set; }
27+
28+
[JsonProperty(Order = 1)]
29+
public string Protocol { get; set; }
30+
31+
[JsonProperty(Order = 1)]
32+
public string ProvisioningState { get; set; }
33+
34+
[JsonIgnore]
35+
public string FrontendIPConfigurationText
36+
{
37+
get { return JsonConvert.SerializeObject(FrontendIPConfiguration, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
38+
}
39+
40+
public bool ShouldSerializeBackendPort()
41+
{
42+
return !string.IsNullOrEmpty(this.Name);
43+
}
44+
}
45+
}

src/ResourceManager/Network/Commands.Network/Models/PSLoadBalancingRule.cs

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,16 @@ namespace Microsoft.Azure.Commands.Network.Models
1717
{
1818
using Newtonsoft.Json;
1919

20-
public class PSLoadBalancingRule : PSChildResource
20+
public class PSLoadBalancingRule : PSInboundRule
2121
{
22-
[JsonProperty(Order = 1)]
23-
public PSResourceId FrontendIPConfiguration { get; set; }
24-
2522
[JsonProperty(Order = 1)]
2623
public PSResourceId BackendAddressPool { get; set; }
2724

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

3128
[JsonProperty(Order = 1)]
32-
public string Protocol { get; set; }
33-
34-
[JsonProperty(Order = 1)]
35-
public int? FrontendPort { get; set; }
36-
37-
[JsonProperty(Order = 1)]
38-
public int? BackendPort { get; set; }
29+
public int FrontendPort { get; set; }
3930

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

49-
[JsonProperty(Order = 1)]
50-
public string ProvisioningState { get; set; }
51-
52-
[JsonIgnore]
53-
public string FrontendIPConfigurationText
54-
{
55-
get { return JsonConvert.SerializeObject(FrontendIPConfiguration, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
56-
}
57-
5840
[JsonIgnore]
5941
public string BackendAddressPoolText
6042
{
@@ -67,5 +49,9 @@ public string ProbeText
6749
get { return JsonConvert.SerializeObject(Probe, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
6850
}
6951

52+
public bool ShouldSerializeFrontendPort()
53+
{
54+
return !string.IsNullOrEmpty(this.Name);
55+
}
7056
}
7157
}

src/ResourceManager/Network/Commands.Network/Models/PSNetworkInterface.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,10 @@ public string NetworkSecurityGroupText
5959
{
6060
get { return JsonConvert.SerializeObject(NetworkSecurityGroup, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
6161
}
62+
63+
public bool ShouldSerializeIpConfigurations()
64+
{
65+
return !string.IsNullOrEmpty(this.Name);
66+
}
6267
}
6368
}

src/ResourceManager/Network/Commands.Network/Models/PSNetworkInterfaceIpConfiguration.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,15 @@ public string LoadBalancerInboundNatRulesText
3838
{
3939
get { return JsonConvert.SerializeObject(LoadBalancerInboundNatRules, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
4040
}
41+
42+
public bool ShouldSerializeLoadBalancerBackendAddressPools()
43+
{
44+
return !string.IsNullOrEmpty(this.Name);
45+
}
46+
47+
public bool ShouldSerializeLoadBalancerInboundNatRules()
48+
{
49+
return !string.IsNullOrEmpty(this.Name);
50+
}
4151
}
4252
}

src/ResourceManager/Network/Commands.Network/Models/PSNetworkSecurityGroup.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,25 @@ public string SubnetsText
5454
{
5555
get { return JsonConvert.SerializeObject(Subnets, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
5656
}
57+
58+
public bool ShouldSerializeSecurityRules()
59+
{
60+
return !string.IsNullOrEmpty(this.Name);
61+
}
62+
63+
public bool ShouldSerializeDefaultSecurityRules()
64+
{
65+
return !string.IsNullOrEmpty(this.Name);
66+
}
67+
68+
public bool ShouldSerializeNetworkInterfaces()
69+
{
70+
return !string.IsNullOrEmpty(this.Name);
71+
}
72+
73+
public bool ShouldSerializeSubnets()
74+
{
75+
return !string.IsNullOrEmpty(this.Name);
76+
}
5777
}
5878
}

src/ResourceManager/Network/Commands.Network/Models/PSProbe.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,20 @@ public string LoadBalancingRulesText
4747
{
4848
get { return JsonConvert.SerializeObject(LoadBalancingRules, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
4949
}
50+
51+
public bool ShouldSerializePort()
52+
{
53+
return !string.IsNullOrEmpty(this.Name);
54+
}
55+
56+
public bool ShouldSerializeIntervalInSeconds()
57+
{
58+
return !string.IsNullOrEmpty(this.Name);
59+
}
60+
61+
public bool ShouldSerializeNumberOfProbes()
62+
{
63+
return !string.IsNullOrEmpty(this.Name);
64+
}
5065
}
5166
}

src/ResourceManager/Network/Commands.Network/Models/PSRouteTable.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,15 @@ public string SubnetsText
3838
{
3939
get { return JsonConvert.SerializeObject(Subnets, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
4040
}
41+
42+
public bool ShouldSerializeSubnets()
43+
{
44+
return !string.IsNullOrEmpty(this.Name);
45+
}
46+
47+
public bool ShouldSerializeRoutes()
48+
{
49+
return !string.IsNullOrEmpty(this.Name);
50+
}
4151
}
4252
}

src/ResourceManager/Network/Commands.Network/Models/PSSubnet.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
namespace Microsoft.Azure.Commands.Network.Models
1616
{
1717
using System.Collections.Generic;
18+
using System.Runtime.CompilerServices;
1819

1920
using Newtonsoft.Json;
2021

@@ -52,5 +53,10 @@ public string RouteTableText
5253
{
5354
get { return JsonConvert.SerializeObject(RouteTable, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
5455
}
56+
57+
public bool ShouldSerializeIpConfigurations()
58+
{
59+
return !string.IsNullOrEmpty(this.Name);
60+
}
5561
}
5662
}

0 commit comments

Comments
 (0)