Skip to content

Commit 366b71f

Browse files
committed
scrub creator
1 parent 5540d95 commit 366b71f

14 files changed

Lines changed: 49 additions & 48 deletions

File tree

src/DeterministicIoPackaging/Patching/CorePatcher.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
class CorePatcher :
22
IPatcher
33
{
4+
static XNamespace dc = "http://purl.org/dc/elements/1.1/";
5+
static XName creator = dc + "creator";
46
static XNamespace cp = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties";
57
static XName lastModifiedBy = cp + "lastModifiedBy";
68
static XNamespace dcterms = "http://purl.org/dc/terms/";
@@ -10,6 +12,7 @@
1012
public void PatchXml(XDocument xml)
1113
{
1214
var root = xml.Root!;
15+
root.Element(creator)?.Remove();
1316
root.Element(lastModifiedBy)?.Remove();
1417
root.Element(created)?.Remove();
1518
root.Element(modified)?.Remove();

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project>
33
<PropertyGroup>
44
<NoWarn>CS1591;CS0649;CA1416;NU1608;NU1109</NoWarn>
5-
<Version>0.9.0</Version>
5+
<Version>0.10.0</Version>
66
<LangVersion>preview</LangVersion>
77
<AssemblyVersion>1.0.0</AssemblyVersion>
88
<Description>Modify System.IO.Packaging (https://learn.microsoft.com/en-us/dotnet/api/system.io.packaging) files to ensure they are deterministic. Helpful for testing, build reproducibility, security verification, and ensuring package integrity across different build environments.</Description>

src/Tests/Patching/CorePatcherTests.Patch.DotNet.verified.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
22
<dc:title>The Title</dc:title>
33
<dc:subject />
4-
<dc:creator />
54
<cp:keywords />
65
<dc:description />
76
<cp:category />

src/Tests/Patching/CorePatcherTests.Patch.Net.verified.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
22
<dc:title>The Title</dc:title>
33
<dc:subject />
4-
<dc:creator />
54
<cp:keywords />
65
<dc:description />
76
<cp:category />

src/Tests/Patching/CorePatcherTests.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ public Task Patch()
88
"""
99
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1010
<cp:coreProperties
11-
xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
12-
xmlns:dc="http://purl.org/dc/elements/1.1/"
13-
xmlns:dcterms="http://purl.org/dc/terms/"
14-
xmlns:dcmitype="http://purl.org/dc/dcmitype/"
15-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
16-
<dc:title>The Title</dc:title>
17-
<dc:subject />
18-
<dc:creator />
19-
<cp:keywords />
20-
<dc:description />
21-
<cp:lastModifiedBy>Simon Cropp</cp:lastModifiedBy>
22-
<dcterms:created xsi:type="dcterms:W3CDTF">2020-01-01T00:00:00Z</dcterms:created>
23-
<dcterms:modified xsi:type="dcterms:W3CDTF">2020-01-01T00:00:00Z</dcterms:modified>
24-
<cp:category />
11+
xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
12+
xmlns:dc="http://purl.org/dc/elements/1.1/"
13+
xmlns:dcterms="http://purl.org/dc/terms/"
14+
xmlns:dcmitype="http://purl.org/dc/dcmitype/"
15+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
16+
<dc:title>The Title</dc:title>
17+
<dc:subject />
18+
<cp:keywords />
19+
<dc:description />
20+
<cp:lastModifiedBy>Simon Cropp</cp:lastModifiedBy>
21+
<dc:creator>simon</dc:creator>
22+
<dcterms:created xsi:type="dcterms:W3CDTF">2020-01-01T00:00:00Z</dcterms:created>
23+
<dcterms:modified xsi:type="dcterms:W3CDTF">2020-01-01T00:00:00Z</dcterms:modified>
24+
<cp:category />
2525
</cp:coreProperties>
2626
""";
2727

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
[TestFixture]
22
public class RelationshipPatcherTests
33
{
4-
[Test]
5-
public Task Patch()
6-
{
7-
var xml =
8-
"""
9-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
10-
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
11-
<Relationship
12-
Id="rId2"
13-
Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"
14-
Target="docProps/core.xml"/>
15-
<Relationship
16-
Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"
17-
Target="docProps/app.xml"/>
18-
<Relationship
19-
Id="rId1"
20-
Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
21-
Target="xl/workbook.xml"/>
22-
<Relationship
23-
Id="rId4"
24-
Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"
25-
Target="package/services/metadata/core-properties/f81c51cec5594be694368ed6b7beba9.psmdcp"/>
26-
</Relationships>
27-
""";
28-
var document = PatchHelper.Patch<RelationshipPatcher>(xml);
29-
return Verify(document);
30-
}
4+
[Test]
5+
public Task Patch()
6+
{
7+
var xml =
8+
"""
9+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
10+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
11+
<Relationship
12+
Id="rId2"
13+
Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"
14+
Target="docProps/core.xml"/>
15+
<Relationship
16+
Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"
17+
Target="docProps/app.xml"/>
18+
<Relationship
19+
Id="rId1"
20+
Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
21+
Target="xl/workbook.xml"/>
22+
<Relationship
23+
Id="rId4"
24+
Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"
25+
Target="package/services/metadata/core-properties/f81c51cec5594be694368ed6b7beba9.psmdcp"/>
26+
</Relationships>
27+
""";
28+
var document = PatchHelper.Patch<RelationshipPatcher>(xml);
29+
return Verify(document);
30+
}
3131
}
-12 Bytes
Binary file not shown.
-6 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?xml version="1.0" encoding="utf-8" standalone="yes"?><cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:title>The Title</dc:title><dc:subject /><dc:creator /><cp:keywords /><dc:description /><cp:category /></cp:coreProperties>
1+
<?xml version="1.0" encoding="utf-8" standalone="yes"?><cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:title>The Title</dc:title><dc:subject /><cp:keywords /><dc:description /><cp:category /></cp:coreProperties>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?xml version="1.0" encoding="utf-8" standalone="yes"?><cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:title>The Title</dc:title><dc:subject /><dc:creator /><cp:keywords /><dc:description /><cp:category /></cp:coreProperties>
1+
<?xml version="1.0" encoding="utf-8" standalone="yes"?><cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:title>The Title</dc:title><dc:subject /><cp:keywords /><dc:description /><cp:category /></cp:coreProperties>

0 commit comments

Comments
 (0)