@@ -25,7 +25,7 @@ internal static class Issues {
2525 private const int DISK_SPACE_THRESHOLD = 85 ;
2626 private const int DISK_IO_THRESHOLD = 75 ;
2727
28- public enum SeverityLevel {
28+ public enum SeverityLevel : byte {
2929 info = 1 ,
3030 warning = 2 ,
3131 error = 3 ,
@@ -228,6 +228,10 @@ public static void ScanDevice(Database.Entry device) {
228228 issues . Add ( issue . Value ) ;
229229 }
230230
231+ if ( CheckWindowsLifecycle ( device , out Issue ? lifecycleIssue ) && lifecycleIssue . HasValue ) {
232+ issues . Add ( lifecycleIssue . Value ) ;
233+ }
234+
231235 if ( osAttribute ? . value . Contains ( "windows" , StringComparison . OrdinalIgnoreCase ) == true ) {
232236 string ipString = null ;
233237 if ( device . attributes . TryGetValue ( "ip" , out Database . Attribute ip ) && ! String . IsNullOrEmpty ( ip ? . value ) ) {
@@ -288,7 +292,7 @@ public static void CheckIpAddresses(out Dictionary<string, Database.Entry> ipAdd
288292 name = nameAttribute ? . value ?? String . Empty ,
289293 identifier = ips [ i ] ,
290294 category = "Database" ,
291- source = "Internal check " ,
295+ source = "Internal" ,
292296 file = device . Value . filename ,
293297 isUser = false ,
294298 } ) ;
@@ -324,7 +328,7 @@ public static void CheckMacAddresses() {
324328 name = nameAttribute ? . value ?? String . Empty ,
325329 identifier = macs [ i ] . Length == 12 ? Regex . Replace ( macs [ i ] , @"(\w{2})(?=\w)" , "$1:" ) : macs [ i ] ,
326330 category = "Database" ,
327- source = "Internal check " ,
331+ source = "Internal" ,
328332 file = device . Value . filename ,
329333 isUser = false ,
330334 } ) ;
@@ -942,7 +946,7 @@ public static bool CheckPasswordStrength(Database.Entry entry, bool isUser, out
942946 name = nameAttribute ? . value ?? String . Empty ,
943947 identifier = target ,
944948 category = "Password" ,
945- source = "Internal check " ,
949+ source = "Internal" ,
946950 file = entry . filename ,
947951 isUser = isUser ,
948952 } ;
@@ -954,6 +958,62 @@ public static bool CheckPasswordStrength(Database.Entry entry, bool isUser, out
954958 return false ;
955959 }
956960
961+ public static bool CheckWindowsLifecycle ( Database . Entry device , out Issue ? issue ) {
962+ issue = null ;
963+
964+ if ( device is null ) {
965+ return false ;
966+ }
967+
968+ device . attributes . TryGetValue ( "operating system" , out Database . Attribute osAttribute ) ;
969+ device . attributes . TryGetValue ( "os version" , out Database . Attribute osVersionAttribute ) ;
970+
971+ if ( ! WindowsLifecycle . TryAssess ( osAttribute ? . value , osVersionAttribute ? . value , out WindowsLifecycle . Assessment assessment ) ) {
972+ return false ;
973+ }
974+
975+ if ( assessment . state != WindowsLifecycle . SupportState . expiringSoon
976+ && assessment . state != WindowsLifecycle . SupportState . outOfSupport ) {
977+ return false ;
978+ }
979+
980+ device . attributes . TryGetValue ( "name" , out Database . Attribute nameAttribute ) ;
981+
982+ string osName = assessment . productName . Contains ( assessment . release , StringComparison . OrdinalIgnoreCase )
983+ ? assessment . productName
984+ : $ "{ assessment . productName } { assessment . release } ";
985+
986+ string message = assessment . state == WindowsLifecycle . SupportState . outOfSupport
987+ ? $ "{ osName } ({ assessment . version } ) has reached EOS"
988+ : $ "{ osName } ({ assessment . version } ) reaches EOS on { assessment . endOfSupport : yyyy-MM-dd} ({ assessment . daysLeft } days left)";
989+
990+ string ipString = string . Empty ;
991+ if ( device . attributes . TryGetValue ( "ip" , out Database . Attribute ip ) && ! String . IsNullOrEmpty ( ip ? . value ) ) {
992+ ipString = ip . value . Split ( ';' ) . Select ( o => o . Trim ( ) ) . ToArray ( ) [ 0 ] ;
993+ }
994+
995+ Issues . SeverityLevel severity ;
996+ if ( assessment . state == WindowsLifecycle . SupportState . outOfSupport ) {
997+ severity = SeverityLevel . critical ;
998+ }
999+ else {
1000+ severity = assessment . daysLeft < 90 ? SeverityLevel . error : SeverityLevel . warning ;
1001+ }
1002+
1003+ issue = new Issue {
1004+ severity = severity ,
1005+ message = message ,
1006+ name = nameAttribute ? . value ?? String . Empty ,
1007+ identifier = ipString ,
1008+ category = "Operating system" ,
1009+ source = "Internal" ,
1010+ file = device . filename ,
1011+ isUser = false
1012+ } ;
1013+
1014+ return true ;
1015+ }
1016+
9571017 public static bool CheckDiskSpace ( string file , string target , double percent , string diskCaption , out Issue ? issue ) {
9581018 string message = $ "{ Math . Round ( percent , 1 ) } % free space on disk { Data . EscapeJsonText ( diskCaption ) } :";
9591019
0 commit comments