Skip to content
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

Modify logic to addMemeber() and removeMemeber() methods in OscarGroup.java #56

Open
kateyang1998 opened this issue Dec 11, 2024 · 0 comments

Comments

@kateyang1998
Copy link
Collaborator

kateyang1998 commented Dec 11, 2024

This is first found by Sourcery-AI, and it generated two issue tickets related to these methods #51 #52

For methods addMethod() and removeMethod() in OscarGroup.java, below are the current codes:
/**
* Adds a member to the group.
*
* @param user the Principal to be added
* @return true whether the member was added
*/
public boolean addMember(Principal user) {
if (!principals.contains(user))
principals.add(user);
return true;
}

/**
 * Removes a member from the group.
 *
 * @param user the Principal to be removed
 * @return true whether the member was removed
 */
public boolean removeMember(Principal user) {
    principals.remove(user);
    return true;
}

We can see that the logic in these two methods are - return true whether the member was added / the member was removed.

Sourcery-AI suggested us to modify the logic to - return true when the member was not added, otherwise return false / return true when the member is existed to remove, otherwise return false. In this way, it will be better for us to maintain the security issue.

This won't be a hard fix, but the thing is, we don't know why the previous team set up the logic in the current way (return true anyhow). We feel like to discuss with Magenta first before we modify the codes.

@kateyang1998 kateyang1998 converted this from a draft issue Dec 11, 2024
@kateyang1998 kateyang1998 self-assigned this Dec 11, 2024
@kateyang1998 kateyang1998 removed their assignment Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Known Issue
Development

No branches or pull requests

1 participant