Remove use of RemoteAddress inner text
Rob Mensching committed
Jun 27, 2020 at 14:06 UTC
8181317ba1b9f718b6e54ce13cba04351e464c01
5 files changed
+38
-41
src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs
+1
-1
@@ -6,7 +6,7 @@
6
<Component>
7
<File Source="example.txt" />
8
<fw:FirewallException Id="ExampleFirewall" Description="An example firewall" Name="example" Port="42">
9
- <fw:RemoteAddress>*</fw:RemoteAddress>
9
+ <fw:RemoteAddress Value="*" />
10
</fw:FirewallException>
11
</Component>
12
</ComponentGroup>
src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs
+1
-1
@@ -6,7 +6,7 @@
6
<Component>
7
<File Source="example.txt" />
8
<fw:FirewallException Description="An example outbound firewall" Name="example" Port="42" Outbound="yes">
9
- <fw:RemoteAddress>*</fw:RemoteAddress>
9
+ <fw:RemoteAddress Value="*" />
10
</fw:FirewallException>
11
</Component>
12
</ComponentGroup>
src/wixext/FirewallCompiler.cs
+8
-3
@@ -312,13 +312,19 @@ namespace WixToolset.Firewall
312
private void ParseRemoteAddressElement(Intermediate intermediate, IntermediateSection section, XElement element, ref string remoteAddresses)
313
{
314
var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element);
315
+ string address = null;
316
317
// no attributes
318
foreach (var attrib in element.Attributes())
319
{
320
if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace)
321
{
321
- this.ParseHelper.UnexpectedAttribute(element, attrib);
322
+ switch (attrib.Name.LocalName)
323
+ {
324
+ case "Value":
325
+ address = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
326
+ break;
327
+ }
328
}
329
else
330
{
@@ -328,10 +334,9 @@ namespace WixToolset.Firewall
334
335
this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);
336
331
- var address = this.ParseHelper.GetTrimmedInnerText(element);
337
if (String.IsNullOrEmpty(address))
338
{
334
- this.Messaging.Write(FirewallErrors.IllegalEmptyRemoteAddress(sourceLineNumbers));
339
+ this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Value"));
340
}
341
else
342
{
src/wixext/FirewallErrors.cs
-6
@@ -12,11 +12,6 @@ namespace WixToolset.Firewall
12
return Message(sourceLineNumbers, Ids.IllegalRemoteAddressWithScopeAttribute, "The RemoteAddress element cannot be specified because its parent FirewallException already specified the Scope attribute. To use RemoteAddress elements, omit the Scope attribute.");
13
}
14
15
- public static Message IllegalEmptyRemoteAddress(SourceLineNumber sourceLineNumbers)
16
- {
17
- return Message(sourceLineNumbers, Ids.IllegalEmptyRemoteAddress, "The RemoteAddress element's inner text cannot be an empty string or completely whitespace.");
18
- }
19
-
15
public static Message NoExceptionSpecified(SourceLineNumber sourceLineNumbers)
16
{
17
return Message(sourceLineNumbers, Ids.NoExceptionSpecified, "The FirewallException element doesn't identify the target of the firewall exception. To create an application exception, nest the FirewallException element under a File element or provide a value for the File or Program attributes. To create a port exception, provide a value for the Port attribute.");
@@ -35,7 +30,6 @@ namespace WixToolset.Firewall
30
public enum Ids
31
{
32
IllegalRemoteAddressWithScopeAttribute = 6401,
38
- IllegalEmptyRemoteAddress = 6402,
33
NoExceptionSpecified = 6403,
34
}
35
}
src/wixext/firewall.xsd
+28
-30
@@ -33,7 +33,7 @@
33
<xs:choice minOccurs="0" maxOccurs="unbounded">
34
<xs:annotation>
35
<xs:documentation>
36
- Explicitly-listed remote addresses that this exception allows through the
36
+ Explicitly-listed remote addresses that this exception allows through the
37
firewall.
38
</xs:documentation>
39
</xs:annotation>
@@ -51,7 +51,7 @@
51
<xs:attribute name="Name" type="xs:string" use="required">
52
<xs:annotation>
53
<xs:documentation>
54
- Name of this firewall exception, visible to the user in the firewall
54
+ Name of this firewall exception, visible to the user in the firewall
55
control panel.
56
</xs:documentation>
57
</xs:annotation>
@@ -63,7 +63,7 @@
63
The scope of this firewall exception, which indicates whether incoming
64
connections can come from any computer including those on the Internet
65
or only those on the local network subnet. To more precisely specify
66
- allowed remote address, specify a custom scope using RemoteAddress
66
+ allowed remote address, specify a custom scope using RemoteAddress
67
child elements.
68
</xs:documentation>
69
</xs:annotation>
@@ -78,10 +78,10 @@
78
<xs:attribute name="Port" type="xs:string">
79
<xs:annotation>
80
<xs:documentation>
81
- Port to allow through the firewall for this exception.
81
+ Port to allow through the firewall for this exception.
82
83
- If you use Port and also File or Program in the same
84
- FirewallException element, the exception will fail to install on
83
+ If you use Port and also File or Program in the same
84
+ FirewallException element, the exception will fail to install on
85
Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to
86
ignore the resulting failure, but the exception will not be added.
87
</xs:documentation>
@@ -91,11 +91,11 @@
91
<xs:attribute name="Protocol">
92
<xs:annotation>
93
<xs:documentation>
94
- IP protocol used for this firewall exception. If Port is defined,
95
- "tcp" is assumed if the protocol is not specified.
94
+ IP protocol used for this firewall exception. If Port is defined,
95
+ "tcp" is assumed if the protocol is not specified.
96
97
- If you use Protocol and also File or Program in the same
98
- FirewallException element, the exception will fail to install on
97
+ If you use Protocol and also File or Program in the same
98
+ FirewallException element, the exception will fail to install on
99
Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to
100
ignore the resulting failure, but the exception will not be added.
101
</xs:documentation>
@@ -111,11 +111,11 @@
111
<xs:attribute name="File" type="xs:string">
112
<xs:annotation>
113
<xs:documentation>
114
- Identifier of a file to be granted access to all incoming ports and
114
+ Identifier of a file to be granted access to all incoming ports and
115
protocols. If you use File, you cannot also use Program.
116
117
- If you use File and also Port or Protocol in the same
118
- FirewallException element, the exception will fail to install on
117
+ If you use File and also Port or Protocol in the same
118
+ FirewallException element, the exception will fail to install on
119
Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to
120
ignore the resulting failure, but the exception will not be added.
121
</xs:documentation>
@@ -125,13 +125,13 @@
125
<xs:attribute name="Program" type="xs:string">
126
<xs:annotation>
127
<xs:documentation>
128
- Path to a target program to be granted access to all incoming ports and
129
- protocols. Note that this is a formatted field, so you can use [#fileId]
130
- syntax to refer to a file being installed. If you use Program, you cannot
128
+ Path to a target program to be granted access to all incoming ports and
129
+ protocols. Note that this is a formatted field, so you can use [#fileId]
130
+ syntax to refer to a file being installed. If you use Program, you cannot
131
also use File.
132
133
- If you use Program and also Port or Protocol in the same
134
- FirewallException element, the exception will fail to install on
133
+ If you use Program and also Port or Protocol in the same
134
+ FirewallException element, the exception will fail to install on
135
Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to
136
ignore the resulting failure, but the exception will not be added.
137
</xs:documentation>
@@ -141,7 +141,7 @@
141
<xs:attribute name="IgnoreFailure" type="YesNoType">
142
<xs:annotation>
143
<xs:documentation>
144
- If "yes", failures to register this firewall exception will be silently
144
+ If "yes", failures to register this firewall exception will be silently
145
ignored. If "no" (the default), failures will cause rollback.
146
</xs:documentation>
147
</xs:annotation>
@@ -165,7 +165,7 @@
165
<xs:attribute name="Description" type="xs:string">
166
<xs:annotation>
167
<xs:documentation>
168
- Description for this firewall rule displayed in Windows Firewall manager in
168
+ Description for this firewall rule displayed in Windows Firewall manager in
169
Windows Vista and later.
170
</xs:documentation>
171
</xs:annotation>
@@ -184,26 +184,24 @@
184
<xs:element name="RemoteAddress">
185
<xs:annotation>
186
<xs:documentation>
187
- A remote address to which the port or program can listen. Address formats vary
187
+ A remote address to which the port or program can listen. Address formats vary
188
based on the version of Windows and Windows Firewall the program is being installed
189
on. For Windows XP SP2 and Windows Server 2003 SP1, see
190
<html:a href="http://msdn.microsoft.com/en-us/library/aa365270.aspx">
191
RemoteAddresses Property</html:a>.
192
For Windows Vista and Windows Server 2008, see
193
- <html:a href="http://msdn.microsoft.com/en-us/library/aa365366.aspx">
193
+ <html:a href="https://docs.microsoft.com/en-us/windows/win32/api/netfw/nf-netfw-inetfwrule-get_remoteaddresses">
194
RemoteAddresses Property</html:a>.
195
</xs:documentation>
196
</xs:annotation>
197
<xs:complexType>
198
- <xs:simpleContent>
199
- <xs:extension base="xs:string">
200
- <xs:annotation>
201
- <xs:documentation>
198
+ <xs:attribute name="Value" type="xs:string" use="required">
199
+ <xs:annotation>
200
+ <xs:documentation>
201
A remote address.
203
- </xs:documentation>
204
- </xs:annotation>
205
- </xs:extension>
206
- </xs:simpleContent>
202
+ </xs:documentation>
203
+ </xs:annotation>
204
+ </xs:attribute>
205
</xs:complexType>
206
</xs:element>
207