-
Notifications
You must be signed in to change notification settings - Fork 43
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
Remove database use from handleRelevantRepositoryEvent #4705
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2662c7f
to
7267e59
Compare
jhrozek
commented
Oct 10, 2024
// If not, this means we got a deleted event for a | ||
// webhook ID that doesn't correspond to the | ||
// one we have stored in the DB. | ||
matchHookProps, err := properties.NewProperties(map[string]any{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This codepath was not easy to test. In the end I resorted to a trick and:
- registered a repo
- changed the hookID value in the DB
- deleted the webhook
- made sure the message is ignored
JAORMX
reviewed
Oct 11, 2024
7267e59
to
14aa03b
Compare
JAORMX
previously approved these changes
Oct 11, 2024
Comparing properties will be useful to check if a matching property is a subset of the retrieved properties.
We'll match the received entity on these properties
After receiving an entity, check if the `message.MatchProps` map is set. If yes, make sure that it is a subset of the properties of the entity just received. If it is not, drop the message. This will allow us to restrict forwarding the message by properties set by the caller.
Instead of fetching the repo directly in the handler and forwarding to a handler, create a NewEntityRefreshAndDoMessage message and offload the entity processing to minder-core. This removes the last piece of the github webhook that was directly touching the database with the exception of looking up the github app installation. Fixes: mindersec#4703
…h hint and private/archived repos
9948f1c
to
c67653b
Compare
JAORMX
approved these changes
Oct 11, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
message.MatchProps
map is set. If yes, make sure that it is a subset of the properties of the entity just received. If it is not, drop the message. This will allow us to restrict forwarding the message by properties set by the caller.Fixes: #4703
Change Type
Testing
mostly unit tests + adding and removing repos
Review Checklist: