]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/vulnerabilities.cgi
vulnerabilities.cgi: Simplify regexes
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / vulnerabilities.cgi
index 8c9c5eddc85797f61387532f9a04baead82e4efd..b7e11c7100e2f1aad8a00aa1ee0665368123282f 100644 (file)
@@ -22,8 +22,8 @@
 use strict;
 
 # enable only the following on debugging purpose
-use warnings;
-use CGI::Carp 'fatalsToBrowser';
+#use warnings;
+#use CGI::Carp 'fatalsToBrowser';
 
 require '/var/ipfire/general-functions.pl';
 require "${General::swroot}/lang.pl";
@@ -125,14 +125,23 @@ for my $vuln (sort keys %VULNERABILITIES) {
                $colour = "white";
                $bgcolour = ${Header::colourred};
 
+       # Mitigated but smt is enabled
+       } elsif ($status eq "Mitigation-SMT") {
+               $status_message = $Lang::tr{'mitigated'};
+               $colour = "white";
+               $bgcolour = ${Header::colourred};
+
        # Mitigated
        } elsif ($status eq "Mitigation") {
                $status_message = $Lang::tr{'mitigated'};
-               $colour = "black";
-               $bgcolour = ${Header::colourorange};
+               $colour = "white";
+               $bgcolour = ${Header::colourgreen};
 
+       # Unknown report from kernel
        } else {
-               next;
+               $status_message = $status;
+               $colour = "black";
+               $bgcolour = ${Header::colouryellow};
        }
 
        my $table_colour = ($id++ % 2) ? $color{'color22'} : $color{'color20'};
@@ -170,12 +179,20 @@ print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
 
 &Header::openbox('100%', 'center', $Lang::tr{'settings'});
 
+my $smt_status = &smt_status();
+
 print <<END;
        <table class="tbl" width="66%">
                <tbody>
+                       <tr>
+                               <th colspan="2" align="center">
+                                       <strong>$smt_status</strong>
+                               </th>
+                       </tr>
+
                        <tr>
                                <td width="50%" align="left">
-                                       <strong>$Lang::tr{'enable smt'}</strong>
+                                       $Lang::tr{'enable smt'}
                                </td>
 
                                <td width="50%" align="center">
@@ -216,9 +233,31 @@ sub check_status($) {
        my $status = <FILE>;
        close(FILE);
 
-       if ($status =~ /^(Mitigation): (.*)$/) {
+       if ($status =~ /^(Mitigation): (.*vulnerable.*)$/) {
+               return ("Mitigation-SMT", $2);
+       }
+
+       if ($status =~ /^(Vulnerable|Mitigation): (.*)$/) {
                return ($1, $2);
        } 
 
        return $status;
 }
+
+sub smt_status() {
+       open(FILE, "/sys/devices/system/cpu/smt/control");
+       my $status = <FILE>;
+       close(FILE);
+
+       chomp($status);
+
+       if ($status eq "on") {
+               return $Lang::tr{'smt enabled'};
+       } elsif (($status eq "off") || ($status eq "forceoff")) {
+               return $Lang::tr{'smt disabled'};
+       } elsif ($status eq "notsupported") {
+               return $Lang::tr{'smt not supported'};
+       }
+
+       return $status;
+}