IBM ConfigFile upload : Fix content-type validation
While uploading the ConfigFiles, BMC was only checking if it is
not multipart/form-data. This commit is to change the validation
to check for only allowed content-type: application/octet-stream
Tested by:
Uploaded Configfile with below content-types
1. application/octet-stream - passed
2. application/x-www-form-urlencoded - failed
3. application/json - failed
4. multipart/form-data - failed
5. text/plain - failed
6. application/octet-streamabcd - failed
Signed-off-by: Sunitha Harish <sunithaharish04@gmail.com>
Change-Id: Iedadacd2306f729479ee36afff52e29d8112daf6
diff --git a/include/ibm/management_console_rest.hpp b/include/ibm/management_console_rest.hpp
index cab6523..e6b5cb2 100644
--- a/include/ibm/management_console_rest.hpp
+++ b/include/ibm/management_console_rest.hpp
@@ -86,17 +86,15 @@
{
std::error_code ec;
// Check the content-type of the request
- std::string_view contentType = req.getHeaderValue("content-type");
- if (boost::starts_with(contentType, "multipart/form-data"))
+ boost::beast::string_view contentType = req.getHeaderValue("content-type");
+ if (!boost::iequals(contentType, "application/octet-stream"))
{
- BMCWEB_LOG_DEBUG
- << "This is multipart/form-data. Invalid content for PUT";
-
asyncResp->res.result(boost::beast::http::status::not_acceptable);
asyncResp->res.jsonValue["Description"] = contentNotAcceptableMsg;
return;
}
- BMCWEB_LOG_DEBUG << "Not a multipart/form-data. Continue..";
+ BMCWEB_LOG_DEBUG
+ << "File upload in application/octet-stream format. Continue..";
BMCWEB_LOG_DEBUG
<< "handleIbmPut: Request to create/update the save-area file";