Skip to content
This repository has been archived by the owner on Nov 21, 2019. It is now read-only.
This repository is currently being migrated. It's locked while the migration is in progress.

get_server_info errors out on pytan 2.0.3 against tanium 6.2 #9

Closed
lespea opened this issue Aug 27, 2015 · 10 comments
Closed

get_server_info errors out on pytan 2.0.3 against tanium 6.2 #9

lespea opened this issue Aug 27, 2015 · 10 comments
Assignees

Comments

@lespea
Copy link

lespea commented Aug 27, 2015

In pytan.sessions.py the function get_server_info it looks like self.http_post is returning a str instead of json:

d == digit; h == hex

dddd-ddddd-hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

This of course is problematic as you can't call get on a unicode string. The library technically continues functioning after the exception is thrown though...

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "../lib/pytan/handler.py", line 1609, in _derive_server_version
    self.server_version = self.session.get_server_version()
  File "../lib/pytan/sessions.py", line 421, in get_server_version
    self.server_info = self.get_server_info()
  File "../lib/pytan/sessions.py", line 409, in get_server_info
    body['diags_flat'] = self._flatten_server_info(body.get('Diagnostics', []))
AttributeError: 'unicode' object has no attribute 'get'Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "../lib/pytan/handler.py", line 1609, in _derive_server_version
    self.server_version = self.session.get_server_version()
  File "../lib/pytan/sessions.py", line 421, in get_server_version
    self.server_info = self.get_server_info()
  File "../lib/pytan/sessions.py", line 409, in get_server_info
    body['diags_flat'] = self._flatten_server_info(body.get('Diagnostics', []))
AttributeError: 'unicode' object has no attribute 'get'

I don't really have access to the Tanium instance but I can try to work with the platform owner if this is unexpected. I did a simple get on /info.json and it looks like the second number increases every time and the last bit is random (I tried hex decoding it but it was gibberish).

@lifehackjim
Copy link
Contributor

Nevermind - just read the subject. Is port 444 open on your firewall for your tanium server? Port 444 is necessary for pytan to access /info (and /info.json) in 6.2

@lifehackjim lifehackjim self-assigned this Aug 27, 2015
@lespea
Copy link
Author

lespea commented Aug 27, 2015

Yeah the connection is made to 444 just fine and everything works it's just returning that weird string instead of json. I hard-coded the "server version" to 6.2 so get_server_info is never called and everything works fine (question fires and returns the expected results).

@lifehackjim
Copy link
Contributor

That's.. odd. I've never seen that. Though that string aligns with what would be a session-id, possibly. I'm about to check in a change to pytan.sessions.Sessions.get_server_info() that makes that function a little more error proof. Mind trying with the develop branch?

@lifehackjim
Copy link
Contributor

Point of note, http_post is SUPPOSED to return a string.

get_server_info() is supposed to parse that string as json into a python dict here: https://github.com/tanium/pytan/blob/2.0.3/lib/pytan/sessions.py#L389

@lespea
Copy link
Author

lespea commented Aug 28, 2015

Oh right when I said string I just meant it wasn't a json structure (ie it wouldn't be a dictionary which was expected). I went home for the day but I can checkout the dev branch (just master or is there another one?) and see what happens.

@lifehackjim
Copy link
Contributor

The develop branch is here: https://github.com/tanium/pytan/tree/develop

It contains the next version of PyTan (which is likely to be 2.1.0, although it's currently marked as 2.0.4).

I check in all my changes to develop and once I've fully tested them all, I push to master and do version increments/etc.

@lespea
Copy link
Author

lespea commented Aug 28, 2015

Okay cool I'll give it a shot tomorrow and let you know how it goes. Thanks!

@lespea
Copy link
Author

lespea commented Aug 28, 2015

Wow that's a lot of documentation in that branch; nice job!

Anyway got this exception now:

2015-08-28 15:19:28,949 WARNING  pytan.sessions.Session: Unable to find Version key in Settings: {}
2015-08-28 15:19:28,949 WARNING  pytan.sessions.Session: Unable to find Version key in Settings: {}
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "../lib/pytan/handler.py", line 194, in get_server_version
    self.server_version_dict = self._parse_versioning()
  File "../lib/pytan/handler.py", line 2320, in _parse_versioning
    raise pytan.exceptions.VersionParseError(m(self.server_version))
VersionParseError: Unable to parse major, minor, revision, and build from server version string: Unable to determine

info_dict is what you're setting in the json.loads exception body; with a value equal to the string I posted above.

@lifehackjim
Copy link
Contributor

Are you able to webex with me? let's take this direct to email, something is going on that I can't see through what you've provided me.

jim.olsen@tanium.com

@lespea
Copy link
Author

lespea commented Sep 21, 2015

Fixed in 2.1.0. Thanks!

@lespea lespea closed this as completed Sep 21, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants