Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG] Fixed mass_assignment vuln #566

Merged
merged 1 commit into from
Jan 10, 2024
Merged

[BUG] Fixed mass_assignment vuln #566

merged 1 commit into from
Jan 10, 2024

Conversation

timothycarambat
Copy link
Member

Pull Request Type

  • ✨ feat
  • πŸ› fix
  • ♻️ refactor
  • πŸ’„ style
  • πŸ”¨ chore
  • πŸ“ docs

What is in this change?

Path to invitation logic on backend permissions

@timothycarambat timothycarambat self-assigned this Jan 10, 2024
Copy link

server/endpoints/invite.js

Instead of using console.error for logging errors, consider using a dedicated logging library like Winston or Bunyan. These libraries provide more control over log levels, formats, and destinations. They also handle JSON objects well, which can be useful when logging errors or other data structures.
Create Issue
See the diff
Checkout the fix

    const logger = require('winston');
    //...
    } catch (e) {
      logger.error(e);
      response.sendStatus(500).end();
    }
git fetch origin && git checkout -b ReviewBot/Impro-c83tsc5 origin/ReviewBot/Impro-c83tsc5

Consider using HTTP status code constants instead of hardcoding the status codes. This will make the code more readable and maintainable. You can use the 'http-status-codes' npm package for this purpose.
Create Issue
See the diff
Checkout the fix

    const HttpStatus = require('http-status-codes');
    //...
    response.status(HttpStatus.OK).json({ success: true, error: null });
    //...
    response.sendStatus(HttpStatus.INTERNAL_SERVER_ERROR).end();
git fetch origin && git checkout -b ReviewBot/Impro-lcry3ou origin/ReviewBot/Impro-lcry3ou

Consider validating the username and password before creating the user. This can help prevent SQL Injection attacks and ensure that the data is in the correct format before it is inserted into the database. You can use a library like 'joi' for input validation.
Create Issue
See the diff
Checkout the fix

    const Joi = require('joi');
    //...
    const schema = Joi.object({
      username: Joi.string().alphanum().min(3).max(30).required(),
      password: Joi.string().pattern(new RegExp('^[a-zA-Z0-9]{3,30}$')).required(),
    });
    const { error } = schema.validate({ username, password });
    if (error) {
      response.status(400).json({ success: false, error: error.details[0].message });
      return;
    }
git fetch origin && git checkout -b ReviewBot/Impro-19pyzlf origin/ReviewBot/Impro-19pyzlf

@timothycarambat timothycarambat merged commit 8cd3a92 into Mintplex-Labs:master Jan 10, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants