Skip to content

Commit

Permalink
Merge branch 'master' into blackout/SYN-8589/auth.perms.list-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSquires authored Jan 23, 2025
2 parents 764cc46 + 07e8f45 commit 348ea5d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions changes/4a4d016df5220dbe11c742d168326ee0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
desc: Added ``$lib.cell.iden`` to retrieve the iden of the Cortex which the Storm
query is executing on. Unlike ``$lib.cell.getCellInfo().cell.iden``, this value
is available to non-admin users.
prs: []
type: feat
...
11 changes: 11 additions & 0 deletions synapse/lib/stormlib/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class CellLib(s_stormtypes.Lib):
A Storm Library for interacting with the Cortex.
'''
_storm_locals = (
{'name': 'iden', 'desc': 'The Cortex service identifier.',
'type': {'type': 'gtor', '_gtorfunc': '_getCellIden',
'returns': {'type': 'str', 'desc': 'The Cortex service identifier.'}}},
{'name': 'getCellInfo', 'desc': 'Return metadata specific for the Cortex.',
'type': {'type': 'function', '_funcname': '_getCellInfo', 'args': (),
'returns': {'type': 'dict', 'desc': 'A dictionary containing metadata.', }}},
Expand Down Expand Up @@ -174,6 +177,10 @@ class CellLib(s_stormtypes.Lib):
)
_storm_lib_path = ('cell',)

def __init__(self, runt, name=()):
s_stormtypes.Lib.__init__(self, runt, name=name)
self.gtors['iden'] = self._getCellIden

def getObjLocals(self):
return {
'getCellInfo': self._getCellInfo,
Expand All @@ -187,6 +194,10 @@ def getObjLocals(self):
'uptime': self._uptime,
}

@s_stormtypes.stormfunc(readonly=True)
async def _getCellIden(self):
return self.runt.snap.core.getCellIden()

async def _hotFixesApply(self):
if not self.runt.isAdmin():
mesg = '$lib.cell.stormFixesApply() requires admin privs.'
Expand Down
3 changes: 3 additions & 0 deletions synapse/tests/test_lib_stormlib_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ async def test_stormlib_cell(self):

async with self.getTestCore() as core:

ret = await core.callStorm('return ( $lib.cell.iden )')
self.eq(ret, core.getCellIden())

ret = await core.callStorm('return ( $lib.cell.getCellInfo() )')
self.eq(ret, await core.getCellInfo())

Expand Down

0 comments on commit 348ea5d

Please sign in to comment.