10000 SEAB-6000: Track GitHub App UNINSTALL events by svonworl · Pull Request #5852 · dockstore/dockstore · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

SEAB-6000: Track GitHub App UNINSTALL events #5852

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

Merged
merged 5 commits into from
Mar 28, 2024

Conversation

svonworl
Copy link
Contributor
@svonworl svonworl commented Mar 25, 2024

Description
The installation_repositories GitHub event can describe either additions or removals, depending on the value of its "action" property. This PR modifies handleGitHubInstallation to handle the "removed" action of a propagated GitHub installation_repositories event and adds a corresponding UNINSTALL lambda event type.

The corresponding lambda PR is dockstore/lambda#161

Review Instructions
Add the qa GitHub App to a repo, wait five minutes, and confirm that the corresponding INSTALL entry appears in the apps logs. Then, remove the GitHub App from the repo, wait five minutes, and confirm that the corresponding UNINSTALL entry appears in the apps logs. Confirm that in the apps logs, "Uninstall" is properly capitalized.

Issue
https://ucsc-cgl.atlassian.net/browse/SEAB-6000

Security and Privacy

No concerns.

  • Security and Privacy assessed

e.g. Does this change...

  • Any user data we collect, or data location?
  • Access control, authentication or authorization?
  • Encryption features?

Please make sure that you've checked the following before submitting your pull request. Thanks!

  • Check that you pass the basic style checks and unit tests by running mvn clean install
  • Ensure that the PR targets the correct branch. Check the milestone or fix version of the ticket.
  • Follow the existing JPA patterns for queries, using named parameters, to avoid SQL injection
  • If you are changing dependencies, check the Snyk status check or the dashboard to ensure you are not introducing new high/critical vulnerabilities
  • Assume that inputs to the API can be malicious, and sanitize and/or check for Denial of Service type values, e.g., massive sizes
  • Do not serve user-uploaded binary images through the Dockstore API
  • Ensure that endpoints that only allow privileged access enforce that with the @RolesAllowed annotation
  • Do not create cookies, although this may change in the future
  • If this PR is for a user-facing feature, create and link a documentation ticket for this feature (usually in the same milestone as the linked issue). Style points if you create a documentation PR directly and link that instead.

LOG.info(String.format("Retrospectively processing branch/tag %s in %s(%s)", Utilities.cleanForLogging(gitReference), Utilities.cleanForLogging(repository),
Utilities.cleanForLogging(username)));
}
githubWebhookRelease(repository, username, gitReference, installationId, deliveryId, null, false);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code in this block didn't change, it's indented one level because it's now conditional.

Copy link
Member

Choose a reason for hiding this comment

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

"Hide whitespace" option works well too

@svonworl svonworl changed the title SEAB-6000: Track UNINSTALL Github App events SEAB-6000: Track Github App UNINSTALL events Mar 25, 2024
@svonworl svonworl changed the title SEAB-6000: Track Github App UNINSTALL events SEAB-6000: Track GitHub App UNINSTALL events Mar 25, 2024
Copy link
codecov bot commented Mar 25, 2024

Codecov Report

Attention: Patch coverage is 0% with 36 lines in your changes are missing coverage. Please review.

Project coverage is 70.18%. Comparing base (6a2a085) to head (23b8926).
Report is 1 commits behind head on develop.

Files Patch % Lines
...ckstore/webservice/resources/WorkflowResource.java 0.00% 22 Missing ⚠️
.../core/webhook/InstallationRepositoriesPayload.java 0.00% 13 Missing ⚠️
...java/io/dockstore/webservice/core/LambdaEvent.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #5852      +/-   ##
=============================================
- Coverage      73.04%   70.18%   -2.86%     
+ Complexity      5142     4957     -185     
=============================================
  Files            366      366              
  Lines          18974    19000      +26     
  Branches        2020     2025       +5     
=============================================
- Hits           13860    13336     -524     
- Misses          4137     4694     +557     
+ Partials         977      970       -7     
Flag Coverage Δ
bitbuckettests 27.07% <0.00%> (-0.04%) ⬇️
integrationtests 51.12% <0.00%> (-7.29%) ⬇️
languageparsingtests 10.95% <0.00%> (-0.02%) ⬇️
localstacktests 21.54% <0.00%> (-0.03%) ⬇️
toolintegrationtests 30.44% <0.00%> (-0.05%) ⬇️
unit-tests_and_non-confidential-tests 28.89% <0.00%> (-0.04%) ⬇️
workflowintegrationtests 38.68% <0.00%> (+3.83%) ⬆️

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.

@JsonProperty("repositories_added")
@Schema(name = "repositories_added", description = "An array of repository objects, which were added to the installation", requiredMode = RequiredMode.REQUIRED)
private List<WebhookRepository> repositoriesAdded;

@JsonProperty("repositories_removed")
@Schema(name = "repositories_removed", description = "An array of repository objects, which were removed from the installation", requiredMode = RequiredMode.REQUIRED)
Copy link
Member

Choose a reason for hiding this comment

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

TIL they're working on an openapi 4 for things like this (i.e. either this parameter or this other one OAI/OpenAPI-Specification#256 (comment) )

i.e. it's a little weird that both repositoriesRemoved and repositoriesAdded are required

final String action = payload.getAction();
// Currently, the action can be either "added" or "removed".
// This check is not necessary, but will detect if github adds another type of action to the event.
if (!List.of("added", "removed").contains(action)) {
Copy link
Member

Choose a reason for hiding this comment

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

Share an enum with dockstore-integration-testing/src/test/java/io/dockstore/webservice/helpers/GitHubAppHelper.java so that if one is changed, the future me knows to change the other at the same time

Copy link
Member

Choose a reason for hiding this comment

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

And link to installation_repositories I suppose

LOG.info(String.format("Retrospectively processing branch/tag %s in %s(%s)", Utilities.cleanForLogging(gitReference), Utilities.cleanForLogging(repository),
Utilities.cleanForLogging(username)));
}
githubWebhookRelease(repository, username, gitReference, installationId, deliveryId, null, false);
Copy link
Member

Choose a reason for hiding this comment

The rea 8000 son will be displayed to describe this comment to others. Learn more.

"Hide whitespace" option works well too

Copy link
Collaborator
@coverbeck coverbeck left a comment

Choose a reason for hiding this comment

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

Looks good, but I like Denis' suggestion of an enum, so I'll wait for that change for final approval.

Copy link
Contributor
@kathy-t kathy-t left a comment

Choose a reason for hiding this comment

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

Was here, I agree with Denis' feedback so will wait for that

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
71.8% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@@ -56,6 +56,16 @@ public static void handleGitHubRelease(WorkflowsApi workflowsApi, String reposit
public static void handleGitHubInstallation(WorkflowsApi workflowsApi, List<String> repositories, String gitHubUsername) {
InstallationRepositoriesPayload payload = new InstallationRepositoriesPayload()
.repositoriesAdded(repositories.stream().map(repo -> new WebhookRepository().fullName(repo)).toList());
payload.setAction(io.dockstore.webservice.core.webhook.InstallationRepositoriesPayload.Action.ADDED.toString());
Copy link
Member

Choose a reason for hiding this comment

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

Could import io.dockstore.webservice.core.webhook.InstallationRepositoriesPayload to make this a bit more concise, not worth changing unless there are other changes

@svonworl svonworl merged commit 8c6524e into develop Mar 28, 2024
@svonworl svonworl deleted the feature/seab-6000/track-uninstall-events branch March 28, 2024 16:04
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.

4 participants
0