Skip to content
This repository was archived by the owner on May 9, 2020. It is now read-only.

verify rsa.Key object to prevent segfault #32

Merged
merged 2 commits into from
Jul 16, 2014

Conversation

stavxyz
Copy link
Contributor

@stavxyz stavxyz commented Jul 16, 2014

Issue reported in #28

In [1]: from chef import api

In [2]: client = api.ChefAPI('https://api.opscode.com/organizations/myorg', None, 'user')

In [3]: client.api_request('GET', '/roles')
Segmentation fault (core dumped)

One option (implemented in this PR) would be to raise an exception when trying to instantiate ChefAPI:

In [1]: from chef import api

In [2]: client = api.ChefAPI('https://api.opscode.com/organizations/myorg', None, 'user')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-fada3a31c9af> in <module>()
----> 1 client = api.ChefAPI('https://api.opscode.com/organizations/myorg', None, 'user')

~/pychef/chef/api.py in __init__(self, url, key, client, version, headers)
     77             key = Key(key)
     78         if not key.key:
---> 79             raise TypeError("ChefAPI attribute 'key' was invalid.")
     80         self.key = key
     81         self.client = client

TypeError: ChefAPI attribute 'key' was invalid.

In [3]:

@coderanger
Copy link
Owner

Would probably be ValueError instead of TypeError, but looks like a good check, thanky :)

@stavxyz
Copy link
Contributor Author

stavxyz commented Jul 16, 2014

Good point.

coderanger added a commit that referenced this pull request Jul 16, 2014
verify rsa.Key object to prevent segfault
@coderanger coderanger merged commit 5ee4cea into coderanger:master Jul 16, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants