synapse 2.195.1__py311-none-any.whl → 2.197.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 (60) hide show
  1. synapse/axon.py +72 -5
  2. synapse/common.py +23 -0
  3. synapse/cortex.py +13 -8
  4. synapse/cryotank.py +2 -2
  5. synapse/daemon.py +1 -0
  6. synapse/lib/aha.py +159 -4
  7. synapse/lib/cell.py +133 -8
  8. synapse/lib/config.py +3 -3
  9. synapse/lib/jsonstor.py +2 -1
  10. synapse/lib/modelrev.py +5 -1
  11. synapse/lib/multislabseqn.py +2 -2
  12. synapse/lib/nexus.py +4 -1
  13. synapse/lib/reflect.py +4 -5
  14. synapse/lib/schemas.py +478 -1
  15. synapse/lib/snap.py +14 -7
  16. synapse/lib/storm.py +12 -394
  17. synapse/lib/stormlib/aha.py +351 -1
  18. synapse/lib/stormlib/graph.py +0 -61
  19. synapse/lib/stormlib/index.py +52 -0
  20. synapse/lib/stormlib/utils.py +37 -0
  21. synapse/lib/stormtypes.py +121 -1
  22. synapse/lib/task.py +13 -2
  23. synapse/lib/urlhelp.py +1 -1
  24. synapse/lib/version.py +2 -2
  25. synapse/models/base.py +3 -0
  26. synapse/models/doc.py +62 -0
  27. synapse/models/infotech.py +55 -16
  28. synapse/models/orgs.py +20 -14
  29. synapse/models/risk.py +23 -10
  30. synapse/models/transport.py +8 -3
  31. synapse/telepath.py +12 -0
  32. synapse/tests/test_axon.py +23 -0
  33. synapse/tests/test_common.py +28 -0
  34. synapse/tests/test_datamodel.py +15 -0
  35. synapse/tests/test_lib_aha.py +201 -0
  36. synapse/tests/test_lib_boss.py +15 -6
  37. synapse/tests/test_lib_cell.py +104 -0
  38. synapse/tests/test_lib_jsonstor.py +1 -0
  39. synapse/tests/test_lib_modelrev.py +6 -0
  40. synapse/tests/test_lib_stormlib_aha.py +188 -0
  41. synapse/tests/test_lib_stormlib_index.py +39 -0
  42. synapse/tests/test_lib_stormlib_utils.py +14 -0
  43. synapse/tests/test_lib_stormtypes.py +90 -3
  44. synapse/tests/test_lib_task.py +31 -13
  45. synapse/tests/test_model_base.py +2 -0
  46. synapse/tests/test_model_doc.py +38 -0
  47. synapse/tests/test_model_infotech.py +28 -1
  48. synapse/tests/test_model_orgs.py +9 -0
  49. synapse/tests/test_model_risk.py +2 -0
  50. synapse/tests/test_model_transport.py +1 -0
  51. synapse/tests/test_telepath.py +26 -0
  52. synapse/tests/test_tools_aha.py +192 -0
  53. synapse/tools/aha/mirror.py +193 -0
  54. synapse/tools/changelog.py +32 -27
  55. synapse/tools/genpkg.py +2 -2
  56. {synapse-2.195.1.dist-info → synapse-2.197.0.dist-info}/METADATA +1 -1
  57. {synapse-2.195.1.dist-info → synapse-2.197.0.dist-info}/RECORD +60 -55
  58. {synapse-2.195.1.dist-info → synapse-2.197.0.dist-info}/LICENSE +0 -0
  59. {synapse-2.195.1.dist-info → synapse-2.197.0.dist-info}/WHEEL +0 -0
  60. {synapse-2.195.1.dist-info → synapse-2.197.0.dist-info}/top_level.txt +0 -0
synapse/lib/storm.py CHANGED
@@ -26,14 +26,13 @@ import synapse.lib.config as s_config
26
26
  import synapse.lib.autodoc as s_autodoc
27
27
  import synapse.lib.grammar as s_grammar
28
28
  import synapse.lib.msgpack as s_msgpack
29
+ import synapse.lib.schemas as s_schemas
29
30
  import synapse.lib.spooled as s_spooled
30
31
  import synapse.lib.version as s_version
31
32
  import synapse.lib.hashitem as s_hashitem
32
33
  import synapse.lib.stormctrl as s_stormctrl
33
34
  import synapse.lib.stormtypes as s_stormtypes
34
35
 
35
- import synapse.lib.stormlib.graph as s_stormlib_graph
36
-
37
36
  logger = logging.getLogger(__name__)
38
37
 
39
38
  addtriggerdescr = '''
@@ -190,391 +189,6 @@ Examples:
190
189
  wget https://vertex.link https://vtx.lk
191
190
  '''
192
191
 
193
- permdef_schema = {
194
- 'type': 'object',
195
- 'properties': {
196
- 'perm': {'type': 'array', 'items': {'type': 'string'}},
197
- 'desc': {'type': 'string'},
198
- 'gate': {'type': 'string'},
199
- 'ex': {'type': 'string'}, # Example string
200
- 'workflowconfig': {'type': 'boolean'},
201
- 'default': {'type': 'boolean', 'default': False},
202
- },
203
- 'required': ['perm', 'desc', 'gate'],
204
- }
205
-
206
- reqValidPermDef = s_config.getJsValidator(permdef_schema)
207
-
208
- reqValidPkgdef = s_config.getJsValidator({
209
- 'type': 'object',
210
- 'properties': {
211
- 'name': {'type': 'string'},
212
- 'version': {
213
- 'type': 'string',
214
- 'pattern': s_version.semverstr,
215
- },
216
- 'build': {
217
- 'type' 'object'
218
- 'properties': {
219
- 'time': {'type': 'number'},
220
- },
221
- 'required': ['time'],
222
- },
223
- 'codesign': {
224
- 'type': 'object',
225
- 'properties': {
226
- 'sign': {'type': 'string'},
227
- 'cert': {'type': 'string'},
228
- },
229
- 'required': ['cert', 'sign'],
230
- },
231
- # TODO: Remove me after Synapse 3.0.0.
232
- 'synapse_minversion': {
233
- 'type': ['array', 'null'],
234
- 'items': {'type': 'number'}
235
- },
236
- 'synapse_version': {
237
- 'type': 'string',
238
- },
239
- 'modules': {
240
- 'type': ['array', 'null'],
241
- 'items': {'$ref': '#/definitions/module'}
242
- },
243
- 'docs': {
244
- 'type': ['array', 'null'],
245
- 'items': {'$ref': '#/definitions/doc'},
246
- },
247
- 'logo': {
248
- 'type': 'object',
249
- 'properties': {
250
- 'mime': {'type': 'string'},
251
- 'file': {'type': 'string'},
252
- },
253
- 'additionalProperties': True,
254
- 'required': ['mime', 'file'],
255
- },
256
- 'commands': {
257
- 'type': ['array', 'null'],
258
- 'items': {'$ref': '#/definitions/command'},
259
- },
260
- 'graphs': {
261
- 'type': ['array', 'null'],
262
- 'items': s_stormlib_graph.gdefSchema,
263
- },
264
- 'desc': {'type': 'string'},
265
- 'svciden': {'type': ['string', 'null'], 'pattern': s_config.re_iden},
266
- 'onload': {'type': 'string'},
267
- 'author': {
268
- 'type': 'object',
269
- 'properties': {
270
- 'url': {'type': 'string'},
271
- 'name': {'type': 'string'},
272
- },
273
- 'required': ['name', 'url'],
274
- },
275
- 'depends': {
276
- 'properties': {
277
- 'requires': {'type': 'array', 'items': {'$ref': '#/definitions/require'}},
278
- 'conflicts': {'type': 'array', 'items': {'$ref': '#/definitions/conflict'}},
279
- },
280
- 'additionalProperties': True,
281
- },
282
- 'perms': {
283
- 'type': 'array',
284
- 'items': permdef_schema,
285
- },
286
- 'configvars': {
287
- 'type': 'array',
288
- 'items': {
289
- 'type': 'object',
290
- 'properties': {
291
- 'name': {'type': 'string'},
292
- 'varname': {'type': 'string'},
293
- 'desc': {'type': 'string'},
294
- 'default': {},
295
- 'workflowconfig': {'type': 'boolean'},
296
- 'type': {'$ref': '#/definitions/configvartype'},
297
- 'scopes': {
298
- 'type': 'array',
299
- 'items': {
300
- 'type': 'string',
301
- 'enum': ['global', 'self']
302
- },
303
- },
304
- },
305
- 'required': ['name', 'varname', 'desc', 'type', 'scopes'],
306
- },
307
- },
308
- },
309
- 'additionalProperties': True,
310
- 'required': ['name', 'version'],
311
- 'definitions': {
312
- 'doc': {
313
- 'type': 'object',
314
- 'properties': {
315
- 'title': {'type': 'string'},
316
- 'content': {'type': 'string'},
317
- },
318
- 'additionalProperties': True,
319
- 'required': ['title', 'content'],
320
- },
321
- 'module': {
322
- 'type': 'object',
323
- 'properties': {
324
- 'name': {'type': 'string'},
325
- 'storm': {'type': 'string'},
326
- 'modconf': {'type': 'object'},
327
- 'apidefs': {
328
- 'type': ['array', 'null'],
329
- 'items': {'$ref': '#/definitions/apidef'},
330
- },
331
- 'asroot': {'type': 'boolean'},
332
- 'asroot:perms': {'type': 'array',
333
- 'items': {'type': 'array',
334
- 'items': {'type': 'string'}},
335
- },
336
- },
337
- 'additionalProperties': True,
338
- 'required': ['name', 'storm']
339
- },
340
- 'apidef': {
341
- 'type': 'object',
342
- 'properties': {
343
- 'name': {'type': 'string'},
344
- 'desc': {'type': 'string'},
345
- 'deprecated': {'$ref': '#/definitions/deprecatedItem'},
346
- 'type': {
347
- 'type': 'object',
348
- 'properties': {
349
- 'type': {
350
- 'type': 'string',
351
- 'enum': ['function']
352
- },
353
- 'args': {
354
- 'type': 'array',
355
- 'items': {'$ref': '#/definitions/apiarg'},
356
- },
357
- 'returns': {
358
- 'type': 'object',
359
- 'properties': {
360
- 'name': {
361
- 'type': 'string',
362
- 'enum': ['yields'],
363
- },
364
- 'desc': {'type': 'string'},
365
- 'type': {
366
- 'oneOf': [
367
- {'$ref': '#/definitions/apitype'},
368
- {'type': 'array', 'items': {'$ref': '#/definitions/apitype'}},
369
- ],
370
- },
371
- },
372
- 'additionalProperties': False,
373
- 'required': ['type', 'desc']
374
- },
375
- },
376
- 'additionalProperties': False,
377
- 'required': ['type', 'returns'],
378
- },
379
- },
380
- 'additionalProperties': False,
381
- 'required': ['name', 'desc', 'type']
382
- },
383
- 'apiarg': {
384
- 'type': 'object',
385
- 'properties': {
386
- 'name': {'type': 'string'},
387
- 'desc': {'type': 'string'},
388
- 'type': {
389
- 'oneOf': [
390
- {'$ref': '#/definitions/apitype'},
391
- {'type': 'array', 'items': {'$ref': '#/definitions/apitype'}},
392
- ],
393
- },
394
- 'default': {'type': ['boolean', 'integer', 'string', 'null']},
395
- },
396
- 'additionalProperties': False,
397
- 'required': ['name', 'desc', 'type']
398
- },
399
- 'deprecatedItem': {
400
- 'type': 'object',
401
- 'properties': {
402
- 'eolvers': {'type': 'string', 'minLength': 1,
403
- 'description': "The version which will not longer support the item."},
404
- 'eoldate': {'type': 'string', 'minLength': 1,
405
- 'description': 'Optional string indicating Synapse releases after this date may no longer support the item.'},
406
- 'mesg': {'type': ['string', 'null'], 'default': None,
407
- 'description': 'Optional message to include in the warning text.'}
408
- },
409
- 'oneOf': [
410
- {
411
- 'required': ['eolvers'],
412
- 'not': {'required': ['eoldate']}
413
- },
414
- {
415
- 'required': ['eoldate'],
416
- 'not': {'required': ['eolvers']}
417
- }
418
- ],
419
- 'additionalProperties': False,
420
- },
421
- 'apitype': {
422
- 'type': 'string',
423
- },
424
- 'command': {
425
- 'type': 'object',
426
- 'properties': {
427
- 'name': {
428
- 'type': 'string',
429
- 'pattern': s_grammar.re_scmd
430
- },
431
- 'cmdargs': {
432
- 'type': ['array', 'null'],
433
- 'items': {'$ref': '#/definitions/cmdarg'},
434
- },
435
- 'cmdinputs': {
436
- 'type': ['array', 'null'],
437
- 'items': {'$ref': '#/definitions/cmdinput'},
438
- },
439
- 'storm': {'type': 'string'},
440
- 'forms': {'$ref': '#/definitions/cmdformhints'},
441
- 'perms': {'type': 'array',
442
- 'items': {'type': 'array',
443
- 'items': {'type': 'string'}},
444
- },
445
- },
446
- 'additionalProperties': True,
447
- 'required': ['name', 'storm']
448
- },
449
- 'cmdarg': {
450
- 'type': 'array',
451
- 'items': [
452
- {'type': 'string'},
453
- {
454
- 'type': 'object',
455
- 'properties': {
456
- 'help': {'type': 'string'},
457
- 'default': {},
458
- 'dest': {'type': 'string'},
459
- 'required': {'type': 'boolean'},
460
- 'action': {'type': 'string'},
461
- 'nargs': {'type': ['string', 'integer']},
462
- 'choices': {
463
- 'type': 'array',
464
- 'uniqueItems': True,
465
- 'minItems': 1,
466
- },
467
- 'type': {
468
- 'type': 'string',
469
- 'enum': list(s_datamodel.Model().types)
470
- },
471
- },
472
- }
473
- ],
474
- 'additionalItems': False,
475
- },
476
- 'cmdinput': {
477
- 'type': 'object',
478
- 'properties': {
479
- 'form': {'type': 'string'},
480
- 'help': {'type': 'string'},
481
- },
482
- 'additionalProperties': True,
483
- 'required': ['form'],
484
- },
485
- 'configvartype': {
486
- 'anyOf': [
487
- {'type': 'array', 'items': {'$ref': '#/definitions/configvartype'}},
488
- {'type': 'string'},
489
- ]
490
- },
491
- # deprecated
492
- 'cmdformhints': {
493
- 'type': 'object',
494
- 'properties': {
495
- 'input': {
496
- 'type': 'array',
497
- 'uniqueItems': True,
498
- 'items': {
499
- 'type': 'string',
500
- }
501
- },
502
- 'output': {
503
- 'type': 'array',
504
- 'uniqueItems': True,
505
- 'items': {
506
- 'type': 'string',
507
- }
508
- },
509
- 'nodedata': {
510
- 'type': 'array',
511
- 'uniqueItems': True,
512
- 'items': {
513
- 'type': 'array',
514
- 'items': [
515
- {'type': 'string'},
516
- {'type': 'string'},
517
- ],
518
- 'additionalItems': False,
519
- },
520
- },
521
- }
522
- },
523
- 'require': {
524
- 'type': 'object',
525
- 'properties': {
526
- 'name': {'type': 'string'},
527
- 'version': {'type': 'string'},
528
- 'desc': {'type': 'string'},
529
- 'optional': {'type': 'boolean'},
530
- },
531
- 'additionalItems': True,
532
- 'required': ('name', 'version'),
533
- },
534
- 'conflict': {
535
- 'type': 'object',
536
- 'properties': {
537
- 'name': {'type': 'string'},
538
- 'version': {'type': 'string'},
539
- 'desc': {'type': 'string'},
540
- },
541
- 'additionalItems': True,
542
- 'required': ('name',),
543
- },
544
- }
545
- })
546
-
547
- reqValidDdef = s_config.getJsValidator({
548
- 'type': 'object',
549
- 'properties': {
550
- 'name': {'type': 'string'},
551
- 'storm': {'type': 'string'},
552
- 'view': {'type': 'string', 'pattern': s_config.re_iden},
553
- 'user': {'type': 'string', 'pattern': s_config.re_iden},
554
- 'iden': {'type': 'string', 'pattern': s_config.re_iden},
555
- 'enabled': {'type': 'boolean', 'default': True},
556
- 'stormopts': {
557
- 'oneOf': [
558
- {'type': 'null'},
559
- {'$ref': '#/definitions/stormopts'}
560
- ]
561
- }
562
- },
563
- 'additionalProperties': True,
564
- 'required': ['iden', 'user', 'storm'],
565
- 'definitions': {
566
- 'stormopts': {
567
- 'type': 'object',
568
- 'properties': {
569
- 'repr': {'type': 'boolean'},
570
- 'path': {'type': 'string'},
571
- 'show': {'type': 'array', 'items': {'type': 'string'}}
572
- },
573
- 'additionalProperties': True,
574
- },
575
- }
576
- })
577
-
578
192
  stormcmds = (
579
193
  {
580
194
  'name': 'queue.add',
@@ -2463,11 +2077,15 @@ class Runtime(s_base.Base):
2463
2077
 
2464
2078
  class Parser:
2465
2079
 
2466
- def __init__(self, prog=None, descr=None, root=None):
2080
+ def __init__(self, prog=None, descr=None, root=None, model=None):
2467
2081
 
2468
2082
  if root is None:
2469
2083
  root = self
2470
2084
 
2085
+ if model is None:
2086
+ model = s_datamodel.Model()
2087
+ self.model = model
2088
+
2471
2089
  self.prog = prog
2472
2090
  self.descr = descr
2473
2091
 
@@ -2495,7 +2113,7 @@ class Parser:
2495
2113
  assert len(names)
2496
2114
 
2497
2115
  argtype = opts.get('type')
2498
- if argtype is not None and argtype not in s_datamodel.Model().types:
2116
+ if argtype is not None and argtype not in s_schemas.datamodel_basetypes:
2499
2117
  mesg = f'Argument type "{argtype}" is not a valid model type name'
2500
2118
  raise s_exc.BadArg(mesg=mesg, argtype=str(argtype))
2501
2119
 
@@ -2643,7 +2261,7 @@ class Parser:
2643
2261
  valu = todo.popleft()
2644
2262
  if argtype is not None:
2645
2263
  try:
2646
- valu = s_datamodel.Model().type(argtype).norm(valu)[0]
2264
+ valu = self.model.type(argtype).norm(valu)[0]
2647
2265
  except Exception:
2648
2266
  mesg = f'Invalid value for type ({argtype}): {valu}'
2649
2267
  return self.help(mesg=mesg)
@@ -2666,7 +2284,7 @@ class Parser:
2666
2284
  valu = todo.popleft()
2667
2285
  if argtype is not None:
2668
2286
  try:
2669
- valu = s_datamodel.Model().type(argtype).norm(valu)[0]
2287
+ valu = self.model.type(argtype).norm(valu)[0]
2670
2288
  except Exception:
2671
2289
  mesg = f'Invalid value for type ({argtype}): {valu}'
2672
2290
  return self.help(mesg=mesg)
@@ -2689,7 +2307,7 @@ class Parser:
2689
2307
 
2690
2308
  if argtype is not None:
2691
2309
  try:
2692
- valu = s_datamodel.Model().type(argtype).norm(valu)[0]
2310
+ valu = self.model.type(argtype).norm(valu)[0]
2693
2311
  except Exception:
2694
2312
  mesg = f'Invalid value for type ({argtype}): {valu}'
2695
2313
  return self.help(mesg=mesg)
@@ -2718,7 +2336,7 @@ class Parser:
2718
2336
  valu = todo.popleft()
2719
2337
  if argtype is not None:
2720
2338
  try:
2721
- valu = s_datamodel.Model().type(argtype).norm(valu)[0]
2339
+ valu = self.model.type(argtype).norm(valu)[0]
2722
2340
  except Exception:
2723
2341
  mesg = f'Invalid value for type ({argtype}): {valu}'
2724
2342
  return self.help(mesg=mesg)
@@ -2945,7 +2563,7 @@ class Cmd:
2945
2563
  return self.__class__.__doc__
2946
2564
 
2947
2565
  def getArgParser(self):
2948
- return Parser(prog=self.getName(), descr=self.getDescr())
2566
+ return Parser(prog=self.getName(), descr=self.getDescr(), model=self.runt.model)
2949
2567
 
2950
2568
  async def setArgv(self, argv):
2951
2569