synapse 2.166.0__py311-none-any.whl → 2.167.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/axon.py +4 -10
  2. synapse/cortex.py +31 -1
  3. synapse/exc.py +1 -0
  4. synapse/lib/aha.py +2 -0
  5. synapse/lib/base.py +11 -4
  6. synapse/lib/cell.py +11 -2
  7. synapse/lib/hive.py +11 -0
  8. synapse/lib/node.py +4 -2
  9. synapse/lib/schemas.py +1 -1
  10. synapse/lib/stormlib/aha.py +366 -16
  11. synapse/lib/stormlib/macro.py +11 -18
  12. synapse/lib/stormlib/stix.py +1 -1
  13. synapse/lib/stormtypes.py +18 -2
  14. synapse/lib/types.py +2 -0
  15. synapse/lib/version.py +2 -2
  16. synapse/lib/view.py +4 -3
  17. synapse/models/base.py +8 -0
  18. synapse/models/files.py +3 -0
  19. synapse/telepath.py +1 -0
  20. synapse/tests/files/stormpkg/dotstorm/dotstorm.yaml +3 -0
  21. synapse/tests/test_cortex.py +39 -2
  22. synapse/tests/test_lib_aha.py +1 -2
  23. synapse/tests/test_lib_cell.py +6 -2
  24. synapse/tests/test_lib_grammar.py +62 -64
  25. synapse/tests/test_lib_httpapi.py +1 -1
  26. synapse/tests/test_lib_rstorm.py +4 -4
  27. synapse/tests/test_lib_storm.py +3 -3
  28. synapse/tests/test_lib_stormlib_aha.py +196 -0
  29. synapse/tests/test_lib_stormlib_compression.py +12 -12
  30. synapse/tests/test_lib_stormlib_macro.py +94 -0
  31. synapse/tests/test_lib_stormlib_spooled.py +1 -1
  32. synapse/tests/test_lib_stormtypes.py +44 -33
  33. synapse/tests/test_lib_view.py +50 -3
  34. synapse/tests/test_model_files.py +3 -0
  35. synapse/tests/test_tools_genpkg.py +26 -0
  36. synapse/tests/test_tools_hiveload.py +1 -0
  37. synapse/tests/test_tools_hivesave.py +1 -0
  38. synapse/tests/utils.py +22 -3
  39. synapse/tools/autodoc.py +1 -1
  40. synapse/tools/hive/load.py +3 -0
  41. synapse/tools/hive/save.py +3 -0
  42. {synapse-2.166.0.dist-info → synapse-2.167.0.dist-info}/METADATA +3 -3
  43. {synapse-2.166.0.dist-info → synapse-2.167.0.dist-info}/RECORD +46 -45
  44. {synapse-2.166.0.dist-info → synapse-2.167.0.dist-info}/LICENSE +0 -0
  45. {synapse-2.166.0.dist-info → synapse-2.167.0.dist-info}/WHEEL +0 -0
  46. {synapse-2.166.0.dist-info → synapse-2.167.0.dist-info}/top_level.txt +0 -0
@@ -1,43 +1,169 @@
1
- import synapse.common as s_common
1
+ import synapse.exc as s_exc
2
2
  import synapse.lib.stormtypes as s_stormtypes
3
3
 
4
+ @s_stormtypes.registry.registerLib
5
+ class AhaLib(s_stormtypes.Lib):
6
+ '''
7
+ A Storm Library for interacting with AHA.
8
+ '''
9
+
10
+ _storm_locals = (
11
+ {'name': 'del', 'desc': '''Delete a service from AHA.
12
+
13
+ Examples:
14
+ Deleting a service with its relative name::
15
+
16
+ $lib.aha.del(00.mysvc...)
17
+
18
+ Deleting a service with its full name::
19
+
20
+ $lib.aha.del(00.mysvc.loop.vertex.link)
21
+ ''',
22
+ 'type': {'type': 'function', '_funcname': '_methAhaDel',
23
+ 'args': (
24
+ {'name': 'svcname', 'type': 'str',
25
+ 'desc': 'The name of the service to delete. It is easiest to use the relative name of a service, ending with "...".', },
26
+ ),
27
+ 'returns': {'type': 'null'}}},
28
+ {'name': 'get', 'desc': '''Get information about an AHA service.
29
+
30
+ Examples:
31
+ Getting service information with a relative name::
32
+
33
+ $lib.aha.get(00.cortex...)
34
+
35
+ Getting service information with its full name::
36
+
37
+ $lib.aha.get(00.cortex.loop.vertex.link)
38
+ ''',
39
+ 'type': {'type': 'function', '_funcname': '_methAhaGet',
40
+ 'args': (
41
+ {'name': 'svcname', 'type': 'str',
42
+ 'desc': 'The name of the AHA service to look up. It is easiest to use the relative name of a service, ending with "...".', },
43
+ {'name': 'filters', 'type': 'dict', 'default': None,
44
+ 'desc': 'An optional dictionary of filters to use when resolving the AHA service.'}
45
+ ),
46
+ 'returns': {'type': ('null', 'dict'),
47
+ 'desc': 'The AHA service information dictionary, or $lib.null.', }}},
48
+ {'name': 'list', 'desc': 'Enumerate all of the AHA services.',
49
+ 'type': {'type': 'function', '_funcname': '_methAhaList', 'args': (),
50
+ 'returns': {'name': 'Yields', 'type': 'list',
51
+ 'desc': 'The AHA service dictionaries.', }}},
52
+ )
53
+ _storm_lib_path = ('aha',)
54
+ def getObjLocals(self):
55
+ return {
56
+ 'del': self._methAhaDel,
57
+ 'get': self._methAhaGet,
58
+ 'list': self._methAhaList,
59
+ }
60
+
61
+ @s_stormtypes.stormfunc(readonly=True)
62
+ async def _methAhaList(self):
63
+ self.runt.reqAdmin()
64
+ proxy = await self.runt.snap.core.reqAhaProxy()
65
+ async for info in proxy.getAhaSvcs():
66
+ yield info
67
+
68
+ async def _methAhaDel(self, svcname):
69
+ self.runt.reqAdmin()
70
+ svcname = await s_stormtypes.tostr(svcname)
71
+ proxy = await self.runt.snap.core.reqAhaProxy()
72
+ svc = await proxy.getAhaSvc(svcname)
73
+ if svc is None:
74
+ raise s_exc.NoSuchName(mesg=f'No AHA service for {svcname=}')
75
+ if svc.get('services'): # It is an AHA Pool!
76
+ mesg = f'Cannot use $lib.aha.del() to remove an AHA Pool. Use $lib.aha.pool.del(); {svcname=}'
77
+ raise s_exc.BadArg(mesg=mesg)
78
+ return await proxy.delAhaSvc(svc.get('svcname'), network=svc.get('svcnetw'))
79
+
80
+ @s_stormtypes.stormfunc(readonly=True)
81
+ async def _methAhaGet(self, svcname, filters=None):
82
+ self.runt.reqAdmin()
83
+ svcname = await s_stormtypes.tostr(svcname)
84
+ filters = await s_stormtypes.toprim(filters)
85
+ proxy = await self.runt.snap.core.reqAhaProxy()
86
+ return await proxy.getAhaSvc(svcname, filters=filters)
87
+
4
88
  @s_stormtypes.registry.registerLib
5
89
  class AhaPoolLib(s_stormtypes.Lib):
6
90
  '''
7
91
  A Storm Library for interacting with AHA service pools.
8
92
  '''
93
+
94
+ _storm_locals = (
95
+ {'name': 'add', 'desc': '''Add a new AHA service pool.
96
+
97
+ Examples:
98
+ Add a pool via its relative name::
99
+
100
+ $lib.aha.pool.add(pool00.cortex...)
101
+ ''',
102
+ 'type': {'type': 'function', '_funcname': '_methPoolAdd',
103
+ 'args': (
104
+ {'name': 'name', 'type': 'str',
105
+ 'desc': 'The name of the pool to add. It is easiest to use the relative name of a pool, ending with "...".', },
106
+ ),
107
+ 'returns': {'type': 'aha:pool'}}},
108
+ {'name': 'del', 'desc': '''Delete an existing AHA service pool.
109
+
110
+ Examples:
111
+ Delete a pool via its relative name::
112
+
113
+ $lib.aha.pool.del(pool00.cortex...)
114
+ ''',
115
+ 'type': {'type': 'function', '_funcname': '_methPoolDel',
116
+ 'args': (
117
+ {'name': 'name', 'type': 'str',
118
+ 'desc': 'The name of the pool to delete. It is easiest to use the relative name of a pool, ending with "...".', },
119
+ ),
120
+ 'returns': {'type': 'dict', 'desc': 'The AHA pool definition that was deleted.'}}},
121
+ {'name': 'get', 'desc': 'Get an existing AHA service pool.',
122
+ 'type': {'type': 'function', '_funcname': '_methPoolGet',
123
+ 'args': (
124
+ {'name': 'name', 'type': 'str',
125
+ 'desc': 'The name of the pool to get. It is easiest to use the relative name of a pool, ending with "...".', },
126
+ ),
127
+ 'returns': {'type': ['null', 'aha:pool'], 'desc': 'The pool if it exists, or $lib.null.'}}},
128
+ {'name': 'list', 'desc': 'Enumerate all of the AHA service pools.',
129
+ 'type': {'type': 'function', '_funcname': '_methPoolList',
130
+ 'returns': {'name': 'yields', 'type': 'aha:pool'}}},
131
+ )
9
132
  _storm_lib_path = ('aha', 'pool')
10
133
 
11
134
  def getObjLocals(self):
12
135
  return {
13
- 'add': self.add,
14
- 'del': self._del,
15
- 'get': self.get,
16
- 'list': self.list,
136
+ 'add': self._methPoolAdd,
137
+ 'del': self._methPoolDel,
138
+ 'get': self._methPoolGet,
139
+ 'list': self._methPoolList,
17
140
  }
18
141
 
19
- async def add(self, name):
142
+ async def _methPoolAdd(self, name):
20
143
  self.runt.reqAdmin()
144
+ name = await s_stormtypes.tostr(name)
21
145
  proxy = await self.runt.snap.core.reqAhaProxy()
22
146
  poolinfo = {'creator': self.runt.user.iden}
23
147
  poolinfo = await proxy.addAhaPool(name, poolinfo)
24
148
  return AhaPool(self.runt, poolinfo)
25
149
 
26
- async def _del(self, name):
150
+ async def _methPoolDel(self, name):
27
151
  self.runt.reqAdmin()
152
+ name = await s_stormtypes.tostr(name)
28
153
  proxy = await self.runt.snap.core.reqAhaProxy()
29
154
  return await proxy.delAhaPool(name)
30
155
 
31
- async def get(self, name):
156
+ @s_stormtypes.stormfunc(readonly=True)
157
+ async def _methPoolGet(self, name):
32
158
  self.runt.reqAdmin()
159
+ name = await s_stormtypes.tostr(name)
33
160
  proxy = await self.runt.snap.core.reqAhaProxy()
34
161
  poolinfo = await proxy.getAhaPool(name)
35
162
  if poolinfo is not None:
36
163
  return AhaPool(self.runt, poolinfo)
37
164
 
38
165
  @s_stormtypes.stormfunc(readonly=True)
39
- async def list(self):
40
-
166
+ async def _methPoolList(self):
41
167
  self.runt.reqAdmin()
42
168
  proxy = await self.runt.snap.core.reqAhaProxy()
43
169
 
@@ -49,6 +175,36 @@ class AhaPool(s_stormtypes.StormType):
49
175
  '''
50
176
  Implements the Storm API for an AHA pool.
51
177
  '''
178
+ _storm_locals = (
179
+ {'name': 'add', 'desc': '''Add a service to the AHA pool
180
+
181
+ Examples:
182
+ Add a service to a pool with its relative name::
183
+
184
+ $pool = $lib.aha.pool.get(pool00.cortex...)
185
+ $pool.add(00.cortex...)
186
+ ''',
187
+ 'type': {'type': 'function', '_funcname': '_methPoolSvcAdd',
188
+ 'args': (
189
+ {'name': 'svcname', 'type': 'str',
190
+ 'desc': 'The name of the AHA service to add. It is easiest to use the relative name of a service, ending with "...".', },
191
+ ),
192
+ 'returns': {'type': 'null', }}},
193
+ {'name': 'add', 'desc': '''Remove a service from the AHA pool.
194
+
195
+ Examples:
196
+ Remove a service from a pool with its relative name::
197
+
198
+ $pool = $lib.aha.pool.get(pool00.cortex...)
199
+ $pool.del(00.cortex...)
200
+ ''',
201
+ 'type': {'type': 'function', '_funcname': '_methPoolSvcDel',
202
+ 'args': (
203
+ {'name': 'svcname', 'type': 'str',
204
+ 'desc': 'The name of the AHA service to remove. It is easiest to use the relative name of a service, ending with "...".', },
205
+ ),
206
+ 'returns': {'type': 'null', }}},
207
+ )
52
208
  _storm_typename = 'aha:pool'
53
209
 
54
210
  def __init__(self, runt, poolinfo):
@@ -57,8 +213,8 @@ class AhaPool(s_stormtypes.StormType):
57
213
  self.poolinfo = poolinfo
58
214
 
59
215
  self.locls.update({
60
- 'add': self.add,
61
- 'del': self._del,
216
+ 'add': self._methPoolSvcAdd,
217
+ 'del': self._methPoolSvcDel,
62
218
  })
63
219
 
64
220
  async def stormrepr(self):
@@ -67,7 +223,7 @@ class AhaPool(s_stormtypes.StormType):
67
223
  async def _derefGet(self, name):
68
224
  return self.poolinfo.get(name)
69
225
 
70
- async def add(self, svcname):
226
+ async def _methPoolSvcAdd(self, svcname):
71
227
  self.runt.reqAdmin()
72
228
  svcname = await s_stormtypes.tostr(svcname)
73
229
 
@@ -80,7 +236,7 @@ class AhaPool(s_stormtypes.StormType):
80
236
 
81
237
  self.poolinfo.update(poolinfo)
82
238
 
83
- async def _del(self, svcname):
239
+ async def _methPoolSvcDel(self, svcname):
84
240
  self.runt.reqAdmin()
85
241
  svcname = await s_stormtypes.tostr(svcname)
86
242
 
@@ -146,7 +302,7 @@ stormcmds = (
146
302
  ),
147
303
  'storm': '''
148
304
  $pool = $lib.aha.pool.get($cmdopts.poolname)
149
- if (not $pool) { $lib.exit(`No AHA serivce pool named: {$cmdopts.poolname}`) }
305
+ if (not $pool) { $lib.exit(`No AHA service pool named: {$cmdopts.poolname}`) }
150
306
 
151
307
  $pool.add($cmdopts.svcname)
152
308
  $lib.print(`AHA service ({$cmdopts.svcname}) added to service pool ({$pool.name})`)
@@ -161,10 +317,204 @@ stormcmds = (
161
317
  ),
162
318
  'storm': '''
163
319
  $pool = $lib.aha.pool.get($cmdopts.poolname)
164
- if (not $pool) { $lib.exit(`No AHA serivce pool named: {$cmdopts.poolname}`) }
320
+ if (not $pool) { $lib.exit(`No AHA service pool named: {$cmdopts.poolname}`) }
165
321
 
166
322
  $pool.del($cmdopts.svcname)
167
323
  $lib.print(`AHA service ({$cmdopts.svcname}) removed from service pool ({$pool.name})`)
168
324
  ''',
169
325
  },
326
+ {
327
+ 'name': 'aha.svc.stat',
328
+ 'descr': '''Show all information for a specific AHA service.
329
+
330
+ If the --nexus argument is given, the Cortex will attempt to connect the service and report the Nexus offset of the service.
331
+
332
+ The ready value indicates that a service has entered into the realtime change window for synchronizing changes from its leader.
333
+ ''',
334
+ 'cmdargs': (
335
+ ('svc', {'help': 'The service to inspect.'}),
336
+ ('--nexus', {'help': 'Try to connect to online services and report their nexus offset.',
337
+ 'default': False, 'action': 'store_true'}),
338
+ ),
339
+ 'storm': '''
340
+ function _getNexus(svcname) {
341
+ $_url = `aha://{$svcname}/`
342
+ try {
343
+ $_prox = $lib.telepath.open($_url)
344
+ $_info = $_prox.getCellInfo()
345
+ return ( $_info.cell.nexsindx )
346
+ } catch * as _err {
347
+ $_emsg = $_err.mesg
348
+ if ($_emsg = null ) {
349
+ $_emsg = `{$_err}`
350
+ }
351
+ return ( $_emsg )
352
+ }
353
+ }
354
+
355
+ $svc = $lib.aha.get($cmdopts.svc)
356
+ if ($svc = null) {
357
+ $lib.print(`No service found for: "{$cmdopts.svc}"`)
358
+ } else {
359
+ $services = $svc.services
360
+ if $services {
361
+ $lib.print(`Resolved {$cmdopts.svc} to an AHA Pool.\n`)
362
+ $lib.print(`The pool currently has {$lib.len($services)} members.`)
363
+
364
+ $lib.print(`AHA Pool: {$svc.name}`)
365
+ for ($_svcname, $_svcinfo) in $services {
366
+ $lib.print(`Member: {$_svcname}`)
367
+ }
368
+ } else {
369
+ $lib.print(`Resolved {$cmdopts.svc} to an AHA Service.\n`)
370
+ $svcinfo = $svc.svcinfo
371
+ $leader = $svcinfo.leader
372
+ if ($leader = null) {
373
+ $leader = 'Service did not register itself with a leader name.'
374
+ }
375
+ $online = false
376
+ if $svcinfo.online {
377
+ $online = true
378
+ }
379
+ $ready = 'null'
380
+ if $lib.dict.has($svcinfo, ready) {
381
+ $ready = `{$svcinfo.ready}`
382
+ }
383
+ $lib.print(`Name: {$svc.name}`)
384
+ $lib.print(`Online: {$online}`)
385
+ $lib.print(`Ready: {$ready}`)
386
+ $lib.print(`Run iden: {$svcinfo.run}`)
387
+ $lib.print(`Cell iden: {$svcinfo.iden}`)
388
+ $lib.print(`Leader: {$leader}`)
389
+
390
+ if $cmdopts.nexus {
391
+ if $svcinfo.online {
392
+ $nexusOffset = $_getNexus($svc.name)
393
+ } else {
394
+ $nexusOffset = 'Service is not online. Will not attempt to retrieve its nexus offset.'
395
+ }
396
+ $lib.print(`Nexus: {$nexusOffset}`)
397
+ }
398
+
399
+ $lib.print('Connection information:')
400
+ $urlinfo = $svcinfo.urlinfo
401
+ $keys = $lib.dict.keys($urlinfo)
402
+ $keys.sort()
403
+ for $k in $keys {
404
+ $dk = `{$k}:`
405
+ $dk = $dk.ljust(12)
406
+ $lib.print(` {$dk}{$urlinfo.$k}`)
407
+ }
408
+ }
409
+ }
410
+ '''
411
+ },
412
+ {
413
+ 'name': 'aha.svc.list',
414
+ 'descr': '''List AHA services.
415
+
416
+ If the --nexus argument is given, the Cortex will attempt to connect to each service and report the Nexus offset of the service.
417
+
418
+ The ready column indicates that a service has entered into the realtime change window for synchronizing changes from its leader.''',
419
+ 'cmdargs': (
420
+ ('--nexus', {'help': 'Try to connect to online services and report their nexus offset.',
421
+ 'default': False, 'action': 'store_true'}),
422
+ ),
423
+ 'storm': '''
424
+ function _getNexus(svcname) {
425
+ $_url = `aha://{$svcname}/`
426
+ try {
427
+ $_prox = $lib.telepath.open($_url)
428
+ $_info = $_prox.getCellInfo()
429
+ return ( $_info.cell.nexsindx )
430
+ } catch * as _err {
431
+ $_emsg = $_err.mesg
432
+ if ($_emsg = null ) {
433
+ $_emsg = `{$_err}`
434
+ }
435
+ return ( $_emsg )
436
+ }
437
+ }
438
+
439
+ $svcs = ()
440
+ for $svc in $lib.aha.list() {
441
+ $svcs.append($svc)
442
+ }
443
+
444
+ if ($lib.len($svcs) = 0) {
445
+ $lib.print('No AHA services registered.')
446
+ }
447
+ else {
448
+ $columns = 'Name Leader Online Ready Host Port '
449
+ if $cmdopts.nexus {
450
+ $columns = `{$columns} Nexus`
451
+ }
452
+
453
+ $leaders = $lib.set()
454
+ for $info in $svcs {
455
+ $svcinfo = $info.svcinfo
456
+ if $svcinfo {
457
+ if ($info.svcname = $svcinfo.leader) {
458
+ $leaders.add($svcinfo.run)
459
+ }
460
+ }
461
+ }
462
+
463
+ $lib.print($columns)
464
+
465
+ for $info in $svcs {
466
+ $name = $info.name
467
+ $nexusOffset = (null)
468
+ $svcinfo = $info.svcinfo
469
+
470
+ if $cmdopts.nexus {
471
+ if $svcinfo.online {
472
+ $nexusOffset = $_getNexus($name)
473
+ } else {
474
+ $nexusOffset = 'Service is not online. Will not attempt to retrieve its nexus offset.'
475
+ }
476
+ }
477
+ $name=$name.ljust(45)
478
+
479
+ $online = false
480
+ if $svcinfo.online {
481
+ $online = true
482
+ }
483
+ $online = $online.ljust(6)
484
+
485
+ $urlinfo = $svcinfo.urlinfo
486
+
487
+ $host = $urlinfo.host
488
+ $host = $host.ljust(15)
489
+
490
+ $port = $lib.cast(str, $urlinfo.port) // Cast to str
491
+ $port = $port.ljust(5)
492
+
493
+ $ready = 'null'
494
+ if $lib.dict.has($svcinfo, ready) {
495
+ $ready = `{$svcinfo.ready}`
496
+ }
497
+ $ready = $ready.ljust(5)
498
+
499
+ $leader = null
500
+ if ( $svcinfo.leader != null ) {
501
+ if $leaders.has($svcinfo.run) {
502
+ $leader = true
503
+ } else {
504
+ $leader = false
505
+ }
506
+ }
507
+ $leader = $leader.ljust(6)
508
+
509
+ if $info {
510
+ $s = `{$name} {$leader} {$online} {$ready} {$host} {$port}`
511
+ if ($nexusOffset != null) {
512
+ $s = `{$s} {$nexusOffset}`
513
+ }
514
+ $lib.print($s)
515
+ }
516
+ }
517
+ }
518
+ '''
519
+ }
170
520
  )
@@ -34,7 +34,7 @@ stormcmds = [
34
34
  'name': 'macro.del',
35
35
  'descr': macro_del_descr,
36
36
  'cmdargs': (
37
- ('name', {'help': 'The name of the macro to delete.'}),
37
+ ('name', {'type': 'str', 'help': 'The name of the macro to delete.'}),
38
38
  ),
39
39
  'storm': '''
40
40
  $lib.macro.del($cmdopts.name)
@@ -45,7 +45,7 @@ stormcmds = [
45
45
  'name': 'macro.set',
46
46
  'descr': macro_set_descr,
47
47
  'cmdargs': (
48
- ('name', {'help': 'The name of the macro to set.'}),
48
+ ('name', {'type': 'str', 'help': 'The name of the macro to set.'}),
49
49
  ('storm', {'help': 'The storm command string or embedded query to set.'}),
50
50
  ),
51
51
  'storm': '''
@@ -57,7 +57,7 @@ stormcmds = [
57
57
  'name': 'macro.get',
58
58
  'descr': macro_get_descr,
59
59
  'cmdargs': (
60
- ('name', {'help': 'The name of the macro to display.'}),
60
+ ('name', {'type': 'str', 'help': 'The name of the macro to display.'}),
61
61
  ),
62
62
  'storm': '''
63
63
  $mdef = $lib.macro.get($cmdopts.name)
@@ -74,8 +74,14 @@ stormcmds = [
74
74
  'storm': '''
75
75
  $count = $(0)
76
76
  for ($name, $mdef) in $lib.macro.list() {
77
- $user = $lib.auth.users.get($mdef.user)
78
- $lib.print('{name} (owner: {user})', name=$name.ljust(20), user=$user.name)
77
+ $user = $lib.auth.users.get($mdef.creator)
78
+ $username = $lib.null
79
+ if (not $user) {
80
+ $username = `User not found ({$mdef.creator})`
81
+ } else {
82
+ $username = $user.name
83
+ }
84
+ $lib.print('{name} (owner: {user})', name=$name.ljust(20), user=$username)
79
85
  $count = $($count + 1)
80
86
  }
81
87
  $lib.print('{count} macros found', count=$count)
@@ -185,27 +191,17 @@ class LibMacro(s_stormtypes.Lib):
185
191
  async def _funcMacroGet(self, name):
186
192
  name = await s_stormtypes.tostr(name)
187
193
 
188
- if len(name) > 491:
189
- raise s_exc.BadArg(mesg='Macro names may only be up to 491 chars.')
190
-
191
194
  return self.runt.snap.core.getStormMacro(name, user=self.runt.user)
192
195
 
193
196
  async def _funcMacroDel(self, name):
194
-
195
197
  name = await s_stormtypes.tostr(name)
196
198
 
197
- if len(name) > 491:
198
- raise s_exc.BadArg(mesg='Macro names may only be up to 491 chars.')
199
-
200
199
  return await self.runt.snap.core.delStormMacro(name, user=self.runt.user)
201
200
 
202
201
  async def _funcMacroSet(self, name, storm):
203
202
  name = await s_stormtypes.tostr(name)
204
203
  storm = await s_stormtypes.tostr(storm)
205
204
 
206
- if len(name) > 491:
207
- raise s_exc.BadArg(mesg='Macro names may only be up to 491 chars.')
208
-
209
205
  await self.runt.getStormQuery(storm)
210
206
 
211
207
  if self.runt.snap.core.getStormMacro(name) is None:
@@ -220,9 +216,6 @@ class LibMacro(s_stormtypes.Lib):
220
216
  name = await s_stormtypes.tostr(name)
221
217
  info = await s_stormtypes.toprim(info)
222
218
 
223
- if len(name) > 491:
224
- raise s_exc.BadArg(mesg='Macro names may only be up to 491 chars.')
225
-
226
219
  if not isinstance(info, dict):
227
220
  raise s_exc.BadArg(mesg='Macro info must be a dictionary object.')
228
221
 
@@ -585,7 +585,7 @@ def validateStix(bundle, version='2.1'):
585
585
  'result': {},
586
586
  }
587
587
  bundle = json.loads(json.dumps(bundle))
588
- opts = stix2validator.ValidationOptions(strict=True, version=version, no_cache=True)
588
+ opts = stix2validator.ValidationOptions(strict=True, version=version)
589
589
  try:
590
590
  results = stix2validator.validate_parsed_json(bundle, options=opts)
591
591
  except stix2validator.ValidationError as e:
synapse/lib/stormtypes.py CHANGED
@@ -3936,7 +3936,13 @@ class LibTelepath(Lib):
3936
3936
  scheme = url.split('://')[0]
3937
3937
  if not self.runt.allowed(('lib', 'telepath', 'open', scheme)):
3938
3938
  self.runt.confirm(('storm', 'lib', 'telepath', 'open', scheme))
3939
- return Proxy(self.runt, await self.runt.getTeleProxy(url))
3939
+ try:
3940
+ return Proxy(self.runt, await self.runt.getTeleProxy(url))
3941
+ except s_exc.SynErr:
3942
+ raise
3943
+ except Exception as e:
3944
+ mesg = f'Failed to connect to Telepath service: "{s_urlhelp.sanitizeUrl(url)}" error: {str(e)}'
3945
+ raise s_exc.StormRuntimeError(mesg=mesg) from e
3940
3946
 
3941
3947
  @registry.registerType
3942
3948
  class Proxy(StormType):
@@ -7382,7 +7388,11 @@ class View(Prim):
7382
7388
  The parent View iden.
7383
7389
 
7384
7390
  nomerge (bool)
7385
- Setting to $lib.true will prevent the layer from being merged.
7391
+ Deprecated - use protected. Updates to this option will be redirected to
7392
+ the protected option (below) until this option is removed.
7393
+
7394
+ protected (bool)
7395
+ Setting to $lib.true will prevent the layer from being merged or deleted.
7386
7396
 
7387
7397
  layers (list(str))
7388
7398
  Set the list of layer idens for a non-forked view. Layers are specified
@@ -7781,6 +7791,8 @@ class View(Prim):
7781
7791
 
7782
7792
  @stormfunc(readonly=True)
7783
7793
  async def _methViewGet(self, name, defv=None):
7794
+ if name == 'nomerge':
7795
+ name = 'protected'
7784
7796
  return self.valu.get(name, defv)
7785
7797
 
7786
7798
  def _reqView(self):
@@ -7807,6 +7819,10 @@ class View(Prim):
7807
7819
  valu = await toprim(valu)
7808
7820
 
7809
7821
  elif name == 'nomerge':
7822
+ name = 'protected'
7823
+ valu = await tobool(valu)
7824
+
7825
+ elif name == 'protected':
7810
7826
  valu = await tobool(valu)
7811
7827
 
7812
7828
  elif name == 'layers':
synapse/lib/types.py CHANGED
@@ -1447,6 +1447,8 @@ class Edge(Type):
1447
1447
 
1448
1448
  def postTypeInit(self):
1449
1449
 
1450
+ self.deprecated = True
1451
+
1450
1452
  self.fieldoffs = {'n1': 0, 'n2': 1}
1451
1453
 
1452
1454
  self.ndeftype = self.modl.types.get('ndef') # type: Ndef
synapse/lib/version.py CHANGED
@@ -223,6 +223,6 @@ def reqVersion(valu, reqver,
223
223
  ##############################################################################
224
224
  # The following are touched during the release process by bumpversion.
225
225
  # Do not modify these directly.
226
- version = (2, 166, 0)
226
+ version = (2, 167, 0)
227
227
  verstring = '.'.join([str(x) for x in version])
228
- commit = '09f8a7b3ad1f2ed5949e7d1a9dc7d17161fab932'
228
+ commit = '7b2983533ea27d69e547ac54d9aab953630137c2'
synapse/lib/view.py CHANGED
@@ -1098,7 +1098,8 @@ class View(s_nexus.Pusher): # type: ignore
1098
1098
  '''
1099
1099
  Set a mutable view property.
1100
1100
  '''
1101
- if name not in ('name', 'desc', 'parent', 'nomerge', 'quorum'):
1101
+ if name not in ('name', 'desc', 'parent', 'nomerge', 'protected', 'quorum'):
1102
+ # TODO: Remove nomerge after Synapse 3.x.x
1102
1103
  mesg = f'{name} is not a valid view info key'
1103
1104
  raise s_exc.BadOptValu(mesg=mesg)
1104
1105
 
@@ -1346,8 +1347,8 @@ class View(s_nexus.Pusher): # type: ignore
1346
1347
  if self.parent is None:
1347
1348
  raise s_exc.CantMergeView(mesg=f'Cannot merge view ({self.iden}) that has not been forked.')
1348
1349
 
1349
- if self.info.get('nomerge'):
1350
- raise s_exc.CantMergeView(mesg=f'Cannot merge view ({self.iden}) that has nomerge set.')
1350
+ if self.info.get('protected'):
1351
+ raise s_exc.CantMergeView(mesg=f'Cannot merge view ({self.iden}) that has protected set.')
1351
1352
 
1352
1353
  if self.parent.info.get('quorum') is not None:
1353
1354
  raise s_exc.CantMergeView(mesg=f'Cannot merge view({self.iden}). Parent view requires quorum voting.')
synapse/models/base.py CHANGED
@@ -63,28 +63,36 @@ class BaseModule(s_module.CoreModule):
63
63
  'doc': 'A generic rule linked to matches with -(matches)> edges.'}),
64
64
 
65
65
  ('graph:cluster', ('guid', {}), {
66
+ 'deprecated': True,
66
67
  'doc': 'A generic node, used in conjunction with Edge types, to cluster arbitrary nodes to a '
67
68
  'single node in the model.'}),
68
69
 
69
70
  ('graph:node', ('guid', {}), {
71
+ 'deprecated': True,
70
72
  'doc': 'A generic node used to represent objects outside the model.'}),
71
73
 
72
74
  ('graph:event', ('guid', {}), {
75
+ 'deprecated': True,
73
76
  'doc': 'A generic event node to represent events outside the model.'}),
74
77
 
75
78
  ('edge:refs', ('edge', {}), {
79
+ 'deprecated': True,
76
80
  'doc': 'A digraph edge which records that N1 refers to or contains N2.'}),
77
81
 
78
82
  ('edge:has', ('edge', {}), {
83
+ 'deprecated': True,
79
84
  'doc': 'A digraph edge which records that N1 has N2.'}),
80
85
 
81
86
  ('edge:wentto', ('timeedge', {}), {
87
+ 'deprecated': True,
82
88
  'doc': 'A digraph edge which records that N1 went to N2 at a specific time.'}),
83
89
 
84
90
  ('graph:edge', ('edge', {}), {
91
+ 'deprecated': True,
85
92
  'doc': 'A generic digraph edge to show relationships outside the model.'}),
86
93
 
87
94
  ('graph:timeedge', ('timeedge', {}), {
95
+ 'deprecated': True,
88
96
  'doc': 'A generic digraph time edge to show relationships outside the model.'}),
89
97
 
90
98
  ('meta:priority', ('int', {'enums': prioenums, 'enums:strict': False}), {