Skip to content

NetHSM: Broken list-users command for "invalid" usernames #705

@CMon

Description

@CMon

bug description

using NetHsm as backend.

I created a user called n-admin on the nethsm and try to print it with the list-users command.

I am able to create the user without problems. a curl to /api/v1/users results in the user being listed.

BUT if i use nitropy nethsm --host localhost:8443 --username admin --password <password> --no-verify-tls list-users i get the following error:

An unhandled exception occurred
        Exception encountered: ApiValueError("Invalid value `Development~n-admin`, must match regular expression `^([a-zA-Z0-9]+~)?[a-zA-Z0-9]+$` at ('args[0]', 1, 'user')")

Why are you checking for valid usernames on print? and not on creation? nevertheless the user is totally capable of being used (at least for adding operators, keys and tags to them)

For my point of view there is no need to not allow - inside a username, or at least reject the creation of users with invalid characters (better than preventing them from being listed)

local reproduction

  1. run local container: docker run --rm -it -p 8443:8443 --name local-hsm -d docker.io/nitrokey/nethsm:testing
  2. provision container:
nitropy nethsm --host localhost:8443 --username admin --password adminadmin --no-verify-tls \
  provision \
    --unlock-passphrase unlockunlock \
    --admin-passphrase adminadmin \
    <<-EOF
unlockunlock2
adminadmin
EOF
  1. create n-admin: nitropy nethsm --host localhost:8443 --username admin --password adminadmin --no-verify-tls add-user --user-id "n-admin" --passphrase adminadmin --namespace Development --create-namespace --role Administrator --real-name "N Admin"
  2. try to list users: nitropy nethsm --host localhost:8443 --username admin --password adminadmin --no-verify-tls list-users

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions