Open
Conversation
Bruce-Qi
approved these changes
Aug 19, 2025
Bruce-Qi
left a comment
There was a problem hiding this comment.
Your change is good and improves code safety and clarity.Just make sure all usages are updated to handle the new Unknown value, and add/update tests as needed.also keep them updated in the docs.
This file contains hidden or 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
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.
Describe
I found potential memory safety and stability issues in the Cat codebase:
CWE-476 (NULL Pointer Dereference):
In several parts of the Cat project, such as calls to
AlertType.getTypeByName(), an unknown alert type name could cause the method to returnnull.If the returned value is used directly without a null check (e.g., calling
.getName()or.getTitle()), this could lead to a NullPointerException and result in a crash or undefined behavior.Expected behavior
AlertType.getTypeByName()should always return a validAlertTypeinstance.AlertType.Unknown, notnull.Actual behavior
getTypeByName()returnednull.alert.getType().getName()), a NullPointerException would occur at runtime, potentially causing a crash.How to Reproduce
AlertType.getTypeByName("SOME_INVALID_TYPE").null..getName()or.getTitle()on the returned value without a null check.Patch
This patch adds an
Unknownenum value toAlertTypeand modifiesgetTypeByName()to returnAlertType.Unknowninstead ofnullwhen the type name is unrecognized.This change ensures that a valid enum value is always returned, preventing null pointer dereference vulnerabilities.