-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hardening/3109 remove payload word part 2 #35
Conversation
kzangeli
commented
Aug 8, 2018
- Removed an unnecessary lookup of rest service.
- Split connectionTreat (MHD callback) in three functions
…rent types of call from MHD
…hree parts (functions)
To which step/stage of telefonicaid#3109 this PR corresponds? Step 1, stage 4 maybe (given the last implemented on was step 1, stage 3)? |
src/lib/common/string.cpp
Outdated
@@ -162,7 +162,7 @@ bool getIPv6Port(const std::string& in, std::string& outIp, std::string& outPort | |||
* | |||
* stringSplit - | |||
*/ | |||
int stringSplit(const std::string& in, char delimiter, std::vector<std::string>& outV) | |||
int stringSplit(const std::string& in, char delimiter, std::vector<std::string>& outV, bool skipLastComponentIfEmpty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New parameter (skipLastComponentIfEmpty) is a bit obscure... An explantation (or example) in the function preamble would be great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the name was descriptive enough ...
It's about not understanding /xxx/ as two components, but one (skip last component if it is empty).
but sure, it's easy enough to comment this in the function header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 4dfd0c0
src/lib/jsonParse/jsonRequest.cpp
Outdated
std::string errorReply; | ||
char reqTypeV[STRING_SIZE_FOR_INT]; | ||
|
||
restErrorReplyGet(ciP, SccBadRequest, details, &errorReply); | ||
restErrorReplyGet(ciP, SccBadRequest, "service not found", &errorReply); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "service not found" should be a #define? I remember we have a .h with the "magic strings" used in error messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 4dfd0c0
this part was not even in the initial plan. About splitting the connectionTreat function in three separate functions ... that I believe might be an old issue |
@@ -69,7 +69,7 @@ RestService* restBadVerbV = NULL; | |||
|
|||
/* ***************************************************************************** | |||
* | |||
* restServiceGet - | |||
* restServiceVectorGet - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This refactor is hard to follow... could you summarize the changes a little bit, pls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, this very function only changes name.
the problem comes later, in the following function.
what is changed is that i no longer lookup the rest service in the rest Service vector, as that is already done, and saved in ciP->restserviceP.
the diff is really messy ... :(
return restServiceLookup(ciP, badVerbP); | ||
} | ||
|
||
return &restBadVerbV[104]; // FIXME 02: 99.9% sure we never get here, but if ... Change the 104 service for a fixed one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From where the magic number 104 did come?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, this is beyond ugly.
I am sure we never get there, as all possible errors are caught before.
That said, &restBadVerbV[104]
is a pointer to the last restservice item in the badVerb vector, the one that takes care of any error, not yet found.
As the fixme says, should be changed for a fixed struct for this case.
fixme in place, not really in a hurry to implement it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, once the new way of getting the info for "bad verb" (end of the "really big" step 1 in issue telefonicaid#3109) this will go away
@@ -584,7 +584,7 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36}) | |||
======================================= | |||
POST http://localhost:REGEX(\d+)/notify | |||
Fiware-Servicepath: / | |||
Content-Length: 208 | |||
Content-Length: REGEX((208|291)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another weird change in Content-Length... This .test should be annnotated in the issue we created about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this is one more for that strange thing that is happening ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note added in issue telefonicaid#3258
@@ -203,6 +171,38 @@ SET (SOURCES | |||
rest/restReply_test.cpp | |||
rest/RestService_test.cpp | |||
rest/rest_test.cpp | |||
|
|||
# serviceRoutines/badVerbGetOnly_test.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I undesrtand the test has been disabled maybe due to the effort it would take to adjust them. In the past you mentioned they should be removed... If so, let's do that in this PR, no need to wait any longer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, i decided to leave all those.
might do the effort to put all these unit tests back in, soon.
just not right now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NTC
@@ -136,7 +136,7 @@ TEST(RestService, payloadParse) | |||
* | |||
* noSuchService - | |||
*/ | |||
TEST(RestService, noSuchServiceAndNotFound) | |||
TEST(RestService, DISABLED_noSuchServiceAndNotFound) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the test should be enterily removed? Related with #35
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, we can remove all of them, not that i care very much.
however ... is it really better to remove then than to keep them to perhaps some day (soon) incorporate again?
i decided to go conservative ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, prefer to leave it.
some day we will reincorporate all these functests
So, NTC
And yes, we're still in step one. Stage 4 seems OK |
@@ -510,7 +510,7 @@ static RestService badVerbV[] = | |||
{ InvalidRequest, 2, { "ngsi9", "*" }, badNgsi9Request }, | |||
{ InvalidRequest, 2, { "ngsi10", "*" }, badNgsi10Request }, | |||
{ InvalidRequest, 0, { "*", "*", "*", "*", "*", "*" }, badRequest }, | |||
{ InvalidRequest, 0, { }, NULL }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the refactor and changes done in this PR has any impact in Developers Manual?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we didn't get down to this level of details in the manual, fortunately ...