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:
Cyrus 2020-11-30 14:16:57 -05:00
parent bfeff6c867
commit 6eefb393a3
3 changed files with 76 additions and 64 deletions

View File

@ -743,18 +743,19 @@ public abstract class AbstractAttestationCertificateAuthority
Pattern pattern = Pattern.compile("([^\\s]+(\\.(?i)(rimpcr|rimel|bin|log))$)");
Matcher matcher;
if (dv.hasSwidfile()) {
if (dv.getSwidfileCount() > 0) {
for (ByteString swidFile : dv.getSwidfileList()) {
try {
dbBaseRim = BaseReferenceManifest.select(referenceManifestManager)
.includeArchived()
.byHashCode(Arrays.hashCode(dv.getSwidfile().toByteArray()))
.byHashCode(Arrays.hashCode(swidFile.toByteArray()))
.getRIM();
if (dbBaseRim == null) {
dbBaseRim = new BaseReferenceManifest(
String.format("%s.swidtag",
clientName),
dv.getSwidfile().toByteArray());
swidFile.toByteArray());
BaseReferenceManifest base = (BaseReferenceManifest) dbBaseRim;
for (SwidResource swid : base.parseResource()) {
@ -766,7 +767,7 @@ public abstract class AbstractAttestationCertificateAuthority
dbBaseRim = new BaseReferenceManifest(
String.format("%s.swidtag",
clientName),
dv.getSwidfile().toByteArray());
swidFile.toByteArray());
break;
}
}
@ -782,19 +783,21 @@ public abstract class AbstractAttestationCertificateAuthority
LOG.error(ioEx);
}
}
}
if (dv.hasLogfile()) {
if (dv.getLogfileCount() > 0) {
for (ByteString logFile : dv.getLogfileList()) {
try {
support = SupportReferenceManifest.select(referenceManifestManager)
.includeArchived()
.byHashCode(Arrays.hashCode(dv.getLogfile().toByteArray()))
.byHashCode(Arrays.hashCode(logFile.toByteArray()))
.getRIM();
if (support == null) {
support = new SupportReferenceManifest(
String.format("%s.rimel",
clientName),
dv.getLogfile().toByteArray());
logFile.toByteArray());
support.setPlatformManufacturer(dv.getHw().getManufacturer());
support.setPlatformModel(dv.getHw().getProductName());
support.setTagId(tagId);
@ -817,6 +820,7 @@ public abstract class AbstractAttestationCertificateAuthority
LOG.error(ioEx);
}
}
}
if (dv.hasLivelog()) {
fileName = String.format("%s.measurement",

View File

@ -54,7 +54,7 @@ if [ -d "$RIM_FILE_LOCATION" ]; then
echo "tcg.rim.dir=$RIM_FILE_LOCATION" > "$TCG_BOOT_FILE"
fi
if [ -d "$TAG_FILE_LOCATION" ]; then
if [ -d "$SWIDTAG_FILE_LOCATION" ]; then
echo "tcg.swidtag.dir=$SWIDTAG_FILE_LOCATION" >> "$TCG_BOOT_FILE"
fi

View File

@ -89,13 +89,21 @@ int provision() {
const std::string& swid_dir = props.get("tcg.swidtag.dir", "");
try {
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) {
logger.error(hirsRuntimeException.what());
}
try {
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) {
logger.error(hirsRuntimeException.what());
}