synapse 2.224.0__py311-none-any.whl → 2.225.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.
- synapse/axon.py +10 -5
- synapse/lib/cell.py +1 -1
- synapse/lib/const.py +4 -0
- synapse/lib/multislabseqn.py +36 -1
- synapse/lib/nexus.py +67 -8
- synapse/lib/queue.py +4 -1
- synapse/lib/rstorm.py +2 -2
- synapse/lib/schemas.py +11 -1
- synapse/lib/slabseqn.py +28 -0
- synapse/lib/storm.py +5 -1
- synapse/lib/stormhttp.py +7 -1
- synapse/lib/version.py +2 -2
- synapse/models/inet.py +4 -0
- synapse/models/media.py +4 -0
- synapse/models/risk.py +3 -0
- synapse/tests/test_cortex.py +2 -2
- synapse/tests/test_lib_agenda.py +1 -1
- synapse/tests/test_lib_cell.py +1 -1
- synapse/tests/test_lib_certdir.py +1 -1
- synapse/tests/test_lib_httpapi.py +1 -1
- synapse/tests/test_lib_layer.py +1 -1
- synapse/tests/test_lib_multislabseqn.py +22 -0
- synapse/tests/test_lib_nexus.py +42 -1
- synapse/tests/test_lib_slabseqn.py +30 -1
- synapse/tests/test_lib_storm.py +59 -1
- synapse/tests/test_lib_stormhttp.py +16 -0
- synapse/tests/test_lib_stormlib_oauth.py +1 -1
- synapse/tests/test_lib_stormsvc.py +1 -1
- synapse/tests/test_lib_trigger.py +1 -1
- synapse/tests/test_model_inet.py +6 -0
- synapse/tests/test_model_media.py +4 -1
- synapse/tests/test_model_risk.py +2 -0
- synapse/tests/{test_tools_axon2axon.py → test_tools_axon_copy.py} +4 -4
- synapse/tests/{test_tools_pullfile.py → test_tools_axon_get.py} +4 -4
- synapse/tests/{test_tools_pushfile.py → test_tools_axon_put.py} +7 -7
- synapse/tests/{test_tools_csvtool.py → test_tools_cortex_csv.py} +12 -3
- synapse/tests/{test_tools_feed.py → test_tools_cortex_feed.py} +2 -2
- synapse/tests/{test_tools_apikey.py → test_tools_service_apikey.py} +1 -4
- synapse/tests/{test_tools_backup.py → test_tools_service_backup.py} +5 -5
- synapse/tests/{test_tools_demote.py → test_tools_service_demote.py} +1 -1
- synapse/tests/{test_tools_healthcheck.py → test_tools_service_healthcheck.py} +1 -1
- synapse/tests/{test_tools_livebackup.py → test_tools_service_livebackup.py} +1 -1
- synapse/tests/{test_tools_modrole.py → test_tools_service_modrole.py} +1 -1
- synapse/tests/{test_tools_moduser.py → test_tools_service_moduser.py} +1 -1
- synapse/tests/{test_tools_promote.py → test_tools_service_promote.py} +1 -1
- synapse/tests/{test_tools_reload.py → test_tools_service_reload.py} +1 -1
- synapse/tests/{test_tools_shutdown.py → test_tools_service_shutdown.py} +1 -1
- synapse/tests/{test_tools_snapshot.py → test_tools_service_snapshot.py} +1 -1
- synapse/tests/{test_tools_storm.py → test_tools_storm_cli.py} +1 -1
- synapse/tests/{test_tools_pkgs_gendocs.py → test_tools_storm_pkg_doc.py} +12 -3
- synapse/tests/{test_tools_genpkg.py → test_tools_storm_pkg_gen.py} +1 -1
- synapse/tests/{test_tools_autodoc.py → test_tools_utils_autodoc.py} +1 -1
- synapse/tests/test_tools_utils_changelog.py +454 -0
- synapse/tests/{test_tools_easycert.py → test_tools_utils_easycert.py} +48 -46
- synapse/tests/{test_tools_guid.py → test_tools_utils_guid.py} +3 -3
- synapse/tests/{test_tools_json2mpk.py → test_tools_utils_json2mpk.py} +3 -3
- synapse/tests/{test_tools_rstorm.py → test_tools_utils_rstorm.py} +6 -1
- synapse/tests/utils.py +3 -1
- synapse/tools/apikey.py +4 -83
- synapse/tools/autodoc.py +3 -1031
- synapse/tools/axon/copy.py +44 -0
- synapse/tools/axon/get.py +64 -0
- synapse/tools/axon/put.py +122 -0
- synapse/tools/axon2axon.py +3 -36
- synapse/tools/backup.py +6 -176
- synapse/tools/changelog.py +3 -1098
- synapse/tools/cortex/csv.py +236 -0
- synapse/tools/cortex/feed.py +151 -0
- synapse/tools/csvtool.py +3 -227
- synapse/tools/demote.py +4 -40
- synapse/tools/docker/validate.py +3 -3
- synapse/tools/easycert.py +4 -129
- synapse/tools/feed.py +3 -140
- synapse/tools/genpkg.py +3 -307
- synapse/tools/guid.py +7 -6
- synapse/tools/healthcheck.py +3 -101
- synapse/tools/json2mpk.py +6 -38
- synapse/tools/livebackup.py +4 -27
- synapse/tools/modrole.py +3 -108
- synapse/tools/moduser.py +3 -179
- synapse/tools/pkgs/gendocs.py +3 -164
- synapse/tools/promote.py +4 -41
- synapse/tools/pullfile.py +3 -56
- synapse/tools/pushfile.py +3 -114
- synapse/tools/reload.py +4 -61
- synapse/tools/rstorm.py +3 -26
- synapse/tools/service/__init__.py +0 -0
- synapse/tools/service/apikey.py +90 -0
- synapse/tools/service/backup.py +181 -0
- synapse/tools/service/demote.py +47 -0
- synapse/tools/service/healthcheck.py +109 -0
- synapse/tools/service/livebackup.py +34 -0
- synapse/tools/service/modrole.py +116 -0
- synapse/tools/service/moduser.py +184 -0
- synapse/tools/service/promote.py +48 -0
- synapse/tools/service/reload.py +68 -0
- synapse/tools/service/shutdown.py +51 -0
- synapse/tools/service/snapshot.py +64 -0
- synapse/tools/shutdown.py +5 -45
- synapse/tools/snapshot.py +4 -57
- synapse/tools/storm/__init__.py +0 -0
- synapse/tools/storm/__main__.py +5 -0
- synapse/tools/{storm.py → storm/_cli.py} +0 -3
- synapse/tools/storm/pkg/__init__.py +0 -0
- synapse/tools/{pkgs/pandoc_filter.py → storm/pkg/_pandoc_filter.py} +1 -1
- synapse/tools/storm/pkg/doc.py +176 -0
- synapse/tools/storm/pkg/gen.py +315 -0
- synapse/tools/utils/__init__.py +0 -0
- synapse/tools/utils/autodoc.py +1040 -0
- synapse/tools/utils/changelog.py +1124 -0
- synapse/tools/utils/easycert.py +136 -0
- synapse/tools/utils/guid.py +11 -0
- synapse/tools/utils/json2mpk.py +46 -0
- synapse/tools/utils/rstorm.py +35 -0
- {synapse-2.224.0.dist-info → synapse-2.225.0.dist-info}/METADATA +1 -1
- {synapse-2.224.0.dist-info → synapse-2.225.0.dist-info}/RECORD +120 -91
- synapse/tests/test_tools_changelog.py +0 -196
- /synapse/tests/{test_tools_axon.py → test_tools_axon_dump_load.py} +0 -0
- {synapse-2.224.0.dist-info → synapse-2.225.0.dist-info}/WHEEL +0 -0
- {synapse-2.224.0.dist-info → synapse-2.225.0.dist-info}/licenses/LICENSE +0 -0
- {synapse-2.224.0.dist-info → synapse-2.225.0.dist-info}/top_level.txt +0 -0
synapse/axon.py
CHANGED
|
@@ -1651,8 +1651,9 @@ class Axon(s_cell.Cell):
|
|
|
1651
1651
|
filename=field.get('filename'),
|
|
1652
1652
|
content_transfer_encoding=field.get('content_transfer_encoding'))
|
|
1653
1653
|
|
|
1654
|
-
async with sess.request(method, url, headers=headers, params=params,
|
|
1655
|
-
|
|
1654
|
+
async with sess.request(method, url, headers=headers, params=params, data=data, ssl=ssl,
|
|
1655
|
+
max_line_size=s_const.MAX_LINE_SIZE,
|
|
1656
|
+
max_field_size=s_const.MAX_FIELD_SIZE) as resp:
|
|
1656
1657
|
info = {
|
|
1657
1658
|
'ok': True,
|
|
1658
1659
|
'url': str(resp.url),
|
|
@@ -1698,8 +1699,10 @@ class Axon(s_cell.Cell):
|
|
|
1698
1699
|
async with aiohttp.ClientSession(connector=connector, timeout=atimeout) as sess:
|
|
1699
1700
|
try:
|
|
1700
1701
|
await self._reqHas(sha256)
|
|
1701
|
-
async with sess.request(method, url, headers=headers, params=params,
|
|
1702
|
-
data=self.get(sha256),
|
|
1702
|
+
async with sess.request(method, url, headers=headers, params=params, ssl=ssl,
|
|
1703
|
+
data=self.get(sha256),
|
|
1704
|
+
max_line_size=s_const.MAX_LINE_SIZE,
|
|
1705
|
+
max_field_size=s_const.MAX_FIELD_SIZE) as resp:
|
|
1703
1706
|
|
|
1704
1707
|
info = {
|
|
1705
1708
|
'ok': True,
|
|
@@ -1827,7 +1830,9 @@ class Axon(s_cell.Cell):
|
|
|
1827
1830
|
async with aiohttp.ClientSession(connector=connector, timeout=atimeout) as sess:
|
|
1828
1831
|
|
|
1829
1832
|
try:
|
|
1830
|
-
async with sess.request(method, url, headers=headers, params=params, json=json, data=body, ssl=ssl
|
|
1833
|
+
async with sess.request(method, url, headers=headers, params=params, json=json, data=body, ssl=ssl,
|
|
1834
|
+
max_line_size=s_const.MAX_LINE_SIZE,
|
|
1835
|
+
max_field_size=s_const.MAX_FIELD_SIZE) as resp:
|
|
1831
1836
|
|
|
1832
1837
|
info = self._flatten_clientresponse(resp)
|
|
1833
1838
|
|
synapse/lib/cell.py
CHANGED
synapse/lib/const.py
CHANGED
synapse/lib/multislabseqn.py
CHANGED
|
@@ -353,7 +353,6 @@ class MultiSlabSeqn(s_base.Base):
|
|
|
353
353
|
else:
|
|
354
354
|
indx = self.indx
|
|
355
355
|
|
|
356
|
-
assert self.tailseqn
|
|
357
356
|
retn = self.tailseqn.add(item, indx=indx)
|
|
358
357
|
|
|
359
358
|
if advances:
|
|
@@ -363,6 +362,42 @@ class MultiSlabSeqn(s_base.Base):
|
|
|
363
362
|
|
|
364
363
|
return retn
|
|
365
364
|
|
|
365
|
+
async def addWithPackRetn(self, item, indx=None):
|
|
366
|
+
'''
|
|
367
|
+
Add a single item to the sequence, returning the offset and packed item.
|
|
368
|
+
'''
|
|
369
|
+
advances = True
|
|
370
|
+
|
|
371
|
+
if indx is not None:
|
|
372
|
+
if indx < self.firstindx:
|
|
373
|
+
raise s_exc.BadIndxValu(mesg=f'indx lower than first index in sequence {self.firstindx}')
|
|
374
|
+
|
|
375
|
+
if indx < self._ranges[-1]:
|
|
376
|
+
ridx = self._getRangeIndx(indx)
|
|
377
|
+
assert ridx is not None
|
|
378
|
+
|
|
379
|
+
async with self._getSeqn(ridx) as seqn:
|
|
380
|
+
retn = seqn.addWithPackRetn(item, indx=indx)
|
|
381
|
+
|
|
382
|
+
return retn
|
|
383
|
+
|
|
384
|
+
if indx >= self.indx:
|
|
385
|
+
self.indx = indx
|
|
386
|
+
else:
|
|
387
|
+
advances = False
|
|
388
|
+
else:
|
|
389
|
+
indx = self.indx
|
|
390
|
+
|
|
391
|
+
assert self.tailseqn
|
|
392
|
+
retn = self.tailseqn.addWithPackRetn(item, indx=indx)
|
|
393
|
+
|
|
394
|
+
if advances:
|
|
395
|
+
self.indx += 1
|
|
396
|
+
|
|
397
|
+
self._wake_waiters()
|
|
398
|
+
|
|
399
|
+
return retn
|
|
400
|
+
|
|
366
401
|
async def last(self) -> Optional[Tuple[int, Any]]:
|
|
367
402
|
ridx = self._getRangeIndx(self.indx - 1)
|
|
368
403
|
if ridx is None:
|
synapse/lib/nexus.py
CHANGED
|
@@ -12,6 +12,9 @@ import synapse.common as s_common
|
|
|
12
12
|
import synapse.telepath as s_telepath
|
|
13
13
|
|
|
14
14
|
import synapse.lib.base as s_base
|
|
15
|
+
import synapse.lib.scope as s_scope
|
|
16
|
+
import synapse.lib.queue as s_queue
|
|
17
|
+
import synapse.lib.msgpack as s_msgpack
|
|
15
18
|
|
|
16
19
|
logger = logging.getLogger(__name__)
|
|
17
20
|
|
|
@@ -20,6 +23,9 @@ leaderversion = 'Leader is a higher version than we are.'
|
|
|
20
23
|
# As a mirror follower, amount of time before giving up on a write request
|
|
21
24
|
FOLLOWER_WRITE_WAIT_S = 30.0
|
|
22
25
|
|
|
26
|
+
WINDOW_MAXSIZE = 10_000
|
|
27
|
+
YIELD_PREFIX = b'\x92\xa8t2:yield\x81\xa4retn\x92\xc3\x92'
|
|
28
|
+
|
|
23
29
|
class RegMethType(type):
|
|
24
30
|
'''
|
|
25
31
|
Metaclass that collects all methods in class with _regme prop into a class member called _regclstupls
|
|
@@ -99,6 +105,8 @@ class NexsRoot(s_base.Base):
|
|
|
99
105
|
self._mirready = asyncio.Event() # for testing
|
|
100
106
|
|
|
101
107
|
self._mirrors: List[ChangeDist] = []
|
|
108
|
+
self._linkmirrors: List[s_queue.Window] = []
|
|
109
|
+
|
|
102
110
|
self._nexskids: Dict[str, 'Pusher'] = {}
|
|
103
111
|
|
|
104
112
|
# Used to match pending follower write requests with the responses arriving on the log
|
|
@@ -134,6 +142,11 @@ class NexsRoot(s_base.Base):
|
|
|
134
142
|
self.nexslog.setIndex(maxindx)
|
|
135
143
|
|
|
136
144
|
async def fini():
|
|
145
|
+
for wind in self._linkmirrors:
|
|
146
|
+
await wind.fini()
|
|
147
|
+
|
|
148
|
+
for dist in self._mirrors:
|
|
149
|
+
await dist.fini()
|
|
137
150
|
|
|
138
151
|
for futu in self._futures.values(): # pragma: no cover
|
|
139
152
|
futu.cancel()
|
|
@@ -389,8 +402,16 @@ class NexsRoot(s_base.Base):
|
|
|
389
402
|
async def _eat(self, item, indx=None):
|
|
390
403
|
|
|
391
404
|
if self.donexslog:
|
|
392
|
-
saveindx = await self.nexslog.
|
|
393
|
-
|
|
405
|
+
saveindx, packitem = await self.nexslog.addWithPackRetn(item, indx=indx)
|
|
406
|
+
|
|
407
|
+
if self._linkmirrors:
|
|
408
|
+
tupl = (saveindx, YIELD_PREFIX + s_msgpack.en(saveindx) + packitem)
|
|
409
|
+
for wind in tuple(self._linkmirrors):
|
|
410
|
+
await wind.put(tupl)
|
|
411
|
+
|
|
412
|
+
if self._mirrors:
|
|
413
|
+
for dist in tuple(self._mirrors):
|
|
414
|
+
dist.update()
|
|
394
415
|
|
|
395
416
|
else:
|
|
396
417
|
saveindx = self.nexshot.get('nexs:indx')
|
|
@@ -415,7 +436,15 @@ class NexsRoot(s_base.Base):
|
|
|
415
436
|
|
|
416
437
|
async def iter(self, offs: int, tellready=False, wait=True) -> AsyncIterator[Any]:
|
|
417
438
|
'''
|
|
418
|
-
Returns an iterator of change entries in the log
|
|
439
|
+
Returns an iterator of change entries in the log.
|
|
440
|
+
|
|
441
|
+
Notes:
|
|
442
|
+
If this method is being called in the context of a Telepath call,
|
|
443
|
+
it will directly send messages to the scope "link" object when it
|
|
444
|
+
has caught up to the realtime change window; instead of yielding
|
|
445
|
+
them as a generator. This is an optimization to avoid duplication
|
|
446
|
+
of msgpack'ing the same object over and over again as the number
|
|
447
|
+
of mirrors increases.
|
|
419
448
|
'''
|
|
420
449
|
if not self.donexslog:
|
|
421
450
|
return
|
|
@@ -437,11 +466,41 @@ class NexsRoot(s_base.Base):
|
|
|
437
466
|
if not wait:
|
|
438
467
|
return
|
|
439
468
|
|
|
440
|
-
|
|
441
|
-
async
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
469
|
+
if (link := s_scope.get('link')) is None:
|
|
470
|
+
async with self.getChangeDist(maxoffs) as dist:
|
|
471
|
+
async for item in dist:
|
|
472
|
+
yield item
|
|
473
|
+
|
|
474
|
+
else:
|
|
475
|
+
async with self.getMirrorWindow() as wind:
|
|
476
|
+
|
|
477
|
+
# Ensure we are caught up after grabbing a window
|
|
478
|
+
sync = True
|
|
479
|
+
|
|
480
|
+
async for item in self.nexslog.iter(maxoffs):
|
|
481
|
+
maxoffs = item[0] + 1
|
|
482
|
+
yield item
|
|
483
|
+
|
|
484
|
+
async for offs, item in wind:
|
|
485
|
+
if sync:
|
|
486
|
+
if offs < maxoffs:
|
|
487
|
+
continue
|
|
488
|
+
sync = False
|
|
489
|
+
|
|
490
|
+
await link.send(item)
|
|
491
|
+
|
|
492
|
+
@contextlib.asynccontextmanager
|
|
493
|
+
async def getMirrorWindow(self):
|
|
494
|
+
async with await s_queue.Window.anit(maxsize=WINDOW_MAXSIZE, clearonfini=True) as wind:
|
|
495
|
+
|
|
496
|
+
async def fini():
|
|
497
|
+
self._linkmirrors.remove(wind)
|
|
498
|
+
|
|
499
|
+
wind.onfini(fini)
|
|
500
|
+
|
|
501
|
+
self._linkmirrors.append(wind)
|
|
502
|
+
|
|
503
|
+
yield wind
|
|
445
504
|
|
|
446
505
|
@contextlib.asynccontextmanager
|
|
447
506
|
async def getChangeDist(self, offs: int) -> AsyncIterator[ChangeDist]:
|
synapse/lib/queue.py
CHANGED
|
@@ -118,14 +118,17 @@ class Window(s_base.Base):
|
|
|
118
118
|
its maxsize, it will be fini()d. On fini(), the Window will continue to
|
|
119
119
|
yield results until empty and then return.
|
|
120
120
|
'''
|
|
121
|
-
async def __anit__(self, maxsize=None):
|
|
121
|
+
async def __anit__(self, maxsize=None, clearonfini=False):
|
|
122
122
|
await s_base.Base.__anit__(self)
|
|
123
123
|
self.maxsize = maxsize
|
|
124
124
|
self.event = asyncio.Event()
|
|
125
125
|
|
|
126
126
|
self.linklist = collections.deque()
|
|
127
|
+
self.clearonfini = clearonfini
|
|
127
128
|
|
|
128
129
|
async def fini():
|
|
130
|
+
if self.clearonfini:
|
|
131
|
+
self.linklist.clear()
|
|
129
132
|
self.event.set()
|
|
130
133
|
|
|
131
134
|
self.onfini(fini)
|
synapse/lib/rstorm.py
CHANGED
|
@@ -25,8 +25,8 @@ import synapse.lib.stormhttp as s_stormhttp
|
|
|
25
25
|
|
|
26
26
|
import synapse.cmds.cortex as s_cmds_cortex
|
|
27
27
|
|
|
28
|
-
import synapse.tools.storm as s_storm
|
|
29
|
-
import synapse.tools.
|
|
28
|
+
import synapse.tools.storm._cli as s_storm
|
|
29
|
+
import synapse.tools.storm.pkg.gen as s_genpkg
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
re_directive = regex.compile(r'^\.\.\s(shell.*|storm.*|[^:])::(?:\s(.*)$|$)')
|
synapse/lib/schemas.py
CHANGED
|
@@ -393,7 +393,6 @@ _changelogTypes = {'migration': 'Automatic Migrations',
|
|
|
393
393
|
'note': 'Notes',
|
|
394
394
|
'doc': 'Improved documentation',
|
|
395
395
|
'deprecation': 'Deprecations'}
|
|
396
|
-
|
|
397
396
|
_changelogSchema = {
|
|
398
397
|
'type': 'object',
|
|
399
398
|
'properties': {
|
|
@@ -405,6 +404,10 @@ _changelogSchema = {
|
|
|
405
404
|
'type': 'string',
|
|
406
405
|
'minLength': 1,
|
|
407
406
|
},
|
|
407
|
+
'desc:literal': {
|
|
408
|
+
'type': 'boolean',
|
|
409
|
+
'default': False,
|
|
410
|
+
},
|
|
408
411
|
'prs': {
|
|
409
412
|
'type': 'array',
|
|
410
413
|
'items': {
|
|
@@ -948,6 +951,13 @@ _reqValidPkgdefSchema = {
|
|
|
948
951
|
'type': ['array', 'null'],
|
|
949
952
|
'items': {'$ref': '#/definitions/cmdinput'},
|
|
950
953
|
},
|
|
954
|
+
'cmdconf': {
|
|
955
|
+
'type': 'object',
|
|
956
|
+
'properties': {
|
|
957
|
+
'svciden': {'type': 'string', 'pattern': s_config.re_iden},
|
|
958
|
+
},
|
|
959
|
+
'additionalProperties': True,
|
|
960
|
+
},
|
|
951
961
|
'storm': {'type': 'string'},
|
|
952
962
|
'forms': {'$ref': '#/definitions/cmdformhints'},
|
|
953
963
|
'perms': {'type': 'array',
|
synapse/lib/slabseqn.py
CHANGED
|
@@ -87,6 +87,34 @@ class SlabSeqn:
|
|
|
87
87
|
|
|
88
88
|
return indx
|
|
89
89
|
|
|
90
|
+
def addWithPackRetn(self, item, indx=None):
|
|
91
|
+
'''
|
|
92
|
+
Add a single item to the sequence, returning the offset and packed item.
|
|
93
|
+
'''
|
|
94
|
+
packitem = s_msgpack.en(item)
|
|
95
|
+
if indx is not None:
|
|
96
|
+
if indx >= self.indx:
|
|
97
|
+
self.slab.put(s_common.int64en(indx), packitem, append=True, db=self.db)
|
|
98
|
+
self.indx = indx + 1
|
|
99
|
+
self.size += 1
|
|
100
|
+
self._wake_waiters()
|
|
101
|
+
return indx, packitem
|
|
102
|
+
|
|
103
|
+
oldv = self.slab.replace(s_common.int64en(indx), packitem, db=self.db)
|
|
104
|
+
if oldv is None:
|
|
105
|
+
self.size += 1
|
|
106
|
+
return indx, packitem
|
|
107
|
+
|
|
108
|
+
indx = self.indx
|
|
109
|
+
self.slab.put(s_common.int64en(indx), packitem, append=True, db=self.db)
|
|
110
|
+
|
|
111
|
+
self.indx += 1
|
|
112
|
+
self.size += 1
|
|
113
|
+
|
|
114
|
+
self._wake_waiters()
|
|
115
|
+
|
|
116
|
+
return indx, packitem
|
|
117
|
+
|
|
90
118
|
def first(self):
|
|
91
119
|
|
|
92
120
|
for lkey, lval in self.slab.scanByFull(db=self.db):
|
synapse/lib/storm.py
CHANGED
|
@@ -2545,10 +2545,14 @@ class PureCmd(Cmd):
|
|
|
2545
2545
|
|
|
2546
2546
|
cmdopts = s_stormtypes.CmdOpts(self)
|
|
2547
2547
|
|
|
2548
|
+
cmdconf = self.cdef.get('cmdconf', {})
|
|
2549
|
+
if cmdconf:
|
|
2550
|
+
cmdconf = s_msgpack.deepcopy(cmdconf, use_list=True)
|
|
2551
|
+
|
|
2548
2552
|
opts = {
|
|
2549
2553
|
'vars': {
|
|
2550
2554
|
'cmdopts': cmdopts,
|
|
2551
|
-
'cmdconf':
|
|
2555
|
+
'cmdconf': cmdconf,
|
|
2552
2556
|
}
|
|
2553
2557
|
}
|
|
2554
2558
|
|
synapse/lib/stormhttp.py
CHANGED
|
@@ -12,6 +12,7 @@ import synapse.common as s_common
|
|
|
12
12
|
|
|
13
13
|
import synapse.lib.base as s_base
|
|
14
14
|
import synapse.lib.json as s_json
|
|
15
|
+
import synapse.lib.const as s_const
|
|
15
16
|
import synapse.lib.msgpack as s_msgpack
|
|
16
17
|
import synapse.lib.version as s_version
|
|
17
18
|
import synapse.lib.stormtypes as s_stormtypes
|
|
@@ -400,7 +401,12 @@ class LibHttp(s_stormtypes.Lib):
|
|
|
400
401
|
proxy = await s_stormtypes.toprim(proxy)
|
|
401
402
|
ssl_opts = await s_stormtypes.toprim(ssl_opts)
|
|
402
403
|
|
|
403
|
-
kwargs = {
|
|
404
|
+
kwargs = {
|
|
405
|
+
'max_line_size': s_const.MAX_LINE_SIZE,
|
|
406
|
+
'max_field_size': s_const.MAX_FIELD_SIZE,
|
|
407
|
+
'allow_redirects': allow_redirects,
|
|
408
|
+
}
|
|
409
|
+
|
|
404
410
|
if params:
|
|
405
411
|
kwargs['params'] = s_stormtypes.strifyHttpArg(params, multi=True)
|
|
406
412
|
|
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,
|
|
226
|
+
version = (2, 225, 0)
|
|
227
227
|
verstring = '.'.join([str(x) for x in version])
|
|
228
|
-
commit = '
|
|
228
|
+
commit = 'd2ab923e3df9fe64611ac05b6ffdd7e8c2dc1b22'
|
synapse/models/inet.py
CHANGED
|
@@ -3819,8 +3819,12 @@ class InetModule(s_module.CoreModule):
|
|
|
3819
3819
|
('inet:service:account', {}, (
|
|
3820
3820
|
|
|
3821
3821
|
('user', ('inet:user', {}), {
|
|
3822
|
+
'alts': ('users',),
|
|
3822
3823
|
'doc': 'The current user name of the account.'}),
|
|
3823
3824
|
|
|
3825
|
+
('users', ('array', {'type': 'inet:user', 'sorted': True, 'uniq': True}), {
|
|
3826
|
+
'doc': 'An array of alternate user names for this account.'}),
|
|
3827
|
+
|
|
3824
3828
|
('parent', ('inet:service:account', {}), {
|
|
3825
3829
|
'doc': 'A parent account which owns this account.'}),
|
|
3826
3830
|
|
synapse/models/media.py
CHANGED
|
@@ -35,6 +35,10 @@ class MediaModule(s_module.CoreModule):
|
|
|
35
35
|
'disp': {'hint': 'text'},
|
|
36
36
|
'doc': 'A brief summary of the news item.'}),
|
|
37
37
|
|
|
38
|
+
('body', ('str', {}), {
|
|
39
|
+
'disp': {'hint': 'text', 'syntax': 'markdown'},
|
|
40
|
+
'doc': 'The body of the news item.'}),
|
|
41
|
+
|
|
38
42
|
('publisher', ('ou:org', {}), {
|
|
39
43
|
'doc': 'The organization which published the news.'}),
|
|
40
44
|
|
synapse/models/risk.py
CHANGED
|
@@ -420,6 +420,9 @@ class RiskModule(s_module.CoreModule):
|
|
|
420
420
|
('type', ('risk:mitigation:type:taxonomy', {}), {
|
|
421
421
|
'doc': 'A taxonomy type entry for the mitigation.'}),
|
|
422
422
|
|
|
423
|
+
('id', ('str', {'strip': True}), {
|
|
424
|
+
'doc': 'An identifier for the mitigation.'}),
|
|
425
|
+
|
|
423
426
|
('desc', ('str', {}), {
|
|
424
427
|
'disp': {'hint': 'text'},
|
|
425
428
|
'doc': 'A description of the mitigation approach for the vulnerability.'}),
|
synapse/tests/test_cortex.py
CHANGED
|
@@ -28,8 +28,8 @@ import synapse.lib.version as s_version
|
|
|
28
28
|
import synapse.lib.modelrev as s_modelrev
|
|
29
29
|
import synapse.lib.stormsvc as s_stormsvc
|
|
30
30
|
|
|
31
|
-
import synapse.tools.backup as s_tools_backup
|
|
32
|
-
import synapse.tools.promote as s_tools_promote
|
|
31
|
+
import synapse.tools.service.backup as s_tools_backup
|
|
32
|
+
import synapse.tools.service.promote as s_tools_promote
|
|
33
33
|
|
|
34
34
|
import synapse.tests.utils as s_t_utils
|
|
35
35
|
from synapse.tests.utils import alist
|
synapse/tests/test_lib_agenda.py
CHANGED
|
@@ -9,7 +9,7 @@ import synapse.exc as s_exc
|
|
|
9
9
|
import synapse.common as s_common
|
|
10
10
|
import synapse.tests.utils as s_t_utils
|
|
11
11
|
|
|
12
|
-
import synapse.tools.backup as s_tools_backup
|
|
12
|
+
import synapse.tools.service.backup as s_tools_backup
|
|
13
13
|
|
|
14
14
|
import synapse.lib.agenda as s_agenda
|
|
15
15
|
from synapse.lib.agenda import TimeUnit as s_tu
|
synapse/tests/test_lib_cell.py
CHANGED
|
@@ -38,7 +38,7 @@ import synapse.lib.lmdbslab as s_lmdbslab
|
|
|
38
38
|
import synapse.lib.crypto.passwd as s_passwd
|
|
39
39
|
import synapse.lib.platforms.linux as s_linux
|
|
40
40
|
|
|
41
|
-
import synapse.tools.backup as s_tools_backup
|
|
41
|
+
import synapse.tools.service.backup as s_tools_backup
|
|
42
42
|
|
|
43
43
|
import synapse.tests.utils as s_t_utils
|
|
44
44
|
|
|
@@ -9,7 +9,7 @@ import synapse.common as s_common
|
|
|
9
9
|
import synapse.lib.certdir as s_certdir
|
|
10
10
|
import synapse.lib.msgpack as s_msgpack
|
|
11
11
|
import synapse.tests.utils as s_t_utils
|
|
12
|
-
import synapse.tools.
|
|
12
|
+
import synapse.tools.storm.pkg.gen as s_genpkg
|
|
13
13
|
|
|
14
14
|
import cryptography.x509 as c_x509
|
|
15
15
|
import cryptography.exceptions as c_exc
|
synapse/tests/test_lib_layer.py
CHANGED
|
@@ -13,7 +13,7 @@ import synapse.lib.layer as s_layer
|
|
|
13
13
|
import synapse.lib.msgpack as s_msgpack
|
|
14
14
|
import synapse.lib.spooled as s_spooled
|
|
15
15
|
|
|
16
|
-
import synapse.tools.backup as s_tools_backup
|
|
16
|
+
import synapse.tools.service.backup as s_tools_backup
|
|
17
17
|
|
|
18
18
|
import synapse.tests.utils as s_t_utils
|
|
19
19
|
|
|
@@ -226,6 +226,28 @@ class MultiSlabSeqn(s_t_utils.SynTest):
|
|
|
226
226
|
# Iterator exhausted: should have just the cache slab (10) and the tail slab (20)
|
|
227
227
|
self.len(2, msqn._openslabs)
|
|
228
228
|
|
|
229
|
+
async def test_multislabseqn_retnpack(self):
|
|
230
|
+
|
|
231
|
+
with self.getTestDir() as dirn:
|
|
232
|
+
|
|
233
|
+
async with await s_multislabseqn.MultiSlabSeqn.anit(dirn) as msqn:
|
|
234
|
+
|
|
235
|
+
self.eq((0, b'\xa4foo1'), await msqn.addWithPackRetn('foo1'))
|
|
236
|
+
self.eq((1, b'\xa4foo2'), await msqn.addWithPackRetn('foo2'))
|
|
237
|
+
self.eq((0, b'\xa4foo3'), await msqn.addWithPackRetn('foo3', indx=0))
|
|
238
|
+
|
|
239
|
+
await msqn.addWithPackRetn('foo4', indx=10)
|
|
240
|
+
await msqn.rotate()
|
|
241
|
+
await msqn.addWithPackRetn('foo5')
|
|
242
|
+
await msqn.addWithPackRetn('foo6', indx=7)
|
|
243
|
+
|
|
244
|
+
self.true(await msqn.cull(10))
|
|
245
|
+
|
|
246
|
+
with self.raises(s_exc.BadIndxValu):
|
|
247
|
+
await msqn.addWithPackRetn('foo7', indx=7)
|
|
248
|
+
|
|
249
|
+
self.eq((12, b'\xa4foo8'), msqn.tailseqn.addWithPackRetn('foo8'))
|
|
250
|
+
|
|
229
251
|
async def test_multislabseqn_cull(self):
|
|
230
252
|
|
|
231
253
|
with self.getTestDir() as dirn:
|
synapse/tests/test_lib_nexus.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
+
import contextlib
|
|
2
3
|
from unittest import mock
|
|
3
4
|
|
|
4
5
|
import synapse.exc as s_exc
|
|
@@ -61,7 +62,7 @@ class SampleNexus2(SampleNexus, SampleMixin):
|
|
|
61
62
|
|
|
62
63
|
class NexusTest(s_t_utils.SynTest):
|
|
63
64
|
|
|
64
|
-
async def
|
|
65
|
+
async def test_nexus_base(self):
|
|
65
66
|
|
|
66
67
|
with self.getTestDir() as dirn:
|
|
67
68
|
dir1 = s_common.genpath(dirn, 'nexus1')
|
|
@@ -111,6 +112,19 @@ class NexusTest(s_t_utils.SynTest):
|
|
|
111
112
|
stream.seek(0)
|
|
112
113
|
self.isin('while replaying log', stream.read())
|
|
113
114
|
|
|
115
|
+
nexsindx = nexus1.nexsroot.nexslog.index()
|
|
116
|
+
|
|
117
|
+
async def listen():
|
|
118
|
+
async for item in nexus1.getNexusChanges(nexsindx, wait=True):
|
|
119
|
+
break
|
|
120
|
+
return item
|
|
121
|
+
|
|
122
|
+
task = nexus1.schedCoro(listen())
|
|
123
|
+
self.eq('foo', await nexus1.doathing(eventdict))
|
|
124
|
+
offs, item = await asyncio.wait_for(task, timeout=12)
|
|
125
|
+
self.eq(offs, nexsindx)
|
|
126
|
+
self.eq(item[1], 'thing:doathing')
|
|
127
|
+
|
|
114
128
|
async def test_nexus_modroot(self):
|
|
115
129
|
|
|
116
130
|
async with self.getTestCell() as cell:
|
|
@@ -395,3 +409,30 @@ class NexusTest(s_t_utils.SynTest):
|
|
|
395
409
|
await core.nodes('[ it:dev:str=foo ]', opts={'view': forkiden})
|
|
396
410
|
|
|
397
411
|
core.nexsroot._nexskids[layriden] = layr
|
|
412
|
+
|
|
413
|
+
async def test_nexus_iter(self):
|
|
414
|
+
async with self.getTestCell(conf={'nexslog:en': True}) as cell:
|
|
415
|
+
await cell.sync()
|
|
416
|
+
|
|
417
|
+
# Force nexus events to be added while constructing a Window
|
|
418
|
+
orig = s_nexus.NexsRoot.getMirrorWindow
|
|
419
|
+
|
|
420
|
+
@contextlib.asynccontextmanager
|
|
421
|
+
async def slowwindow(self):
|
|
422
|
+
await cell.sync()
|
|
423
|
+
async with orig(self) as wind:
|
|
424
|
+
await cell.sync()
|
|
425
|
+
yield wind
|
|
426
|
+
|
|
427
|
+
items = []
|
|
428
|
+
with mock.patch('synapse.lib.nexus.NexsRoot.getMirrorWindow', slowwindow):
|
|
429
|
+
async with cell.getLocalProxy() as prox:
|
|
430
|
+
async for indx, item in prox.getNexusChanges(0):
|
|
431
|
+
items.append(indx)
|
|
432
|
+
if indx == 2:
|
|
433
|
+
await cell.sync()
|
|
434
|
+
elif indx == 3:
|
|
435
|
+
break
|
|
436
|
+
|
|
437
|
+
# We didn't miss or duplicate items added during window construction
|
|
438
|
+
self.eq([0, 1, 2, 3], items)
|
|
@@ -15,7 +15,7 @@ class SlabSeqn(s_t_utils.SynTest):
|
|
|
15
15
|
def chk_size(self, seqn):
|
|
16
16
|
self.eq(seqn.stat()['entries'], seqn.size)
|
|
17
17
|
|
|
18
|
-
async def
|
|
18
|
+
async def test_slab_seqn_base(self):
|
|
19
19
|
|
|
20
20
|
with self.getTestDir() as dirn:
|
|
21
21
|
|
|
@@ -174,3 +174,32 @@ class SlabSeqn(s_t_utils.SynTest):
|
|
|
174
174
|
|
|
175
175
|
res = await asyncio.wait_for(genr.__anext__(), timeout=1)
|
|
176
176
|
self.eq((1, 'bar'), res)
|
|
177
|
+
|
|
178
|
+
async def test_slab_seqn_retnpack(self):
|
|
179
|
+
|
|
180
|
+
with self.getTestDir() as dirn:
|
|
181
|
+
async with await s_lmdbslab.Slab.anit(dirn, map_size=10_0000) as slab:
|
|
182
|
+
|
|
183
|
+
seqn = s_slabseqn.SlabSeqn(slab, 'seqn:test')
|
|
184
|
+
|
|
185
|
+
self.eq((0, b'\xa4foo1'), seqn.addWithPackRetn('foo1'))
|
|
186
|
+
self.eq((1, b'\xa4foo2'), seqn.addWithPackRetn('foo2'))
|
|
187
|
+
self.eq((0, b'\xa4foo3'), seqn.addWithPackRetn('foo3', indx=0))
|
|
188
|
+
|
|
189
|
+
seqn.addWithPackRetn('foo4', indx=10)
|
|
190
|
+
seqn.addWithPackRetn('foo5')
|
|
191
|
+
seqn.addWithPackRetn('foo6', indx=7)
|
|
192
|
+
seqn.addWithPackRetn('foo7', indx=7)
|
|
193
|
+
|
|
194
|
+
self.eq((12, b'\xa4foo8'), seqn.addWithPackRetn('foo8'))
|
|
195
|
+
|
|
196
|
+
valus = [valu for valu in seqn.iter(0)]
|
|
197
|
+
evals = [
|
|
198
|
+
(0, 'foo3',),
|
|
199
|
+
(1, 'foo2'),
|
|
200
|
+
(7, 'foo7'),
|
|
201
|
+
(10, 'foo4'),
|
|
202
|
+
(11, 'foo5'),
|
|
203
|
+
(12, 'foo8'),
|
|
204
|
+
]
|
|
205
|
+
self.eq(valus, evals)
|