Skip to content

Commit 29a4e0b

Browse files
authored
Add checks for missing strings in the LocalizedStrings (#77)
* Hide tempate event function * Added validation that all ETW required strings are in the localization file * readding removed newline
1 parent df79bad commit 29a4e0b

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

TameMyCerts.Tests/ETWTests.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,27 @@ public void VerifyEventIDs()
6666
_ = method.Invoke(ETWLogger.Log, parameterValues);
6767
// This checks that there is a event with the correct ID has been registered
6868
Assert.Equal(eventId, _listener.Events[0].EventId);
69-
//output.WriteLine($"Found the {method.Name}");
69+
//_output.WriteLine(_listener.Events[0].Message);
70+
}
71+
}
72+
73+
[Fact]
74+
public void ValidateEventStrings()
75+
{
76+
var loggerType = typeof(ETWLogger);
77+
78+
var methods = loggerType.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
79+
foreach (var method in methods)
80+
{
81+
82+
var localizedStringProperty = typeof(LocalizedStrings).GetProperty($"event_{method.Name}", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
83+
84+
if (localizedStringProperty is null)
85+
{
86+
Assert.Fail($"No localized string found for method event_{method.Name}");
87+
}
88+
89+
7090
}
7191
}
7292
}

TameMyCerts/ETWLogger.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ public void YKVal_4209_Found_Attestation_Location(int requestId, string attestat
244244

245245
#region Certificate Content Validator events 4601-4799
246246

247+
/*
247248
[Event(4601, Level = EventLevel.Informational, Channel = EventChannel.Operational,
248249
Task = Tasks.CertificateContentValidator, Keywords = EventKeywords.None)]
249250
public void CCVal_4601_(string denyingPolicy, int requestId)
@@ -253,6 +254,7 @@ public void CCVal_4601_(string denyingPolicy, int requestId)
253254
WriteEvent(4601, denyingPolicy, requestId);
254255
}
255256
}
257+
*/
256258

257259
[Event(4651, Level = EventLevel.Verbose, Channel = EventChannel.Debug, Task = Tasks.CertificateContentValidator,
258260
Keywords = EventKeywords.None)]

0 commit comments

Comments
 (0)