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

Protection of API key #13

Closed
raschi-de opened this issue Dec 10, 2021 · 6 comments
Closed

Protection of API key #13

raschi-de opened this issue Dec 10, 2021 · 6 comments

Comments

@raschi-de
Copy link

The API key essentially works like a password and I think it should be protected as such. Especially for interactive command line, it is not a good practice to store the API key as accessible as environment variables or type it in the command (and thus expose it in command history).

I suggest that at least in interactive mode it should be possible to ommit the -a option and the tool should then ask the user interactively to enter the password (ideally with obscured or no UI feedback). That is how for example openssh CLI handles the protection of the SSH key / user password.

@mprpic
Copy link
Contributor

mprpic commented Dec 14, 2021

Specifying API tokens through environment variables is pretty standard as far as CLI tools go, see e.g.:

We could certainly modify the behavior to prompt for the token if neither the env var is configured nor the -a option used, that should be an easy fix. Note though that you'll have to submit the token on every command since each request requires it and there is no caching or session support built into the library right now.

For a better solution, we could define a config file where you could specify the credentials or alternatively a command that fetches them, akin to AWS's cli: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sourcing-external.html

That's a larger feature though and should probably be filed separately if desired.

@mprpic mprpic closed this as completed in f5db6fa Dec 15, 2021
@mprpic
Copy link
Contributor

mprpic commented Dec 15, 2021

Implemented in f5db6fa

If neither the option or the env var is specified, you'll get a prompt with a hidden input, e.g.:

$ cve -u joe -o acme quota
API key: 
...

@raschi-de
Copy link
Author

Thanks for picking up the suggestion - I agree that it is only relevant / useable for interactive command line use cases, as stated in the original request (and other tools like OpenSSH do exactly that).

@raschi-de
Copy link
Author

raschi-de commented Dec 15, 2021 via email

@mprpic
Copy link
Contributor

mprpic commented Dec 15, 2021

Hey @raschi-de, not a stupid question at all :-) I pushed the fix to this repo but have not published an updated package of cvelib to PyPI yet so the version available there (0.5.0 at the moment) does not contain this code change. I'll push out a new update some time today and then you can just run python3 -m pip install --upgrade. Look out for a new release to be available in either of these places:

@raschi-de
Copy link
Author

raschi-de commented Dec 15, 2021 via email

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

No branches or pull requests

2 participants