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

fix: carefully assign ghapp names #467

Merged
merged 2 commits into from
Mar 26, 2024
Merged

Conversation

giovanni-guidini
Copy link
Contributor

The configuration for ghapps need to be done carefully before they can
be used. And that process is manual.

However it's very simple for a user to simply go and install an app to
their organization and point it's webhooks to us. In this case we would
think it's the default app and break the app.

So now we update the app's names everytime we get a new webhook for it.
Only the configured default app may use the default name, all others,
unless they manually receive a custom name, will be 'unconfigured_app'.

Closes: codecov/engineering-team#1445

Purpose/Motivation

What is the feature? Why is this being done?

Links to relevant tickets

What does this PR do?

Include a brief description of the changes in this PR. Bullet points are your friend.

Notes to Reviewer

Anything to note to the team? Any tips on how to review, or where to start?

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@giovanni-guidini giovanni-guidini requested a review from a team March 22, 2024 15:11
installation_default_app_id = get_config("github", "integration", "id")
# `app_id` and `installation_default_app_id` should both be ints
# But just to avoid differences parsing either the YAML or the request data
# Casting them to str for the comparison (str has less change of failing)
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably want to check if pem_path is set here. If it is, we can also not change the name. Otherwise we are enforcing only one default app.

The configuration for ghapps need to be done carefully before they can
be used. And that process is _manual_.

However it's very simple for a user to simply go and install an app to
their organization and point it's webhooks to us. In this case we would
think it's the default app and break the app.

So now we update the app's names everytime we get a new webhook for it.
Only the configured default app may use the default name, all others,
unless they manually receive a custom name, will be 'unconfigured_app'.

Closes: codecov/engineering-team#1445
@codecov-notifications
Copy link

codecov-notifications bot commented Mar 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@codecov-qa
Copy link

codecov-qa bot commented Mar 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.05%. Comparing base (af074c2) to head (76dbd20).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #467   +/-   ##
=======================================
  Coverage   96.05%   96.05%           
=======================================
  Files         643      643           
  Lines       17120    17127    +7     
=======================================
+ Hits        16444    16451    +7     
  Misses        676      676           
Flag Coverage Δ
unit 96.05% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 96.05% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

codecov-public-qa bot commented Mar 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (af074c2) 96.05% compared to head (76dbd20) 96.05%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #467   +/-   ##
=======================================
  Coverage   96.05%   96.05%           
=======================================
  Files         643      643           
  Lines       17120    17127    +7     
=======================================
+ Hits        16444    16451    +7     
  Misses        676      676           
Flag Coverage Δ
unit 96.05% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 96.05% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
codecov_auth/models.py 98.97% <100.00%> (+<0.01%) ⬆️
webhook_handlers/views/github.py 99.04% <100.00%> (+0.01%) ⬆️

Impacted file tree graph

Allows for multiple apps with the default name,
as long as they are configured.

Basically for an app to have a custom name (including the default one),
it needs to be configured. Otherwise it's moved to the "unconfigured_app" category.
Copy link

codecov bot commented Mar 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.78%. Comparing base (af074c2) to head (76dbd20).

Changes have been made to critical files, which contain lines commonly executed in production. Learn more

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #467   +/-   ##
=====================================
  Coverage   95.78   95.78           
=====================================
  Files        765     765           
  Lines      17706   17713    +7     
=====================================
+ Hits       16958   16965    +7     
  Misses       748     748           
Flag Coverage Δ
unit 96.05% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 96.05% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@giovanni-guidini giovanni-guidini merged commit 33fa79d into main Mar 26, 2024
21 checks passed
@giovanni-guidini giovanni-guidini deleted the gio/fix-ghapp-names branch March 26, 2024 13:34
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.

Don't use default name on GH app install if it does not match installation default
3 participants