-
Notifications
You must be signed in to change notification settings - Fork 27
Prevent Duplicate Nicknames #185
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
base: master
Are you sure you want to change the base?
Prevent Duplicate Nicknames #185
Conversation
| return true; | ||
| } | ||
|
|
||
| if (plugin.getDataManager().findData(data -> data.getNickname().equals(newNickname)) != null) { |
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.
Bug: NullPointerException when getNickname().equals() is called on a null nickname in NickCommand's findData predicate.
Severity: CRITICAL | Confidence: 1.00
🔍 Detailed Analysis
A NullPointerException occurs when NickCommand attempts to find an existing nickname using plugin.getDataManager().findData(). The predicate data -> data.getNickname().equals(newNickname) will invoke .equals() on a null object if any online player has not yet set their nickname (as nickname defaults to null). This unhandled exception crashes the server. A similar vulnerability exists in SlackBot.java line 319 where pData.getSlackId().equals(id) can also cause a NullPointerException if slackId is null.
💡 Suggested Fix
Before calling .equals() on data.getNickname(), ensure data.getNickname() is not null. A safe check would be newNickname.equals(data.getNickname()) or data.getNickname() != null && data.getNickname().equals(newNickname).
🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/main/java/com/hackclub/hccore/commands/NickCommand.java#L46
Potential issue: A NullPointerException occurs when `NickCommand` attempts to find an
existing nickname using `plugin.getDataManager().findData()`. The predicate `data ->
data.getNickname().equals(newNickname)` will invoke `.equals()` on a `null` object if
any online player has not yet set their nickname (as `nickname` defaults to `null`).
This unhandled exception crashes the server. A similar vulnerability exists in
`SlackBot.java` line 319 where `pData.getSlackId().equals(id)` can also cause a
NullPointerException if `slackId` is `null`.
Did we get this right? 👍 / 👎 to inform future reviews.
Reference_id: 2711684
|
oh, that's what that workflow does :heavysob: |
aelithron
left a comment
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.
Please null-check as Sentry mentioned, I think this could lead to a problem where people can't set nicknames and a NullPointerException happens.
Don't let multiple people have the same nicknames, because this has been used for impersonation