summaryrefslogtreecommitdiff
path: root/redfish-core/lib/update_service.hpp
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2021-10-26 22:45:59 +0300
committerEd Tanous <edtanous@google.com>2022-02-28 03:17:20 +0300
commitace85d606dca3e9b6c1dbe1c7ee9a685be169ed6 (patch)
tree30890ae4279c77daffa7344cf44cd3ef2228444c /redfish-core/lib/update_service.hpp
parent30a3c431478584109d6d3a52f4d9541d5275902a (diff)
downloadbmcweb-ace85d606dca3e9b6c1dbe1c7ee9a685be169ed6.tar.xz
Add url type safety to message registry
There are a number of places where we use message registry messages incorrectly. This patchset attempts to fix them, and invoke some type safety when they're used such that they're more obvious to use. Namely, it changes a number of the message registry methods to accept a boost::urls::url_view for its argument instead of a const std::string&. This forces the calling code to correctly encode a URL to use the method, which should make it obvious that it's not for an ID, a property name, or anything else. In the course of doing this, several places were found to be using the first argument incorrectly. Tested: curl --insecure --user root:0penBmc https://192.168.7.2/redfish/v1/Chassis/foobar Returns: { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The requested resource of type #Chassis.v1_16_0.Chassis named foobar was not found.", "MessageArgs": [ "#Chassis.v1_16_0.Chassis", "foobar" ], "MessageId": "Base.1.8.1.ResourceNotFound", "MessageSeverity": "Critical", "Resolution": "Provide a valid resource identifier and resubmit the request." } ], "code": "Base.1.8.1.ResourceNotFound", "message": "The requested resource of type #Chassis.v1_16_0.Chassis named foobar was not found." } Identically to previously. Also tested with IDs that contained % encoded characters, like foobar%10, which gave the same result. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Icbb3bce5d190a260610087c9ef35e7becc5a50c7
Diffstat (limited to 'redfish-core/lib/update_service.hpp')
-rw-r--r--redfish-core/lib/update_service.hpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index 1288815f8e..6c61e40d34 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -931,8 +931,9 @@ inline void requestRoutesSoftwareInventory(App& app)
<< "Input swID " + *swId + " not found!";
messages::resourceMissingAtURI(
asyncResp->res,
- "/redfish/v1/UpdateService/FirmwareInventory/" +
- *swId);
+ crow::utility::urlFromPieces(
+ "redfish", "v1", "UpdateService",
+ "FirmwareInventory", *swId));
return;
}
asyncResp->res.jsonValue["@odata.type"] =