summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-05-12ibm-locks: shut up clang-tidy by disabling codePatrick Williams2-3/+13
There is code in ibm/locks that has had clang-tidy warnings disabled for a while due to multiple safety and endianness issues. The code has not been fixed in a while and with clang-16 it is unable to be exempted further. Disable it until someone who cares can fix this in the proper way. ``` ../include/ibm/locks.hpp:522:14: error: 'p' is an unsafe pointer used for buffer access [-Werror,-Wunsafe-buffer-usage] uint8_t* p = reinterpret_cast<uint8_t*>(&resourceId1); ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../include/ibm/locks.hpp:527:25: note: used in buffer access here uint8_t pPosition = p[position]; ^ ../include/ibm/locks.hpp:524:14: error: 'q' is an unsafe pointer used for buffer access [-Werror,-Wunsafe-buffer-usage] uint8_t* q = reinterpret_cast<uint8_t*>(&resourceId2); ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../include/ibm/locks.hpp:529:25: note: used in buffer access here uint8_t qPosition = q[position]; ``` Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I8a7fcbed1099419ad1715c86ffcbfef20820251e
2023-05-12use emplace where appropriate per clang-tidyPatrick Williams13-26/+25
The clang-tidy warning 'modernize-use-emplace' correctly flags a few places where emplace should be used over push. Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I6ca79285a87d6927e718345dc8dce0387e6b1eda
2023-05-12fix clang-tidy warnings with unreachable returnsPatrick Williams3-5/+0
``` /data0/jenkins/workspace/ci-repository/openbmc/bmcweb/http/verb.hpp:51:12: error: 'return' will never be executed [clang-diagnostic-unreachable-code-return,-warnings-as-errors] /data0/jenkins/workspace/ci-repository/openbmc/bmcweb/http/utility.hpp:99:12: error: 'return' will never be executed [clang-diagnostic-unreachable-code-return,-warnings-as-errors] /data0/jenkins/workspace/ci-repository/openbmc/bmcweb/redfish-core/include/utils/query_param.hpp:272:13: error: 'break' will never be executed [clang-diagnostic-unreachable-code-break,-warnings-as-errors] ``` Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Ia74f4fb4f34875097d1ef04b26e40908cc175088
2023-05-12chassis: fix clang-tidy warningPatrick Williams1-1/+2
``` /data0/jenkins/workspace/ci-repository/openbmc/bmcweb/redfish-core/lib/chassis.hpp:130:13: error: loop will run at most once (loop increment never executed) [clang-diagnostic-unreachable-code-loop-increment,-warnings-as-errors] for (const auto& service : object.second) ``` Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I3d7743115ec31d6f704a857f3e878fa1b7728a60
2023-05-12http-app: fix unused macro clang-tidy warningPatrick Williams1-1/+1
``` /data0/jenkins/workspace/ci-repository/openbmc/bmcweb/http/app.hpp:27:9: error: macro is not used [clang-diagnostic-unused-macros,-warnings-as-errors] #define BMCWEB_ROUTE(app, url) ``` Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I49b6239d7d5f31c52af6f6e5b0bc57be22a299b5
2023-05-12http-logging: fix clang-tidy warningsPatrick Williams1-6/+5
``` /data0/jenkins/workspace/ci-repository/openbmc/bmcweb/http/logging.hpp:132:9: error: macro is not used [clang-diagnostic-unused-macros,-warnings-as-errors] #define BMCWEB_LOG_CRITICAL ``` Add NOLINTBEGIN/NOLINTEND guards around the whole of the macro definitions because there are now multiple clang-tidy warning types that call out this behavior, but we want it in this case. Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Iac2ee839999f36424ca6dfed212d0bad0a2f3ae5
2023-05-12certificate-service: fix clang-tidy warningsPatrick Williams1-4/+4
``` ../redfish-core/lib/certificate_service.hpp:154:32: error: 'i' is an unsafe pointer used for buffer access [-Werror,-Wunsafe-buffer-usage] std::string_view::iterator i = value.begin(); ``` Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I6b6fb17d58bb7a3bd861aaf020540586490693da
2023-05-12Don't rely on implicit operator comparisonEd Tanous1-1/+2
Json has a bunch of implicit overloaded operators for comparing vectors/arrays/maps with their json counterparts. Unfortunately, when used in unit tests, these cause warnings in clang, so update the code to use the ElementsAre check from gmock. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I658557cb59d568fd50cf6f3bef73d6f90b5c56cf
2023-05-12log-services: fix clang-tidy warningsPatrick Williams2-24/+16
A number of similar warnings about unsafe pointer arithmetic. ``` ../redfish-core/lib/log_services.hpp:269:39: error: unsafe pointer arithmetic [-Werror,-Wunsafe-buffer-usage] indexStr.data(), indexStr.data() + indexStr.size(), index); ``` Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Icc4a0d2f418c76d6987ef2318b0098d30d116389
2023-05-11query-param: fix clang-tidy warningsPatrick Williams1-5/+5
``` ../redfish-core/include/utils/query_param.hpp:287:51: error: unsafe pointer arithmetic [-Werror,-Wunsafe-buffer-usage] auto it = std::from_chars(value.data(), value.data() + value.size(), ~~~~~~^~~~~~ ../redfish-core/include/utils/query_param.hpp:307:45: error: unsafe pointer arithmetic [-Werror,-Wunsafe-buffer-usage] std::from_chars(value.data(), value.data() + value.size(), param); ``` Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Ic93d3e98e0539f5c7068b93ff7e4505fdd5bbfe1
2023-05-11json-html-serializer: fix clang-tidy warningPatrick Williams1-25/+26
``` ../include/json_html_serializer.hpp:426:42: error: 'end' declared with a const-qualified typedef; results in the type being 'char *const' instead of 'const char *' [misc-misplaced-const,-warnings-as-errors] const std::array<char, 64>::iterator end = ^ /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/array:106:44: note: typedef declared here typedef value_type* iterator; ../include/json_html_serializer.hpp:165:60: error: unsafe pointer arithmetic [-Werror,-Wunsafe-buffer-usage] std::snprintf(stringBuffer.data() + bytes, 7, ../include/json_html_serializer.hpp:327:11: error: 'bufferPtr' is an unsafe pointer used for buffer access [-Werror,-Wunsafe-buffer-usage] auto* bufferPtr = begin(numberbuffer); ../include/json_html_serializer.hpp:393:11: error: 'begin' is an unsafe pointer used for buffer access [-Werror,-Wunsafe-buffer-usage] char* begin = numberbuffer.data(); ../include/json_html_serializer.hpp:425:56: error: unsafe pointer arithmetic [-Werror,-Wunsafe-buffer-usage] std::remove(numberbuffer.begin(), numberbuffer.begin() + len, ','); ``` Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: If6aaf038c939ad76da73e68e746a56b0905b2804
2023-05-11mutual-tls: fix clang-tidy warningPatrick Williams1-4/+4
``` ../http/mutual_tls.hpp:77:35: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] unsigned char usageChar = usage->data[i]; ``` Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Icc6905f31fdd54b683fe7807eb72e9b78437b2d1
2023-05-11pam-authenticate: fix clang-tidy warningPatrick Williams1-6/+9
``` ../include/pam_authenticate.hpp:11:75: error: 'msg' is an unsafe pointer used for buffer access [-Werror,-Wunsafe-buffer-usage] inline int pamFunctionConversation(int numMsg, const struct pam_message** msg, ``` Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Ic0e6d63b01eea78cac54407246363177cb208f8b
2023-05-11multipart-parser: fix clang-tidy issuesPatrick Williams1-18/+11
``` ../include/multipart_parser.hpp:77:21: error: 'buffer' is an unsafe pointer used for buffer access [-Werror,-Wunsafe-buffer-usage] const char* buffer = req.body().data(); ../include/multipart_parser.hpp:246:38: error: 'buffer' is an unsafe pointer used for buffer access [-Werror,-Wunsafe-buffer-usage] void skipNonBoundary(const char* buffer, size_t len, size_t boundaryEnd, ``` Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Iad3b4b241ec75a152e240755a307a970798079fb
2023-05-11time-utils: fix clang-tidy warningPatrick Williams1-2/+2
The code already does size checking to ensure that buffer overruns are not done, so switch to using operator[] rather than pointer arithmetic. ``` ../redfish-core/include/utils/time_utils.hpp:71:19: error: unsafe pointer arithmetic [-Werror,-Wunsafe-buffer-usage] end = fmt.data() + pos; ``` Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Iaabe82d7c1621dc27ad10288732609dfd0516d17
2023-05-11human-sort: fix clang-tidy warnings about pointer arithmeticPatrick Williams1-6/+6
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I8122bfffaac469ee551c72632b671e8644a4da44
2023-05-11clang-format: copy latest and re-formatPatrick Williams69-302/+245
clang-format-16 has some backwards incompatible changes that require additional settings for best compatibility and re-running the formatter. Copy the latest .clang-format from the docs repository and reformat the repository. Change-Id: I75f89d2959b0f1338c20d72ad669fbdc1d720835 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2023-05-10managers: fix bug of searching dbus object pathPotin Lai1-2/+4
Notice a bug of patching existed object if the object name contains space or underscore. Normally dbus replace space with underscore for object path. Replacing all spaces in input name with underscore to find the correct dbus object path. Tested results: - Add new object Input JSON ``` { "Oem": { "OpenBmc": { "Fan": { "StepwiseControllers": { "Test_1": { "Direction": "Floor", "Inputs": [ "MB_U402_THERM_LOCAL" ], "NegativeHysteresis": 0.0, "PositiveHysteresis": 0.0, "Steps": [ { "Output": 0.0, "Target": 48.0 }, { "Output": 40.0, "Target": 52.0 } ], "Zones": [ { "@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/Zone0" } ] } } } } } } ``` Check result from /redfish/v1/Managers/bmc ``` "Test_1": { "@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/StepwiseControllers/Test_1", "@odata.type": "#OemManager.StepwiseController", "Direction": "Floor", "Inputs": [ "MB U402 THERM LOCAL" ], "NegativeHysteresis": 0.0, "PositiveHysteresis": 0.0, "Steps": [ { "Output": 0.0, "Target": 48.0 }, { "Output": 40.0, "Target": 52.0 } ], "Zones": [ { "@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/Zone0" } ] } ``` - Patching existed object successful Input JSON ``` { "Oem": { "OpenBmc": { "Fan": { "StepwiseControllers": { "Test_1": { "NegativeHysteresis": 0.0, "PositiveHysteresis": 5.0, } } } } } } ``` Check result from /redfish/v1/Managers/bmc ``` "Test_1": { "@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/StepwiseControllers/Test_1", "@odata.type": "#OemManager.StepwiseController", "Direction": "Floor", "Inputs": [ "MB U402 THERM LOCAL" ], "NegativeHysteresis": 0.0, "PositiveHysteresis": 5.0, "Steps": [ { "Output": 0.0, "Target": 48.0 }, { "Output": 40.0, "Target": 52.0 } ], "Zones": [ { "@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/Zone0" } ] } ``` Signed-off-by: Potin Lai <potin.lai@quantatw.com> Change-Id: I12c78e52801bd0814ba2d928cf020e0a04214c39
2023-05-05Update Logging option for the setting log levelMyung Bae7-57/+81
In order to be able to more easily debug bmcweb related issue, a new meson option is added to set a specific logging level Which generates the targeted logging traces rather than all of debug traces. The current option -Dbmcweb-logging which can be either disabled or enabled is changed to allow to set the log level for the specific level traces (e.g. error or critical traces) to be written to the journal. -Dbmcweb-logging=<log-level> where <log-level> can be disabled, enabled, debug, info, warning, error, or critical. - `disabled`: Turns off all bmcweb log traces. - `enabled` : treated as `debug` - Other option can be described in [Logging Levels](DEVELOPING.md). For an example, to enable only 'error', 'critical' log entries, bmcweb can be built with -Dbmcweb-logging=error Testing: - Verified that only the specific logs (e.g. error and critical logs) were displayed by compiling bmcweb with the specific bmcweb-logging level. Change-Id: I522ca26700ea420fee1a5cf688d3e8c6661f2f55 Signed-off-by: Myung Bae <myungbae@us.ibm.com>
2023-05-04bugfix: find existing powersupply for power sensorAlexander Hansen1-1/+2
Fix lookup for existing powersupplies when building json. (dbus: '_' , json: ' ') Tested: manually with 2 Supermicro Power Supplies. Change-Id: Iecd14c0b9860a12c64b004c99cb6a7fb1dd0328a Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
2023-05-04Update depth parameter in getPCIeDeviceListLakshmi Yadlapati1-1/+1
The current call to getSubTreePaths is using a depth of 1, which limits the search to only the direct children of the inventoryPath. However, the interface may be found at any depth in the subtree, so the depth parameter should be set to 0 to search the entire subtree, in order to ensure that all relevant objects are included in the search results. getValidPCIeDevicePath and getPCIeDeviceList should call getSubTreePaths with the same depth parameter value to ensure that the same level of the PCIe device tree is being searched for devices. Tested: Validator passed Change-Id: Ic990581ef186f4bf1511a221c4e305ff6c2afdf2 Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-05-02virtual_media: Fix for bmcweb crashJayaprakash Mutyala1-0/+10
bmcweb crashes when user not providing userName or password while posting ISO form Redfish. This fix provides to avoid bmcweb crash when user try to post ISO images from Redfish without providing username or password. Tested: Redfish validator passed with this change. Verified by Posting ISO from Redfish. Signed-off-by: Arun Kapale <arunx.kapale@intel.com> Signed-off-by: Jayaprakash Mutyala <mutyalax.jayaprakash@intel.com> Change-Id: Ib9c7ed668f13943bdacdd9afda0e65d6bcc438d0
2023-05-02Aggregation: Process subordinate top collectionsCarson Labrado2-15/+320
Adds a function to process responses from URIs that are uptree from a top level collection. A follow-up patch will hook this into the aggregation code to allow adding links to top level collections which are only supported by satellite BMCs. Adds test cases to validate this function is working correctly. Tested: New test cases pass Signed-off-by: Carson Labrado <clabrado@google.com> Change-Id: I7f0fd6c3955398e2fde136c1d3b37a6bf4bf06b9
2023-05-01Fix PCIeDevice redfish validator failureLakshmi Yadlapati1-1/+1
Specify correct interface for getSubTreePaths in getPCIeDeviceList. This commit addresses a Redfish validator failure that occurred after a previous commit. ''' https://github.com/openbmc/bmcweb/commit/94c3a10b94c3ce063d6c1aed3a597f0d524594d5 ''' Both the inventory path and interface were incorrect, and the inventory path was fixed in the previous commit. This commit fixes the interface in the getSubTreePaths function to ensure that it returns the correct PCIeDevice list. Without the correct interface, the function was returning incorrect devices, which was causing the Redfish validator failure. Tested: Validator passed for PCIeDevice Change-Id: Iab6a26ee0dd933be6cf371bdd13e5d10d6d10efa Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-04-28Cleanup pcie codeLakshmi Yadlapati1-12/+6
Remove unused variable pcieService, fix pciePath and use global variables pciePath and pcieDeviceInterface. Tested: tested PCIeDeviceCollection and PCIeDevice, and tested the changes with the peci-pcie commit https://gerrit.openbmc.org/c/openbmc/peci-pcie/+/62100 Change-Id: Iff8aee3f8bc43740b1885a2da584b0e6cf579dcc Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-04-28Add Asset information for PCIeDeviceSunnySrivastava19842-0/+70
This commit publishes inventory properties like SparePartNumber, Model, PartNumber, SerialNumber, Manufacturer for PCIe devices. Tested: Validator passed ``` "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card10", "@odata.type": "#PCIeDevice.v1_9_0.PCIeDevice", "Id": "pcie_card10", "Manufacturer": "", "Model": "6B87", "Name": "PCIe Device", "PCIeFunctions": { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card10/PCIeFunctions" }, "PCIeInterface": { "LanesInUse": 16, "PCIeType": "Gen4" }, "PartNumber": "03FL204", "SerialNumber": "YA31UF07200Z", "SparePartNumber": "03FL205" ``` Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com> Change-Id: I850fe5eb2b3b3b9d47f4256ce0c4408bb1dd2bd1 Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-04-28Refactor SystemPCIeFunction methodLakshmi Yadlapati1-104/+121
Move SystemPCIeFunction to a separate method, and refactor the code. Validate the PCIe device path and add link header. Tested: Validator passed ``` { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card7/PCIeFunctions/0", "@odata.type": "#PCIeFunction.v1_2_3.PCIeFunction", "ClassCode": "0x020000", "DeviceId": "0x1657", "FunctionId": 0, "Id": "0", "Links": { "PCIeDevice": { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card7" } }, "Name": "PCIe Function", "RevisionId": "0x01", "SubsystemId": "0x0420", "SubsystemVendorId": "0x1014", "VendorId": "0x14e4" } ``` Change-Id: I99add03210983a255a615512b6137d04982f83a5 Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-04-28Refactor SystemPCIeFunctionCollection methodLakshmi Yadlapati1-80/+81
Move SystemPCIeFunctionCollection to a separate method, and refactor the code. Validate the PCIe device path and add link header. Tested: Validator passed ``` { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card7/PCIeFunctions", "@odata.type": "#PCIeFunctionCollection.PCIeFunctionCollection", "Description": "Collection of PCIe Functions for PCIe Device pcie_card7", "Members": [ { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card7/PCIeFunctions/0" } ], "Name": "PCIe Function Collection", "PCIeFunctions@odata.count": 1 } ``` Change-Id: I5aa10ce0b4d2f20104612f840cf4098698a83470 Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-04-28Refactor SystemPCIeDevice methodLakshmi Yadlapati1-95/+177
Move SystemPCIeDevice to a separate method, and refactor the code. Validate the PCIe device path. Tested: Validator passed ```# curl -k https://$bmc/redfish/v1/Systems/system/PCIeDevices/pcie_card7 { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card7", "@odata.type": "#PCIeDevice.v1_9_0.PCIeDevice", "Id": "pcie_card7", "Name": "PCIe Device", "PCIeInterface": { "LanesInUse": 4, "PCIeType": "Gen1" } } ``` Change-Id: Ib9bd3ff37293b64adbf9987c3d932882befd21d4 Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-04-28Moving to correct PCIe Device interfaceLakshmi Yadlapati1-1/+1
Move PCIe device interface to "xyz.openbmc_project.Inventory.Item.PCIeDevice". peci-pcie commit: https://gerrit.openbmc.org/c/openbmc/peci-pcie/+/62100 Tested: Validator passed Change-Id: Ica6f4ca37bf9adca18bedc69422ff05f0c7d73f2 Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-04-28Removed myself from OWNERS fileKrzysztof Grobelny1-15/+0
Reason: I will be leaving OpenBmc project soon. Change-Id: I726eaafe38a15636fd855b591bb73b5c62108a5a Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
2023-04-27Remove nameStr from routerEd Tanous1-26/+2
It isn't used anywhere in the code, so it can be removed, and the router simplified. These common data structures have caused problems, in that they're not copied to child handlers, and cause bugs like #249. Tested: Redfish service validator passes. Basic sanity tests of both static file routes such as $metadata (which use DynamicRule) as well as method routes, such as /redfish/v1, return valid data. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I93ad74581912e18ee5db9aaa9ecdaf08ed765418
2023-04-27Remove number support from the routerEd Tanous5-507/+76
The router historically came from crow. Crow supported wildcards of <int>, <float>, and <double>. bmcweb doesn't use them, nor should it in basically any case, as we now have explicit 404 handling. This commit removes them. This amounts to about -450 lines of code, but it's some of the scarier code we have, some of it existing in the namespace "black_magic". Reducing the brain debt for people working in this subsystem seems worthwhile. There is no case in the future where we would use integer based url parameters. Tested: Redfish service validator passes. Should be good enough coverage for a code removal. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I34add8df7d3486952474ca7ec3dc6be990c50ed0
2023-04-25http_connection: Allow empty json objectsLei YU1-1/+1
Currently http_connection will produce empty body in the response if the res.jsonValue is empty, including empty array, object. This makes the output confusing in case a response does contain an empty object or array. Change the code to print the json object even if it's empty object or array, so that the output is consistent with the `res.jsonValue`. Tested: With an OEM URL that returns empty array depending on the system config, the response becomes `[]` instead of empty. Signed-off-by: Lei YU <yulei.sh@bytedance.com> Change-Id: Ie97378a2cffce7b1fd6586a56b6cfa7d5c476dc1
2023-04-25dbus_utility: Support new ObjectMapper methodsWilly Tu1-0/+36
The new ObjectMapper methods are added as part of https://gerrit.openbmc.org/c/openbmc/phosphor-objmgr/+/57822 - GetAssociatedSubTree - GetAssociatedSubTreePaths The two methods are meant to be used to replace places where two dbus calls are used to get subtree and then get associated objects. Change-Id: I80a7ea935700a1ac5aebe6271f242aa103cc3d59 Signed-off-by: Willy Tu <wltu@google.com>
2023-04-25Fix regression in virtual mediaBoleslaw Ogonczyk Makowski1-1/+2
VmMode::Proxy was being checked incorrectly in [1] instead of VmMode::Legacy which didn't allow mounting in legacy mode. Removing return in [2] caused the code to display an error while unmounting even when unmounted successfully. Tested: Can mount in legacy mode Unmounting successfully in legacy mode doesn't display an error [1]: https://github.com/openbmc/bmcweb/commit/365a73f4725a6cefa3d69168ae5500fd05ff8866#diff-3d181e155cfa7f397eface92af17130f3db87773ce4219d9c7e24e00b76b94acR865 [2]: https://github.com/openbmc/bmcweb/commit/365a73f4725a6cefa3d69168ae5500fd05ff8866#diff-3d181e155cfa7f397eface92af17130f3db87773ce4219d9c7e24e00b76b94acL956 Change-Id: I522369cfd81ca084c7379ff97371f8a292950849 Signed-off-by: Boleslaw Ogonczyk Makowski <boleslawx.ogonczyk-makowski@intel.com>
2023-04-19log_services: Fix isContentTypeAllowed checksMatt Spinler1-2/+2
The commit https://gerrit.openbmc.org/c/openbmc/bmcweb/+/56694 inadvertently changed the polarity on the if checks using the newly introduced isContentTypeAllowed function which caused 'Bad Request' to be returned when the content type was allowed. Tested: Getting the EventLog and PostCodes attachment would return the data instead of 'Bad Request'. Signed-off-by: Matt Spinler <spinler@us.ibm.com> Change-Id: Iafcdeaba1a0723326347bb2a832b53bbf0aab230
2023-04-18Copy privilegeset into websocket ruleEd Tanous1-0/+1
Resolves #249 Tested: Running websockets now shows rules being applied ``` Apr 10 20:26:35 p10bmc bmcweb[745]: (2023-04-10 20:26:35) [INFO "http_connection.hpp":209] Request: 0x11e3248 HTTP/1.1 GET /console0 ::ffff:X.XX.XX.XXX | Apr 10 20:26:35 p10bmc bmcweb[745]: (2023-04-10 20:26:35) [DEBUG "routing.hpp":1460] Matched rule (upgrade) '/console0' 1 / 2 Apr 10 20:26:36 p10bmc bmcweb[745]: (2023-04-10 20:26:36) [DEBUG "routing.hpp":1299] userName = admin userRole = priv-admin Apr 10 20:26:36 p10bmc bmcweb[745]: (2023-04-10 20:26:36) [DEBUG "routing.hpp":101] checkPrivileges: Active BASE priv: ConfigureManager <<<<<< Apr 10 20:26:36 p10bmc bmcweb[745]: (2023-04-10 20:26:36) [DEBUG "routing.hpp":101] checkPrivileges: Active BASE priv: ConfigureComponents <<<<<< Apr 10 20:26:36 p10bmc bmcweb[745]: (2023-04-10 20:26:36) [ERROR "routing.hpp":1361] isUserPrivileged: URL: /console0 IsPrivelegeSetEmpty: 0 Username: admin ``` Signed-off-by: Ed Tanous <edtanous@google.com> Tested-by: Ninad Palsule <ninadpalsule@us.ibm.com> Change-Id: Ia2eae1847822b50a425afd2e5e13b528393aa7ad
2023-04-17Fix clang-tidy issue in aggregationEd Tanous1-2/+2
clang-tidy flags the following error, which is correct. ``` ../redfish-core/include/query.hpp:145:26: error: static member accessed through instance [readability-static-accessed-through-instance,-warnings-as-errors] needToCallHandlers = RedfishAggregator::getInstance().beginAggregation( ``` Tested (Carson): Verified that queries to top level collections as well as aggregated resources still return as expected. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I440fb29d2e0b3da52bfd564676d33b72f69f2fbc Signed-off-by: Carson Labrado <clabrado@google.com>
2023-04-12meson: remove deprecated get_pkgconfig_variablePatrick Williams1-1/+1
Since meson 0.56, the `get_pkgconfig_variable` has been deprecated. In meson 0.58 the `get_variable` was enhanced to no longer require the `pkgconfig` keyword argument. Ensure meson 0.58 is required and update the usage of all `get_pkgconfig_variable` and `get_variable` to be the modern variant. Change-Id: I61193ae9fb34cec80af60acef68ff643c392e29d Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2023-04-11Fix PowerSubsystem/PowerSupplies causing validator to failGeorge Liu1-0/+2
In the following commit[1], the member of Members was removed by mistake, causing the validator to fail. This commit fixes this problem. Redfish validator failing with the following: ERROR - Members: Mandatory prop does not exist 1 failMandatoryExist errors in /redfish/v1/Chassis/chassis/PowerSubsystem/PowerSupplies 1 failMandatoryExist errors in /redfish/v1/Chassis/motherboard/PowerSubsystem/PowerSupplies [1] https://gerrit.openbmc.org/c/openbmc/bmcweb/+/57668/26..29//COMMIT_MSG#b15 Tested: Validator passes Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I814e07d860422c5dce0fbb6267cb58dc07a74c31
2023-04-11Implements PowerSupplies schemaGeorge Liu4-0/+134
This commit implements the Redfish PowerSupplyCollection at /redfish/v1/Chassis/<chassis Id>/PowerSubsystem/PowerSupplies. It shall contain an array of links to resources of type PowerSupply that represent the power supplies that provide power to this chassis. For the association between power supply and chassis, refer to[1]. Also, the members property is implemented in the next commit with the PowerSupply implementation, this is so the validator will pass. [1] https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/57428 Tested: Validator passes 1. curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Chassis/chassis/PowerSubsystem/ PowerSupplies { "@odata.id": "/redfish/v1/Chassis/chassis/PowerSubsystem/ PowerSupplies" "@odata.type": "#PowerSupplyCollection.PowerSupplyCollection", "Description": "The collection of PowerSupply resource instances chassis", "Members": [ ], "Members@odata.count": 0, "Name": "Power Supply Collection" } 2. Bad chassisId curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Chassis/chassisError/PowerSubsystem/ PowerSupplies { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The requested resource of type Chassis named 'chassisError' was not found.", "MessageArgs": [ "Chassis", "chassisError" ], "MessageId": "Base.1.13.0.ResourceNotFound", "MessageSeverity": "Critical", "Resolution": "Provide a valid resource identifier and resubmit the request." } ], "code": "Base.1.13.0.ResourceNotFound", "message": "The requested resource of type Chassis named 'chassisError' was not found." } } Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I48e087d6fb52013e3a96b44391cc4d86049ac176
2023-04-07Aggregation: Check for subordinate collectionCarson Labrado2-0/+234
Adds a search function which is able to determine if a passed URI is a top level collection, is uptree from a top level collection, or both. The type being searched for depends on a second argument passed to the function. Each of these searches are used to add links to top level collections which are only supported by a satellite BMC. They all use similar steps so rolling them into a single function cuts down on redundant code. Adds test cases to verify the implementation is correct. Tested: New test cases pass Signed-off-by: Carson Labrado <clabrado@google.com> Change-Id: I72ae7442d5f314656b57a73aee544bca516fa7c2
2023-04-06Fix websocket csrf checkingGunnar Mills2-4/+2
https://github.com/openbmc/bmcweb/commit/f8aa3d2704d3897eb724dab9ac596af8b1f0e33e (4/15/20) added CSRF check into websockets but later setting cookieAuth to true was removed so this session->cookieAuth is always false. https://github.com/openbmc/bmcweb/commit/3909dc82a003893812f598434d6c4558107afa28 (7/15/20). 2 choices here add back this cookieAuth=true when cookie auth is used or remove this "if cookieAuth" and do this check anytime BMCWEB_INSECURE_DISABLE_CSRF_PREVENTION isn't enabled. Really we shouldn't support any other auth on websockets so maybe if (!session->cookieAuth){ unauthorized; } if go with the first choice. Went with the 2nd choice because cleaner. This checking is a bit weird because it uses protocol for csrf checking. https://github.com/openbmc/webui-vue/blob/b63e9d9a70dabc4c9a7038f7727fca6bd17d940a/src/views/Operations/SerialOverLan/SerialOverLanConsole.vue#L98 Tested: Before could log in to webui-vue, delete the XSRF-TOKEN but still connect to the host console. After if deleted the XSRF-TOKEN (browser dev tools), the websocket does not connect. Don't have a system with KVM, VM enabled so wasn't able to check those but the webui-vue code for them looks to pass the token. The webui-vue host console works the same as before if you aren't messing with the XSRF-TOKEN. Change-Id: Ibd5910587648f68809c7fd518bcf5a0bcf8cf329 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2023-04-05Revisit OEM schemasEd Tanous1-57/+85
This documentation was written a while ago, and needs some updates in its statements, as well as updates that have happened to the Redfish spec in the meantime. There's lots of wording here that implies a level of control for maintainers, when really, it's about the ecosystem as a whole. Overall goals in the rewording: - Added emphasis on the Redfish specification rules, not maintainers. - Addition of the OpenBMC namespace (now called out int he specification) and guides to reuse. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iffb88f8c466743fe0badb61d5d5bebfa6741b876
2023-04-04Add HotPluggable support in RedfishLogananth Sundararaj2-17/+42
HotPluggable is an indication of whether this component can be inserted or removed while the equipment is in operation. HotPluggable is a property can read from the Entity manager under the xyz.openbmc_project.Inventory.Decorator.Replaceable interface. Tested: Tested and verified in YosemiteV2 platform and Redfish validator has passed. Change-Id: I7b2203b1843fa3cbdbef7803b598d113346c0682 Signed-off-by: Logananth Sundararaj <logananth_s@hcl.com>
2023-03-29Fix If Match header in Http layerHieu Huynh1-0/+6
Commit [1] prevents the clients performing methods if missing ETag from the If-Match header. For the "If-Match: *" [2] that representing any resource, it should be the valid command. [1] https://github.com/openbmc/bmcweb/commit/2d6cb56b6b47c3fbb0d234ade5c1208edb69ef1f [2] https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match Tested: Can performing methods GET/POST/PATCH/DELETE with "If-Match: *" header. Signed-off-by: Hieu Huynh <hieuh@os.amperecomputing.com> Change-Id: I2e5a81ed33336a939b01bd6b64d3ff99501341d0
2023-03-28Support for configurable host reboot countCorey Hardesty1-29/+107
ComputerSystem.v1.11 introduced a new property, AutomaticRetryAttempts, which allows for the amount of automatic retry attempts on host boot failures to be configured through Redfish. This commit adds support for this new property. The added function "setAutomaticRetryAttempts()" allows users to set the "RetryAttempts" property externally through bmcweb. This property is documented in D-Bus and has a default value of 3. All implementations of the interface have this property implemented. The new code preserves backward compatibility and does not break any existing user-facing behavior. Tested: - Ensured that the new "AutomaticRetryAttempts" property could be retrieved through bmcweb. Verified that it was accurately representing its corresponding DBus property, "RetryAttempts". - Sent curl commands to patch the "AutomaticRetryAttempts" property which also updates the "AttemptsLeft" DBus property represented as "RemainingAutomaticRetryAttempts" as expected. - Verified that changes made to "RetryAttempts" through DBus were accurately represented in successive "Gets" from bmcweb. - Passed Redfish Validator curl -k -H "X-AUTH" -X GET https://${BMC_IP}/redfish/v1/Systems/system/ "Boot": { "AutomaticRetryAttempts": 3, "AutomaticRetryConfig": "RetryAttempts", "AutomaticRetryConfig@Redfish.AllowableValues": [ "Disabled", "RetryAttempts" ], "RemainingAutomaticRetryAttempts": 3, "StopBootOnFault": "Never", "TrustedModuleRequiredToBoot": "Disabled" }, curl -k -X PATCH https://${BMC_IP}/redfish/v1/Systems/system/ -d '{"Boot": {"AutomaticRetryAttempts":4}}' "Boot": { "AutomaticRetryAttempts": 4, "AutomaticRetryConfig": "RetryAttempts", "AutomaticRetryConfig@Redfish.AllowableValues": [ "Disabled", "RetryAttempts" ], "RemainingAutomaticRetryAttempts": 4, "StopBootOnFault": "Never", "TrustedModuleRequiredToBoot": "Disabled" }, Signed-off-by: Corey Hardesty <corey.hardesty@icloud.com> Change-Id: I034782847a2318e2604bdd0cf33cdf705d224acb Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-03-28Aggregation: Prefix fix HttpHeaders propertyCarson Labrado2-0/+73
The "HttpHeaders" property in a response is an array of HTTP headers. We perform prefix fixing on the "Location" header from responses so we should also fix any "Location" headers which are contained by "HttpHeaders" in an aggregated response. This requires special handling since each header is represented as a single string in the response. Added testcase for HttpHeaders property Tested: All unit tests pass Signed-off-by: Carson Labrado <clabrado@google.com> Change-Id: I3040c4ea52b2bebcb6e206bb50585c6a75538f0a
2023-03-24UpdateService: Support for MultipartHttpPushUriGeorge Liu1-47/+167
Since a service support the MultipartHttpPushUri property within the UpdateService resource, so add a new MultipartHttpPushUri property, This property shall contain a URI used to perform a Redfish Specification-defined Multipart HTTP or HTTPS POST of a software image for the purpose of installing software contained within the image, and use the requirements of a multipart/form-data to request body for HTTP push software update. Tested: curl -k -H "X-Auth-Token: $token" -H "Content-Type: multipart/form-data" -F 'UpdateParameters={"Targets":["/redfish/v1/Managers/bmc"], "@Redfish.OperationApplyTime":"Immediate"};type=application/json' -F 'UpdateFile=@obmc-phosphor-image.static.mtd.tar;type=application/ octet-stream' https://${bmc}/redfish/v1/UpdateService/update { "@odata.id": "/redfish/v1/TaskService/Tasks/0", "@odata.type": "#Task.v1_4_3.Task", "Id": "0", "TaskState": "Running", "TaskStatus": "OK" } Passed the validator: Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: Ie1ea0594337efdb073270aba6918389c4381a2b3