-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57f51d9
commit 0224907
Showing
5 changed files
with
362 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package dmi | ||
|
||
import ( | ||
"strings" | ||
"time" | ||
|
||
"github.com/foxboron/sbctl/fs" | ||
) | ||
|
||
var Table = DMI{} | ||
|
||
type DMI struct { | ||
BoardName string `json:"board_name"` | ||
BoardVendor string `json:"board_vendor"` | ||
BoardVersion string `json:"board_version"` | ||
ChassisType string `json:"chassis_type"` | ||
FirmwareDate time.Time `json:"firmware_date"` | ||
FirmwareRelease string `json:"firmware_release"` | ||
FirmwareVendor string `json:"firmware_vendor"` | ||
FirmwareVersion string `json:"firmware_version"` | ||
ProductFamily string `json:"product_family"` | ||
ProductName string `json:"product_name"` | ||
ProductSKU string `json:"product_sku"` | ||
ProductVersion string `json:"product_version"` | ||
SystemVendor string `json:"system_vendor"` | ||
} | ||
|
||
func readValue(filename string) string { | ||
f, _ := fs.ReadFile("/sys/devices/virtual/dmi/id/" + filename) | ||
return strings.TrimSpace(string(f)) | ||
} | ||
|
||
func ParseDMI() DMI { | ||
dmi := DMI{} | ||
|
||
dmi.BoardName = readValue("board_name") | ||
dmi.BoardVendor = readValue("board_vendor") | ||
dmi.BoardVersion = readValue("board_version") | ||
dmi.ChassisType = readValue("chassis_type") | ||
dmi.FirmwareDate, _ = time.Parse("01/02/2006", readValue("bios_date")) | ||
dmi.FirmwareRelease = readValue("bios_release") | ||
dmi.FirmwareVendor = readValue("bios_vendor") | ||
dmi.FirmwareVersion = readValue("bios_version") | ||
dmi.ProductFamily = readValue("product_family") | ||
dmi.ProductName = readValue("product_name") | ||
dmi.ProductSKU = readValue("product_sku") | ||
dmi.ProductVersion = readValue("product_version") | ||
dmi.SystemVendor = readValue("sys_vendor") | ||
|
||
return dmi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package quirks | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/foxboron/sbctl/dmi" | ||
) | ||
|
||
var FQ0001 = Quirk { | ||
ID: "FQ0001", | ||
Name: "Defaults to executing on Secure Boot policy violation", | ||
Severity: "CRITICAL", | ||
} | ||
|
||
func HasFQ0001() bool { | ||
unaffectedVersions := []unaffectedVersion{ | ||
// MSI MAG Z490 TOMAHAWK | ||
{Name: "MS-7C80", NameSrc: &dmi.Table.ProductName, NameStrict: true, Version: "1.B0", VersionSrc: &dmi.Table.FirmwareVersion}, | ||
// MSI H310M PRO-C | ||
{Name: "MS-7D02", NameSrc: &dmi.Table.ProductName, NameStrict: true, Version: "1.20", VersionSrc: &dmi.Table.FirmwareVersion}, | ||
} | ||
|
||
affectedDateRanges := []affectedDateRange{ | ||
{From: time.Date(2022, 5, 10, 0, 0, 0, 0, time.UTC)}, | ||
} | ||
|
||
affectedDevices := []affectedDevice{ | ||
// MSI AMD boards | ||
{Name: "X570", NameSrc: &dmi.Table.BoardName, NameStrict: false, DateFrom: time.Date(2021, 12, 16, 0, 0, 0, 0, time.UTC)}, | ||
{Name: "X470", NameSrc: &dmi.Table.BoardName, NameStrict: false, DateFrom: time.Date(2021, 9, 28, 0, 0, 0, 0, time.UTC)}, | ||
{Name: "B550", NameSrc: &dmi.Table.BoardName, NameStrict: false, DateFrom: time.Date(2021, 12, 13, 0, 0, 0, 0, time.UTC)}, | ||
{Name: "B450", NameSrc: &dmi.Table.BoardName, NameStrict: false, DateFrom: time.Date(2021, 12, 13, 0, 0, 0, 0, time.UTC)}, | ||
{Name: "B350", NameSrc: &dmi.Table.BoardName, NameStrict: false, DateFrom: time.Date(2021, 11, 1, 0, 0, 0, 0, time.UTC)}, | ||
{Name: "A520", NameSrc: &dmi.Table.BoardName, NameStrict: false, DateFrom: time.Date(2021, 9, 11, 0, 0, 0, 0, time.UTC)}, | ||
// MSI Intel boards | ||
{Name: "Z590", NameSrc: &dmi.Table.BoardName, NameStrict: false, DateFrom: time.Date(2021, 9, 6, 0, 0, 0, 0, time.UTC)}, | ||
{Name: "Z490", NameSrc: &dmi.Table.BoardName, NameStrict: false, DateFrom: time.Date(2021, 9, 30, 0, 0, 0, 0, time.UTC)}, | ||
{Name: "B560", NameSrc: &dmi.Table.BoardName, NameStrict: false, DateFrom: time.Date(2021, 9, 9, 0, 0, 0, 0, time.UTC)}, | ||
{Name: "B460", NameSrc: &dmi.Table.BoardName, NameStrict: false, DateFrom: time.Date(2021, 10, 22, 0, 0, 0, 0, time.UTC)}, | ||
{Name: "H510", NameSrc: &dmi.Table.BoardName, NameStrict: false, DateFrom: time.Date(2021, 9, 10, 0, 0, 0, 0, time.UTC)}, | ||
{Name: "H410", NameSrc: &dmi.Table.BoardName, NameStrict: false, DateFrom: time.Date(2021, 10, 22, 0, 0, 0, 0, time.UTC)}, | ||
} | ||
|
||
if dmi.Table.BoardVendor == "Micro-Star International Co., Ltd." && dmi.Table.ChassisType == "3" { | ||
if isUnaffectedVersion(unaffectedVersions) { | ||
return false | ||
} else if isAffectedDate(affectedDateRanges) { | ||
FQ0001.Method = "date" | ||
return true | ||
} else if isAffectedDevice(affectedDevices) { | ||
FQ0001.Method = "device_name" | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} |
Oops, something went wrong.