Update source/src/templates.cpp
This commit is contained in:
@@ -256,14 +256,14 @@
|
||||
if (metadata.contains("version")) {
|
||||
registry_version = metadata["version"].get<std::string>();
|
||||
}
|
||||
// REQUIRED: templateXXHash64 - the XXHash64 of extracted contents
|
||||
if (metadata.contains("templateXXHash64")) {
|
||||
registry_hash = metadata["templateXXHash64"].get<std::string>();
|
||||
debug << "Found templateXXHash64 in metadata: " << registry_hash << std::endl;
|
||||
// REQUIRED: unpackedhash - the hash of extracted contents
|
||||
if (metadata.contains("unpackedhash")) {
|
||||
registry_hash = metadata["unpackedhash"].get<std::string>();
|
||||
debug << "Found unpackedhash in metadata: " << registry_hash << std::endl;
|
||||
} else {
|
||||
// templateXXHash64 is required for security
|
||||
// unpackedhash is required for security
|
||||
error << "Template '" << template_name << "' from registry '" << mRegistry.name
|
||||
<< "' does not provide templateXXHash64 for integrity verification." << std::endl;
|
||||
<< "' does not provide unpackedhash for integrity verification." << std::endl;
|
||||
error << "This template cannot be downloaded for security reasons." << std::endl;
|
||||
error << "Please contact the registry administrator to update the template metadata." << std::endl;
|
||||
return template_info();
|
||||
@@ -329,10 +329,10 @@
|
||||
std::string actual_hash = hash_directory_recursive(template_cache_dir.string());
|
||||
|
||||
// Verify the extracted template hash matches what registry claimed
|
||||
// templateXXHash64 is required, so registry_hash should always be set here
|
||||
// unpackedhash is required, so registry_hash should always be set here
|
||||
if (registry_hash.empty()) {
|
||||
// This shouldn't happen as we check for it above, but handle it just in case
|
||||
error << "Internal error: templateXXHash64 was not properly set" << std::endl;
|
||||
error << "Internal error: unpackedhash was not properly set" << std::endl;
|
||||
std::filesystem::remove_all(template_cache_dir);
|
||||
return template_info();
|
||||
}
|
||||
|
Reference in New Issue
Block a user