This commit is contained in:
Richard Holland
2023-10-18 07:41:45 +00:00
parent 7bfc60c6ad
commit d716787378

View File

@@ -331,6 +331,7 @@ syntaxCheckXPOP(Blob const& blob, beast::Journal const& j)
} }
} }
uint32_t found = 0;
for (const auto& key : xpop["validation"]["unl"].getMemberNames()) for (const auto& key : xpop["validation"]["unl"].getMemberNames())
{ {
const auto& value = xpop["validation"]["unl"][key]; const auto& value = xpop["validation"]["unl"][key];
@@ -350,15 +351,17 @@ syntaxCheckXPOP(Blob const& blob, beast::Journal const& j)
JLOG(j.warn()) << "XPOP.validation.unl.public_key invalid key type."; JLOG(j.warn()) << "XPOP.validation.unl.public_key invalid key type.";
return {}; return {};
} }
found |= 1;
} }
else if (key == "manifest") else if (key == "manifest")
{ {
if (!value.isString()) if (!value.isString() || !isBase64(value.asString()))
{ {
JLOG(j.warn()) << "XPOP.validation.unl.manifest missing or " JLOG(j.warn()) << "XPOP.validation.unl.manifest missing or "
"wrong format (should be string)"; "wrong format (should be string)";
return {}; return {};
} }
found |= 2;
} }
else if (key == "blob") else if (key == "blob")
{ {
@@ -368,6 +371,7 @@ syntaxCheckXPOP(Blob const& blob, beast::Journal const& j)
"format (should be base64 string)"; "format (should be base64 string)";
return {}; return {};
} }
found |= 4;
} }
else if (key == "signature") else if (key == "signature")
{ {
@@ -378,6 +382,7 @@ syntaxCheckXPOP(Blob const& blob, beast::Journal const& j)
"format (should be hex string)"; "format (should be hex string)";
return {}; return {};
} }
found |= 8;
} }
else if (key == "version") else if (key == "version")
{ {
@@ -387,6 +392,7 @@ syntaxCheckXPOP(Blob const& blob, beast::Journal const& j)
"wrong format (should be int)"; "wrong format (should be int)";
return {}; return {};
} }
found |= 16;
} }
else else
{ {
@@ -398,6 +404,14 @@ syntaxCheckXPOP(Blob const& blob, beast::Journal const& j)
} }
} }
} }
if (found != 0b11111)
{
JLOG(j.warn())
<< "XPOP.validation.unl entry has wrong format (missing field/s)";
return {};
}
return xpop; return xpop;
} }
catch (...) catch (...)