synapse 2.221.0__py311-none-any.whl → 2.223.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 (46) hide show
  1. synapse/cortex.py +143 -44
  2. synapse/cryotank.py +1 -1
  3. synapse/data/lark/storm.lark +9 -6
  4. synapse/lib/ast.py +13 -5
  5. synapse/lib/layer.py +18 -11
  6. synapse/lib/nexus.py +1 -1
  7. synapse/lib/parser.py +1 -0
  8. synapse/lib/rstorm.py +19 -1
  9. synapse/lib/schemas.py +4 -0
  10. synapse/lib/snap.py +15 -9
  11. synapse/lib/storm.py +0 -190
  12. synapse/lib/stormlib/auth.py +1 -1
  13. synapse/lib/stormlib/cortex.py +1 -1
  14. synapse/lib/stormlib/mime.py +15 -5
  15. synapse/lib/stormlib/pkg.py +598 -0
  16. synapse/lib/stormlib/task.py +115 -0
  17. synapse/lib/stormtypes.py +42 -178
  18. synapse/lib/trigger.py +16 -14
  19. synapse/lib/version.py +2 -2
  20. synapse/lib/view.py +17 -14
  21. synapse/models/files.py +1 -1
  22. synapse/models/orgs.py +3 -0
  23. synapse/tests/test_cortex.py +1 -1
  24. synapse/tests/test_lib_aha.py +68 -53
  25. synapse/tests/test_lib_ast.py +3 -0
  26. synapse/tests/test_lib_cell.py +12 -12
  27. synapse/tests/test_lib_grammar.py +4 -4
  28. synapse/tests/test_lib_rstorm.py +55 -7
  29. synapse/tests/test_lib_storm.py +105 -249
  30. synapse/tests/test_lib_stormlib_auth.py +84 -0
  31. synapse/tests/test_lib_stormlib_cortex.py +1 -0
  32. synapse/tests/test_lib_stormlib_mime.py +24 -0
  33. synapse/tests/test_lib_stormlib_pkg.py +456 -0
  34. synapse/tests/test_lib_stormlib_task.py +98 -0
  35. synapse/tests/test_lib_stormtypes.py +25 -100
  36. synapse/tests/test_lib_trigger.py +66 -3
  37. synapse/tests/test_lib_view.py +53 -0
  38. synapse/tests/test_model_files.py +11 -0
  39. synapse/tests/test_model_orgs.py +6 -1
  40. synapse/tools/cryo/cat.py +2 -1
  41. synapse/tools/cryo/list.py +2 -0
  42. {synapse-2.221.0.dist-info → synapse-2.223.0.dist-info}/METADATA +1 -1
  43. {synapse-2.221.0.dist-info → synapse-2.223.0.dist-info}/RECORD +46 -42
  44. {synapse-2.221.0.dist-info → synapse-2.223.0.dist-info}/WHEEL +0 -0
  45. {synapse-2.221.0.dist-info → synapse-2.223.0.dist-info}/licenses/LICENSE +0 -0
  46. {synapse-2.221.0.dist-info → synapse-2.223.0.dist-info}/top_level.txt +0 -0
@@ -42,6 +42,20 @@ class ExecTeleCaller(s_cell.Cell):
42
42
  resp = await meth(*args, **kwargs)
43
43
  return resp
44
44
 
45
+ class SpecialPathApi(s_cell.CellApi):
46
+ async def __anit__(self, cell, link, user, path):
47
+ await super().__anit__(cell, link, user)
48
+ self.path = path
49
+
50
+ async def getTestPath(self):
51
+ return self.path
52
+
53
+ class PathAwareCell(s_cell.Cell):
54
+ async def getCellApi(self, link, user, path):
55
+ if not path:
56
+ return await self.cellapi.anit(self, link, user)
57
+ return await SpecialPathApi.anit(self, link, user, path)
58
+
45
59
  class AhaTest(s_test.SynTest):
46
60
 
47
61
  async def test_lib_aha_clone(self):
@@ -132,36 +146,36 @@ class AhaTest(s_test.SynTest):
132
146
 
133
147
  async def test_lib_aha_offon(self):
134
148
  with self.getTestDir() as dirn:
135
- cryo0_dirn = s_common.gendir(dirn, 'cryo0')
149
+ cell0_dirn = s_common.gendir(dirn, 'cell0')
136
150
  async with self.getTestAha(dirn=dirn) as aha:
137
151
 
138
152
  replaymult = 1
139
153
  if s_common.envbool('SYNDEV_NEXUS_REPLAY'):
140
154
  replaymult = 2
141
155
 
142
- purl = await aha.addAhaSvcProv('0.cryo')
156
+ purl = await aha.addAhaSvcProv('0.cell')
143
157
 
144
158
  wait00 = aha.waiter(1 * replaymult, 'aha:svcadd')
145
159
 
146
160
  conf = {'aha:provision': purl}
147
- async with self.getTestCryo(dirn=cryo0_dirn, conf=conf) as cryo:
161
+ async with self.getTestCell(dirn=cell0_dirn, conf=conf) as cell:
148
162
  self.len(1 * replaymult, await wait00.wait(timeout=6))
149
163
 
150
- svc = await aha.getAhaSvc('0.cryo...')
164
+ svc = await aha.getAhaSvc('0.cell...')
151
165
  linkiden = svc.get('svcinfo', {}).get('online')
152
166
 
153
167
  # Tear down the Aha cell.
154
168
  await aha.__aexit__(None, None, None)
155
169
 
156
- with self.getAsyncLoggerStream('synapse.lib.aha', f'Set [0.cryo.synapse] offline.') as stream:
170
+ with self.getAsyncLoggerStream('synapse.lib.aha', f'Set [0.cell.synapse] offline.') as stream:
157
171
  async with self.getTestAha(dirn=dirn) as aha:
158
172
  self.true(await asyncio.wait_for(stream.wait(), timeout=12))
159
- svc = await aha.getAhaSvc('0.cryo...')
173
+ svc = await aha.getAhaSvc('0.cell...')
160
174
  self.notin('online', svc.get('svcinfo'))
161
175
 
162
176
  # Try setting something down a second time
163
- await aha.setAhaSvcDown('0.cryo', linkiden, network='synapse')
164
- svc = await aha.getAhaSvc('0.cryo...')
177
+ await aha.setAhaSvcDown('0.cell', linkiden, network='synapse')
178
+ svc = await aha.getAhaSvc('0.cell...')
165
179
  self.notin('online', svc.get('svcinfo'))
166
180
 
167
181
  async def test_lib_aha_basics(self):
@@ -190,7 +204,7 @@ class AhaTest(s_test.SynTest):
190
204
 
191
205
  async with self.getTestAha() as aha:
192
206
 
193
- cryo0_dirn = s_common.gendir(aha.dirn, 'cryo0')
207
+ cell0_dirn = s_common.gendir(aha.dirn, 'cell0')
194
208
 
195
209
  ahaurls = await aha.getAhaUrls()
196
210
 
@@ -200,76 +214,77 @@ class AhaTest(s_test.SynTest):
200
214
  if s_common.envbool('SYNDEV_NEXUS_REPLAY'):
201
215
  replaymult = 2
202
216
 
203
- conf = {'aha:provision': await aha.addAhaSvcProv('0.cryo')}
204
- async with self.getTestCryo(dirn=cryo0_dirn, conf=conf) as cryo:
217
+ conf = {'aha:provision': await aha.addAhaSvcProv('0.cell')}
218
+ async with self.getTestCell(dirn=cell0_dirn, conf=conf) as cell:
205
219
 
206
220
  await wait00.wait(timeout=2)
207
221
 
208
222
  with self.raises(s_exc.NoSuchName):
209
223
  await s_telepath.getAhaProxy({'host': 'hehe.haha'})
210
224
 
211
- async with await s_telepath.openurl('aha://cryo...') as proxy:
225
+ async with await s_telepath.openurl('aha://cell...') as proxy:
212
226
  self.nn(await proxy.getCellIden())
213
227
 
214
228
  with self.raises(s_exc.BadArg):
215
- _proxy = await cryo.ahaclient.proxy(timeout=2)
216
- await _proxy.modAhaSvcInfo('cryo...', {'newp': 'newp'})
229
+ _proxy = await cell.ahaclient.proxy(timeout=2)
230
+ await _proxy.modAhaSvcInfo('cell...', {'newp': 'newp'})
217
231
 
218
- async with await s_telepath.openurl('aha://0.cryo...') as proxy:
232
+ async with await s_telepath.openurl('aha://0.cell...') as proxy:
219
233
  self.nn(await proxy.getCellIden())
220
234
 
221
235
  # force a reconnect...
222
- proxy = await cryo.ahaclient.proxy(timeout=2)
236
+ proxy = await cell.ahaclient.proxy(timeout=2)
223
237
  async with aha.waiter(2 * replaymult, 'aha:svcadd'):
224
238
  await proxy.fini()
225
239
 
226
- async with await s_telepath.openurl('aha://cryo...') as proxy:
240
+ async with await s_telepath.openurl('aha://cell...') as proxy:
227
241
  self.nn(await proxy.getCellIden())
228
242
 
229
243
  # force the service into passive mode...
230
244
  async with aha.waiter(3 * replaymult, 'aha:svcdown', 'aha:svcadd', timeout=6):
231
- await cryo.setCellActive(False)
245
+ await cell.setCellActive(False)
232
246
 
233
247
  with self.raises(s_exc.NoSuchName):
234
- async with await s_telepath.openurl('aha://cryo...') as proxy:
248
+ async with await s_telepath.openurl('aha://cell...') as proxy:
235
249
  pass
236
250
 
237
- async with await s_telepath.openurl('aha://0.cryo...') as proxy:
251
+ async with await s_telepath.openurl('aha://0.cell...') as proxy:
238
252
  self.nn(await proxy.getCellIden())
239
253
 
240
254
  async with aha.waiter(1 * replaymult, 'aha:svcadd', timeout=6):
241
- await cryo.setCellActive(True)
255
+ await cell.setCellActive(True)
242
256
 
243
- async with await s_telepath.openurl('aha://cryo...') as proxy:
257
+ async with await s_telepath.openurl('aha://cell...') as proxy:
244
258
  self.nn(await proxy.getCellIden())
245
259
 
246
260
  wait01 = aha.waiter(2 * replaymult, 'aha:svcadd')
247
261
 
248
- conf = {'aha:provision': await aha.addAhaSvcProv('0.cryo')}
249
- async with self.getTestCryo(conf=conf) as cryo:
262
+ conf = {'aha:provision': await aha.addAhaSvcProv('0.cell')}
263
+ async with self.getTestCell(ctor=PathAwareCell, conf=conf) as cell:
250
264
 
251
- info = await cryo.getCellInfo()
265
+ info = await cell.getCellInfo()
266
+ celliden = info['cell']['iden']
252
267
 
253
- self.eq(info['cell']['aha'], {'name': '0.cryo', 'leader': 'cryo', 'network': 'synapse'})
268
+ self.eq(info['cell']['aha'], {'name': '0.cell', 'leader': 'cell', 'network': 'synapse'})
254
269
 
255
270
  await wait01.wait(timeout=2)
256
271
 
257
- async with await s_telepath.openurl('aha://cryo.synapse') as proxy:
258
- self.nn(await proxy.getCellIden())
272
+ async with await s_telepath.openurl('aha://cell.synapse') as proxy:
273
+ self.eq(celliden, await proxy.getCellIden())
259
274
 
260
- async with await s_telepath.openurl('aha://0.cryo.synapse') as proxy:
261
- self.nn(await proxy.getCellIden())
262
- await proxy.puts('hehe', ('hehe', 'haha'))
275
+ async with await s_telepath.openurl('aha://0.cell.synapse') as proxy:
276
+ self.eq(celliden, await proxy.getCellIden())
263
277
 
264
- async with await s_telepath.openurl('aha://0.cryo.synapse/*/hehe') as proxy:
265
- self.nn(await proxy.iden())
278
+ async with await s_telepath.openurl('aha://0.cell.synapse/*/hehe/haha') as proxy:
279
+ self.eq(celliden, await proxy.getCellIden())
280
+ self.eq(('hehe', 'haha'), await proxy.getTestPath())
266
281
 
267
282
  async with aha.getLocalProxy() as ahaproxy:
268
283
 
269
284
  svcs = [x async for x in ahaproxy.getAhaSvcs('synapse')]
270
285
  self.len(2, svcs)
271
286
  names = [s['name'] for s in svcs]
272
- self.sorteq(('cryo.synapse', '0.cryo.synapse'), names)
287
+ self.sorteq(('cell.synapse', '0.cell.synapse'), names)
273
288
 
274
289
  self.none(await ahaproxy.getCaCert('vertex.link'))
275
290
  cacert0 = await ahaproxy.genCaCert('vertex.link')
@@ -278,7 +293,7 @@ class AhaTest(s_test.SynTest):
278
293
  self.eq(cacert0, cacert1)
279
294
  self.eq(cacert0, await ahaproxy.getCaCert('vertex.link'))
280
295
 
281
- csrpem = cryo.certdir.genHostCsr('cryo.vertex.link').decode()
296
+ csrpem = cell.certdir.genHostCsr('cell.vertex.link').decode()
282
297
 
283
298
  hostcert00 = await ahaproxy.signHostCsr(csrpem)
284
299
  hostcert01 = await ahaproxy.signHostCsr(csrpem)
@@ -287,7 +302,7 @@ class AhaTest(s_test.SynTest):
287
302
  self.nn(hostcert01)
288
303
  self.ne(hostcert00, hostcert01)
289
304
 
290
- csrpem = cryo.certdir.genUserCsr('visi@vertex.link').decode()
305
+ csrpem = cell.certdir.genUserCsr('visi@vertex.link').decode()
291
306
 
292
307
  usercert00 = await ahaproxy.signUserCsr(csrpem)
293
308
  usercert01 = await ahaproxy.signUserCsr(csrpem)
@@ -310,7 +325,7 @@ class AhaTest(s_test.SynTest):
310
325
  self.eq(info.get('status'), 'ok')
311
326
  result = info.get('result')
312
327
  self.len(2, result)
313
- self.eq({'0.cryo.synapse', 'cryo.synapse'},
328
+ self.eq({'0.cell.synapse', 'cell.synapse'},
314
329
  {svcinfo.get('name') for svcinfo in result})
315
330
 
316
331
  async with sess.get(svcsurl, json={'network': 'synapse'}) as resp:
@@ -319,7 +334,7 @@ class AhaTest(s_test.SynTest):
319
334
  self.eq(info.get('status'), 'ok')
320
335
  result = info.get('result')
321
336
  self.len(2, result)
322
- self.eq({'0.cryo.synapse', 'cryo.synapse'},
337
+ self.eq({'0.cell.synapse', 'cell.synapse'},
323
338
  {svcinfo.get('name') for svcinfo in result})
324
339
 
325
340
  async with sess.get(svcsurl, json={'network': 'newp'}) as resp:
@@ -351,10 +366,10 @@ class AhaTest(s_test.SynTest):
351
366
  self.eq(info.get('code'), 'AuthDeny')
352
367
 
353
368
  async with aha.getLocalProxy() as ahaproxy:
354
- await ahaproxy.delAhaSvc('cryo', network='synapse')
355
- await ahaproxy.delAhaSvc('0.cryo', network='synapse')
356
- self.none(await ahaproxy.getAhaSvc('cryo.synapse'))
357
- self.none(await ahaproxy.getAhaSvc('0.cryo.synapse'))
369
+ await ahaproxy.delAhaSvc('cell', network='synapse')
370
+ await ahaproxy.delAhaSvc('0.cell', network='synapse')
371
+ self.none(await ahaproxy.getAhaSvc('cell.synapse'))
372
+ self.none(await ahaproxy.getAhaSvc('0.cell.synapse'))
358
373
  self.len(0, [s async for s in ahaproxy.getAhaSvcs()])
359
374
 
360
375
  with self.raises(s_exc.BadArg):
@@ -431,24 +446,24 @@ class AhaTest(s_test.SynTest):
431
446
  async with self.getTestAha() as aha:
432
447
 
433
448
  wait00 = aha.waiter(1, 'aha:svcadd')
434
- conf = {'aha:provision': await aha.addAhaSvcProv('0.cryo')}
449
+ conf = {'aha:provision': await aha.addAhaSvcProv('0.cell')}
435
450
 
436
- async with self.getTestCryo(conf=conf) as cryo:
451
+ async with self.getTestCell(conf=conf) as cell:
437
452
 
438
453
  self.true(await wait00.wait(timeout=2))
439
454
 
440
- async with await s_telepath.openurl('aha://0.cryo...') as proxy:
455
+ async with await s_telepath.openurl('aha://0.cell...') as proxy:
441
456
  self.nn(await proxy.getCellIden())
442
457
 
443
- proxy = await cryo.ahaclient.proxy()
458
+ proxy = await cell.ahaclient.proxy()
444
459
 
445
460
  # avoid race to notify client...
446
- async with cryo.ahaclient.waiter(1, 'tele:client:linkloop', timeout=2):
461
+ async with cell.ahaclient.waiter(1, 'tele:client:linkloop', timeout=2):
447
462
  await aha.fini()
448
463
  self.true(await proxy.waitfini(timeout=10))
449
464
 
450
465
  with self.raises(asyncio.TimeoutError):
451
- await cryo.ahaclient.proxy(timeout=0.1)
466
+ await cell.ahaclient.proxy(timeout=0.1)
452
467
 
453
468
  async def test_lib_aha_onlink_fail(self):
454
469
 
@@ -463,12 +478,12 @@ class AhaTest(s_test.SynTest):
463
478
  aha.testerr = True
464
479
  wait00 = aha.waiter(1, 'aha:svcadd')
465
480
 
466
- conf = {'aha:provision': await aha.addAhaSvcProv('0.cryo')}
467
- async with self.getTestCryo(conf=conf) as cryo:
481
+ conf = {'aha:provision': await aha.addAhaSvcProv('0.cell')}
482
+ async with self.getTestCell(conf=conf) as cell:
468
483
 
469
484
  self.none(await wait00.wait(timeout=2))
470
485
 
471
- svc = await aha.getAhaSvc('0.cryo...')
486
+ svc = await aha.getAhaSvc('0.cell...')
472
487
  self.none(svc)
473
488
 
474
489
  wait01 = aha.waiter(1 * replaymult, 'aha:svcadd')
@@ -476,11 +491,11 @@ class AhaTest(s_test.SynTest):
476
491
 
477
492
  self.nn(await wait01.wait(timeout=2))
478
493
 
479
- svc = await aha.getAhaSvc('0.cryo...')
494
+ svc = await aha.getAhaSvc('0.cell...')
480
495
  self.nn(svc)
481
496
  self.nn(svc.get('svcinfo', {}).get('online'))
482
497
 
483
- async with await s_telepath.openurl('aha://0.cryo...') as proxy:
498
+ async with await s_telepath.openurl('aha://0.cell...') as proxy:
484
499
  self.nn(await proxy.getCellIden())
485
500
 
486
501
  async def test_lib_aha_bootstrap(self):
@@ -3095,6 +3095,9 @@ class AstTest(s_test.SynTest):
3095
3095
  with self.raises(s_exc.StormRuntimeError):
3096
3096
  self.len(1, await core.nodes('inet:ipv4=1.2.3.4 <(seen)- *=woot'))
3097
3097
 
3098
+ with self.raises(s_exc.NoSuchForm):
3099
+ self.len(1, await core.nodes('$foo=(null) inet:ipv4=1.2.3.4 <(seen)- $foo'))
3100
+
3098
3101
  self.len(1, await core.nodes('inet:ipv4=1.2.3.4 <(seen)- *'))
3099
3102
  self.len(1, await core.nodes('inet:ipv4=1.2.3.4 <(seen)- meta:source'))
3100
3103
  self.len(1, await core.nodes('inet:ipv4=1.2.3.4 <(seen)- meta:source:name'))
@@ -1587,22 +1587,22 @@ class CellTest(s_t_utils.SynTest):
1587
1587
 
1588
1588
  with self.getTestDir() as dirn:
1589
1589
 
1590
- async with self.getTestCryo(dirn=dirn) as cryo:
1590
+ async with self.getTestCell(dirn=dirn) as cell:
1591
1591
 
1592
- cryo.certdir.genCaCert('localca')
1593
- cryo.certdir.genHostCert('localhost', signas='localca')
1594
- cryo.certdir.genUserCert('root@localhost', signas='localca')
1595
- cryo.certdir.genUserCert('newp@localhost', signas='localca')
1592
+ cell.certdir.genCaCert('localca')
1593
+ cell.certdir.genHostCert('localhost', signas='localca')
1594
+ cell.certdir.genUserCert('root@localhost', signas='localca')
1595
+ cell.certdir.genUserCert('newp@localhost', signas='localca')
1596
1596
 
1597
- root = await cryo.auth.addUser('root@localhost')
1597
+ root = await cell.auth.addUser('root@localhost')
1598
1598
  await root.setAdmin(True)
1599
1599
 
1600
- async with self.getTestCryo(dirn=dirn) as cryo:
1600
+ async with self.getTestCell(dirn=dirn) as cell:
1601
1601
 
1602
- addr, port = await cryo.dmon.listen('ssl://0.0.0.0:0?hostname=localhost&ca=localca')
1602
+ addr, port = await cell.dmon.listen('ssl://0.0.0.0:0?hostname=localhost&ca=localca')
1603
1603
 
1604
1604
  async with await s_telepath.openurl(f'ssl://root@127.0.0.1:{port}?hostname=localhost') as proxy:
1605
- self.eq(cryo.iden, await proxy.getCellIden())
1605
+ self.eq(cell.iden, await proxy.getCellIden())
1606
1606
 
1607
1607
  with self.raises(s_exc.BadCertHost):
1608
1608
  url = f'ssl://root@127.0.0.1:{port}?hostname=borked.localhost'
@@ -1616,12 +1616,12 @@ class CellTest(s_t_utils.SynTest):
1616
1616
  self.eq(cm.exception.get('username'), 'newp@localhost')
1617
1617
 
1618
1618
  # add newp
1619
- unfo = await cryo.addUser('newp@localhost')
1619
+ unfo = await cell.addUser('newp@localhost')
1620
1620
  async with await s_telepath.openurl(f'ssl://newp@127.0.0.1:{port}?hostname=localhost') as proxy:
1621
- self.eq(cryo.iden, await proxy.getCellIden())
1621
+ self.eq(cell.iden, await proxy.getCellIden())
1622
1622
 
1623
1623
  # Lock newp
1624
- await cryo.setUserLocked(unfo.get('iden'), True)
1624
+ await cell.setUserLocked(unfo.get('iden'), True)
1625
1625
  with self.raises(s_exc.AuthDeny) as cm:
1626
1626
  url = f'ssl://newp@127.0.0.1:{port}?hostname=localhost'
1627
1627
  async with await s_telepath.openurl(url) as proxy:
@@ -1267,7 +1267,7 @@ _ParseResults = [
1267
1267
  'Query: [EditTagPropDel: [TagProp: [TagName: [Const: baz, Const: faz], Const: lol]]]',
1268
1268
  'Query: [EditTagPropSet: [TagProp: [TagName: [Const: baz, Const: faz], Const: lol], Const: =, Const: 20]]',
1269
1269
  'Query: [LiftTagProp: [TagProp: [TagName: [Const: tag], Const: somegeoloctypebecauseihatelife], Const: near=, List: [VarValue: [Const: lat], VarValue: [Const: long]]]]',
1270
- 'Query: [LiftPropBy: [VarValue: [Const: foo], Const: near=, Const: 20]]',
1270
+ 'Query: [LiftPropBy: [DerefProps: [VarValue: [Const: foo]], Const: near=, Const: 20]]',
1271
1271
  'Query: [EditNodeAdd: [FormName: [Const: test:str], Const: =, VarDeref: [VarDeref: [VarDeref: [VarDeref: [VarDeref: [VarValue: [Const: foo], Const: woot], Const: var], VarValue: [Const: bar]], Const: mar], VarValue: [Const: car]]]]',
1272
1272
  'Query: [LiftPropBy: [Const: test:str, Const: =, VarDeref: [VarDeref: [VarValue: [Const: foo], VarValue: [Const: space key]], Const: subkey]]]',
1273
1273
  'Query: [ForLoop: [Const: iterkey, VarDeref: [VarDeref: [VarValue: [Const: foo], VarValue: [Const: bar key]], VarValue: [Const: biz key]], SubQuery: [Query: [LiftPropBy: [Const: inet:ipv4, Const: =, VarDeref: [VarDeref: [VarDeref: [VarValue: [Const: foo], VarValue: [Const: bar key]], VarValue: [Const: biz key]], VarValue: [Const: iterkey]]]]]]]',
@@ -1337,11 +1337,11 @@ _ParseResults = [
1337
1337
  'Query: [VarEvalOper: [FuncCall: [VarDeref: [VarValue: [Const: lib], Const: print], CallArgs: [DollarExpr: [FuncCall: [VarDeref: [DollarExpr: [RelPropValue: [Const: prop]], Const: upper], CallArgs: [], CallKwargs: []]]], CallKwargs: []]]]',
1338
1338
  'Query: [VarEvalOper: [FuncCall: [VarDeref: [VarValue: [Const: lib], Const: print], CallArgs: [VarDeref: [DollarExpr: [ExprDict: [Const: unicode, Const: 1]], DollarExpr: [RelPropValue: [Const: prop]]]], CallKwargs: []]]]',
1339
1339
  'Query: [VarEvalOper: [FuncCall: [VarDeref: [VarValue: [Const: lib], Const: print], CallArgs: [DollarExpr: [ExprNode: [VarDeref: [DollarExpr: [ExprDict: [Const: unicode, Const: 1]], DollarExpr: [RelPropValue: [Const: prop]]], Const: +, DollarExpr: [Const: 2]]]], CallKwargs: []]]]',
1340
- 'Query: [LiftFormTag: [VarValue: [Const: form], TagName: [VarValue: [Const: tag]]]]',
1341
- 'Query: [LiftFormTagProp: [FormTagProp: [VarValue: [Const: form], TagName: [VarValue: [Const: tag]], VarValue: [Const: prop]]]]',
1340
+ 'Query: [LiftFormTag: [DerefProps: [VarValue: [Const: form]], TagName: [VarValue: [Const: tag]]]]',
1341
+ 'Query: [LiftFormTagProp: [FormTagProp: [DerefProps: [VarValue: [Const: form]], TagName: [VarValue: [Const: tag]], VarValue: [Const: prop]]]]',
1342
1342
  'Query: [LiftProp: [Const: inet:ipv4]]',
1343
1343
  'Query: [LiftPropBy: [Const: inet:ipv4, Const: =, Const: 1.2.3.4]]',
1344
- 'Query: [LiftPropBy: [VarValue: [Const: form], Const: =, VarValue: [Const: valu]]]',
1344
+ 'Query: [LiftPropBy: [DerefProps: [VarValue: [Const: form]], Const: =, VarValue: [Const: valu]]]',
1345
1345
  'Query: [LiftPropBy: [Const: test:str, Const: =, Const: foobar], FormPivot: [Const: inet:dns*], isjoin=False]',
1346
1346
  'Query: [LiftPropBy: [Const: test:str, Const: =, Const: foobar], FormPivot: [Const: inet:dns:*], isjoin=False]',
1347
1347
  'Query: [LiftPropBy: [Const: test:str, Const: =, Const: foobar], FormPivot: [List: [Const: meta:source, Const: inet:dns:a]], isjoin=False]',
@@ -1,4 +1,5 @@
1
1
  import os
2
+ import sys
2
3
 
3
4
  import vcr
4
5
 
@@ -226,10 +227,10 @@ Bye!
226
227
  shell_input00 = '''
227
228
  Shell with environment variable.
228
229
 
229
- .. shell-env:: SYN_LOG_LEVEL=DEBUG SYN_FOO=BAR
230
- .. shell:: python3 -c "import os; print('LEVEL', os.environ.get('SYN_LOG_LEVEL')); print('FOO', os.environ.get('SYN_FOO'))"
230
+ .. shell-env:: SYN_HEHE_HAHA=BEEP SYN_FOO=BAR
231
+ .. shell:: python3 -c "import os; print('HEHE_HAHA', os.environ.get('SYN_HEHE_HAHA')); print('FOO', os.environ.get('SYN_FOO'))"
231
232
  .. shell-env::
232
- .. shell:: python3 -c "import os; print('LEVEL', os.environ.get('SYN_LOG_LEVEL')); print('FOO', os.environ.get('SYN_FOO'))"
233
+ .. shell:: python3 -c "import os; print('HEHE_HAHA', os.environ.get('SYN_HEHE_HAHA')); print('FOO', os.environ.get('SYN_FOO'))"
233
234
  '''
234
235
 
235
236
  shell_output00 = '''
@@ -237,17 +238,17 @@ Shell with environment variable.
237
238
 
238
239
  ::
239
240
 
240
- python3 -c "import os; print('LEVEL', os.environ.get('SYN_LOG_LEVEL')); print('FOO', os.environ.get('SYN_FOO'))"
241
+ python3 -c "import os; print('HEHE_HAHA', os.environ.get('SYN_HEHE_HAHA')); print('FOO', os.environ.get('SYN_FOO'))"
241
242
 
242
- LEVEL DEBUG
243
+ HEHE_HAHA BEEP
243
244
  FOO BAR
244
245
 
245
246
 
246
247
  ::
247
248
 
248
- python3 -c "import os; print('LEVEL', os.environ.get('SYN_LOG_LEVEL')); print('FOO', os.environ.get('SYN_FOO'))"
249
+ python3 -c "import os; print('HEHE_HAHA', os.environ.get('SYN_HEHE_HAHA')); print('FOO', os.environ.get('SYN_FOO'))"
249
250
 
250
- LEVEL None
251
+ HEHE_HAHA None
251
252
  FOO None
252
253
 
253
254
 
@@ -776,3 +777,50 @@ class RStormLibTest(s_test.SynTest):
776
777
  fd.write(fix_input_for_cli(fail02).encode())
777
778
  with self.raises(s_exc.StormRuntimeError):
778
779
  await get_rst_text(path)
780
+
781
+ async def test_rstorm_python_path(self):
782
+ content = '''#comment
783
+ import synapse.lib.cell as s_cell
784
+ import synapse.lib.stormsvc as s_stormsvc
785
+
786
+ class SomeApi(s_stormsvc.StormSvc, s_cell.CellApi):
787
+ _storm_svc_name = 'someservice'
788
+ _storm_svc_vers = '0.1.0',
789
+ _storm_svc_pkgs = ()
790
+
791
+ class SomeService(s_cell.Cell):
792
+ cellapi = SomeApi
793
+ '''
794
+ with self.getTestDir() as dirn:
795
+ with s_common.genfile(dirn, 'somefile.py') as fd:
796
+ fd.write(content.encode())
797
+ pythonpath_rst_in = f'''
798
+ .. storm-cortex:: default
799
+ .. storm-python-path:: {dirn}
800
+ .. storm-svc:: somefile.SomeService fooservice {{"https:port": 0}}
801
+ .. storm:: service.list
802
+
803
+ hello world
804
+ '''
805
+ rst_path = s_common.genpath(dirn, 'test.rst')
806
+
807
+ with s_common.genfile(rst_path) as fd:
808
+ fd.write(pythonpath_rst_in.encode())
809
+
810
+ pythonpath_rst_out = await get_rst_text(rst_path)
811
+ self.notin('storm-python-path', pythonpath_rst_out)
812
+ self.isin('(fooservice) (someservice @ 0.1.0)', pythonpath_rst_out)
813
+ self.isin('hello world', pythonpath_rst_out)
814
+ # Fini handler cleaned up the path manipulation
815
+ self.notin(dirn, sys.path)
816
+
817
+ # Sad path
818
+ pythonpath_rst_in = f'''
819
+ .. storm-python-path:: {dirn}/{s_common.guid()}
820
+ hello world
821
+ '''
822
+ rst_path = s_common.genpath(dirn, 'test.rst')
823
+ with s_common.genfile(rst_path) as fd:
824
+ fd.write(pythonpath_rst_in.encode())
825
+ with self.raises(s_exc.NoSuchDir):
826
+ await get_rst_text(rst_path)