Skip to content
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

Merged
merged 9 commits into from
Aug 9, 2018

Conversation

kzangeli
Copy link

@kzangeli kzangeli commented Aug 8, 2018

  • Removed an unnecessary lookup of rest service.
  • Split connectionTreat (MHD callback) in three functions

@fgalan
Copy link
Collaborator

fgalan commented Aug 8, 2018

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)?

@@ -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)
Copy link
Collaborator

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.

Copy link
Author

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4dfd0c0

std::string errorReply;
char reqTypeV[STRING_SIZE_FOR_INT];

restErrorReplyGet(ciP, SccBadRequest, details, &errorReply);
restErrorReplyGet(ciP, SccBadRequest, "service not found", &errorReply);
Copy link
Collaborator

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4dfd0c0

@kzangeli
Copy link
Author

kzangeli commented Aug 8, 2018

this part was not even in the initial plan.
just something I "left" for later as it was far from trivial to implement all this, when I implemented the earlier search of the rest service.

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 -
Copy link
Collaborator

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?

Copy link
Author

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
Copy link
Collaborator

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?

Copy link
Author

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

Copy link
Author

@kzangeli kzangeli Aug 9, 2018

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))
Copy link
Collaborator

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.

Copy link
Author

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 ...

Copy link
Author

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover?

Copy link
Collaborator

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.

Copy link
Author

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

Copy link
Author

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)
Copy link
Collaborator

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

Copy link
Author

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 ...

Copy link
Author

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

@kzangeli
Copy link
Author

kzangeli commented Aug 8, 2018

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 },
Copy link
Collaborator

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?

Copy link
Author

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 ...

@kzangeli kzangeli merged commit b4b1018 into master Aug 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants