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

Hopsworks prints API Key when configured incorrectly #184

Closed
MKLepium opened this issue Nov 9, 2023 · 1 comment
Closed

Hopsworks prints API Key when configured incorrectly #184

MKLepium opened this issue Nov 9, 2023 · 1 comment

Comments

@MKLepium
Copy link
Contributor

MKLepium commented Nov 9, 2023

If the API Key is incorrectly printed as a secret in (for example huggingface.co) and contains a "[API-Key]\n", newline at the end you the resulting stacktrace will contain the plain API Key. The http

image

I have redacted my API key, but this error is only there when the API Key contains a \n at the end. If I remove the \n from the end of my API key, the error disappears.

@MKLepium
Copy link
Contributor Author

MKLepium commented Nov 9, 2023

One way to test for this case would be:

def test_login_newline_in_api_key(self):
    try:
        imaginaryApiKey = "ImaginaryApiKey\n"
        project = hopsworks.login(api_key_value=imaginaryApiKey)
    except Exception as e:
        self.assertNotIn(imaginaryApiKey.strip(), str(e))

If run with:

python -m unittest tests.hopsworks.test_login.TestLogin.test_login_newline_in_api_key

Currently the output would be:

Connected. Call `.close()` to terminate connection gracefully.
InsecureRequestWarning: Unverified HTTPS request is being made to host 'c.app.hopsworks.ai'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
F
======================================================================
FAIL: test_login_newline_in_api_key (tests.hopsworks.test_login.TestLogin)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/mk/hopsworks-api/python/tests/hopsworks/test_login.py", line 236, in test_login_newline_in_api_key
    project = hopsworks.login(api_key_value=imaginaryApiKey)
ValueError: Invalid header value b'ApiKey ImaginaryApiKey\n'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mk/hopsworks-api/python/tests/hopsworks/test_login.py", line 239, in test_login_newline_in_api_key
    self.assertNotIn(imaginaryApiKey.strip(), str(e))
AssertionError: 'ImaginaryApiKey' unexpectedly found in "Invalid header value b'ApiKey ImaginaryApiKey\\n'"

----------------------------------------------------------------------
Ran 1 test in 0.240s

FAILED (failures=1)

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

1 participant