Reinforce the claim of key ownership on the processors #135
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.
The goal of this change is to mitigate bugs like the one we have for Iris EmerisHQ/demeris-backend#794, where a trace isn't handled by the correct processor.
The entry point for a processor is the
OwnKey
method, when it returns true, the trace is passed toProcess
, meaning the processor will handle it. For most processors,OwnKey
just checks if the key starts with a specific prefix, but this is actually too weak because a lot of different modules shares the same prefix. To avoid mistakes, this change adds more constraints like checking if the content of the key matches what is expected for this module.Since the content of the key for a module can change between sdk version, the code responsible for checking its content has been delegated in
datamarshaler/keys_vXX
files, andOwnKey
just calls it. This change has only been applied toIn the future, if other bugs like that appear, we'll need to port the related processors to this pattern.
Also, I could have done more refac, but I preferred to keep the change simple and review-able in a reasonable time.