synapse 2.196.0__py311-none-any.whl → 2.198.0__py311-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of synapse might be problematic. Click here for more details.

Files changed (61) hide show
  1. synapse/axon.py +3 -0
  2. synapse/common.py +3 -0
  3. synapse/cortex.py +13 -11
  4. synapse/cryotank.py +2 -2
  5. synapse/lib/aha.py +3 -0
  6. synapse/lib/ast.py +277 -165
  7. synapse/lib/auth.py +39 -11
  8. synapse/lib/cell.py +24 -6
  9. synapse/lib/config.py +3 -3
  10. synapse/lib/hive.py +2 -1
  11. synapse/lib/hiveauth.py +10 -1
  12. synapse/lib/jsonstor.py +6 -5
  13. synapse/lib/layer.py +6 -5
  14. synapse/lib/multislabseqn.py +2 -2
  15. synapse/lib/node.py +10 -4
  16. synapse/lib/parser.py +46 -21
  17. synapse/lib/schemas.py +491 -1
  18. synapse/lib/snap.py +68 -26
  19. synapse/lib/storm.lark +13 -11
  20. synapse/lib/storm.py +13 -395
  21. synapse/lib/storm_format.py +3 -2
  22. synapse/lib/stormlib/graph.py +0 -61
  23. synapse/lib/stormlib/index.py +52 -0
  24. synapse/lib/stormtypes.py +16 -5
  25. synapse/lib/task.py +13 -2
  26. synapse/lib/urlhelp.py +1 -1
  27. synapse/lib/version.py +2 -2
  28. synapse/models/doc.py +62 -0
  29. synapse/models/infotech.py +18 -0
  30. synapse/models/orgs.py +6 -4
  31. synapse/models/risk.py +9 -0
  32. synapse/models/syn.py +18 -2
  33. synapse/tests/files/stormpkg/badendpoints.yaml +7 -0
  34. synapse/tests/files/stormpkg/testpkg.yaml +8 -0
  35. synapse/tests/test_cortex.py +108 -0
  36. synapse/tests/test_datamodel.py +7 -0
  37. synapse/tests/test_lib_aha.py +12 -42
  38. synapse/tests/test_lib_ast.py +57 -0
  39. synapse/tests/test_lib_auth.py +143 -2
  40. synapse/tests/test_lib_boss.py +15 -6
  41. synapse/tests/test_lib_cell.py +43 -0
  42. synapse/tests/test_lib_grammar.py +54 -2
  43. synapse/tests/test_lib_lmdbslab.py +24 -0
  44. synapse/tests/test_lib_storm.py +20 -0
  45. synapse/tests/test_lib_stormlib_index.py +39 -0
  46. synapse/tests/test_lib_stormlib_macro.py +3 -3
  47. synapse/tests/test_lib_stormtypes.py +14 -2
  48. synapse/tests/test_lib_task.py +31 -13
  49. synapse/tests/test_model_doc.py +38 -0
  50. synapse/tests/test_model_infotech.py +13 -0
  51. synapse/tests/test_model_orgs.py +7 -0
  52. synapse/tests/test_model_risk.py +6 -0
  53. synapse/tests/test_model_syn.py +58 -0
  54. synapse/tests/test_tools_genpkg.py +10 -0
  55. synapse/tools/genpkg.py +2 -2
  56. synapse/tools/hive/load.py +1 -0
  57. {synapse-2.196.0.dist-info → synapse-2.198.0.dist-info}/METADATA +1 -1
  58. {synapse-2.196.0.dist-info → synapse-2.198.0.dist-info}/RECORD +61 -58
  59. {synapse-2.196.0.dist-info → synapse-2.198.0.dist-info}/LICENSE +0 -0
  60. {synapse-2.196.0.dist-info → synapse-2.198.0.dist-info}/WHEEL +0 -0
  61. {synapse-2.196.0.dist-info → synapse-2.198.0.dist-info}/top_level.txt +0 -0
synapse/axon.py CHANGED
@@ -1017,6 +1017,7 @@ class Axon(s_cell.Cell):
1017
1017
  '''
1018
1018
  for item in self.axonhist.carve(tick, tock=tock):
1019
1019
  yield item
1020
+ await asyncio.sleep(0)
1020
1021
 
1021
1022
  async def hashes(self, offs, wait=False, timeout=None):
1022
1023
  '''
@@ -1086,10 +1087,12 @@ class Axon(s_cell.Cell):
1086
1087
 
1087
1088
  async for byts in self._getBytsOffsSize(sha256, offs, size):
1088
1089
  yield byts
1090
+ await asyncio.sleep(0)
1089
1091
 
1090
1092
  else:
1091
1093
  async for byts in self._get(sha256):
1092
1094
  yield byts
1095
+ await asyncio.sleep(0)
1093
1096
 
1094
1097
  async def _get(self, sha256):
1095
1098
 
synapse/common.py CHANGED
@@ -1222,6 +1222,9 @@ def trimText(text: str, n: int = 256, placeholder: str = '...') -> str:
1222
1222
  assert n > plen
1223
1223
  return f'{text[:mlen]}{placeholder}'
1224
1224
 
1225
+ def queryhash(text):
1226
+ return hashlib.md5(text.encode(errors='surrogatepass'), usedforsecurity=False).hexdigest()
1227
+
1225
1228
  def _patch_http_cookies():
1226
1229
  '''
1227
1230
  Patch stdlib http.cookies._unquote from the 3.11.10 implementation if
synapse/cortex.py CHANGED
@@ -77,6 +77,7 @@ import synapse.lib.stormlib.yaml as s_stormlib_yaml # NOQA
77
77
  import synapse.lib.stormlib.basex as s_stormlib_basex # NOQA
78
78
  import synapse.lib.stormlib.cache as s_stormlib_cache # NOQA
79
79
  import synapse.lib.stormlib.graph as s_stormlib_graph # NOQA
80
+ import synapse.lib.stormlib.index as s_stormlib_index # NOQA
80
81
  import synapse.lib.stormlib.iters as s_stormlib_iters # NOQA
81
82
  import synapse.lib.stormlib.macro as s_stormlib_macro
82
83
  import synapse.lib.stormlib.model as s_stormlib_model
@@ -1496,7 +1497,7 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
1496
1497
  'desc': 'Controls the ability to remove a file from the Axon.'},
1497
1498
  ))
1498
1499
  for pdef in self._cortex_permdefs:
1499
- s_storm.reqValidPermDef(pdef)
1500
+ s_schemas.reqValidPermDef(pdef)
1500
1501
 
1501
1502
  def _getPermDefs(self):
1502
1503
 
@@ -1770,7 +1771,7 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
1770
1771
  gdef['updated'] = now
1771
1772
  gdef['permissions']['users'][user.iden] = s_cell.PERM_ADMIN
1772
1773
 
1773
- s_stormlib_graph.reqValidGdef(gdef)
1774
+ s_schemas.reqValidGdef(gdef)
1774
1775
 
1775
1776
  await self.reqValidStormGraph(gdef)
1776
1777
 
@@ -1778,7 +1779,7 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
1778
1779
 
1779
1780
  @s_nexus.Pusher.onPush('storm:graph:add')
1780
1781
  async def _addStormGraph(self, gdef):
1781
- s_stormlib_graph.reqValidGdef(gdef)
1782
+ s_schemas.reqValidGdef(gdef)
1782
1783
 
1783
1784
  await self.reqValidStormGraph(gdef)
1784
1785
 
@@ -1857,7 +1858,7 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
1857
1858
  gdef = copy.deepcopy(gdef)
1858
1859
  gdef.update(info)
1859
1860
 
1860
- s_stormlib_graph.reqValidGdef(gdef)
1861
+ s_schemas.reqValidGdef(gdef)
1861
1862
 
1862
1863
  await self.reqValidStormGraph(gdef)
1863
1864
 
@@ -1879,7 +1880,7 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
1879
1880
 
1880
1881
  await self._setEasyPerm(gdef, scope, iden, level)
1881
1882
 
1882
- s_stormlib_graph.reqValidGdef(gdef)
1883
+ s_schemas.reqValidGdef(gdef)
1883
1884
 
1884
1885
  self.graphs.set(gden, gdef)
1885
1886
 
@@ -2876,7 +2877,7 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
2876
2877
  await self.reqValidStormGraph(gdef)
2877
2878
 
2878
2879
  # Validate package def (post normalization)
2879
- s_storm.reqValidPkgdef(pkgdef)
2880
+ s_schemas.reqValidPkgdef(pkgdef)
2880
2881
 
2881
2882
  for configvar in pkgdef.get('configvars', ()):
2882
2883
  self._reqStormPkgVarType(pkgname, configvar.get('type'))
@@ -4421,6 +4422,9 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
4421
4422
  for cdef in s_stormlib_vault.stormcmds:
4422
4423
  await self._trySetStormCmd(cdef.get('name'), cdef)
4423
4424
 
4425
+ for cdef in s_stormlib_index.stormcmds:
4426
+ await self._trySetStormCmd(cdef.get('name'), cdef)
4427
+
4424
4428
  async def _initPureStormCmds(self):
4425
4429
  oldcmds = []
4426
4430
  for name, cdef in self.cmddefs.items():
@@ -4451,7 +4455,7 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
4451
4455
  for path, ctor in s_stormtypes.registry.iterLibs():
4452
4456
  # Ensure each ctor's permdefs are valid
4453
4457
  for pdef in ctor._storm_lib_perms:
4454
- s_storm.reqValidPermDef(pdef)
4458
+ s_schemas.reqValidPermDef(pdef)
4455
4459
  # Skip libbase which is registered as a default ctor in the storm Runtime
4456
4460
  if path:
4457
4461
  self.addStormLib(path, ctor)
@@ -4652,10 +4656,8 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
4652
4656
  if not path:
4653
4657
  return await self.cellapi.anit(self, link, user)
4654
4658
 
4655
- # allow an admin to directly open the cortex hive
4656
- # (perhaps this should be a Cell() level pattern)
4657
4659
  if path[0] == 'hive' and user.isAdmin():
4658
- s_common.deprecated('Cortex /hive telepath path', curv='2.167.0')
4660
+ s_common.deprecated('Cortex /hive telepath path', curv='2.198.0', eolv='2.199.0')
4659
4661
  return await self.hiveapi.anit(self.hive, user)
4660
4662
 
4661
4663
  if path[0] == 'layer':
@@ -5672,7 +5674,7 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
5672
5674
  async def runStormDmon(self, iden, ddef):
5673
5675
 
5674
5676
  # validate ddef before firing task
5675
- s_storm.reqValidDdef(ddef)
5677
+ s_schemas.reqValidDdef(ddef)
5676
5678
 
5677
5679
  dmon = self.stormdmons.getDmon(iden)
5678
5680
  if dmon is not None:
synapse/cryotank.py CHANGED
@@ -8,7 +8,7 @@ import synapse.common as s_common
8
8
 
9
9
  import synapse.lib.base as s_base
10
10
  import synapse.lib.cell as s_cell
11
- import synapse.lib.storm as s_storm
11
+ import synapse.lib.schemas as s_schemas
12
12
  import synapse.lib.lmdbslab as s_lmdbslab
13
13
  import synapse.lib.slabseqn as s_slabseqn
14
14
  import synapse.lib.slaboffs as s_slaboffs
@@ -314,7 +314,7 @@ class CryoCell(s_cell.Cell):
314
314
  ))
315
315
 
316
316
  for pdef in self._cryo_permdefs:
317
- s_storm.reqValidPermDef(pdef)
317
+ s_schemas.reqValidPermDef(pdef)
318
318
 
319
319
  def _getPermDefs(self):
320
320
  permdefs = list(s_cell.Cell._getPermDefs(self))
synapse/lib/aha.py CHANGED
@@ -1592,6 +1592,7 @@ class AhaCell(s_cell.Cell):
1592
1592
  self.slab.delete(iden, db='aha:provs')
1593
1593
  provinfo = s_msgpack.un(byts)
1594
1594
  logger.info(f'Deleted service provisioning service={provinfo.get("conf").get("aha:name")}, iden={iden.decode()}')
1595
+ await asyncio.sleep(0)
1595
1596
 
1596
1597
  @s_nexus.Pusher.onPushAuto('aha:enroll:clear')
1597
1598
  async def clearAhaUserEnrolls(self):
@@ -1599,6 +1600,7 @@ class AhaCell(s_cell.Cell):
1599
1600
  self.slab.delete(iden, db='aha:enrolls')
1600
1601
  userinfo = s_msgpack.un(byts)
1601
1602
  logger.info(f'Deleted user enrollment username={userinfo.get("name")}, iden={iden.decode()}')
1603
+ await asyncio.sleep(0)
1602
1604
 
1603
1605
  @s_nexus.Pusher.onPushAuto('aha:clone:clear')
1604
1606
  async def clearAhaClones(self):
@@ -1606,6 +1608,7 @@ class AhaCell(s_cell.Cell):
1606
1608
  self.slab.delete(lkey, db='aha:clones')
1607
1609
  cloninfo = s_msgpack.un(byts)
1608
1610
  logger.info(f'Deleted AHA clone enrollment username={cloninfo.get("host")}, iden={s_common.ehex(lkey)}')
1611
+ await asyncio.sleep(0)
1609
1612
 
1610
1613
  @s_nexus.Pusher.onPushAuto('aha:svc:prov:del')
1611
1614
  async def delAhaSvcProv(self, iden):