diff options
author | chris_bednarski <Chris.Bednarski@minfos.com.au> | 2023-08-26 18:51:38 +1000 |
---|---|---|
committer | Bob Arnson <github@bobs.org> | 2023-11-19 12:17:13 -0500 |
commit | 80e604761b4f43b9b79a4878fcae360b071a7c35 (patch) | |
tree | 9ca40a1d60a2ef1a5a1a426382356ae8b7cf9868 /src/ext/Firewall/wixext | |
parent | 6e974490eeabc9a3728aa2fb9ad07e8a5adf4fb6 (diff) | |
download | wix-80e604761b4f43b9b79a4878fcae360b071a7c35.tar.gz wix-80e604761b4f43b9b79a4878fcae360b071a7c35.tar.bz2 wix-80e604761b4f43b9b79a4878fcae360b071a7c35.zip |
change firewall extension table name to Wix5FirewallException
Diffstat (limited to 'src/ext/Firewall/wixext')
-rw-r--r-- | src/ext/Firewall/wixext/FirewallCompiler.cs | 40 | ||||
-rw-r--r-- | src/ext/Firewall/wixext/FirewallDecompiler.cs | 40 | ||||
-rw-r--r-- | src/ext/Firewall/wixext/FirewallTableDefinitions.cs | 6 |
3 files changed, 66 insertions, 20 deletions
diff --git a/src/ext/Firewall/wixext/FirewallCompiler.cs b/src/ext/Firewall/wixext/FirewallCompiler.cs index 19ee0b6d..ed49ba9c 100644 --- a/src/ext/Firewall/wixext/FirewallCompiler.cs +++ b/src/ext/Firewall/wixext/FirewallCompiler.cs | |||
@@ -135,7 +135,12 @@ namespace WixToolset.Firewall | |||
135 | protocol = FirewallConstants.NET_FW_IP_PROTOCOL_UDP; | 135 | protocol = FirewallConstants.NET_FW_IP_PROTOCOL_UDP; |
136 | break; | 136 | break; |
137 | default: | 137 | default: |
138 | this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, "Protocol", protocolValue, "tcp", "udp")); | 138 | int parsedProtocol; |
139 | if (!Int32.TryParse(protocolValue, out parsedProtocol) || parsedProtocol > 255 || parsedProtocol < 0) | ||
140 | { | ||
141 | this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, "Protocol", protocolValue, "tcp", "udp", "0-255")); | ||
142 | } | ||
143 | protocol = parsedProtocol; | ||
139 | break; | 144 | break; |
140 | } | 145 | } |
141 | break; | 146 | break; |
@@ -149,8 +154,20 @@ namespace WixToolset.Firewall | |||
149 | case "localSubnet": | 154 | case "localSubnet": |
150 | remoteAddresses = "LocalSubnet"; | 155 | remoteAddresses = "LocalSubnet"; |
151 | break; | 156 | break; |
157 | case "DNS": | ||
158 | remoteAddresses = "dns"; | ||
159 | break; | ||
160 | case "DHCP": | ||
161 | remoteAddresses = "dhcp"; | ||
162 | break; | ||
163 | case "WINS": | ||
164 | remoteAddresses = "wins"; | ||
165 | break; | ||
166 | case "defaultGateway": | ||
167 | remoteAddresses = "DefaultGateway"; | ||
168 | break; | ||
152 | default: | 169 | default: |
153 | this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, "Scope", scope, "any", "localSubnet")); | 170 | this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, "Scope", scope, "any", "localSubnet", "DNS", "DHCP", "WINS", "defaultGateway")); |
154 | break; | 171 | break; |
155 | } | 172 | } |
156 | break; | 173 | break; |
@@ -251,6 +268,21 @@ namespace WixToolset.Firewall | |||
251 | this.Messaging.Write(FirewallErrors.NoExceptionSpecified(sourceLineNumbers)); | 268 | this.Messaging.Write(FirewallErrors.NoExceptionSpecified(sourceLineNumbers)); |
252 | } | 269 | } |
253 | 270 | ||
271 | // Ports can only be specified if the protocol is TCP or UDP. | ||
272 | if (!String.IsNullOrEmpty(port) && protocol.HasValue) | ||
273 | { | ||
274 | switch(protocol.Value) | ||
275 | { | ||
276 | case FirewallConstants.NET_FW_IP_PROTOCOL_TCP: | ||
277 | case FirewallConstants.NET_FW_IP_PROTOCOL_UDP: | ||
278 | break; | ||
279 | |||
280 | default: | ||
281 | this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, element.Name.LocalName, "Port", "Protocol", protocol.Value.ToString())); | ||
282 | break; | ||
283 | } | ||
284 | } | ||
285 | |||
254 | if (!this.Messaging.EncounteredError) | 286 | if (!this.Messaging.EncounteredError) |
255 | { | 287 | { |
256 | // at this point, File attribute and File parent element are treated the same | 288 | // at this point, File attribute and File parent element are treated the same |
@@ -300,8 +332,8 @@ namespace WixToolset.Firewall | |||
300 | symbol.Attributes = attributes; | 332 | symbol.Attributes = attributes; |
301 | } | 333 | } |
302 | 334 | ||
303 | this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedFirewallExceptionsInstall", this.Context.Platform, CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); | 335 | this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix5SchedFirewallExceptionsInstall", this.Context.Platform, CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); |
304 | this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedFirewallExceptionsUninstall", this.Context.Platform, CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); | 336 | this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix5SchedFirewallExceptionsUninstall", this.Context.Platform, CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); |
305 | } | 337 | } |
306 | } | 338 | } |
307 | 339 | ||
diff --git a/src/ext/Firewall/wixext/FirewallDecompiler.cs b/src/ext/Firewall/wixext/FirewallDecompiler.cs index 69f2c3f4..9ddd8a9a 100644 --- a/src/ext/Firewall/wixext/FirewallDecompiler.cs +++ b/src/ext/Firewall/wixext/FirewallDecompiler.cs | |||
@@ -32,7 +32,7 @@ namespace WixToolset.Firewall | |||
32 | { | 32 | { |
33 | switch (table.Name) | 33 | switch (table.Name) |
34 | { | 34 | { |
35 | case "Wix4FirewallException": | 35 | case "Wix5FirewallException": |
36 | this.DecompileWixFirewallExceptionTable(table); | 36 | this.DecompileWixFirewallExceptionTable(table); |
37 | break; | 37 | break; |
38 | default: | 38 | default: |
@@ -69,18 +69,29 @@ namespace WixToolset.Firewall | |||
69 | string[] addresses = ((string)row[2]).Split(','); | 69 | string[] addresses = ((string)row[2]).Split(','); |
70 | if (addresses.Length == 1) | 70 | if (addresses.Length == 1) |
71 | { | 71 | { |
72 | // special-case the Scope attribute values | 72 | switch(addresses[0]) |
73 | if (addresses[0] == "*") | ||
74 | { | 73 | { |
75 | firewallException.Add(new XAttribute("Scope", "any")); | 74 | case "*": |
76 | } | 75 | firewallException.Add(new XAttribute("Scope", "any")); |
77 | else if (addresses[0] == "LocalSubnet") | 76 | break; |
78 | { | 77 | case "LocalSubnet": |
79 | firewallException.Add(new XAttribute("Scope", "localSubnet")); | 78 | firewallException.Add(new XAttribute("Scope", "localSubnet")); |
80 | } | 79 | break; |
81 | else | 80 | case "dns": |
82 | { | 81 | firewallException.Add(new XAttribute("Scope", "DNS")); |
83 | FirewallDecompiler.AddRemoteAddress(firewallException, addresses[0]); | 82 | break; |
83 | case "dhcp": | ||
84 | firewallException.Add(new XAttribute("Scope", "DHCP")); | ||
85 | break; | ||
86 | case "wins": | ||
87 | firewallException.Add(new XAttribute("Scope", "WINS")); | ||
88 | break; | ||
89 | case "DefaultGateway": | ||
90 | firewallException.Add(new XAttribute("Scope", "defaultGateway")); | ||
91 | break; | ||
92 | default: | ||
93 | FirewallDecompiler.AddRemoteAddress(firewallException, addresses[0]); | ||
94 | break; | ||
84 | } | 95 | } |
85 | } | 96 | } |
86 | else | 97 | else |
@@ -107,6 +118,9 @@ namespace WixToolset.Firewall | |||
107 | case FirewallConstants.NET_FW_IP_PROTOCOL_UDP: | 118 | case FirewallConstants.NET_FW_IP_PROTOCOL_UDP: |
108 | firewallException.Add(new XAttribute("Protocol", "udp")); | 119 | firewallException.Add(new XAttribute("Protocol", "udp")); |
109 | break; | 120 | break; |
121 | default: | ||
122 | firewallException.Add(new XAttribute("Protocol", row[4])); | ||
123 | break; | ||
110 | } | 124 | } |
111 | } | 125 | } |
112 | 126 | ||
@@ -183,7 +197,7 @@ namespace WixToolset.Firewall | |||
183 | /// <param name="tables">Collection of all tables.</param> | 197 | /// <param name="tables">Collection of all tables.</param> |
184 | private void FinalizeFirewallExceptionTable(TableIndexedCollection tables) | 198 | private void FinalizeFirewallExceptionTable(TableIndexedCollection tables) |
185 | { | 199 | { |
186 | if (tables.TryGetTable("Wix4FirewallException", out var firewallExceptionTable)) | 200 | if (tables.TryGetTable("Wix5FirewallException", out var firewallExceptionTable)) |
187 | { | 201 | { |
188 | foreach (var row in firewallExceptionTable.Rows) | 202 | foreach (var row in firewallExceptionTable.Rows) |
189 | { | 203 | { |
diff --git a/src/ext/Firewall/wixext/FirewallTableDefinitions.cs b/src/ext/Firewall/wixext/FirewallTableDefinitions.cs index 04918f5f..26dedbf1 100644 --- a/src/ext/Firewall/wixext/FirewallTableDefinitions.cs +++ b/src/ext/Firewall/wixext/FirewallTableDefinitions.cs | |||
@@ -7,15 +7,15 @@ namespace WixToolset.Firewall | |||
7 | public static class FirewallTableDefinitions | 7 | public static class FirewallTableDefinitions |
8 | { | 8 | { |
9 | public static readonly TableDefinition WixFirewallException = new TableDefinition( | 9 | public static readonly TableDefinition WixFirewallException = new TableDefinition( |
10 | "Wix4FirewallException", | 10 | "Wix5FirewallException", |
11 | FirewallSymbolDefinitions.WixFirewallException, | 11 | FirewallSymbolDefinitions.WixFirewallException, |
12 | new[] | 12 | new[] |
13 | { | 13 | { |
14 | new ColumnDefinition("Wix4FirewallException", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The primary key, a non-localized token.", modularizeType: ColumnModularizeType.Column), | 14 | new ColumnDefinition("Wix5FirewallException", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The primary key, a non-localized token.", modularizeType: ColumnModularizeType.Column), |
15 | new ColumnDefinition("Name", ColumnType.Localized, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Localizable display name.", modularizeType: ColumnModularizeType.Property), | 15 | new ColumnDefinition("Name", ColumnType.Localized, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Localizable display name.", modularizeType: ColumnModularizeType.Property), |
16 | new ColumnDefinition("RemoteAddresses", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Remote address to accept incoming connections from.", modularizeType: ColumnModularizeType.Property), | 16 | new ColumnDefinition("RemoteAddresses", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Remote address to accept incoming connections from.", modularizeType: ColumnModularizeType.Property), |
17 | new ColumnDefinition("Port", ColumnType.String, 0, primaryKey: false, nullable: true, ColumnCategory.Formatted, minValue: 1, description: "Port number.", modularizeType: ColumnModularizeType.Property), | 17 | new ColumnDefinition("Port", ColumnType.String, 0, primaryKey: false, nullable: true, ColumnCategory.Formatted, minValue: 1, description: "Port number.", modularizeType: ColumnModularizeType.Property), |
18 | new ColumnDefinition("Protocol", ColumnType.Number, 1, primaryKey: false, nullable: true, ColumnCategory.Integer, minValue: 6, maxValue: 17, description: "Protocol (6=TCP; 17=UDP)."), | 18 | new ColumnDefinition("Protocol", ColumnType.Number, 1, primaryKey: false, nullable: true, ColumnCategory.Integer, minValue: 0, maxValue: 255, description: "Protocol (6=TCP; 17=UDP). https://www.iana.org/assignments/protocol-numbers"), |
19 | new ColumnDefinition("Program", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Exception for a program (formatted path name).", modularizeType: ColumnModularizeType.Property), | 19 | new ColumnDefinition("Program", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Exception for a program (formatted path name).", modularizeType: ColumnModularizeType.Property), |
20 | new ColumnDefinition("Attributes", ColumnType.Number, 4, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Vital=1"), | 20 | new ColumnDefinition("Attributes", ColumnType.Number, 4, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Vital=1"), |
21 | new ColumnDefinition("Profile", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Integer, minValue: 1, maxValue: 2147483647, description: "Profile (1=domain; 2=private; 4=public; 2147483647=all)."), | 21 | new ColumnDefinition("Profile", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Integer, minValue: 1, maxValue: 2147483647, description: "Profile (1=domain; 2=private; 4=public; 2147483647=all)."), |