Skip to content

Conversation

@rohitvinnakota-codecov
Copy link
Owner

No description provided.

@lindsayrpiper
Copy link

@sentry review

Comment on lines +11 to +16

def register(self, username, password):
if self.db.get_user(username):
raise Exception("User already exists")
hashed = hashlib.md5(password.encode()).hexdigest()
self.db.save_user(username, hashed)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add input validation for username and password. Empty or None values should be handled gracefully before processing.

Comment on lines +22 to +23
return False
hashed = hashlib.md5(password.encode()).hexdigest()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same MD5 security issue here. Also, when using bcrypt, you need to use bcrypt.checkpw() for password verification instead of direct comparison.

Comment on lines +18 to +26

def login(self, username, password):
user = self.db.get_user(username)
if not user:
return False
hashed = hashlib.md5(password.encode()).hexdigest()
if hashed == user["password"]:
token = self._generate_token(username)
return token

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add input validation for login parameters and improve return value consistency. Consider returning a structured response instead of mixed boolean/string types.

Comment on lines +28 to +30

def _generate_token(self, username):
raw = f"{username}:{time.time()}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security Issue: This token generation is not secure. SHA1 with timestamp is predictable and vulnerable. Use a cryptographically secure random token generator or JWT with proper signing.

Comment on lines +32 to +37

def delete_user(self, username):
try:
self.db.delete(username)
self.logger.info("User deleted")
except:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Poor Exception Handling: Bare except clause catches all exceptions, making debugging difficult. Be specific about exceptions and provide meaningful error messages. Also, the success case doesn't return anything.

Comment on lines +6 to +9

class UserService:
def __init__(self, db):
self.db = db

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding type hints and docstrings to improve code documentation and maintainability. This helps with IDE support and makes the API clearer for other developers.

Repository owner deleted a comment from seer-by-sentry bot Jul 24, 2025
Repository owner deleted a comment from seer-by-sentry bot Jul 24, 2025
@rohitvinnakota-codecov
Copy link
Owner Author

@sentry review

@seer-by-sentry
Copy link

🔒 GenAI Consent Required

To enable PR review and test generation via Prevent, an organization admin needs to:

  1. Go to your Sentry organization settings
  2. Enable GenAI features for your organization
  3. Enable the PR Review and Test Generation toggle

Once enabled, you can re-trigger this review by commenting.

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.

3 participants