summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-02-09Run update-schemas.pyEd Tanous4-7/+60
Apparently these are being edited by hand in some cases, which we should avoid where possible. Based on the contents, it seems pretty likely that 71b861b64bde714410c4fe94f1628a70cb6b17aa is the offending commit that missed checking in these new index files, and was likely editing things by hand. Tested: Redfish service validator passing. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I86f6c46e61139a85ece900a665bce6ac7795800f
2022-02-09Allow setting MinPasswordLength in AccountServicePaul Fertser1-3/+16
The MinPasswordLength property is writable according to the Redfish schema and phosphor-user-manager allows setting it, so implement the corresponding call. Tested: $ curl -k 'https://root:0penBmc@[fe80::5054:ff:fe12:3402%tap0]/redfish/v1/AccountService' -X PATCH -d '{"MinPasswordLength": 12}' { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "Successfully Completed Request", "MessageArgs": [], "MessageId": "Base.1.8.1.Success", "MessageSeverity": "OK", "Resolution": "None" } ] } $ curl -s -k 'https://root:0penBmc@[fe80::5054:ff:fe12:3402%tap0]/redfish/v1/AccountService' | jq .MinPasswordLength 12 root@qemuarm:~# grep cracklib /etc/pam.d/common-password password [success=ok default=die] pam_cracklib.so debug enforce_for_root reject_username minlen=12 difok=0 lcredit=0 ocredit=0 dcredit=0 ucredit=0 $ curl -k 'https://root:0penBmc@[fe80::5054:ff:fe12:3402%tap0]/redfish/v1/AccountService' -X PATCH -d '{"MinPasswordLength": 8}' { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "Successfully Completed Request", "MessageArgs": [], "MessageId": "Base.1.8.1.Success", "MessageSeverity": "OK", "Resolution": "None" } ] } $ curl -s -k 'https://root:0penBmc@[fe80::5054:ff:fe12:3402%tap0]/redfish/v1/AccountService' | jq .MinPasswordLength 8 root@qemuarm:~# grep cracklib /etc/pam.d/common-password password [success=ok default=die] pam_cracklib.so debug enforce_for_root reject_username minlen=8 difok=0 lcredit=0 ocredit=0 dcredit=0 ucredit=0 With https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-user-manager/+/50589 applied this doesn't silently ignore the value that is less than the lower limit and produces an error, the old value is preserved: $ curl -k 'https://root:0penBmc@[fe80::5054:ff:fe12:3402%tap0]/redfish/v1/AccountService' -X PATCH -d '{"MinPasswordLength": 7}' { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The request failed due to an internal service error. The service is still operational.", "MessageArgs": [], "MessageId": "Base.1.8.1.InternalError", "MessageSeverity": "Critical", "Resolution": "Resubmit the request. If the problem persists, consider resetting the service." } ], "code": "Base.1.8.1.InternalError", "message": "The request failed due to an internal service error. The service is still operational." } $ curl -s -k 'https://root:0penBmc@[fe80::5054:ff:fe12:3402%tap0]/redfish/v1/AccountService' | jq .MinPasswordLength 8 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Change-Id: I17e5aa6ca7825fcffbec3939d572bc7ccc01405b
2022-02-09Send push-style event only if EventService enabledsunharis_in2-6/+29
As per DMTF Redfish, if the event service is disabled, events are not expected to be posted to the existing subscribers This commit adds validation to check "ServiceEnabled" property while sending events. An additional check is made not to attempt sending events if there are no event subscribers at BMC Tested by: Using DMTF Redfish-Event-Listener script with some local modification to support the latest event subscription specifications 1. With a Push-style event subscriber setup, set "ServiceEnabled" to false PATCH /redfish/v1/EventService -d '{"ServiceEnabled":false}' 2. Generate events and check no events are posted to subscriber 2. Set "ServiceEnabled" to true. BMC should resume sending further events 3. Check if BMC attempts to send events by forming the eventRecords when there are no subscriptions made - Verified with traces that events are not sent out 4. With "ServiceEnabled" set to false, verified the SubmitTestEvent fails Signed-off-by: Sunitha Harish <sunharis@in.ibm.com> Change-Id: Icbe7c25ba12bbfb73e59639c484fccdf384ebecf
2022-02-08Add UrlFromPieces helper functionEd Tanous2-0/+37
This commit attempts to improve our ability to encode URIs from pieces of a string. In the past, we've used std::string::operator+= for this, which has problems in that bad characters are not encoded correctly into a URI. As an example, if we got a dbus path with _2F (ascii /) in it, our current code would push that directly into the uri and break the redfish tree. Examples of use are provided in the unit tests. Tested: Unit tests pass, no functional changes yet. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I5801d2146a5c948396d4766ac96f1f2b25205a0f
2022-02-08Implement TODO in beast source fileEd Tanous1-45/+1
Now that https://github.com/chriskohlhoff/asio/issues/533 is resolved and https://github.com/boostorg/beast/pull/2331 and https://github.com/boostorg/beast/pull/2337 Are merged and updated into yocto, we can get rid of this ugliness, and do as the author intends. Tested: Unit tests pass, code compiles. Header changes only. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ifa61053c5a7e7fe9b5b0232614e8daa9741b1d6c
2022-02-08Capture int by value in stringValueTooLongEd Tanous2-6/+4
Per the coding standard, we should be capturing this by int, not const int&. Tested: There are no uses of stringValueTooLong(), so noop change to binary. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Idfcb05c962e0a0d489db263a6f845bb1789b5842
2022-02-08Rerun parse_registries.pyEd Tanous4-1634/+1332
After the last string wrapping rule change, we never re-ran the script to regenerate, which puts all of these strings on their own line. While this is non-ideal for reading comprehension, it's the rule we have at the moment, so we should be consistent. 12778e61c281b8f8c0f976dec225fb0c30edcb47 appears to have incorrectly checked in a bad version of the privilege registry, which this commit diffs out again. I have inspected https://redfish.dmtf.org/registries/Redfish_1.2.0_PrivilegeRegistry.json by hand, and verified that those overrides are not present. Tested: Whitespace changes only Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I517a7cf13eba2dfd3211491c08ecce69ee68257f
2022-02-07Enable readability-redundant-control-flow checksEd Tanous13-47/+5
These checks are a nice addition to our static analysis, as they simplify code quite a bit, as can be seen by this diff being negative lines. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I60ede4ad23d7e5337e811d70ddcab24bf8986891
2022-02-07Enable readability-named-parameter checksEd Tanous10-68/+58
We don't have too many violations here, probably because we don't have many optional parameters. Fix the existing instances, and enable the check. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I4d512f0ec90b060fb60a42fe3cd6ba72fb6c6bcb
2022-02-04Remove NEW_BOOST_URL macroEd Tanous3-127/+2
Now that the subtree update is done, this define is no longer needed. Tested: Code compiles. Noop. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Idc5d7ef69c009982a2476fadc1d95e3280bfff48
2022-02-04Remove getTimestampEd Tanous2-51/+18
The aforementioned function is only used in the log services, and is used incorrectly in that context. This commit replaces it with the correct (and unit tested) getDateTimeUintMs, which is what we should be using for dbus->time conversions in all cases, to avoid time_t overflows when static casting. Tested: Before "Created": "2022-01-31T19:39:58+00:00", "Modified": "2022-01-31T19:39:58+00:00", With change: "Created": "2022-01-31T19:39:58.101000+00:00", "Modified": "2022-01-31T19:39:58.101000+00:00", The Redfish validator is okay with this *** /redfish/v1/Systems/system/LogServices/EventLog/Entries/1000 Type (LogEntry.v1_8_0.LogEntry), GET SUCCESS (time: 0) PASS Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie8a2243230ee080d9e8785ae918fad1b1b6ab145
2022-02-02Next round of boost-uri updatesEd Tanous3-0/+118
Boost url has changed some APIs again. This commit updates our URIs to handle it. As part of this work, it also removes some of the debug prints that were put in early on. These aren't really needed these days. This commit invents a temporary #define of NEW_BOOST_URL, so we can get through the subtree update without a hard dependency on this specific version of bmcweb. Ideally boost-url would have some version field, but unfortunately, it is thusfar unversioned, as the long term intent of the author is to be included in boost, and would be versioned there. All the code within the else of the NEW_BOOST_URL flag will be removed once the subtree update is landed. Tested: Added CXXFLAGS:append = " -DNEW_BOOST_URL" to the recipe and checked out on top of the subtree update, and build succeeded. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie2064e45efbc4331bdc5a5ddf44d877cde5e13cb
2022-02-01host-state: do not return anything if unavailableAndrew Geissler1-1/+8
The host state information is provided by the xyz.openbmc_project.State.Host service. There is no guarantee that this service will be up and running by the time bmcweb needs it. Returning an InternalError simply because a service is not yet running is not very user friendly to our clients. In most situations, a client will ignore all data returned when a 500 is returned. Instead of putting systemd Wants/Before type relationships on everything possibly needed by bmcweb, the design point is to simply return what bmcweb can get at that instant in time. With this change, the majority of the redfish system object data can be returned and used by the client. This scenario has been seen a few times on our p10bmc machine. Tested: - Verified that when xyz.openbmc_project.State.Host was unavailable, a call to redfish/v1/Systems/system returned what was available without error. - Verified that redfish validator passed - Verified that redfish validator passed when xyz.openbmc_project.State.Host.service was unavailable Change-Id: I22c6942d2c81083bf90fa4180e95b1fa19221374 Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
2022-01-28Enable readability-container-size-empty testsEd Tanous26-57/+57
This one is a little trivial, but it does help in readability. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I5366d4eec8af2f781b3bad804131ae2eb806e3aa
2022-01-28Simplify human sortEd Tanous1-46/+41
Clang-tidy correctly noted that this method was overly complex and could be simplified. This commit does exactly that. Tested: Unit tests run and passing. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ia225f0d8cc5942f776bc8d5b48ca91de40596451
2022-01-27getDateTimeStdtime: fix building warnings in 32bitsNan Zhou1-7/+12
Also made std::min their own lines to be more readable. Tested: unit test passes and it builds via bitbake. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: Ic32b886cca7c2901d77b4baffd4d4a6d655e0b14
2022-01-26Implement Cable schemaShantappa Teekappanavar10-2/+1159
This commit implements Cable and Cable collection schema on bmcweb. Testing: Validator: @odata.id /redfish/v1/Cables odata Exists PASS @odata.type #CableCollection.CableCollection odata Exists PASS Members@odata.count 2 odata Exists PASS Members Array (size: 2) links: Cable Yes ... Members[0] Link: /redfish/v1/Cables/dp0_cable0 link: Cable Yes PASS Members[1] Link: /redfish/v1/Cables/dp0_cable1 link: Cable Yes PASS Description Collection of Cable Entries none Yes PASS Name Cable Collection none Yes PASS Oem - Resource.Oem No Optional Property Name Value Type Exists Result @odata.id /redfish/v1/Cables/dp0_cable0 odata Exists PASS @odata.type #Cable.v1_0_0.Cable odata Exists PASS CableType string Yes PASS LengthMeters - number No Optional Id dp0_cable0 none Yes PASS Name Cable none Yes PASS Property Name Value Type Exists Result @odata.id /redfish/v1/Cables/dp0_cable1 odata Exists PASS @odata.type #Cable.v1_0_0.Cable odata Exists PASS CableType string Yes PASS LengthMeters - number No Optional Id dp0_cable1 none Yes PASS Name Cable none Yes PASS Note: Removed some of the fields that are optional to reduce commit msg Tesing with Curl commands: $ curl -k -X GET https://{$bmc}/redfish/v1/Cables { "@odata.id": "/redfish/v1/Cables", "@odata.type": "#CableCollection.CableCollection", "Description": "Collection of Cable Entries", "Members": [ { "@odata.id": "/redfish/v1/Cables/dp0_cable0" }, { "@odata.id": "/redfish/v1/Cables/dp0_cable1" } ], "Members@odata.count": 2, "Name": "Cable Collection" } $ curl -k -X GET https://{$bmc}/redfish/v1/Cables/dp0_cable0 { "@odata.id": "/redfish/v1/Cables/dp0_cable0", "@odata.type": "#Cable.v1_0_0.Cable", "CableType": "", "Id": "dp0_cable0", "Name": "Cable" } $ curl -k -X GET https://{$bmc}/redfish/v1/Cables/dp0_cable1 { "@odata.id": "/redfish/v1/Cables/dp0_cable1", "@odata.type": "#Cable.v1_0_0.Cable", "CableType": "", "Id": "dp0_cable1", "Name": "Cable" } Set Length property to 1.5 meters using busctl, and check the properties busctl set-property xyz.openbmc_project.Inventory.Manager \ /xyz/openbmc_project/inventory/cables/dp0_cable0 \ xyz.openbmc_project.Inventory.Item.Cable Length d 1.5 $ curl -k -X GET https://{$bmc}/redfish/v1/Cables/dp0_cable0 { "@odata.id": "/redfish/v1/Cables/dp0_cable0", "@odata.type": "#Cable.v1_0_0.Cable", "CableType": "", "Id": "dp0_cable0", "LengthMeters": 1.5, "Name": "Cable" } Signed-off-by: Shantappa Teekappanavar <sbteeks@yahoo.com> Change-Id: I832ff1c1053f4d8100d04a42cc8046a61e8c1613
2022-01-26[Fix]: Property PhysicalContext is invalid "none"sunitakx5-0/+445
Issue: Redfish validator is throwing error "PhysicalContext: This type is invalid none" for multiple temperature sensors Endpoint : /redfish/v1/Chassis/<Baseboard>/Thermal#/Temperatures/ Root Cause : PhysicalContext Schema was missing from redfish schema metadata Tested: Redfish validator script passed. *** /redfish/v1/Chassis/<baseboard>/Thermal#/Temperatures/0 Type (#Thermal.v1_3_0.Temperature), GET SUCCESS (time: 0) PASS Signed-off-by: sunitakx <sunitax.kumari@intel.com> Change-Id: Ifbfe7d96e99030c0c5ba67a1aba5080cd049e57b
2022-01-25Fix Boost exceptions in GetDateTime seriesEd Tanous2-32/+45
In cases when the input time is too large, we return the maximum supported date in the ISO Extended format. Tested: Unit tests pass Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I0dcd60d10d4357bd8700f0dbc1ef86d94bcc82bb
2022-01-25Update unit tests for getDateTimeEd Tanous1-7/+40
the GetDateTime series needs more unit tests to ensure that we don't get bad behavior when we hit the extremes. This commit does include one tests, for getDateTimeUint that currently throws an exception that shouldn't, which is currently commented out. This needs looked at by someone. Tested: Unit tests pass Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I7f45e5d84d644780832112dca14bdb9c768903ff
2022-01-20EthernetInterfaces:GET & PATCH support for MTUSizeTejas Patil1-2/+39
This commit add support for MTUSize property with GET and PATCH methods under Redfish URI "/redfish/v1/Managers/bmc/EthernetInterfaces/<id>". This property shows the maximum size of the Protocol Data Uint (PDU) in bytes, that can be passed in an Ethernet frame on the network interface. User can GET and SET the MTU Size of any available network interface. The backend implementation for this is committed to below link https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-networkd/+/455591 Testing: - Redfish Validator Test Passed. - curl -k -H "X-Auth-Token: $token" -X PATCH -d '{"MTUSize" : 1280}' https://${bmc}/redfish/v1/Managers/bmc/EthernetInterfaces/eth3 - curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Managers/bmc/EthernetInterfaces/eth3 { "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth3", "@odata.type": "#EthernetInterface.v1_4_1.EthernetInterface", "DHCPv4": { "DHCPEnabled": true, "UseDNSServers": true, "UseDomainName": true, "UseNTPServers": true }, "DHCPv6": { "OperatingMode": "Stateful", "UseDNSServers": true, "UseDomainName": true, "UseNTPServers": true }, "Description": "Management Network Interface", "FQDN": "evb-ast2600", "HostName": "evb-ast2600", "IPv4Addresses": [ { "Address": "10.0.126.64", "AddressOrigin": "DHCP", "Gateway": "10.0.120.1", "SubnetMask": "255.255.248.0" } ], "IPv4StaticAddresses": [], "IPv6AddressPolicyTable": [], "IPv6Addresses": [ { "Address": "4001:df24:df25:df26:a069:c2ff:fe62:1c52", "AddressOrigin": "DHCPv6", "AddressState": null, "PrefixLength": 64 }, { "Address": "fe80::a069:c2ff:fe62:1c52", "AddressOrigin": "LinkLocal", "AddressState": null, "PrefixLength": 64 }, { "Address": "1001:7:7:7:a069:c2ff:fe62:1c52", "AddressOrigin": "DHCPv6", "AddressState": null, "PrefixLength": 64 } ], "IPv6DefaultGateway": "0:0:0:0:0:0:0:0", "IPv6StaticAddresses": [], "Id": "eth3", "InterfaceEnabled": true, "LinkStatus": "LinkUp", "MACAddress": "a2:69:c2:62:1c:52", "MTUSize": 1280, "Name": "Manager Ethernet Interface", "NameServers": [ "10.0.0.31", "10.0.0.32" ], "SpeedMbps": 0, "StaticNameServers": [], "Status": { "Health": "OK", "HealthRollup": "OK", "State": "Enabled" }, "VLANs": { "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth3/VLANs" } } Signed-off-by: Tejas Patil <tejaspp@ami.com> Change-Id: I8f55b3b5016503baecb7b85784d1a8bece69a258
2022-01-20Fix undefined property in PCIeFunctionCollectionJiaqing Zhao1-1/+1
According to Redfish spec, current "PCIeFunctions@odata.count" in PCIeFunctionCollection should be "Members@odata.count". Tested: Redfish validator passed. Change-Id: Iaabcad0f19b619eea26e2902944d3262fe499a5b Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2022-01-20managers: Fix incorrect property name for "Class"Lei YU1-1/+1
The commit 711ac7a9 introduces a bug in redfish-core/lib/managers.hpp that it uses the incorrect property name when getting "Class"'s value. This results in HW CI error that is related to /redfish/v1/Managers/bmc, and manually access this URI results in 500 InternalError. Tested: Verify the /redfish/v1/Managers/bmc URI is OK and the HW CI passes. Signed-off-by: Lei YU <yulei.sh@bytedance.com> Change-Id: Ieb8f98b6cfee6aa22a0320d2410a9b96c536c080
2022-01-19Include what you useEd Tanous7-6/+19
Do a partial update from the include what you use tool. While ideally we'd be able to do this as part of CI, there's still quite a bit of noise in the output that requires manual intervention. Tested: Code compiles Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iaaeb7a9199f64b5d6913c3abab4779b252768ed8
2022-01-18bmcweb: Add/Move common typedefs to dbus utilityShantappa Teekappanavar2-15/+16
The following typedefs that are commonly used by redfish services to get dbus subtree objects: MapperServiceMap = std::vector<std::pair<std::string, std::vector<std::string>>> MapperGetSubTreeResponse = std::vector<std::pair<std::string, MapperServiceMap>> This commit adds the above mentioned typedefs to dbus utility namespace and removes locally defined typedefs in processor.hpp. Testing: Validator: No errors Few sample outputs from curl command: $ curl -k -X GET https://{$bmc}/redfish/v1/Systems/system/Processors { "@odata.id": "/redfish/v1/Systems/system/Processors", "@odata.type": "#ProcessorCollection.ProcessorCollection", "Members": [ { "@odata.id": "/redfish/v1/Systems/system/Processors/dcm0-cpu0" }, { "@odata.id": "/redfish/v1/Systems/system/Processors/dcm0-cpu1" }, { "@odata.id": "/redfish/v1/Systems/system/Processors/dcm1-cpu0" }, { "@odata.id": "/redfish/v1/Systems/system/Processors/dcm1-cpu1" } ], "Members@odata.count": 4, "Name": "Processor Collection" } $ curl -k -X GET https://{$bmc}/redfish/v1/Systems/system/Processors/dcm0-cpu0 { "@odata.id": "/redfish/v1/Systems/system/Processors/dcm0-cpu0", "@odata.type": "#Processor.v1_12_0.Processor", "Id": "dcm0-cpu0", "Location": { "PartLocation": { "ServiceLabel": "U78DA.ND0.WZS004K-P0-C15" } }, "LocationIndicatorActive": false, "Manufacturer": "", "MaxSpeedMHz": 0, "Model": "5C67", "Name": "PROCESSOR MODULE", "PartNumber": "03JM290", "ProcessorId": { "EffectiveFamily": "" }, "ProcessorType": "CPU", "SerialNumber": "YA3936061828", "Socket": "", "SparePartNumber": "F210110", "Status": { "Health": "OK", "State": "Enabled" }, "SubProcessors": { "@odata.id": "/redfish/v1/Systems/system/Processors/dcm0-cpu0/SubProcessors" }, "TotalCores": 8, "TotalThreads": 0 } $ curl -k -X GET https://{$bmc}/redfish/v1/Systems/system/Processors/dcm0-cpu0/SubProcessors { "@odata.id": "/redfish/v1/Systems/system/Processors/dcm0-cpu0/SubProcessors", "@odata.type": "#ProcessorCollection.ProcessorCollection", "Members": [], "Members@odata.count": 0, "Name": "SubProcessor Collection" } Signed-off-by: Shantappa Teekappanavar <sbteeks@yahoo.com> Change-Id: I297c763af38fa5b13ef297e911b338f406b7c6e6
2022-01-13Simplify Crashdump file transferJason M. Bills1-15/+4
This changes to a streambuf_iterator to read the file contents into the response body. It may be slightly slower, but it's easier to read and has less opportunity for errors. Tested: Confirmed that a Crashdump file can be successfully downloaded through Redfish using a browser. Change-Id: Ic143fe4274678e89330bf354d1b8098550e8b85b Signed-off-by: Jason M. Bills <jason.m.bills@intel.com>
2022-01-13Fix 32/64 bit compile issueEd Tanous1-1/+3
It turns out std::string, std::fstream::read, and std::ifstream::tellg all use different integer types, which differ depending on 32 vs 64 bit. This is similar to the problem we already had, just now the compiler is warning us. Wrap in a static_cast to make sure it builds for all environments. Tested: Code compiles in 32 bit. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie8fd610812fd2271e6be599dacca583747b9217f
2022-01-12Fix regresssion in nameEd Tanous1-1/+1
It's unclear whether clang-format lost its mind, or if I did this unintentionally, but it's clearly wrong, and for systems that have sensors in warning, causes a ERROR - Health: Value wARNING Enum not found in ['OK', 'Warning', 'Critical'] error in the service validator. Fix this. Tested: Code compiles, revert. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: If79654fd7026080c89de0ece2c553e6edf97fd8f
2022-01-12Enable and enforce cpp core guidelinesEd Tanous1-0/+8
While in theory we enforce cpp core guidelines in code review, clearly, we're missing some things. This commit enables all the automated checks that we can pass reasonably at the moment. Tested: Code compiles Tested: Ran redfish service validator on the result of the series. No new failures. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I6dca1c822de38931eb9fa252db99fb57401b5a46
2022-01-12Enable pro-type-static-cast-downcast checksEd Tanous2-10/+4
We only had one usage, and it was really bad and breaking const correctness, so fix it to read the crashdump in inline. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I234946fe09d73a9fa0191a15a89d0b2c26f32337
2022-01-12Enable malloc checksEd Tanous2-0/+3
We only use malloc in one place, when we hand a pointer off to PAM. Ignore that one issue, and enable the check. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I37c41c193bae1bab370b03944617c642df0179fc
2022-01-12enable cppcoreguidelines-pro-type-vararg checksEd Tanous2-4/+8
We only use varargs in some code we borrowed from nlohmann, so ignore that, and enable the check. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iab1305784e7532e2ee10c617fb59b75aba142ce6
2022-01-12Enable pro-type-cstyle-cast checksEd Tanous2-2/+4
We actually do a pretty good job of this, and only have one C style cast, that's part of an openssl macro, so ignore the one, and enable the checks. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie0462ee947c8310457365ba2aeea78caedb93da1
2022-01-12Enable const_cast checksEd Tanous4-4/+13
const_cast is an anti pattern. There are a few places we need to do it for interacting with C APIs, so enable the checks, and ignore the existing uses. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: If1748213992b97f5e3e04cf9b86a6fcafbb7cf06
2022-01-12Enable pointer devolution checksEd Tanous3-3/+13
Enable cpp core guidelines checks for pointer deevolution. For the moment, simply ignore the uses, although ideally these should be cleaned up at some point. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I9a8aae94cc7a59529eab89225a37e89628c17597
2022-01-12Enable cpp core guidelines macro checksEd Tanous3-0/+15
We only use a couple macros. Ignore them in the checks. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I38feb10f76f6aaea8899617f081c9be68c88b3eb
2022-01-12Enforce variable initEd Tanous6-10/+13
There were a few places we weren't initting our variables per cpp core guidelines. Fix all of them, and enable checks for this. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iba09924beb9fb26f597ff94d1cecbd6d6b1af912
2022-01-12Enable checks for pointer arithmeticEd Tanous8-9/+40
Quite a few places we've disobeyed this rule, so simply ignore them for now to avoid new issues popping up. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I3e518a8e8742279afb3ad1a9dad54006ed109fb1
2022-01-12Enable reinterpre_cast checksEd Tanous7-23/+44
We seem to use reinterpret cast in a few cases unfortunately. For the moment, simply ignore most of them, and make it so we don't get more. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ic860cf922576b18cdc8d51d6132f5a9cbcc1d9dc
2022-01-12Enable cppcoreguidelines-special-member-functions checksEd Tanous24-0/+118
Part of enforcing cpp core guidelines involves explicitly including all constructors required on a non-trivial class. We were missing quite a few. In all cases, the copy/move/and operator= methods are simply deleted. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie8d6e8bf2bc311fa21a9ae48b0d61ee5c1940999
2022-01-12Enable init checkerEd Tanous15-32/+31
clang-tidy added cppcoreguidelines-init-variables as a check, which is something we already enforce to some extent, but getting CI to enforce it will help reviews move faster. Tested: Code compiles. Noop changes. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I7e10950de617b1d3262265572b1703f2e60b69d0
2022-01-12Enable clang-tidy checks we already passEd Tanous1-1/+10
clang-13 brought some additional checks we can turn on that we already pass, so enable them. List of checks can be found in the diff, and includes the suspicious includes check, which we previously had to disable due to a clang bug. Tested: Code compiles, clang-tidy passes Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I1a4d1da0a8e775cdeb6b898bc1cdb0f3f7b6f06a
2022-01-12Enable bugprone widening checks in clangEd Tanous4-5/+7
Most of the errors we hit are simply places we need to explicitly increase the width of the integer. Luckily, these are few and far between. Tested: Code compiles, unit tests pass. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I617d87f3970ae773e0767bb2f20118fca2e71daa
2022-01-12enable bugprone exception escape checkEd Tanous5-6/+48
clang-13 includes new checks, and finds some issues. The first is that the boost::vector constructor can possibly throw, so replace the underlying flat_map container with std::vector instead. The others are places where we could possibly throw in destructors, which would be bad. Ideally we wouldn't use the destructor pattern, but that would be non-trivial to clean up at this point, so just catch the exception, and log it. At the same time, catch exceptions thrown to main and log them. Tested: Code compiles Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I77b86eaa2fc79e43d1ca044c78ca3b0ce0a7c38c
2022-01-12Enable clang-tidy forward reference checksEd Tanous10-31/+45
Clang-13 adds new checks we can turn on, which find quite a few errors. Tested: Code compiles Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I74b780760014c898cc440b37aea640b33e91c439
2022-01-12Fix seg fault in healthEd Tanous1-4/+4
https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/49840 was recently checked in that made some changes here, and had issues that weren't caught on my system because of how my sensor setup is setup. This commit changes to only make a single copy, then filter the copy inplace, rather than make a copy, filter, then do the move. Tested: Ran redfish service validator in a similar setup to Romulus, and saw that it passed with the same failures as previously. Unit tested: curl --insecure -u root:0penBmc "https://192.168.7.2:443/redfish/v1/TaskService" now succeeds Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I5b59b7074e0a7aad4e95c5ddb625ff24170f3981
2022-01-11Fixed timestamp in telemetry serviceKrzysztof Grobelny2-13/+19
Telemetry service is using timestamp with milliseconds accuracy. Bmcweb code assumed that timestamp is in seconds which produced a bad result. This patchset updates the APIs, and adds a getDateTimeUintMs method, which can be used to convert a millisecond timestamp into a string. In the future, this can be used to get more precision out of the API. Reference: '9.4.3. Date-Time values' https://www.dmtf.org/sites/default/files/standards/documents/DSP0266_1.8.0.pdf Tested: - Telemetry service timestamp show correct timestamp with milliseconds precission. Example: 2022-01-11T13:06:58.648000+00:00 - Other timestamps in bmcweb did not change - All unit tests are passing Reference: Properties.Readings https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Telemetry/Report.interface.yaml Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com> Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I5b40ef6889b5af8c045ec0d35a758967e53dbed2
2022-01-10Enforce const correctnessEd Tanous10-38/+41
For all async calls, we should be consistently capturing non trivial objects by const reference. This corrects bmcweb to be consistent and capture errors by const value, and objects by const reference. Tested: Code compiles. Trivial changes. This saves about 300 bytes on our compressed binary size. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ib3e0b6edef9803a1c480701556949488406305d4
2022-01-10Consistently use ManagedObjectTypeEd Tanous13-474/+443
Some subsystems seem to have invented their own typedefs for this stuff, move to using the one typedef in dbus::utility so we're consistent, and we reduce our templates. Tested: code compiles This saves a negligible amount (104 bytes compressed) on our binary size. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I952ea1f960aa703808d0ac80f35dc24cdd8d5027
2022-01-10Convert VariantType to DbusVariantTypeAppaRao Puli1-3/+4
All bmcweb code is now converted to use DbusVariantType to reduce the image size. Its missed in one place where the code is under compiler flag BMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE. This commit convert missed types to DbusVariantType. Tested: After conversion, image builds fine with compiler flag enabled. Also tested the PFR provisioned dbus calls and it works fine. Change-Id: Idcef956a18a6f822c44399ef867e26551dd8124f Signed-off-by: AppaRao Puli <apparao.puli@intel.com>