mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-02-07 03:40:10 +00:00
Updated the code to pull all the files from a swid tag file directory and a rim log file directory, instead of a single file.
This commit is contained in:
parent
bfeff6c867
commit
6eefb393a3
@ -743,78 +743,82 @@ public abstract class AbstractAttestationCertificateAuthority
|
|||||||
Pattern pattern = Pattern.compile("([^\\s]+(\\.(?i)(rimpcr|rimel|bin|log))$)");
|
Pattern pattern = Pattern.compile("([^\\s]+(\\.(?i)(rimpcr|rimel|bin|log))$)");
|
||||||
Matcher matcher;
|
Matcher matcher;
|
||||||
|
|
||||||
if (dv.hasSwidfile()) {
|
if (dv.getSwidfileCount() > 0) {
|
||||||
try {
|
for (ByteString swidFile : dv.getSwidfileList()) {
|
||||||
dbBaseRim = BaseReferenceManifest.select(referenceManifestManager)
|
try {
|
||||||
.includeArchived()
|
dbBaseRim = BaseReferenceManifest.select(referenceManifestManager)
|
||||||
.byHashCode(Arrays.hashCode(dv.getSwidfile().toByteArray()))
|
.includeArchived()
|
||||||
.getRIM();
|
.byHashCode(Arrays.hashCode(swidFile.toByteArray()))
|
||||||
|
.getRIM();
|
||||||
|
|
||||||
if (dbBaseRim == null) {
|
if (dbBaseRim == null) {
|
||||||
dbBaseRim = new BaseReferenceManifest(
|
dbBaseRim = new BaseReferenceManifest(
|
||||||
String.format("%s.swidtag",
|
String.format("%s.swidtag",
|
||||||
clientName),
|
clientName),
|
||||||
dv.getSwidfile().toByteArray());
|
swidFile.toByteArray());
|
||||||
|
|
||||||
BaseReferenceManifest base = (BaseReferenceManifest) dbBaseRim;
|
BaseReferenceManifest base = (BaseReferenceManifest) dbBaseRim;
|
||||||
for (SwidResource swid : base.parseResource()) {
|
for (SwidResource swid : base.parseResource()) {
|
||||||
matcher = pattern.matcher(swid.getName());
|
matcher = pattern.matcher(swid.getName());
|
||||||
if (matcher.matches()) {
|
if (matcher.matches()) {
|
||||||
//found the file name
|
//found the file name
|
||||||
int dotIndex = swid.getName().lastIndexOf(".");
|
int dotIndex = swid.getName().lastIndexOf(".");
|
||||||
clientName = swid.getName().substring(0, dotIndex);
|
clientName = swid.getName().substring(0, dotIndex);
|
||||||
dbBaseRim = new BaseReferenceManifest(
|
dbBaseRim = new BaseReferenceManifest(
|
||||||
String.format("%s.swidtag",
|
String.format("%s.swidtag",
|
||||||
clientName),
|
clientName),
|
||||||
dv.getSwidfile().toByteArray());
|
swidFile.toByteArray());
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
this.referenceManifestManager.save(dbBaseRim);
|
||||||
|
} else {
|
||||||
|
LOG.info("Client provided Base RIM already loaded in database.");
|
||||||
|
dbBaseRim.restore();
|
||||||
|
dbBaseRim.resetCreateTime();
|
||||||
}
|
}
|
||||||
this.referenceManifestManager.save(dbBaseRim);
|
|
||||||
} else {
|
|
||||||
LOG.info("Client provided Base RIM already loaded in database.");
|
|
||||||
dbBaseRim.restore();
|
|
||||||
dbBaseRim.resetCreateTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
tagId = dbBaseRim.getTagId();
|
tagId = dbBaseRim.getTagId();
|
||||||
} catch (IOException ioEx) {
|
} catch (IOException ioEx) {
|
||||||
LOG.error(ioEx);
|
LOG.error(ioEx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dv.hasLogfile()) {
|
if (dv.getLogfileCount() > 0) {
|
||||||
try {
|
for (ByteString logFile : dv.getLogfileList()) {
|
||||||
support = SupportReferenceManifest.select(referenceManifestManager)
|
try {
|
||||||
.includeArchived()
|
support = SupportReferenceManifest.select(referenceManifestManager)
|
||||||
.byHashCode(Arrays.hashCode(dv.getLogfile().toByteArray()))
|
.includeArchived()
|
||||||
.getRIM();
|
.byHashCode(Arrays.hashCode(logFile.toByteArray()))
|
||||||
|
.getRIM();
|
||||||
|
|
||||||
if (support == null) {
|
if (support == null) {
|
||||||
support = new SupportReferenceManifest(
|
support = new SupportReferenceManifest(
|
||||||
String.format("%s.rimel",
|
String.format("%s.rimel",
|
||||||
clientName),
|
clientName),
|
||||||
dv.getLogfile().toByteArray());
|
logFile.toByteArray());
|
||||||
support.setPlatformManufacturer(dv.getHw().getManufacturer());
|
support.setPlatformManufacturer(dv.getHw().getManufacturer());
|
||||||
support.setPlatformModel(dv.getHw().getProductName());
|
support.setPlatformModel(dv.getHw().getProductName());
|
||||||
support.setTagId(tagId);
|
support.setTagId(tagId);
|
||||||
this.referenceManifestManager.save(support);
|
this.referenceManifestManager.save(support);
|
||||||
} else {
|
} else {
|
||||||
LOG.info("Client provided Support RIM already loaded in database.");
|
LOG.info("Client provided Support RIM already loaded in database.");
|
||||||
if (dbBaseRim != null) {
|
if (dbBaseRim != null) {
|
||||||
support.setPlatformManufacturer(dbBaseRim.getPlatformManufacturer());
|
support.setPlatformManufacturer(dbBaseRim.getPlatformManufacturer());
|
||||||
support.setPlatformModel(dbBaseRim.getPlatformModel());
|
support.setPlatformModel(dbBaseRim.getPlatformModel());
|
||||||
support.setSwidTagVersion(dbBaseRim.getSwidTagVersion());
|
support.setSwidTagVersion(dbBaseRim.getSwidTagVersion());
|
||||||
support.setAssociatedRim(dbBaseRim.getId());
|
support.setAssociatedRim(dbBaseRim.getId());
|
||||||
support.setTagId(dbBaseRim.getTagId());
|
support.setTagId(dbBaseRim.getTagId());
|
||||||
|
}
|
||||||
|
|
||||||
|
support.restore();
|
||||||
|
support.resetCreateTime();
|
||||||
|
this.referenceManifestManager.update(support);
|
||||||
}
|
}
|
||||||
|
} catch (IOException ioEx) {
|
||||||
support.restore();
|
LOG.error(ioEx);
|
||||||
support.resetCreateTime();
|
|
||||||
this.referenceManifestManager.update(support);
|
|
||||||
}
|
}
|
||||||
} catch (IOException ioEx) {
|
|
||||||
LOG.error(ioEx);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ if [ -d "$RIM_FILE_LOCATION" ]; then
|
|||||||
echo "tcg.rim.dir=$RIM_FILE_LOCATION" > "$TCG_BOOT_FILE"
|
echo "tcg.rim.dir=$RIM_FILE_LOCATION" > "$TCG_BOOT_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d "$TAG_FILE_LOCATION" ]; then
|
if [ -d "$SWIDTAG_FILE_LOCATION" ]; then
|
||||||
echo "tcg.swidtag.dir=$SWIDTAG_FILE_LOCATION" >> "$TCG_BOOT_FILE"
|
echo "tcg.swidtag.dir=$SWIDTAG_FILE_LOCATION" >> "$TCG_BOOT_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -89,13 +89,21 @@ int provision() {
|
|||||||
const std::string& swid_dir = props.get("tcg.swidtag.dir", "");
|
const std::string& swid_dir = props.get("tcg.swidtag.dir", "");
|
||||||
try {
|
try {
|
||||||
rim_files = hirs::file_utils::search_directory(rim_dir);
|
rim_files = hirs::file_utils::search_directory(rim_dir);
|
||||||
dv.set_logfile(rim_files);
|
for (const auto& rims : rim_files) {
|
||||||
|
if (rims != "") {
|
||||||
|
dv.add_logfile(rims);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (HirsRuntimeException& hirsRuntimeException) {
|
} catch (HirsRuntimeException& hirsRuntimeException) {
|
||||||
logger.error(hirsRuntimeException.what());
|
logger.error(hirsRuntimeException.what());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
swidtag_files = hirs::file_utils::search_directory(swid_dir);
|
swidtag_files = hirs::file_utils::search_directory(swid_dir);
|
||||||
dv.set_swidfile(swidtag_files);
|
for (const auto& swidtag : swidtag_files) {
|
||||||
|
if (swidtag != "") {
|
||||||
|
dv.add_swidfile(swidtag);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (HirsRuntimeException& hirsRuntimeException) {
|
} catch (HirsRuntimeException& hirsRuntimeException) {
|
||||||
logger.error(hirsRuntimeException.what());
|
logger.error(hirsRuntimeException.what());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user