mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-18 20:47:58 +00:00
working on class code
This commit is contained in:
parent
770b36d4f3
commit
d2032973b5
@ -2,6 +2,8 @@ package hirs.utils;
|
||||
|
||||
import com.github.marandus.pciid.model.Device;
|
||||
import com.github.marandus.pciid.model.DeviceClass;
|
||||
import com.github.marandus.pciid.model.DeviceSubclass;
|
||||
import com.github.marandus.pciid.model.ProgramInterface;
|
||||
import com.github.marandus.pciid.model.Vendor;
|
||||
import com.github.marandus.pciid.service.PciIdsDatabase;
|
||||
import com.google.common.base.Strings;
|
||||
@ -162,20 +164,40 @@ public final class PciIds {
|
||||
/**
|
||||
* Look up the device class name from the PCI IDs list, if the input string contains an ID.
|
||||
* If any part of this fails, return the original manufacturer value.
|
||||
* @param refDeviceClass String
|
||||
* @return String with the discovered vendor name, or the original manufacturer value.
|
||||
* @param refClassCode String, formatted as 2 characters (1 byte) for each of the 3 categories
|
||||
* Example "010802":
|
||||
* Class: "01"
|
||||
* Subclass: "08"
|
||||
* Programming Interface: "02"
|
||||
* @return List<String> 3-element list with the class code
|
||||
* 1st element: human-readable description of Class
|
||||
* 2nd element: human-readable description of Subclass
|
||||
* 3rd element: human-readable description of Programming Interface
|
||||
*/
|
||||
public static String translateDeviceClass(final String refDeviceClass) {
|
||||
String deviceClass = refDeviceClass;
|
||||
if (deviceClass != null && deviceClass.trim().matches("^[0-9A-Fa-f]{6}$")) {
|
||||
DeviceClass devC = DB.findDeviceClass(deviceClass.toLowerCase());
|
||||
DeviceClass devD = DB.findDeviceClass("010802");
|
||||
System.out.println("XXXX: " + devC);
|
||||
System.out.println("YYYY: " + devD);
|
||||
public static List<String> translateDeviceClass(final String refClassCode) {
|
||||
List<String> translatedClassCode = new ArrayList<>();
|
||||
|
||||
String classCode = refClassCode;
|
||||
if (classCode != null && classCode.trim().matches("^[0-9A-Fa-f]{6}$")) {
|
||||
String deviceClass = classCode.substring(0,2).toLowerCase();
|
||||
String deviceSubclass = classCode.substring(2,2).toLowerCase();
|
||||
String programInterface = classCode.substring(4,2).toLowerCase();
|
||||
translatedClassCode.add(deviceClass);
|
||||
translatedClassCode.add(deviceSubclass);
|
||||
translatedClassCode.add(programInterface);
|
||||
DeviceClass devC = DB.findDeviceClass(deviceClass);
|
||||
DeviceSubclass devSc = DB.findDeviceSubclass(deviceClass, deviceSubclass);
|
||||
ProgramInterface progI = DB.findProgramInterface(deviceClass, deviceSubclass, programInterface);
|
||||
if (devC != null && !Strings.isNullOrEmpty(devC.getName())) {
|
||||
deviceClass = devC.getName();
|
||||
translatedClassCode.set(0, devC.getName());
|
||||
}
|
||||
if (devSc != null && !Strings.isNullOrEmpty(devSc.getName())) {
|
||||
translatedClassCode.set(1, devSc.getName());
|
||||
}
|
||||
if (progI != null && !Strings.isNullOrEmpty(progI.getName())) {
|
||||
translatedClassCode.set(2, progI.getName());
|
||||
}
|
||||
}
|
||||
return deviceClass;
|
||||
return translatedClassCode;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package hirs.utils.tpm.eventlog.events;
|
||||
import hirs.utils.HexUtils;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static hirs.utils.PciIds.translateDevice;
|
||||
import static hirs.utils.PciIds.translateDeviceClass;
|
||||
import static hirs.utils.PciIds.translateVendor;
|
||||
@ -115,7 +118,12 @@ public class DeviceSecurityEventDataPciContext extends DeviceSecurityEventDataDe
|
||||
dSEDpciContextInfo += "\n Vendor = " + translateVendor(vendorId);
|
||||
dSEDpciContextInfo += "\n Device = " + translateDevice(vendorId, deviceId);
|
||||
dSEDpciContextInfo += "\n RevisionID = " + revisionId;
|
||||
dSEDpciContextInfo += "\n Device Class = " + translateDeviceClass(classCode);
|
||||
|
||||
List<String> classCodeList = translateDeviceClass(classCode);
|
||||
dSEDpciContextInfo += "\n Device Class:";
|
||||
dSEDpciContextInfo += "\n Class = " + classCodeList.get(0);
|
||||
dSEDpciContextInfo += "\n Subclass = " + classCodeList.get(1);
|
||||
dSEDpciContextInfo += "\n Programming Interface = " + classCodeList.get(2);
|
||||
dSEDpciContextInfo += "\n SubsystemVendor = " + translateVendor(subsystemVendorId);
|
||||
dSEDpciContextInfo += "\n Subsystem = " + translateDevice(subsystemVendorId, subsystemId);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user