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

NSFS | NC | Add Limitation to Account Name #7818

Open
shirady opened this issue Feb 14, 2024 · 3 comments
Open

NSFS | NC | Add Limitation to Account Name #7818

shirady opened this issue Feb 14, 2024 · 3 comments
Labels
Non Containerized Non containerized NS-FS Type:Enhancement New suggestions for behaviours

Comments

@shirady
Copy link
Contributor

shirady commented Feb 14, 2024

Environment info

  • NooBaa Version: master
  • Platform: NC

Actual behavior

  1. Currently, we have no limit to account names (they can be numbers or strings).

Expected behavior

  1. Account names should be limited - for example, length (so we should not handle edge cases of name 0 for example).

Steps to reproduce

  1. Create an account: sudo node src/cmd/manage_nsfs account add --name 0 --new_buckets_path /tmp/nsfs_root1 --uid 1003 --gid 1003
    parietal output:
{
  "response": {
    "code": "AccountCreated",
    "reply": {
      "name": "0",
      "email": "0",
....
}

More information - Screenshots / Logs / Other output

  • For example, in bucket name, we use this function for limitation:
    function validate_bucket_creation(params) {
    if (params.name.length < 3 ||
    params.name.length > 63 ||
    net.isIP(params.name) ||
    !VALID_BUCKET_NAME_REGEXP.test(params.name)) {
    throw new RpcError('INVALID_BUCKET_NAME');
    }
    }
@shirady shirady added Type:Enhancement New suggestions for behaviours NS-FS Non Containerized Non containerized labels Feb 14, 2024
@shirady
Copy link
Contributor Author

shirady commented Mar 10, 2024

@romayalon I didn't find a matching example for the account's name restriction in our code as we have for the bucket name - in NSFS we use validate_bucket_creation which is based on validate_bucket_creation in bucket_server (which is called from create_bucket):

function validate_bucket_creation(req) {
if (req.rpc_params.name.unwrap().length < 3 ||
req.rpc_params.name.unwrap().length > 63 ||
net.isIP(req.rpc_params.name.unwrap()) ||
!VALID_BUCKET_NAME_REGEXP.test(req.rpc_params.name.unwrap())) {
throw new RpcError('INVALID_BUCKET_NAME');
}

I tried to search validate_account (didn't find something) and inside account_server in create_account and didn't find any restriction.
I still think it better at least have the name.length < 3 restriction (I would use the same naming restriction as we have in the bucket to avoid confusion).

@romayalon
Copy link
Contributor

@shirady The only limitation I found is in validate_create_account_params() -

if (req.rpc_params.name.unwrap() !== req.rpc_params.name.unwrap().trim()) {
   throw new RpcError('BAD_REQUEST', 'system name must not contain leading or trailing spaces');
}

I don't mind adding limitations but I can't think of a reason for it to be a must, is there a reason you think it's needed?
You can ofc suggest the limitations you find needed to the team and we can have a discussion, thanks!

@shirady
Copy link
Contributor Author

shirady commented Mar 11, 2024

@romayalon I thought that since we use the argv with minimist we don't need this trim, but I checked this and I think we should have it at constraint as well.
Example: When running sudo node src/cmd/manage_nsfs account add --name ' shira-2013 ' --new_buckets_path /tmp/nsfs_root1 --uid 2013 --gid 2013
This check console.log('SDSD name check', argv.name === argv.name.trim()); returns false.
And we write this config file:
Screenshot 2024-03-11 at 11 04 42

My suggestions for naming constraints:

  • Add the trim as a constraint name !== name.trim().
  • Add a minimum number of characters name.length < 3.

I also suggested to have the same constraint as bucket name, so it will be less confusing to remember the differences between them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Non Containerized Non containerized NS-FS Type:Enhancement New suggestions for behaviours
Projects
None yet
Development

No branches or pull requests

2 participants