summaryrefslogtreecommitdiff
path: root/include
AgeCommit message (Collapse)AuthorFilesLines
2022-03-03Fix clang warnings related to OpenSSL 1.xSzymon Dompke1-2/+2
When CI tests are run locally on machine without OpenSSL 3.0, there are some warnings during clang-tidy scan. They are related to unsupported c-style code (implicit bool/int conversion, casting, and varagrs functions). This change is fixing all of them, without changing functionality. Testing done: - running docker image with UTs on local Ubuntu machine with SSL 1.1 is passing all tests, and no clang errors are reported. Signed-off-by: Szymon Dompke <szymon.dompke@intel.com> Change-Id: I5ec91db8f02f487786811afad77080137bab3c9a
2022-03-02Use std::variantEd Tanous1-3/+2
When first committed, I had a misunderstanding of what dedup variant does. In this case, because we unpack all variants of 64/32 bit and int vs uint, so in this case, dedup variant doesn't do anything, and just adds template complexity. In terms of developer readability, std::variant is a c++ concept that is infinitely googlable, and not having to look it up through sdbusplus should be better. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ia73b642fd06b24187503196bcdfecb9c896d62c9
2022-03-01Remove flat_maps from our dbus parsing typesEd Tanous1-2/+2
There's nowhere in the codebase where we actually use these as maps. 99% of the time, we just iterate and pull these into specific data structures anyway, so there's no reason for them to be maps. This saves a negligible amount (600 bytes) on our compressed binary size. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I91085cfa2cf8d70e0f0fa0f2f3927776667d834f
2022-03-01Change the completionhandler to accept ResNan Zhou2-16/+3
These modifications are from WIP:Redfish:Query parameters:Only (https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/47474). It will be used in future CLs for Query Parameters. The code changed the completion handle to accept Res to be able to recall handle with a new Response object. AsyncResp owns a new res, so there is no need to pass in a res. Also fixed a self-move assignment bug. Context: Originally submitted: https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/480020 Reveted here: https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/48880 Because of failures here: https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/48864 Tested: 1. Romulus QEMU + Robot tests; all passed 2. Use scripts/websocket_test.py to test websockets. It is still work correctly. 3. Tested in real hardware; no new validator errors; tested both authless, session, and basic auth. 4. Hacked codes to return 500 errors on certain resource; response is expected; 5. Tested Eventing, the push style one (not SSE which is still under review), worked as expected. 6. Tested 404 errors; response is expected. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Signed-off-by: John Edward Broadbent <jebr@google.com> Change-Id: I52adb174476e0f6656335baa6657456752a031be
2022-02-25json_utils: Add support jsonRead Patch/ActionWilly Tu1-9/+9
Added support for readJson for Patch and Action. The only difference is that Patch does not allow empty json input while Action does. Action with empty input will use the default value based on the implementation and return 200 OK response code. readJsonPatch will replace the existing readJson and be used for path requests. It will not allow empty json input and all requested keys are required in the json input. readJsonAction will be used for Action requests where it is possible for all of the properties to be optional and allow empty request. The optional properties are determined by the requested values type. All current Action readJson are replaced with readJsonAction. It does not change the existing behavior since it needs `std::optional`. This will have to be updated later as we define the default behavior. Tested: Added unit tests and readJsonAction allows empty empty json object. No Change to Redfish Tree. Change-Id: Ia5e1f81695c528a20f1dc985aee19c920d8adaea Signed-off-by: Willy Tu <wltu@google.com>
2022-02-23Fix clang-tidy issues in nbd proxyEd Tanous1-1/+7
All changes done by the robot, and are trivial. Tested: Code passes clang-tidy. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I04a19bcc5ec74eddf9f3490adbdf70ac5a8bc68f
2022-02-23Update nbd_proxy for new ManagedObjectTypeJason M. Bills1-82/+68
This used to rely on the boost::flat_map find() to find the interface and properties. After the ManagedObjectType changed to a std::vector of std::pair it needs to loop instead of using find() Signed-off-by: Jason M. Bills <jason.m.bills@intel.com> Change-Id: I08d3f09dbfb5ad449aaa058a44d86f4c3eb1a25c
2022-02-17Prepare for clang-tidy-14Ed Tanous2-4/+4
clang-tidy 14 now detects some more stuff that it couldn't before. These are all pretty reasonable and things that we enforce today. All changes were made by the robot. Tested: Code compiles and unit tests pass. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I880d714c97adc38a190472766fb922fbfb30e82a
2022-02-17Use (size() == 0) check for multi_bufferJason M. Bills1-1/+1
multi_buffer doesn't support empty(), so need to check for (size() == 0) instead. Signed-off-by: Jason M. Bills <jason.m.bills@intel.com> Change-Id: I98abaebc68e11d769da57d8e2c1ef54c94f64521
2022-02-15Enable readability-uppercase-literal-suffixEd Tanous1-3/+3
We only had a few violations of this; Fix them and enable the check. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I159e774fd0169a91a092218ec8dc896ba9edebf4
2022-02-15readability-static-accessed-through-instanceEd Tanous1-2/+2
We access std::string::npos through member variables in a couple places. Fix it. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I587f89e1580661aa311dfe4e06591ab38806e241
2022-02-15Enable readability-implicit-bool-conversion checksEd Tanous8-21/+23
These checks ensure that we're not implicitly converting ints or pointers into bools, which makes the code easier to read. Tested: Ran series through redfish service validator. No changes observed. UUID failing in Qemu both before and after. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I1ca0be980d136bd4e5474341f4fd62f2f6bbdbae
2022-02-11Add readability-redundant-* checksEd Tanous5-6/+8
There's a number of redundancies in our code that clang can sanitize out. Fix the existing problems, and enable the checks. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie63d7b7f0777b702fbf1b23a24e1bed7b4f5183b
2022-02-09Enable readability-avoid-const-params-in-declsEd Tanous5-5/+5
This check involves explicitly declaring variables const when they're declared auto, which helps in readability, and makes it more clear that the variables are const. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I71198ea03850384a389a56ad26f2c4a48c75b148
2022-02-07Enable readability-redundant-control-flow checksEd Tanous4-21/+2
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 Tanous2-16/+18
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-01-28Enable readability-container-size-empty testsEd Tanous6-11/+10
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-19Include what you useEd Tanous1-2/+0
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 Teekappanavar1-0/+8
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-12Enable malloc checksEd Tanous1-0/+2
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 Tanous1-4/+7
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 const_cast checksEd Tanous2-4/+11
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-12Enforce variable initEd Tanous2-4/+4
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 Tanous5-5/+26
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 Tanous4-13/+30
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 Tanous7-0/+42
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 Tanous6-12/+10
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 bugprone widening checks in clangEd Tanous1-2/+2
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 Tanous2-4/+19
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 Tanous2-3/+4
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-10Enforce const correctnessEd Tanous2-5/+5
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 Tanous1-4/+2
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-04Make clang-tidy passGunnar Mills1-5/+5
CI is failing on master due to clang-tidy failing for: error: invalid case style for variable 'pkey_ctx' [readability-identifier-naming,-warnings-as-errors] EVP_PKEY_CTX* pkey_ctx = ^~~~~~~~ pkeyCtx Change variable name to make clang-tidy happy. This was introduced in 145bb764. Tested: None. CI passing will validate clang-tidy passing. Change-Id: Iedd8a40a871940066743ff8698dad53bfb0407c0 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2021-12-28Move to common variantEd Tanous3-62/+58
This saves approximately 34kB in the compressed binary size of bmcweb due to reduced template instantiations. This amounts to a 2.5% reduction in the overall size. Note, there were a few places where we broke const-correctness in the form of pulling a non-const reference out of a const variant. This new variant now requires const correctness, so some consts are added where required. Tested: Code compiles. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I6a60c8881c1268627eedb4ffddf16689dc5f6ed2
2021-12-22Add more types to DbusVariantTypeEd Tanous2-10/+60
Ideally, we'd use the DbusVariantType for all variant uses within bmcweb to help with binary size. This commit adds all of the missing types to DbusVariantType in the pursuit of this goal Adding these new types made the struct pretty unwieldy, so as part of that port, it disables clang-format and puts each item on its own line to help with readability. At some point in the future, this list could be alphabetized, but the ordering has the potential to change the function of this, so it's avoided for the moment. As an unrelated note, it turns out that the dbus-rest API never knew how to serialize file descriptors. Using a FD off the system doesn't make much sense, but now that we have a common variant type, we're required to provide serialization specializations, so for the moment this code just converts it to an int. Tested: Code compiles Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ice1953a163c761024f969acf1aa2654a8a7e9661
2021-12-20Implement MIME parsingEd Tanous3-0/+621
This commit adds two core features to bmcweb: 1. A multipart mime parser that can read multipart form requests into bmcweb. This is implemented as a generic parser that identifies the content-type strings and parses them into structures. 2. A /login route that can be logged into with a multipart form. This is to allow changing the login screen to a purely forms based implementation, thus removing the very large whitelist we currently have to maintain, and removing javascript from our threat envelope. More testing is still needed, as this is a parser that exists outside of the secured areas, but in this simple example, it seems to work well. Tested: curl -vvvvv --insecure -X POST -F 'username=root' -F 'password=0penBmc' https://<bmc ip address>:18080/login Returned; { "data": "User 'root' logged in", "message": "200 OK", "status": "ok" } Change-Id: Icc3f4c082d584170b65b9e82f7876926cd38035d Signed-off-by: Ed Tanous<ed@tanous.net> Signed-off-by: George Liu <liuxiwei@inspur.com>
2021-12-15ssl_key_handler: support OpenSSL 3.0 for key verificationPatrick Williams1-0/+24
Loading and checking of keys is one area where OpenSSL 1.0 and 3.0 are not compatible. Many of the functions currently used in the ssl_key_handler are deprecated in 3.0, but the APIs necessary for conversion also do not exist in 1.0. Until OpenSSL 3.0 is widely used in Linux distributions we therefore need to support both APIs. Add a #define on the OPENSSL_VERSION_NUMBER to identify 3.x (or greater) support and switch between the two API sets. Tested: Added to a Yocto test build for the subtree update that includes OpenSSL 3.x and confirmed Romulus QEMU test is successful. Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I22bc77753bb32d1b92932f9918d64856a4e52af8
2021-12-15ssl_key_handler: use OpenSSL 3.0 API for keygenPatrick Williams1-0/+41
The APIs for generating an EC key for have changed between OpenSSL 1.x and OpenSSL 3.x. Create a separate implementation for OpenSSL 3.x. Tested: Copied code from phosphor-certificate-manager, which was tested using unit tests, and confirmed it builds and runs when compiled with the OpenSSL 3.x library. Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I6df0fb5429e0812763dad4a208bb914fb285fd78
2021-12-10Add logging to internal errorEd Tanous1-0/+27
Internal error call sites are propagated through the code, and might be triggered multiple times in the course of a request, which makes them difficult to track the source of. This commit changes the internalError() method to include a print of which invocation within bmcweb triggered the error, using c++20s std::source_location mechanism. Note: clang-13 still doesn't implement std::source_location, so this commit pulls source_location.hpp from lg2 to be able to support all compilers. Tested: Loaded in qemu, and added an internalError() call into systems.hpp for the /redfish/v1/Systems handler. Observed that [CRITICAL "error_messages.cpp":234] Internal Error ../../../../../../workspace/sources/bmcweb/redfish-core/include/../lib/systems.hpp(2820:40) `redfish::requestRoutesSystemsCollection(App&)::<lambda(const crow::Request&, const std::shared_ptr<bmcweb::AsyncResp>&)>`: Got printed to the bmcweb logs. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ic1b4240422445357bc87404de814ad14f86b9edf
2021-12-10Convert IPv4-mapped IPv6 ClientIP back to IPv4Jiaqing Zhao3-9/+11
Current HTTP server creates an IPv6 acceptor to accept both IPv4 and IPv6 connections. In this way, IPv4 address will be presented as IPv6 address in IPv4-mapped format. This patch converts it back to IPv4. Tested: Verified the ClientOriginIP in Session is shown in native IPv4 format instead of IPv4-mapped IPv6 format. Change-Id: Icd51260b2d4572d52f5c670128b7f07f6b5e6912 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2021-11-18meson_options: implement disable-auth; delete pamNan Zhou1-7/+9
Implemented the disable-auth option. This patch also removed the pam option which never worked. Tested: With disable-auth, ``` ~# wget -qO- http://localhost/redfish/v1/Systems/ { "@odata.id": "/redfish/v1/Systems", "@odata.type": "#ComputerSystemCollection.ComputerSystemCollection", "Members": [ { "@odata.id": "/redfish/v1/Systems/system" } ], "Members@odata.count": 1, "Name": "Computer System Collection" } ``` Without disable-auth, ``` ~# wget -qO- http://localhost/redfish/ { "v1": "/redfish/v1/" } ~# wget -qO- http://localhost/redfish/v1/Systems/system wget: server returned error: HTTP/1.1 401 Unauthorized ``` Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I88e4e6fa6ed71096bc866b42b9af283645a65988
2021-11-16reduce error traces in connection and auth codeAndrew Geissler1-1/+1
These logs are reported in good paths (at least web interfaces are working fine when they are logged). Convert them to warnings so they do not show up as false errors when debugging bmcweb. Here's the log we were getting: Oct 08 19:20:48 p10bmc bmcweb[15348]: (2021-10-08 19:20:48) [ERROR "http_connection.hpp":537] 0x14bd360 Error while reading: end of stream Oct 08 19:20:48 p10bmc bmcweb[15348]: (2021-10-08 19:20:48) [ERROR "http_connection.hpp":531] 0x14910b0 async_read_header 308 Bytes Oct 08 19:20:48 p10bmc bmcweb[15348]: (2021-10-08 19:20:48) [ERROR "authorization.hpp":292] authHeader= These code paths, and why they are not real errors, is not totally clear to me. Hoping for some discussion on it in this review. Tested: - Verified these no longer show up when doing basic system management with just error traces enabled in bmcweb Change-Id: If357aeb93ff28ef02e135a888524e057cb188871 Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
2021-11-16Revert "Change the completionhandler to accept Res"Gunnar Mills2-3/+16
This reverts commit 91995f3272010875e1559397e98ca93354066a0e. Seeing bumps fail. https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/48864 Please fix, test, and resubmit. Change-Id: Id539fe66d5a093caf8f22a393f7af7b58ead5247 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2021-11-16Revert "Remove AsyncResp from openHandler"Gunnar Mills5-11/+17
This reverts commit 0f3d3a01aed4040ef73a977a958ecdf4f68111f6. Seeing bumps fail. Change-Id: Ida7b1bae48abbed2e00a5259e8f94b64168d4788 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2021-11-16Remove AsyncResp from openHandlerzhanghch055-17/+11
This change, moving the openHandler back to only supporting websocket disconnects and not 404s.Because AsyncResp is removed from openHandler. Tested: Opened KVM in webui-vue and it works. Signed-off-by: zhanghaicheng <zhanghch05@inspur.com> Change-Id: I90811f4ab91ad41cb298877f76252dce80932b2b
2021-11-16Change the completionhandler to accept Reszhanghch052-16/+3
These modifications are from WIP:Redfish:Query parameters:Only (https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/47474). And they will be used in Redfish:Query Parameters:Only. (https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/38952) The code changed the completion handle to accept Res to be able to recall handle with a new Response object. AsyncResp owns a new res, so there is no need to pass in a res. Tested: 1.Basic and Token auth both still work. 2.Use scripts/websocket_test.py to test websockets. It is still work correctly. python3 websocket_test.py --host 127.0.0.1:2443 This modification is a public part, so you can use any URL to test this function. The response is the same as before. Signed-off-by: zhanghaicheng <zhanghch05@inspur.com> Change-Id: I570e32fb47a9a90fe111fcd1f4054060cd21def3
2021-10-18Rename method to isOnAllowlistEd Tanous1-1/+1
While we're here testing things anyway, it seems like a good time to do a simple method rename following the projects new naming guidelines. This seems like an easy thing to do while we're here anyway and might short circuit a harder discussion later. Tested: Code compiles. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie5ed1c38d7dec13f875efae4acc22f4fd582f9b9
2021-10-18Use less specific includesEd Tanous1-1/+3
Some of the vm includes pull in large portions of boost::process. Use more specific headers as the coding standard recomments. Tested: Code compiles. No functional changes. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I3e90d516c48fe01a29bfdfed272f5e4cc28e5493
2021-10-17Improve HttpHeaders in EventServiceEd Tanous2-6/+21
This commit moves the internal data structures to use boost::beast::http::fields as its internal data structure. fields is a hyper-optimized map implementation for http headers, and has a lot of nice escaping properties. It is what boost::beast::http::request uses under the covers, so this has some niceties in reducing the amount of code, and means we can completely remove the headers structure, and simply rely on req. When this conversion was done, now the type safety of the incoming data needs to have better checking, as loading into the keys has new requirements (like values must be strings), so that type conversion code for to and from json was added, and the POST and PATCH handler updated to put into the new structure. Tested: curl -vvvv --insecure -u root:0penBmc "https://192.168.7.2:443/redfish/v1/EventService/Subscriptions" -X POST -d "{\"Destination\":\"http://192.168.7.2:443/\",\"Context\":\"Public\",\"Protocol\":\"Redfish\",\"HttpHeaders\":[{\"Foo\":\"Bar\"}]}" returned 200. Tested various "bad" headers, and observed the correct type errors. Issued: systemctl restart bmcweb. Subscription restored properly verified with. GET https://localhost:8001/redfish/v1/EventService/Subscriptions/183211400 Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I331f65e1a3960f1812c9baac27dbdcb1d54f112c