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

Webhook event receiver for pull requests which would parse PR metadata #833

Closed
jhrozek opened this issue Sep 4, 2023 · 0 comments · Fixed by #899
Closed

Webhook event receiver for pull requests which would parse PR metadata #833

jhrozek opened this issue Sep 4, 2023 · 0 comments · Fixed by #899
Assignees
Milestone

Comments

@jhrozek
Copy link
Contributor

jhrozek commented Sep 4, 2023

Webhook event receiver for pull requests

As of now, mediator only parses events for repositories and artifacts. We need to extend the webhook receiver (currently handleWebhookEvent) to route requests for pull requests into a new handler. This receiver would be very similar to others that parse events for released artifacts or repository changes.

Pull request metadata parsing

Upon receiving the pull request, the handler will parse the pull request payload data into a protobuf-generated structure. The structure can be reused and extended for other policy rules that parse PRs, but for now we only need the following information.

message FilePatch {
	string name 	= 1;  // file changed, e.g. package-lock.json
	string patchUrl = 2;  // points to the the raw patchfile 
}

message PullRequest {
    string URL = 1;
    int32 ID = 2;

    repeated FilePatch patches = 3;
}

The pull request payload contains the number of changed files, but not the patches themselves, but we can use the ListFiles GH API call to retrieve the files in a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant