nebari icon indicating copy to clipboard operation
nebari copied to clipboard

[ENH] Digital Ocean exposes deploy token when validator error occours

Open viniciusdc opened this issue 1 year ago â€Ē 9 comments

When not all required vars are present in the user environment, a validation error occurs, notifying the user of the missing variables. However, when doing so, it also exposes the values of any already passed var to the user without masking.

Below is an example of such an error message, where a manually masked token, which was in this case fully exposed:

ValidationError: 1 validation error for ConfigSchema
digital_ocean
  Value error, Missing the following required environment variables: {'SPACES_ACCESS_KEY_ID': None, 'DIGITALOCEAN_TOKEN': 
'dop_v1_*****', 'SPACES_SECRET_ACCESS_KEY': None}

            Please see the documentation for more information: https://www.nebari.dev/docs/how-tos/nebari-do [type=value_error, input_value={'kubernetes_version': '1...s': 1, 'max_nodes': 
5}}}, input_type=CommentedMap]
    For further information visit https://errors.pydantic.dev/2.4/v/value_error

viniciusdc avatar Jun 21 '24 14:06 viniciusdc

To fix this issue, look for the validation function and replace the required_variables to missing_variables in here

https://github.com/nebari-dev/nebari/blob/9baab7e29e2ec9b172ef439ddc66a5e51a380066/src/_nebari/utils.py#L352-L355

viniciusdc avatar Jun 21 '24 14:06 viniciusdc

Greetings @viniciusdc, I'd like to try working on this one if alright & maybe get back with some progress in case I need more input. For now may I have some context to reproduce the above ValidationError Edit: Just noticed that it's related to #2530

arjxn-py avatar Jun 21 '24 17:06 arjxn-py

Hi @arjxn-py definetly, to reproduce you will need to follow the deploy on DO docs to some extent, https://www.nebari.dev/docs/how-tos/nebari-do

The exact version I used was nebari==2024.5.1 but it should show up in the latest one as well.

You don't need to deploy it, in my case I provided a config (as you noticed from the related issue) and just ran nebari render -c nebari-config.yaml to trigger some of the validations, but you might encounter it even quicker when running the nebari init do command.

To trigger the exception, just include one of the environment variables that are required:

export DIGITALOCEAN_TOKEN=""          # API token required to generate resources
export SPACES_ACCESS_KEY_ID=""        # public access key for access spaces
export SPACES_SECRET_ACCESS_KEY=""    # the private key for access spaces

in my case, I had the DIGITALOCEAN_TOKEN already populated, so that showed to me when the error was raised. But you might see the same message show up, by not including any at all as well

viniciusdc avatar Jun 21 '24 20:06 viniciusdc

This issue proabably has two things to address:

  • Repalce the required_variables as suggested;
  • And possible add some kind of masking to the values, if they show up after replacing (but I think the missing_variables only use the key name, not the value)

viniciusdc avatar Jun 21 '24 20:06 viniciusdc

feel free to open a PR, even if its a draft :smiley:

viniciusdc avatar Jun 21 '24 20:06 viniciusdc

Thanks a lot @viniciusdc, your comments helped a lot. Sorry that it took me more time than expected as I was in a bit of a dilemma that i'd need Digital Ocean credits to test this out & was trying to manage that. But I was wrong 😅

arjxn-py avatar Jun 24 '24 11:06 arjxn-py

No worries, I am glad all worked in the end :100: . I also should've mentioned that as well next time feel free to ask, as this will help us update the docs later on as well :rocket:

viniciusdc avatar Jun 24 '24 14:06 viniciusdc

feel free to ask, as this will help us update the docs later on as well 🚀

Sounds good, i'd be more than happy to assist with those improvements too :)

arjxn-py avatar Jun 25 '24 07:06 arjxn-py

We are planning on deprecating Digital Ocean support due to low usage. It could still be deployed on Digital Ocean via an existing cluster deployment. @arjxn-py Please comment on the issue if you think we should keep it - https://github.com/nebari-dev/nebari/issues/2542

Adam-D-Lewis avatar Jun 25 '24 15:06 Adam-D-Lewis

I think we can also safely close this one too since this is no longer required, @viniciusdc.

arjxn-py avatar Jul 10 '24 08:07 arjxn-py