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

Hec endpoint issue #419

Merged
merged 7 commits into from
Dec 6, 2021
Merged

Hec endpoint issue #419

merged 7 commits into from
Dec 6, 2021

Conversation

ashah-splunk
Copy link
Contributor

@ashah-splunk ashah-splunk commented Nov 26, 2021

Fix for the Issue #345

Previously path was always updated to path + /
This implementation fails while using the endpoint /services/collector/event as /services/collector/event/ results in 404

The fix removes the hard coded addition of the / to all the paths, and it makes it conditional based on the presence of the path_segment for the get/post actions. If path_segment' exists the pathwill be updated topath + / `

Copy link
Contributor

@fantavlik fantavlik left a comment

Choose a reason for hiding this comment

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

Just need a little more context for what the change is doing and how other paths are affected.

@@ -842,6 +844,8 @@ def post(self, path_segment="", owner=None, app=None, sharing=None, **query):
if path_segment.startswith('/'):
path = path_segment
else:
if not self.path.endswith('/') and path_segment != "":
self.path = self.path if path_segment.startswith('/') else self.path + '/'
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain the fix? I'm not quite sure just by looking at this line why the path starting with / here if path_segment.startswith('/') would have an affect on whether an ending / would be needed and this line seems to be adding a / slash whereas line 727 was seemingly doing the same before? In general it's nice to get some sort of writeup (a few sentences) in the PR summary as to what was broken before and how the behavior changed. For this case you could give an example of how the old path was formed and what the new HEC path is now and how other paths are affected after this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously / was added always for all the paths irrespective of the path_segment, hence the resulting path was always path = path + / which failed for the HEC as /services/collector/event/ results in 404,
Now / will be added only when path_segment is present so that the resulting path = path + / + path_segment and if there is no path_segment then the resulting path = path
Now the / is added conditionally and hence removed from line 727
I will add some comments and also add a test case for the HEC and update the PR

@fantavlik fantavlik self-requested a review December 3, 2021 21:46
@ashah-splunk ashah-splunk merged commit 89e53c0 into develop Dec 6, 2021
@ashah-splunk ashah-splunk deleted the hec_endpoint_issue branch December 16, 2021 04:52
@akaila-splunk akaila-splunk mentioned this pull request Mar 25, 2022
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