summaryrefslogtreecommitdiff
path: root/redfish-core
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2024-04-03 23:45:31 +0300
committerEd Tanous <ed@tanous.net>2024-05-08 18:25:51 +0300
commite5cf777eb93bc434e86483ac210e7a55a509a245 (patch)
tree7288c224a595c1894ae28e01f2e3e548f5d3fd5a /redfish-core
parent17c472452c9a3518aeac636d01b8e2f01c4fa21f (diff)
downloadbmcweb-e5cf777eb93bc434e86483ac210e7a55a509a245.tar.xz
Add https parsing
This is yet another step in parsing HTTP requests. Tested: ''' curl -vvvv -k --user "root:0penBmc" -H "Content-Type: application/json" \ -X POST https://192.168.7.2/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate \ -d '{ \ "TransferProtocol":"TFTP", \ "ImageURI":"https://192.168.7.1/myfile.bin" \ }' ''' Returns ActionParameterNotSupported TransferProtocol: Omitted ImageURI: https://192.168.7.1/myfile.bin Returns ActionParameterNotSupported TransferProtocol: Omitted ImageURI: 192.168.7.1/myfile.bin Returns ActionParameterValueTypeError TransferProtocol: Bad ImageURI: https:/192.168.7.1/myfile.bin Returns: ActionParameterNotSupported No changes to GET requests, so Redfish Service Validator not necessary. Change-Id: Ibf4b69877031f3b8617412c06d40f2d0d0827ac3 Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'redfish-core')
-rw-r--r--redfish-core/lib/update_service.hpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index 6895cb4949..2a40f8afed 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -464,11 +464,15 @@ inline std::optional<boost::urls::url>
res, imageURI, "ImageURI", "UpdateService.SimpleUpdate");
return std::nullopt;
}
- // OpenBMC currently only supports TFTP
+ // OpenBMC currently only supports TFTP or HTTPS
if (*transferProtocol == "TFTP")
{
imageURI = "tftp://" + imageURI;
}
+ else if (*transferProtocol == "HTTPS")
+ {
+ imageURI = "https://" + imageURI;
+ }
else
{
messages::actionParameterNotSupported(res, "TransferProtocol",
@@ -499,6 +503,14 @@ inline std::optional<boost::urls::url>
return std::nullopt;
}
}
+ else if (url->scheme() == "https")
+ {
+ // Empty paths default to "/"
+ if (url->encoded_path().empty())
+ {
+ url->set_encoded_path("/");
+ }
+ }
else
{
messages::actionParameterNotSupported(res, "ImageURI", imageURI);
@@ -515,6 +527,13 @@ inline std::optional<boost::urls::url>
return *url;
}
+inline void doHttpsUpdate(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const boost::urls::url_view_base& url)
+{
+ messages::actionParameterNotSupported(asyncResp->res, "ImageURI",
+ url.buffer());
+}
+
inline void doTftpUpdate(const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const boost::urls::url_view_base& url)
@@ -606,6 +625,10 @@ inline void handleUpdateServiceSimpleUpdateAction(
{
doTftpUpdate(req, asyncResp, *url);
}
+ else if (url->scheme() == "https")
+ {
+ doHttpsUpdate(asyncResp, *url);
+ }
else
{
messages::actionParameterNotSupported(asyncResp->res, "ImageURI",
@@ -841,6 +864,7 @@ inline void
"/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate";
nlohmann::json::array_t allowed;
+ allowed.emplace_back(update_service::TransferProtocolType::HTTPS);
if constexpr (BMCWEB_INSECURE_PUSH_STYLE_NOTIFICATION)
{