mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-02-21 02:01:24 +00:00
working to get class code
This commit is contained in:
parent
2fd6ee0557
commit
de4f6214fb
@ -1,6 +1,7 @@
|
||||
package hirs.utils;
|
||||
|
||||
import com.github.marandus.pciid.model.Device;
|
||||
import com.github.marandus.pciid.model.DeviceClass;
|
||||
import com.github.marandus.pciid.model.Vendor;
|
||||
import com.github.marandus.pciid.service.PciIdsDatabase;
|
||||
import com.google.common.base.Strings;
|
||||
@ -157,4 +158,24 @@ public final class PciIds {
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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);
|
||||
if (devC != null && !Strings.isNullOrEmpty(devC.getName())) {
|
||||
deviceClass = devC.getName();
|
||||
}
|
||||
}
|
||||
return deviceClass;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import hirs.utils.HexUtils;
|
||||
import lombok.Getter;
|
||||
|
||||
import static hirs.utils.PciIds.translateDevice;
|
||||
import static hirs.utils.PciIds.translateDeviceClass;
|
||||
import static hirs.utils.PciIds.translateVendor;
|
||||
|
||||
/**
|
||||
@ -113,10 +114,10 @@ public class DeviceSecurityEventDataPciContext extends DeviceSecurityEventDataDe
|
||||
dSEDpciContextInfo += "\n Device Type = PCI";
|
||||
dSEDpciContextInfo += "\n Vendor = " + translateVendor(vendorId);
|
||||
dSEDpciContextInfo += "\n Device = " + translateDevice(vendorId, deviceId);
|
||||
dSEDpciContextInfo += "\n RevisionID = 0x" + revisionId;
|
||||
dSEDpciContextInfo += "\n ClassCode = 0x" + classCode;
|
||||
dSEDpciContextInfo += "\n RevisionID = " + revisionId;
|
||||
dSEDpciContextInfo += "\n Device Class = " + translateDeviceClass(classCode);
|
||||
dSEDpciContextInfo += "\n SubsystemVendor = " + translateVendor(subsystemVendorId);
|
||||
dSEDpciContextInfo += "\n SubsystemID = 0x" + subsystemId;
|
||||
dSEDpciContextInfo += "\n Subsystem = " + translateDevice(subsystemVendorId, subsystemId);
|
||||
|
||||
return dSEDpciContextInfo;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user