4862 - Disallow Burn Variables that are Hidden and Persisted.
Sean Hall committed
Dec 19, 2020 at 14:41 UTC
85deb61f666f6817c1a137ace4d666c8ae2940fb
5 files changed
+36
-2
src/WixToolset.Core/Compiler_Bundle.cs
+5
@@ -3178,6 +3178,11 @@ namespace WixToolset.Core
3178
this.Core.Write(ErrorMessages.ReservedNamespaceViolation(sourceLineNumbers, node.Name.LocalName, "Name", "Wix"));
3179
}
3180
3181
+ if (hidden && persisted)
3182
+ {
3183
+ this.Core.Write(ErrorMessages.IllegalAttributeValueWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "Hidden", "yes", "Persisted"));
3184
+ }
3185
+
3186
var type = this.ValidateVariableTypeWithValue(sourceLineNumbers, node, typeValue, value);
3187
3188
this.Core.ParseForExtensionElements(node);
src/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs
+23
@@ -55,5 +55,28 @@ namespace WixToolsetTest.CoreIntegration
55
Assert.Equal(21, result.ExitCode);
56
}
57
}
58
+
59
+ [Fact]
60
+ public void BundleVariableWithHiddenPersistedIsRejected()
61
+ {
62
+ var folder = TestData.Get(@"TestData\BadInput");
63
+
64
+ using (var fs = new DisposableFileSystem())
65
+ {
66
+ var baseFolder = fs.GetFolder();
67
+ var intermediateFolder = Path.Combine(baseFolder, "obj");
68
+ var wixlibPath = Path.Combine(intermediateFolder, @"test.wixlib");
69
+
70
+ var result = WixRunner.Execute(new[]
71
+ {
72
+ "build",
73
+ Path.Combine(folder, "HiddenPersistedBundleVariable.wxs"),
74
+ "-intermediateFolder", intermediateFolder,
75
+ "-o", wixlibPath,
76
+ });
77
+
78
+ Assert.Equal(193, result.ExitCode);
79
+ }
80
+ }
81
}
82
}
src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/BundleVariable.wxs
+1
-2
@@ -1,6 +1,5 @@
1
<?xml version="1.0" encoding="utf-8" ?>
2
-<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
3
- xmlns:ex="http://www.example.com/scheams/v1/wxs">
2
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3
<Fragment>
4
<Variable Name="BadType" Type="doesnotexist" Value="dne" />
5
</Fragment>
src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/HiddenPersistedBundleVariable.wxs
new
+6
@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="utf-8" ?>
2
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3
+ <Fragment>
4
+ <Variable Name="BadType" Hidden="yes" Persisted="yes" Value="dne" />
5
+ </Fragment>
6
+</Wix>
src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
+1
@@ -21,6 +21,7 @@
21
<Content Include="TestData\BadInput\BundleVariable.wxs" CopyToOutputDirectory="PreserveNewest" />
22
<Content Include="TestData\BadInput\DuplicateCacheIds.wxs" CopyToOutputDirectory="PreserveNewest" />
23
<Content Include="TestData\BadInput\DuplicatePayloadNames.wxs" CopyToOutputDirectory="PreserveNewest" />
24
+ <Content Include="TestData\BadInput\HiddenPersistedBundleVariable.wxs" CopyToOutputDirectory="PreserveNewest" />
25
<Content Include="TestData\BadInput\RegistryKey.wxs" CopyToOutputDirectory="PreserveNewest" />
26
<Content Include="TestData\BadInput\UnscheduledPackage.wxs" CopyToOutputDirectory="PreserveNewest" />
27
<Content Include="TestData\BadInput\UnscheduledRollbackBoundary.wxs" CopyToOutputDirectory="PreserveNewest" />