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

[MI-51272]: Refactored and removed unused code. #150

Merged
merged 10 commits into from
Mar 28, 2023
Merged

[MI-51272]: Refactored and removed unused code. #150

merged 10 commits into from
Mar 28, 2023

Conversation

avas27JTG
Copy link
Contributor

See [MI-51272]

avas27JTG and others added 6 commits January 4, 2023 16:08
… to "Close" on filter popover. (#17) (#21)

* [MI-2504][webapp]: Changed Hide to Close on filter popover

* [MI-2504][server]: Generated manifest files

* [MI-2504][server]: Updated version in manifest

Co-authored-by: Abhishek Verma <[email protected]>

Co-authored-by: Abhishek Verma <[email protected]>
…API and fixed Boards update subscription. (#22)

* [MI-2505][server]: Added logic to protect subscriptions notification webhook API and fixed Boards update subscription.

* [MI-2505][MI-2518] Fix failing testcases

* [MI-2505]:Added webhook secret encoding and review fixes

* [MI-2505]:Added webhook secret encryption

* [MI-2505]: Fixed CI

* [MI-2505]: Reverted change of auth scopes

* [MI-2505]: Fixed CI

* [MI-2505][MI-2603] Fixed testcases

* [MI-2505]: Used constant for path

* [MI-2505]: Refinded message

* [MI-2505]: Minor review fixes

* [MI-2505][MI-2603] Review fix

Co-authored-by: Abhishek Verma <[email protected]>
Co-authored-by: raghavaggarwal2308 <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Mar 15, 2023

Codecov Report

Patch coverage: 60.00% and project coverage change: +0.19 🎉

Comparison is base (2d2f0ab) 65.65% compared to head (153a186) 65.84%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #150      +/-   ##
==========================================
+ Coverage   65.65%   65.84%   +0.19%     
==========================================
  Files          15       15              
  Lines        3313     3300      -13     
==========================================
- Hits         2175     2173       -2     
+ Misses       1013     1003      -10     
+ Partials      125      124       -1     
Impacted Files Coverage Δ
server/plugin/utils.go 66.47% <0.00%> (+1.46%) ⬆️
server/plugin/api.go 63.54% <100.00%> (ø)
server/plugin/client.go 69.62% <100.00%> (+0.39%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

}
encodedWebhookSecret := c.plugin.Encode(encryptedWebhookSecret)

encodedWebhookSecret := c.plugin.Encode([]byte(c.plugin.getConfiguration().WebhookSecret))
Copy link
Contributor

Choose a reason for hiding this comment

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

Just so I understand, is this base64 encoding required?

Copy link

Choose a reason for hiding this comment

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

+1 on @mickmister comment, is the encoding/decoding needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we are generating webhookSecret using generated type in the plugin's setting which adds some characters that are not accepted by Azure DevOps APIs so we are encoding them before sending

Copy link

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this is working as expected as we are getting - in the generated field value which is not a base64 character and so the URL is breaking
for example, this is a randomly generated field value Y3081salbfxIcUZgx1sFoBwLjwAx5-Rk which has -

Copy link

Choose a reason for hiding this comment

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

Right. It's supposed to be the URL-friendly variant of Base64, but there is a bug there.

I've filed MM-51451.

Regardless of the bug, a better solution here would be coercing the value back to the standard base64-encoding rather than re-encoding it:

strings.ReplaceAll(strings.ReplaceAll(c.plugin.getConfiguration().WebhookSecret, "_", "/"), "-", "+")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure it's better to coerce

Copy link
Contributor Author

@avas27JTG avas27JTG Mar 17, 2023

Choose a reason for hiding this comment

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

Some of the characters are not valid as query-param like + is replaced with (space) when parsing the query-param so to avoid such edge cases have escaped the string so it can be safely placed inside a URL query using method url.QueryEscape which is working correctly for all such cases.

Example of some generated values that creates issue gc6y-Uayt+aufBbwZ73NCCsAYZH62aiP, x3NI6UxUIxifIaUkQqBpU5b+oiX+YKKF

Copy link

Choose a reason for hiding this comment

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

url.QueryEscape does not escape - which you previously mentioned as problematic. And + is part of the standard Base64 charset, which is what you were originally using but now that doesn't work either?

Are you testing this properly? If you know which characters the API accepts and which it doesn't, can you add an unit test for that?

Also is there any reason to wrap the url.QueryEscape in another function call? Seems like it's just unnecessarily complicating things.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no written doc for supported chars but I tried for multiple chars seems like API doesn't have a problem with accepting them, it was the query-param parsing that was giving errors while reading the secret returned from the API, if we pass escaped string everything seems to be working now, have tested this manually.

Regarding the test case, it seems like all encoded characters are sent and received properly, let me know if we still need to add a separate test case for it as I could not get any char generated randomly in the plugin's generated field causing the issue now so, if we add test case it will be mostly valid ones.

@mickmister mickmister added this to the v2.2.2 milestone Mar 15, 2023
@avas27JTG avas27JTG requested a review from mickmister March 16, 2023 14:24
@avas27JTG avas27JTG changed the title [MI-51272] [MI-51272]: Refactored and removed unused code. Mar 21, 2023
@hanzei hanzei added the 2: Dev Review Requires review by a core committer label Mar 21, 2023
@m1lt0n m1lt0n added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer labels Mar 28, 2023
@m1lt0n
Copy link

m1lt0n commented Mar 28, 2023

@DHaussermann based on the planning discussion today then, we can merge this right? cc: @mickmister

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants