Skip to content

Commit

Permalink
More efficient sensor listing. (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximelb committed May 2, 2023
1 parent 33d5684 commit eb3c129
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions limacharlie/Manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def userAccessibleOrgs( self ):
}, altRoot = 'https://app.limacharlie.io/', isNoAuth = True )
return resp

def sensor( self, sid, inv_id = None ):
def sensor( self, sid, inv_id = None, detailedInfo = None ):
'''Get a Sensor object for the specific Sensor ID.
The sensor may or may not be online.
Expand All @@ -362,7 +362,7 @@ def sensor( self, sid, inv_id = None ):
a Sensor object.
'''

s = Sensor( self, sid )
s = Sensor( self, sid, detailedInfo = detailedInfo )
if inv_id is not None:
s.setInvId( inv_id )
elif self._inv_id is not None:
Expand Down Expand Up @@ -406,7 +406,7 @@ def sensors( self, inv_id = None, selector = None, limit = None, with_ip = None,
inv_id = self._inv_id

for s in resp[ 'sensors' ]:
yield self.sensor( s[ 'sid' ], inv_id )
yield self.sensor( s[ 'sid' ], inv_id, detailedInfo = s )

continuationToken = resp.get( 'continuation_token', None )
if continuationToken is None:
Expand Down
8 changes: 5 additions & 3 deletions limacharlie/Sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Sensor( object ):
_ARCHITECTURE_ALPINE64 = 0x00000005
_ARCHITECTURE_CHROME = 0x00000006

def __init__( self, manager, sid ):
def __init__( self, manager, sid, detailedInfo = None ):
try:
uuid.UUID( sid )
except:
Expand All @@ -38,6 +38,7 @@ def __init__( self, manager, sid ):
self._platform = None
self._architecture = None
self._hostname = None
self._detailedInfo = detailedInfo

def setInvId( self, inv_id ):
'''Set an investigation ID to be applied to all actions done using the object.
Expand Down Expand Up @@ -213,7 +214,9 @@ def getInfo( self ):
Returns:
high level information on the Sensor.
'''
data = self._manager._apiCall( '%s' % self.sid, GET )
data = self._detailedInfo
if not data:
data = self._manager._apiCall( '%s' % self.sid, GET )[ 'info' ]

# We massage the info a bit to make it easier to understand.
platToString = {
Expand All @@ -232,7 +235,6 @@ def getInfo( self ):
self._ARCHITECTURE_ALPINE64 : 'alpine64',
self._ARCHITECTURE_CHROME : 'chrome',
}
data = data[ 'info' ]

self._platform = data[ 'plat' ]
self._architecture = data[ 'arch' ]
Expand Down
2 changes: 1 addition & 1 deletion limacharlie/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""limacharlie API for limacharlie.io"""

__version__ = "4.4.6"
__version__ = "4.4.7"
__author__ = "Maxime Lamothe-Brassard ( Refraction Point, Inc )"
__author_email__ = "maxime@refractionpoint.com"
__license__ = "Apache v2"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup

__version__ = "4.4.6"
__version__ = "4.4.7"
__author__ = "Maxime Lamothe-Brassard ( Refraction Point, Inc )"
__author_email__ = "maxime@refractionpoint.com"
__license__ = "Apache v2"
Expand Down

0 comments on commit eb3c129

Please sign in to comment.