Skip to content

Conversation

@SuperYoshi10000
Copy link

Don't let multiple people have the same nicknames, because this has been used for impersonation

return true;
}

if (plugin.getDataManager().findData(data -> data.getNickname().equals(newNickname)) != null) {
Copy link

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

@aelithron
Copy link
Member

oh, that's what that workflow does :heavysob:
looks good overall so i will approve it, won't merge yet but soon

Copy link
Member

@aelithron aelithron left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants