summaryrefslogtreecommitdiff
path: root/include/ibm
AgeCommit message (Collapse)AuthorFilesLines
2023-01-18Fix a boatload of #includesEd Tanous3-9/+10
Most of these missing includes were found by running clang-tidy on all files, including headers. The existing scripts just run clang-tidy on source files, which doesn't catch most of these. Tested: Code compiles Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ic741fbb2cc9e5e92955fd5a1b778a482830e80e8
2022-12-21Change variable scopesEd Tanous1-4/+1
cppcheck correctly notes that a lot of our variables can be declared at more specific scopes, and in every case, it seems to be correct. Tested: Redfish service validator passes. Unit test coverage on others. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ia4414410d0e8f74a3bd40fdc0e0232450d1a6416
2022-12-16Restrict use of subfolder in configfiles pathcm-jishnu1-3/+6
GET function on the config files path now lists all the contents including sub directories. Creation of subdirectories under config files is not allowed from the UI, however its possible to create manually. If we try to access a subfolder with GET command, bmcweb handle the folder name as file name and crashes trying to open. Hence we limit the use of subfolder under config files by not listing them in the response of the GET command. And returning an error if the user is trying to run a GET on subfolder created manually. Tested: Create subfolder under configfiles path curl -k -H "X-Auth-Token: $bmc_token" -X GET -D patch1.txt https://${bmc}/ibm/v1/Host/ConfigFiles Without fix: Lists all contents of the ConfigFiles folder With Fix: lists only the regular files Run the command with subfolder curl -k -H "X-Auth-Token: $bmc_token" -X GET -D patch1.txt https://${bmc}/ibm/v1/Host/ConfigFiles/testfolder Without fix: bmcweb crashes With the fix: “Description”: “Resource Not Found” Change-Id: I71ef5523c6bc425e880a28a6e1175c677ef0a102 Signed-off-by: Jishnu C M <jishnunambiarcm@duck.com>
2022-10-12header cleanupsNan Zhou1-1/+2
This commit fixed several places (but not all) where wrong include directory is specified and prevent the clean up in the chidren changes. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: Ibbba62e2c0cfe3583a65f1befa1b233bd3eebf19
2022-10-07Move ClientID parameter out of OEMEd Tanous1-5/+6
In 2022.2, Redfish added support for the Context parameter on the Session Resource. This parameter has the same function that the OemSession.ClientId field served. This commit moves all the existing ClientId code to produce Context as well. Functionally, this has one important difference, in that Context in Redfish is optionally provided by the user, which means we need to omit it if not given by the user. The old implementation left it set to empty string (""). Because of this, a few minor interfaces need to change to use std::optional. Existing uses of clientId are moved to using value_or("") to keep the same behavior as before. Tested: curl --insecure -X POST -d "{\"UserName\": \"root\", \"Password\": \"0penBmc\"}" https://192.168.7.2/redfish/v1/SessionService/Sessions Returns a Session object with no Context key present curl --insecure -X POST -d "{\"UserName\": \"root\", \"Password\": \"0penBmc\", \"Context\": \"Foobar\"}" https://192.168.7.2/redfish/v1/SessionService/Sessions Returns a Session object with: "Context": "Foobar" Subsequent Gets of /redfish/v1/SessionService/Sessions/<sid> return the same session objects, both with and without Context. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I4df358623f93f3e6cb659e99970ad909cefebc62
2022-09-06IBM Mgmt console lock algorithm improvementSunitha Harish2-28/+21
This commit optimizes the release lock code and adds some traces to give more data for lock conflict scenarios Tested by: 1. With dual client connected, verified the conflicts are returned 2. Tested releaseLock usecase Signed-off-by: Sunitha Harish <sunithaharish04@gmail.com> Change-Id: I3cf99aaa5cc7c2967ae8dbc9c76c9f7378ecebdd
2022-09-06Fixes for IBM Management Console usecasesSunitha Harish1-5/+5
This commit fixes the below issues 1. Bump up the ConfigFile directory max limit For large configurations on the system, the current directory size upper limit of 10MB was exceeding and BMC was sending the error back to the client. This fails the entire large config support. This commit Increases this upper limit of the configFile dir to 25MB 2. Return 409 Error for a lock conflict Tested by: 1. ConfigFile read 2. Single file upload 3. AcquireLock from the same client returns 409 Signed-off-by: Sunitha Harish <sunithaharish04@gmail.com> Change-Id: I9218e8263f31e519d76683822290dfe259c57192
2022-08-11IBM Mgmt console writeLock conflict fixSunitha Harish1-1/+1
The isConflictRecord method was returning false by default which is causing ignoring the same resourceId conflicts. Same resourceId case will pass all the conditions and reach to the end of the function. Returning true means that there is a conflict. This commit fixes this by returning true by default Tested by: 1. Send writeLock requests with same resourceId and segment length Signed-off-by: Sunitha Harish <sunithaharish04@gmail.com> Change-Id: Ie65c6394988a357a8c811b621e113c14924bb8f6
2022-08-06Use enum overload for field settingEd Tanous1-1/+2
There are two overloads of addHeader, one that takes a string, and one that takes a boost enum. For most common headers, boost contains a string table with all of those entries anyway, so there's no point in duplicating the strings, and ensures that we don't make trivial mistakes, like capitalization or - versus underscore that aren't caught at compile time. Tested: This saves a trivial amount (572 bytes) of compressed binary size. curl --insecure -vvv --user root:0penBmc https://192.168.7.2/redfish/v1 returns < Content-Type: application/json curl --insecure -vvv -H "Accept: text/html" --user root:0penBmc https://192.168.7.2/redfish/v1 Returns < Content-Type: text/html;charset=UTF-8 Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I34c198b4f9e219247fcfe719f9b3616d35aea3dc
2022-07-16Remove usages of boost::starts/ends_withEd Tanous2-2/+3
Per the coding standard, now that C++ supports std::string::starts_with and std::string::ends_with, we should be using them over the boost alternatives. This commit goes through and updates all usages. Arguably some of these are incorrect, and instances of common error 13, but because this is mostly a mechanical it intentionally doesn't try to handle it. Tested: Unit tests pass. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ic4c6e5d0da90f7442693199dc691a47d2240fa4f
2022-07-12Fix const correctness issuesEd Tanous1-2/+2
cppcheck correctly notes that a lot of variables in the new code can be const. Make most of them const. Tested: WIP Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I8f37b6353fd707923f533e1d61c5b5419282bf23
2022-07-05Remove unused variablesEd Tanous1-1/+0
cppcheck finds a few variables that were unused in a few modules. Clean them up. Tested: Code compiles, unit tests pass. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I7a95025891bb537b45b99b3cd649ad05533e78f4
2022-06-28Fix shadowed variable issuesEd Tanous1-7/+7
This patchset is the conclusion of a multi-year effort to try to fix shadowed variable names. Variables seem to be shadowed all over, and in most places they exist, there's a "code smell" of things that aren't doing what the author intended. This commit attempts to clean up these in several ways by: 1. Renaming variables where appropriate. 2. Preferring to refer to member variables directly when operating within a class 3. Rearranging code so that pass through variables are handled in the calling scope, rather than passing them through. These patterns are applied throughout the codebase, to the point where -Wshadow can be enabled in meson.build. Tested: Code compiles, unit tests pass. Still need to run redfish service validator. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: If703398c2282f9e096ca2694fd94515de36a098b
2022-06-01Try to fix the lambda formatting issueEd Tanous1-79/+75
clang-tidy has a setting, LambdaBodyIndentation, which it says: "For callback-heavy code, it may improve readability to have the signature indented two levels and to use OuterScope." bmcweb is very callback heavy code. Try to enable it and see if that improves things. There are many cases where the length of a lambda call will change, and reindent the entire lambda function. This is really bad for code reviews, as it's difficult to see the lines changed. This commit should resolve it. This does have the downside of reindenting a lot of functions, which is unfortunate, but probably worth it in the long run. All changes except for the .clang-format file were made by the robot. Tested: Code compiles, whitespace changes only. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ib4aa2f1391fada981febd25b67dcdb9143827f43
2022-05-13Remove brace initialization of json objectsEd Tanous1-6/+6
Brace initialization of json objects, while quite interesting from an academic sense, are very difficult for people to grok, and lead to inconsistencies. This patchset aims to remove a majority of them in lieu of operator[]. Interestingly, this saves about 1% of the binary size of bmcweb. This also has an added benefit that as a design pattern, we're never constructing a new object, then moving it into place, we're always adding to the existing object, which in the future _could_ make things like OEM schemas or properties easier, as there's no case where we're completely replacing the response object. Tested: Ran redfish service validator. No new failures. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iae409b0a40ddd3ae6112cb2d52c6f6ab388595fe
2022-03-07Don't rely on operator << for object loggingEd Tanous1-2/+2
In the upcoming fmt patch, we remove the use of streams, and a number of our logging statements are relying on them. This commit changes them to no longer rely on operator>> or operator+ to build their strings. This alone isn't very useful, but in the context of the next patch makes the automation able to do a complete conversion of all log statements automatically. Tested: enabled logging on local and saw log statements print to console Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I0e5dc2cf015c6924037e38d547535eda8175a6a1
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-15Enable readability-implicit-bool-conversion checksEd Tanous1-1/+1
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 Tanous1-2/+4
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 Tanous2-2/+2
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 Tanous2-14/+1
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 Tanous1-14/+16
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 Tanous1-1/+1
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-12Enable checks for pointer arithmeticEd Tanous1-3/+8
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 Tanous1-0/+2
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 Tanous1-0/+8
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 Tanous2-4/+4
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
2021-10-17ibm: remove unused tinyxml2 includePatrick Williams1-1/+0
Fixes openbmc/bmcweb#226. Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Id8d30c23556fe445c3233f47406d14a6173d568c
2021-09-08IBM Management Interface: Lock ManagementSunitha Harish1-75/+0
This commit removes the lock persistency at BMC Initial interface design had requirements to persist the locks at BMC. But now there is no use-case for the management console to persist them. All required locks are re-acquired after a BMC reboot Tested by: 1. Acquire lock and verify there is no persistency file ibm_mc_persistent_lock_data.json 2. Validated all the lock management APIs work fine Signed-off-by: Sunitha Harish <sunharis@in.ibm.com> Change-Id: I55af5b256b37bcdf66727bffb5a4354b2f6f7fdf
2021-06-16Remove ambiguous privileges constructorEd Tanous1-9/+9
There are a number of endpoints that assume that a given routes privileges are governed by a single set of privileges, instead of multiple sets ORed together. To handle this, there were two overloads of the privileges() method, one that took a vector of Privileges, and one that took an initializer_list of const char*. Unfortunately, this leads some code in AccountService to pick the wrong overload when it's called like this .privileges( {{"ConfigureUsers"}, {"ConfigureManager"}, {"ConfigureSelf"}}) This is supposed to be "User must have ConfigureUsers, or ConfigureManager, or ConfigureSelf". Currently, because it selects the wrong overload, it computes to "User must have ConfigureUsers AND ConfigureManager AND ConfigureSelf. The double braces are supposed to cause this to form a vector of Privileges, but it appears that the initializer list gets consumed, and the single invocation of initializer list is called. Interestingly, trying to put in a privileges overload of intializer_list<initializer_list<const char*>> causes the compilation to fail with an ambiguous call error, which is what I would've expected to see previously in this case, but alas, I'm only a novice when it comes to how the C++ standard works in these edge cases. This is likely due in part to the fact that they were templates of an unused template param (seemingly copied from the previous method) and SFINAE rules around templates. This commit functionally removes one of the privileges overloads, and adds a second set of braces to every privileges call that previously had a single set of braces. Previous code will not compile now, which is IMO a good thing. This likely popped up in the Node class removal, because the Node class explicitly constructs a vector of Privilege objects, ensuing it can hit the right overload Tested: Ran Redfish service validator Tested the specific use case outlined on discord with: Creating a new user with operator privilege: ``` redfishtool -S Always -u root -p 0penBmc -vvvvvvvvv -r 192.168.7.2 AccountService adduser foo mysuperPass1 Operator ``` Then attempting to list accounts: ``` curl -vvvv --insecure --user foo:mysuperPass1 https://192.168.7.2/redfish/v1/AccountService/Accounts/foo ``` Which succeeded and returned the account in question. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I83e62b70e97f56dc57d43b9081f333a02fe85495
2021-04-30Fix typos in commentsAli Ahmed1-4/+4
These comments are part include/ibm/locks.hpp in isConflictRecord Change-Id: If8a6ec3585b43fcb80d086714f16dbf4c80a8ad9 Signed-off-by: Ali Ahmed <ama213000@gmail.com>
2021-04-20Create IBM ConfigFile base directorySunitha Harish3-102/+81
The ConfigFile upload fails when the /var/lib/obmc directory is not available at BMC This commit changes the base directory to /var/lib/bmcweb The subdirectories for the configfiles and locks are created under this new path Migration strategy of this directory and files: This is IBM only feature, compiled under the IBM_MANAGEMENT_CONSOLE flag There is no system out yet which is running this code Internal IBM stake holders are in agreement with the changes Tested by : 1. Tested configfile upload on a BMC where the base directory is not available 2. Tested the configfile upload on a factory BMC. Verified it creates the base directories and the upload is successful 3. Tested the configfile usecases for delete and delete-all 4. Tested the acquire-lock functionality 5. Ran lock unit test successfully Signed-off-by: Sunitha Harish <sunharis@in.ibm.com> Change-Id: Ic3f5f5d0ba0b37950fd397ec835b4fa7babdaa9b
2021-04-08Using AsyncResp everywherezhanghch051-110/+109
Get the core using AsyncResp everywhere, and not have each individual handler creating its own object.We can call app.handle() without fear of the response getting ended after the first tree is done populating. Don't use res.end() anymore. Tested: 1. Validator passed. Signed-off-by: zhanghaicheng <zhanghch05@inspur.com> Change-Id: I867367ce4a0caf8c4b3f4e07e06c11feed0782e8
2021-02-14IBM ConfigFile upload : Fix content-type validationSunitha Harish1-6/+4
While uploading the ConfigFiles, BMC was only checking if it is not multipart/form-data. This commit is to change the validation to check for only allowed content-type: application/octet-stream Tested by: Uploaded Configfile with below content-types 1. application/octet-stream - passed 2. application/x-www-form-urlencoded - failed 3. application/json - failed 4. multipart/form-data - failed 5. text/plain - failed 6. application/octet-streamabcd - failed Signed-off-by: Sunitha Harish <sunithaharish04@gmail.com> Change-Id: Iedadacd2306f729479ee36afff52e29d8112daf6
2021-02-14IBM Management Console: Replacing crow::Response with bmcweb::AsyncRespSunitha Harish1-142/+165
The management_console_rest.hpp uses the crow::Response object to return the response, which is the old way of returning the response to the client. This commit brings the bmcweb::AsyncResp class object for sending the response to the client instead of the crow::Response object Tested by : Performed GET, PATCH, DELETE on the /ibm/v1 resources Signed-off-by: Sunitha Harish <sunharis@in.ibm.com> Change-Id: I5ba01bda68d1e6b4590e910bd187aeb9cd6a149b
2021-02-13Validate the path during ConfigFile uploadSunitha Harish1-13/+162
The IBM management console usecase - ConfigFile upload was allowing to create or modify any file at the BMC when the path url is given as below. PUT https://${bmc}/ibm/v1/Host/ConfigFiles/../../../../../<any file under root dir> --data-binary "junk data" This commit adds validation to the "path" variable after the "ConfigFiles/" in the url - so that only the ConfigFiles are created or modified. The filename validation includes: Restrict the maximum filename length to 20 characters Restrict the allowed charaters to [A-Za-z0-9-] The minimum size of the file allowed is 100 bytes The maximum size of the file allowed is 500KB Maximum total size of the ConfigFile directory at BMC file system allowed is 10MB Tested by: 1. PUT https://${bmc}/ibm/v1/Host/ConfigFiles/../../../../../etc/p2 --data-binary "some data" Bad Request 2. PUT https://${bmc}/ibm/v1/Host/ConfigFiles/../../../etc/p2 --data-binary "some data" Bad Request 3. PUT https://${bmc}/ibm/v1/Host/ConfigFiles/../etc/p2 --data-binary "some data" Bad Request 4. PUT https://${bmc}/ibm/v1/Host/ConfigFiles/etc/p2 --data-binary "some data" { "Description": "Error while creating the file" } 5. PUT https://${bmc}/ibm/v1/Host/ConfigFiles/mydir/p2 --data-binary "some data" { "Description": "Error while creating the file" } 6. PUT https://${bmc}/ibm/v1/Host/ConfigFiles/ --data-binary "some data" Not Found 7. PUT https://${bmc}/ibm/v1/Host/ConfigFiles --data-binary "some data" Method Not Allowed 8. PUT https://${bmc}/ibm/v1/Host/ConfigFiles/p2/../p2 --data-binary "some data" Bad Request 9. PUT https://${bmc}/ibm/v1/Host/ConfigFiles/p2/p2 --data-binary "some data" { "Description": "Error while creating the file" } 10. PUT https://${bmc}/ibm/v1/Host/ConfigFiles/p2/../../../p2 --data-binary "some data" Bad Request 11. PUT https://${bmc}/ibm/v1/Host/ConfigFiles/./../../p2 --data-binary "some data" Bad Request 12. PUT https://${bmc}/ibm/v1/Host/ConfigFiles/. --data-binary "some data" Bad Request 13. PUT https://${bmc}/ibm/v1/Host/../ConfigFiles/p2 --data-binary "some data" Not Found 14. PUT https://${bmc}/ibm/v1/Host/ConfigFiles/p2 --data-binary "some data" { "Description": "File Created" } 15. PUT https://${bmc}/ibm/v1/Host/ConfigFiles/p2 --data-binary "some data" { "Description": "File Updated" } 16. PUT https://${bmc}/ibm/v1/Host/ConfigFiles/p2.ext --data-binary "some data" { "Description": "File Created" } 17. Tested sending filename greater than 20 charaters Bad Request 18. Tested sending filename with special charaters Bad Request 19. Tested sending filesize less than 100bytes Bad request 20. Tested sending filesize greater than 500KB Bad request 21. Tested uploading the file when the directory size is nearly full Bad request 22. Added unit test for isValidConfigFileName Signed-off-by: Sunitha Harish <sunharis@in.ibm.com> Change-Id: I838d39d5765ddc8701f7e5c533a93eebde021cbf
2020-10-29Fix Release Lock APIManojkiran Eda1-1/+1
- 3174e4dfd3185c131a07371b4b5a5b40cf0e0bdb commit had broke the release lock api. This small change has been overlooked in the commit during the refactoring. - status is a bool & status2 would be of type RcReleaseLockApi.As part of refactoring instead of status2 we were returning status(bool) as a parameter in the pair. Tested By: - Functional Lock Testing & openbmc-test-automation passed. (openbmc-test-automation/openpower/ext_interfaces/test_lock_management.robot) Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com> Change-Id: I71334dc863023cd40e9d813a5fa147493f5c3f9f
2020-10-23fix include namesEd Tanous2-3/+2
cppcheck isn't smart enough to recognize these are c++ headers, not c headers. Considering we're already inconsistent about our naming, it's easier to just be consistent, and move the last few files to use .hpp instead of .h. Tested: Code builds, no changes. Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: Ic348d695f8527fa4a0ded53f433e1558c319db40
2020-10-15Lots of performance improvementsEd Tanous1-15/+15
(In the voice of the kid from sixth sense) I see string copies... Apparently there are a lot of places we make unnecessary copies. This fixes all of them. Not sure how to split this up into smaller patches, or if it even needs split up. It seems pretty easy to review to me, because basically every diff is identical. Change-Id: I22b4ae4f96f7e4082d2bc701098a04f7bed95369 Signed-off-by: Ed Tanous <ed@tanous.net> Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
2020-10-09Write the clang-tidy file OpenBMC needsEd Tanous2-206/+166
Now that CI can handle clang-tidy, and a lot of the individual fixes have landed for the various static analysis checks, lets see how close we are. This includes bringing a bunch of the code up to par with the checks that require. Most of them fall into the category of extraneous else statements, const correctness problems, or extra copies. Tested: CI only. Unit tests pass. Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I9fbd346560a75fdd3901fa40c57932486275e912
2020-10-02Fix bad log statementEd Tanous1-1/+1
Someone needs to double check me here, but I suspect this was not doing what the author intended with the sizeof call, considering it's no a C array. Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I603b72837e24be0eca6337d0703dc56c47dba1d3
2020-09-30modernize ibm management consoleEd Tanous2-17/+16
There was some modernization problems in the IBM console. These are all minor, and unlikely to cause problems. The issues were: 1. Trivial destructors need to use the = default syntax 2. Several loops can be simplified into range based for loops 3. push_back should not be paired with make_pair. emplace_back should be used instead. Change-Id: I71b1d5437249d896a6f95c211e176deb676f985d
2020-09-29Fix naming conventionsEd Tanous1-4/+4
Lots of code has been checked in that doesn't match the naming conventions. Lets fix that. Tested: Code compiles. Variable/function renames only. Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I6bd107811d0b724f1fad990016113cdf035b604b
2020-09-22Fix IBM management console to match coding standardEd Tanous2-17/+19
Lots of missing inline definitions, a case where a RVO move is not guaranteed when returning a variant, and removing the header checks, which means that these types of build errors wont happen in the future. Tested: Should be no impact, but could someone from the IBM team grab these changes and sanity check them? Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: Iea0a06b8e744542a7d08e38217718e7a969f2827
2020-09-16remove using namespaceEd Tanous1-1/+0
IBM management console had a using namespace in it. This is against the coding standard. Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: Idfd5eac1a91e82f08139d6913a42a6c882072495
2020-08-17Enable unused variable warnings and resolveEd Tanous1-6/+6
This commit enables the "unused variables" warning in clang. Throughout this, it did point out several issues that would've been functional bugs, so I think it was worthwhile. It also cleaned up several unused variable from old constructs that no longer exist. Tested: Built with clang. Code no longer emits warnings. Downloaded bmcweb to system and pulled up the webui, observed webui loads and logs in properly. Change-Id: I51505f4222cc147d6f2b87b14d7e2ac4a74cafa8 Signed-off-by: Ed Tanous <ed@tanous.net>
2020-08-17Enable clang warningsEd Tanous1-9/+9
This commit enables clang warnings, and fixes all warnings that were found. Most of these fall into a couple categories: Variable shadow issues were fixed by renaming variables unused parameter warnings were resolved by either checking error codes that had been ignored, or removing the name of the variable from the scope. Other various warnings were fixed in the best way I was able to come up with. Note, the redfish Node class is especially insidious, as it causes all imlementers to have variables for parameters, regardless of whether or not they are used. Deprecating the Node class is on my list of things to do, as it adds extra overhead, and in general isn't a useful abstraction. For now, I have simply fixed all the handlers. Tested: Added the current meta-clang meta layer into bblayers.conf, and added TOOLCHAIN_pn-bmcweb = "clang" to my local.conf Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: Ia75b94010359170159c703e535d1c1af182fe700
2020-08-17Remove middlewaresEd Tanous1-2/+1
Middlewares, while kinda cool from an academic standpoint, make our build times even worse than they already are. Given that we only really use 1 real middleware today (token auth) and it needs to move into the parser mode anyway (for security limiting buffer sizes), we might as well use this as an opportunity to delete some code. Some other things that happen: 1. Persistent data now moves out of the crow namespace 2. App is no longer a template 3. All request_routes implementations no longer become templates. This should be a decent (unmeasured) win on compile times. This commit was part of a commit previously called "various cleanups". This separates ONLY the middleware deletion part of that. Note, this also deletes about 400 lines of hard to understand code. Change-Id: I4c19e25491a153a2aa2e4ef46fc797bcb5b3581a Signed-off-by: Ed Tanous <ed@tanous.net>
2020-08-05Handling Broadcast message serviceAsmitha Karunanithi1-4/+37
This commit implements the broadcast of the messages from one connected client to other connected clients via BMC. When the management console creates a subscription on the BMC, they will be provided with the broadcast message service. Tested by: (Used https://github.com/DMTF/Redfish-Event-Listener) 1. Create a subscription POST -D headers.txt https://${bmc}/redfish/v1/EventService/Subscriptions -d '{"Destination":"https://<host:port>","Protocol":"Redfish"}' 2. Send the message POST https://${bmc}/ibm/v1/HMC/BroadcastService -d '{"Message":"<msg>"}' 3. Verify the event is generated and posted to the subscriber: bodydata: {"Message":"<The message from HMC to be forwarded>", "Name":"Broadcast Event","OriginOfCondition": "/ibm/v1/HMC/BroadcastService", "Timestamp":"2020-07-15T12:03:30+00:00"} Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com> Change-Id: Ib36b4f25505cf66251adc5aeda282312996c25af
2020-08-05EventService : Send event for ConfigFile updationAsmitha Karunanithi1-6/+24
The commit implements the sending of push style events to the IBM's management client when a configFile is updated. Tested-By: 1. Create a subscription by passing "ResourceTypes" as ["IBMConfigFile"] POST -D headers.txt https://${bmc}/redfish/v1/EventService/Subscriptions -d '{"Destination" : "https://<host:port>,"ResourceTypes":["IBMConfigFile"],"Protocol":"Redfish"}' 2. Update an existing ConfigFile PUT https://${bmc}/ibm/v1/Host/ConfigFiles/<filename> --data-binary "@<local_path>" 3. Verify the event is generated and posted to the subscriber as the following example: bodydata: { "@odata.type":"#Event.v1_4_0.Event", "Events":[ { "EventId":1, "EventTimestamp":"2020-06-26T08:40:04+00:00", "EventType":"ResourceChanged", "MemberId":0, "Message" :"One or more resource properties have changed.", "MessageArgs":null, "MessageId":"ResourceEvent.1.0.3.ResourceChanged", "OriginOfCondition":"/ibm/v1/Host/ConfigFiles/<filename>", "MessageSeverity":"OK" } ], "Id":1, "Name":"Event Log" } 4. Verified the event is sent to the subscriber when the resourceType list is empty. 5. Verified the client subscribes for other resource - not ConfigFile ; then the event is not sent to the subscriber. Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com> Change-Id: I785c2a5a6e4e721cf722e94693db3a832f69fa50