synapse 2.224.0__py311-none-any.whl → 2.226.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/cortex.py +6 -8
- synapse/lib/agenda.py +28 -15
- synapse/lib/ast.py +4 -8
- 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/platforms/linux.py +2 -0
- 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 +16 -4
- synapse/lib/stormhttp.py +7 -1
- synapse/lib/stormlib/aha.py +3 -3
- synapse/lib/stormtypes.py +10 -3
- synapse/lib/types.py +20 -0
- synapse/lib/version.py +2 -2
- synapse/models/base.py +3 -0
- synapse/models/inet.py +62 -5
- synapse/models/infotech.py +18 -0
- synapse/models/media.py +4 -0
- synapse/models/risk.py +3 -0
- synapse/tests/test_cortex.py +115 -2
- synapse/tests/test_lib_agenda.py +141 -28
- 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_lmdbslab.py +2 -0
- synapse/tests/test_lib_multislabseqn.py +22 -0
- synapse/tests/test_lib_nexus.py +42 -1
- synapse/tests/test_lib_platforms_linux.py +4 -0
- synapse/tests/test_lib_slabseqn.py +30 -1
- synapse/tests/test_lib_storm.py +65 -1
- synapse/tests/test_lib_stormhttp.py +16 -0
- synapse/tests/test_lib_stormlib_aha.py +6 -2
- 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 +37 -0
- synapse/tests/test_model_infotech.py +15 -1
- synapse/tests/test_model_media.py +4 -1
- synapse/tests/test_model_risk.py +2 -0
- synapse/tests/test_tools_aha.py +2 -2
- 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 +15 -1
- synapse/tools/aha/mirror.py +1 -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.226.0.dist-info}/METADATA +1 -1
- {synapse-2.224.0.dist-info → synapse-2.226.0.dist-info}/RECORD +135 -106
- 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.226.0.dist-info}/WHEEL +0 -0
- {synapse-2.224.0.dist-info → synapse-2.226.0.dist-info}/licenses/LICENSE +0 -0
- {synapse-2.224.0.dist-info → synapse-2.226.0.dist-info}/top_level.txt +0 -0
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)
|
|
@@ -60,3 +60,7 @@ class LinuxTest(s_t_utils.SynTest):
|
|
|
60
60
|
self.isinstance(ret, dict)
|
|
61
61
|
self.isin('vm.swappiness', ret)
|
|
62
62
|
self.isinstance(ret['vm.swappiness'], int)
|
|
63
|
+
self.isin('vm.dirty_bytes', ret)
|
|
64
|
+
self.isinstance(ret['vm.dirty_bytes'], int)
|
|
65
|
+
self.isin('vm.dirty_background_bytes', ret)
|
|
66
|
+
self.isinstance(ret['vm.dirty_background_bytes'], int)
|
|
@@ -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)
|
synapse/tests/test_lib_storm.py
CHANGED
|
@@ -21,7 +21,7 @@ import synapse.lib.stormtypes as s_stormtypes
|
|
|
21
21
|
import synapse.tests.utils as s_t_utils
|
|
22
22
|
from synapse.tests.utils import alist
|
|
23
23
|
|
|
24
|
-
import synapse.tools.backup as s_tools_backup
|
|
24
|
+
import synapse.tools.service.backup as s_tools_backup
|
|
25
25
|
|
|
26
26
|
class StormTest(s_t_utils.SynTest):
|
|
27
27
|
|
|
@@ -1095,6 +1095,9 @@ class StormTest(s_t_utils.SynTest):
|
|
|
1095
1095
|
|
|
1096
1096
|
await visi.addRule((True, ('storm', 'asroot', 'cmd', 'asroot', 'yep')))
|
|
1097
1097
|
|
|
1098
|
+
msgs = await core.stormlist('asroot.yep', opts=opts)
|
|
1099
|
+
self.stormIsInWarn('Command (asroot.yep) requires asroot permission which is deprecated', msgs)
|
|
1100
|
+
|
|
1098
1101
|
nodes = await core.nodes('asroot.yep', opts=opts)
|
|
1099
1102
|
self.len(1, nodes)
|
|
1100
1103
|
self.eq('false', nodes[0].ndef[1])
|
|
@@ -1184,6 +1187,9 @@ class StormTest(s_t_utils.SynTest):
|
|
|
1184
1187
|
await visi.addRule((True, ('storm', 'asroot', 'mod', 'foo')))
|
|
1185
1188
|
self.len(1, await core.nodes('yield $lib.import(foo.baz).lol()', opts=opts))
|
|
1186
1189
|
|
|
1190
|
+
msgs = await core.stormlist('$lib.import(foo.bar)')
|
|
1191
|
+
self.stormIsInWarn('Module (foo.bar) requires asroot permission but does not specify any asroot:perms', msgs)
|
|
1192
|
+
|
|
1187
1193
|
# coverage for dyncall/dyniter with asroot...
|
|
1188
1194
|
await core.nodes('$lib.import(foo.bar).dyncall()', opts=opts)
|
|
1189
1195
|
await core.nodes('$lib.import(foo.bar).dyniter()', opts=opts)
|
|
@@ -4724,6 +4730,64 @@ class StormTest(s_t_utils.SynTest):
|
|
|
4724
4730
|
self.stormIsInWarn('"--end-time" is deprecated and will be removed in v3.0.0.', msgs)
|
|
4725
4731
|
self.len(2, [m for m in msgs if m[0] == 'warn'])
|
|
4726
4732
|
|
|
4733
|
+
async def test_storm_cmd_cmdconf(self):
|
|
4734
|
+
pkgdef = {
|
|
4735
|
+
'name': 'testpkg',
|
|
4736
|
+
'version': '1.0.0',
|
|
4737
|
+
'commands': [
|
|
4738
|
+
{
|
|
4739
|
+
'name': 'getcmdconf',
|
|
4740
|
+
'cmdconf': {
|
|
4741
|
+
'valu': 0,
|
|
4742
|
+
'sub': {
|
|
4743
|
+
'valu': 0,
|
|
4744
|
+
},
|
|
4745
|
+
},
|
|
4746
|
+
'storm': '''
|
|
4747
|
+
$lib.print(`VALU: {$cmdconf.valu}.`)
|
|
4748
|
+
$lib.print(`SUBVALU: {$cmdconf.sub.valu}.`)
|
|
4749
|
+
$cmdconf.valu = ($cmdconf.valu + 1)
|
|
4750
|
+
$cmdconf.sub.valu = ($cmdconf.sub.valu + 1)
|
|
4751
|
+
''',
|
|
4752
|
+
},
|
|
4753
|
+
],
|
|
4754
|
+
}
|
|
4755
|
+
|
|
4756
|
+
async with self.getTestCore() as core:
|
|
4757
|
+
await core.addStormPkg(pkgdef)
|
|
4758
|
+
|
|
4759
|
+
msgs = await core.stormlist('getcmdconf')
|
|
4760
|
+
self.stormHasNoWarnErr(msgs)
|
|
4761
|
+
self.stormIsInPrint('VALU: 0.', msgs)
|
|
4762
|
+
self.stormIsInPrint('SUBVALU: 0.', msgs)
|
|
4763
|
+
|
|
4764
|
+
msgs = await core.stormlist('getcmdconf | getcmdconf')
|
|
4765
|
+
self.stormHasNoWarnErr(msgs)
|
|
4766
|
+
msgs = [k for k in msgs if k[0] == 'print']
|
|
4767
|
+
self.len(4, msgs)
|
|
4768
|
+
self.sorteq(
|
|
4769
|
+
['VALU: 0.', 'VALU: 0.', 'SUBVALU: 0.', 'SUBVALU: 0.'],
|
|
4770
|
+
[msg[1].get('mesg') for msg in msgs]
|
|
4771
|
+
)
|
|
4772
|
+
|
|
4773
|
+
msgs = await core.stormlist('for $i in $lib.range(16) {[test:int=$i]} | getcmdconf')
|
|
4774
|
+
self.stormHasNoWarnErr(msgs)
|
|
4775
|
+
|
|
4776
|
+
self.stormIsInPrint('VALU: 0.', msgs)
|
|
4777
|
+
self.stormIsInPrint('VALU: 1.', msgs)
|
|
4778
|
+
self.stormIsInPrint('VALU: 15.', msgs)
|
|
4779
|
+
self.stormNotInPrint('VALU: 16.', msgs)
|
|
4780
|
+
|
|
4781
|
+
self.stormIsInPrint('SUBVALU: 0.', msgs)
|
|
4782
|
+
self.stormIsInPrint('SUBVALU: 1.', msgs)
|
|
4783
|
+
self.stormIsInPrint('SUBVALU: 15.', msgs)
|
|
4784
|
+
self.stormNotInPrint('SUBVALU: 16.', msgs)
|
|
4785
|
+
|
|
4786
|
+
msgs = await core.stormlist('getcmdconf')
|
|
4787
|
+
self.stormHasNoWarnErr(msgs)
|
|
4788
|
+
self.stormIsInPrint('VALU: 0.', msgs)
|
|
4789
|
+
self.stormIsInPrint('SUBVALU: 0.', msgs)
|
|
4790
|
+
|
|
4727
4791
|
async def test_liftby_edge(self):
|
|
4728
4792
|
async with self.getTestCore() as core:
|
|
4729
4793
|
|
|
@@ -47,6 +47,11 @@ class HttpBadJson(s_httpapi.Handler):
|
|
|
47
47
|
async def get(self):
|
|
48
48
|
self.write(b'{"foo": "bar\x80"}')
|
|
49
49
|
|
|
50
|
+
class HttpGiantHeader(s_httpapi.Handler):
|
|
51
|
+
async def get(self):
|
|
52
|
+
self.set_header('Giant', 'x' * 64_000)
|
|
53
|
+
self.write('test')
|
|
54
|
+
|
|
50
55
|
class StormHttpTest(s_test.SynTest):
|
|
51
56
|
|
|
52
57
|
async def test_storm_http_get(self):
|
|
@@ -60,6 +65,7 @@ class StormHttpTest(s_test.SynTest):
|
|
|
60
65
|
core.addHttpApi('/api/v0/test', s_test.HttpReflector, {'cell': core})
|
|
61
66
|
core.addHttpApi('/api/v0/notjson', HttpNotJson, {'cell': core})
|
|
62
67
|
core.addHttpApi('/api/v0/badjson', HttpBadJson, {'cell': core})
|
|
68
|
+
core.addHttpApi('/api/v0/giantheader', HttpGiantHeader, {'cell': core})
|
|
63
69
|
url = f'https://root:root@127.0.0.1:{port}/api/v0/test'
|
|
64
70
|
status_url = f'https://127.0.0.1:{port}/api/v1/status'
|
|
65
71
|
opts = {'vars': {'url': url, 'port': port, 'status_url': status_url}}
|
|
@@ -273,6 +279,16 @@ class StormHttpTest(s_test.SynTest):
|
|
|
273
279
|
self.isinstance(resp, tuple)
|
|
274
280
|
self.len(0, resp)
|
|
275
281
|
|
|
282
|
+
gianturl = f'https://root:root@127.0.0.1:{port}/api/v0/giantheader'
|
|
283
|
+
giantopts = {'vars': {'url': gianturl}}
|
|
284
|
+
q = '''
|
|
285
|
+
$resp = $lib.inet.http.get($url, ssl_verify=$lib.false)
|
|
286
|
+
return ( $resp )
|
|
287
|
+
'''
|
|
288
|
+
resp = await core.callStorm(q, opts=giantopts)
|
|
289
|
+
self.eq(resp['body'], b'test')
|
|
290
|
+
self.len(64_000, resp['headers'].get('Giant'))
|
|
291
|
+
|
|
276
292
|
async def test_storm_http_inject_ca(self):
|
|
277
293
|
|
|
278
294
|
with self.getTestDir() as dirn:
|
|
@@ -341,13 +341,13 @@ Connection information:
|
|
|
341
341
|
|
|
342
342
|
async def mockCellInfo():
|
|
343
343
|
return {
|
|
344
|
-
'cell': {'ready': True, 'nexsindx': 10, '
|
|
344
|
+
'cell': {'ready': True, 'nexsindx': 10, 'active': True},
|
|
345
345
|
'synapse': {'verstring': '2.190.0'},
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
async def mockOutOfSyncCellInfo():
|
|
349
349
|
return {
|
|
350
|
-
'cell': {'ready': True, 'nexsindx': 5, '
|
|
350
|
+
'cell': {'ready': True, 'nexsindx': 5, 'active': False},
|
|
351
351
|
'synapse': {'verstring': '2.190.0'},
|
|
352
352
|
}
|
|
353
353
|
|
|
@@ -378,6 +378,10 @@ Connection information:
|
|
|
378
378
|
msgs = await core00.stormlist('aha.svc.mirror --timeout 1')
|
|
379
379
|
self.stormIsInPrint('Group Status: Out of Sync', msgs)
|
|
380
380
|
|
|
381
|
+
await cell01.nexsroot.client.fini()
|
|
382
|
+
msgs = await core00.stormlist('aha.svc.mirror')
|
|
383
|
+
self.stormIsInPrint('follower', msgs)
|
|
384
|
+
|
|
381
385
|
await aha.delAhaSvc('00.cell', network='synapse')
|
|
382
386
|
msgs = await core00.stormlist('aha.svc.mirror')
|
|
383
387
|
self.stormNotInPrint('Service Mirror Groups:', msgs)
|
|
@@ -11,7 +11,7 @@ import synapse.lib.coro as s_coro
|
|
|
11
11
|
import synapse.lib.oauth as s_oauth
|
|
12
12
|
import synapse.lib.httpapi as s_httpapi
|
|
13
13
|
import synapse.tests.utils as s_test
|
|
14
|
-
import synapse.tools.backup as s_backup
|
|
14
|
+
import synapse.tools.service.backup as s_backup
|
|
15
15
|
|
|
16
16
|
logger = logging.getLogger(__name__)
|
|
17
17
|
|
synapse/tests/test_model_inet.py
CHANGED
|
@@ -2999,17 +2999,21 @@ class InetModelTest(s_t_utils.SynTest):
|
|
|
2999
2999
|
:names=("slack chat",)
|
|
3000
3000
|
:parent={[ inet:service:platform=({"name": "salesforce"}) ]}
|
|
3001
3001
|
:status=available
|
|
3002
|
+
:family=" FooFam "
|
|
3002
3003
|
:period=(2022, 2023)
|
|
3003
3004
|
:creator={[ inet:service:account=({"id": "bar"}) ]}
|
|
3004
3005
|
:remover={[ inet:service:account=({"id": "baz"}) ]}
|
|
3005
3006
|
:provider={ ou:org:name=$provname }
|
|
3006
3007
|
:provider:name=$provname
|
|
3008
|
+
:type=foo.bar
|
|
3007
3009
|
]
|
|
3008
3010
|
'''
|
|
3009
3011
|
nodes = await core.nodes(q, opts=opts)
|
|
3010
3012
|
self.len(1, nodes)
|
|
3011
3013
|
self.eq(nodes[0].ndef, ('inet:service:platform', s_common.guid(('slack',))))
|
|
3012
3014
|
self.eq('foo', nodes[0].get('id'))
|
|
3015
|
+
self.eq('foo.bar.', nodes[0].get('type'))
|
|
3016
|
+
self.eq('foofam', nodes[0].get('family'))
|
|
3013
3017
|
self.eq(nodes[0].get('url'), 'https://slack.com')
|
|
3014
3018
|
self.eq(nodes[0].get('urls'), ('https://slacker.com',))
|
|
3015
3019
|
self.eq(nodes[0].get('zones'), ('slack.com', 'slacker.com'))
|
|
@@ -3039,6 +3043,9 @@ class InetModelTest(s_t_utils.SynTest):
|
|
|
3039
3043
|
nodes = await core.nodes('[ inet:service:platform=({"zone": "slacker.com"}) ]')
|
|
3040
3044
|
self.eq(nodes[0].ndef, platform.ndef)
|
|
3041
3045
|
|
|
3046
|
+
nodes = await core.nodes('inet:service:platform:type:taxonomy')
|
|
3047
|
+
self.sorteq(['foo.', 'foo.bar.'], [n.ndef[1] for n in nodes])
|
|
3048
|
+
|
|
3042
3049
|
q = '''
|
|
3043
3050
|
[ inet:service:instance=(vertex, slack)
|
|
3044
3051
|
:id='T2XK1223Y'
|
|
@@ -3068,6 +3075,7 @@ class InetModelTest(s_t_utils.SynTest):
|
|
|
3068
3075
|
(inet:service:account=(blackout, account, vertex, slack)
|
|
3069
3076
|
:id=U7RN51U1J
|
|
3070
3077
|
:user=blackout
|
|
3078
|
+
:users=(zeblackout, blackoutalt, zeblackout)
|
|
3071
3079
|
:url=https://vertex.link/users/blackout
|
|
3072
3080
|
:email=blackout@vertex.link
|
|
3073
3081
|
:profile={ gen.ps.contact.email vertex.employee blackout@vertex.link }
|
|
@@ -3099,6 +3107,7 @@ class InetModelTest(s_t_utils.SynTest):
|
|
|
3099
3107
|
self.eq(accounts[0].ndef, ('inet:service:account', s_common.guid(('blackout', 'account', 'vertex', 'slack'))))
|
|
3100
3108
|
self.eq(accounts[0].get('id'), 'U7RN51U1J')
|
|
3101
3109
|
self.eq(accounts[0].get('user'), 'blackout')
|
|
3110
|
+
self.eq(accounts[0].get('users'), ('blackoutalt', 'zeblackout'))
|
|
3102
3111
|
self.eq(accounts[0].get('url'), 'https://vertex.link/users/blackout')
|
|
3103
3112
|
self.eq(accounts[0].get('email'), 'blackout@vertex.link')
|
|
3104
3113
|
self.eq(accounts[0].get('profile'), blckprof.ndef[1])
|
|
@@ -3112,6 +3121,10 @@ class InetModelTest(s_t_utils.SynTest):
|
|
|
3112
3121
|
|
|
3113
3122
|
self.len(1, await core.nodes('inet:service:account:email=visi@vertex.link :parent -> inet:service:account'))
|
|
3114
3123
|
|
|
3124
|
+
nodes = await core.nodes('[ inet:service:account=({"user": "blackoutalt"}) ]')
|
|
3125
|
+
self.len(1, nodes)
|
|
3126
|
+
self.eq(accounts[0].ndef, nodes[0].ndef)
|
|
3127
|
+
|
|
3115
3128
|
q = '''
|
|
3116
3129
|
[ inet:service:group=(developers, group, vertex, slack)
|
|
3117
3130
|
:id=X1234
|
|
@@ -3187,6 +3200,7 @@ class InetModelTest(s_t_utils.SynTest):
|
|
|
3187
3200
|
q = '''
|
|
3188
3201
|
[ inet:service:login=*
|
|
3189
3202
|
:method=password
|
|
3203
|
+
:url=https://vertex.link/api/v1/login
|
|
3190
3204
|
:session=$blcksess
|
|
3191
3205
|
:server=tcp://10.10.10.4:443
|
|
3192
3206
|
:client=tcp://192.168.0.10:12345
|
|
@@ -3196,6 +3210,7 @@ class InetModelTest(s_t_utils.SynTest):
|
|
|
3196
3210
|
nodes = await core.nodes(q, opts=opts)
|
|
3197
3211
|
self.len(1, nodes)
|
|
3198
3212
|
self.eq(nodes[0].get('method'), 'password.')
|
|
3213
|
+
self.eq(nodes[0].get('url'), 'https://vertex.link/api/v1/login')
|
|
3199
3214
|
|
|
3200
3215
|
server = await core.nodes('inet:server=tcp://10.10.10.4:443')
|
|
3201
3216
|
self.len(1, server)
|
|
@@ -3555,6 +3570,28 @@ class InetModelTest(s_t_utils.SynTest):
|
|
|
3555
3570
|
self.len(1, await core.nodes('inet:service:subscription :pay:instrument -> econ:bank:account'))
|
|
3556
3571
|
self.len(1, await core.nodes('inet:service:subscription :subscriber -> inet:service:tenant'))
|
|
3557
3572
|
|
|
3573
|
+
nodes = await core.nodes('''
|
|
3574
|
+
[ inet:service:agent=*
|
|
3575
|
+
:name=woot
|
|
3576
|
+
:names=(foo, bar)
|
|
3577
|
+
:desc="Foo Bar"
|
|
3578
|
+
:software={[ it:prod:softver=(hehe, haha) ]}
|
|
3579
|
+
:platform={inet:service:platform | limit 1}
|
|
3580
|
+
|
|
3581
|
+
// ensure we got the interface...
|
|
3582
|
+
:creator={ inet:service:account | limit 1 }
|
|
3583
|
+
]
|
|
3584
|
+
''')
|
|
3585
|
+
self.len(1, nodes)
|
|
3586
|
+
self.eq(nodes[0].get('name'), 'woot')
|
|
3587
|
+
self.eq(nodes[0].get('names'), ('bar', 'foo'))
|
|
3588
|
+
self.eq(nodes[0].get('desc'), 'Foo Bar')
|
|
3589
|
+
self.nn(nodes[0].get('creator'))
|
|
3590
|
+
self.nn(nodes[0].get('platform'))
|
|
3591
|
+
|
|
3592
|
+
self.len(1, await core.nodes('inet:service:action | limit 1 | [ :agent={ inet:service:agent } ]'))
|
|
3593
|
+
self.len(1, await core.nodes('inet:service:platform | limit 1 | [ :software={[ it:prod:softver=(hehe, haha) ]} ]'))
|
|
3594
|
+
|
|
3558
3595
|
async def test_model_inet_tls_ja4(self):
|
|
3559
3596
|
|
|
3560
3597
|
async with self.getTestCore() as core:
|
|
@@ -2163,6 +2163,20 @@ class InfotechModelTest(s_t_utils.SynTest):
|
|
|
2163
2163
|
self.eq(node.get('url'),
|
|
2164
2164
|
'https://github.com/vertexproject/synapse/commit/03c71e723bceedb38ef8fc14543c30b9e82e64cf')
|
|
2165
2165
|
|
|
2166
|
+
nodes = await core.nodes('''
|
|
2167
|
+
[ it:dev:repo:entry=*
|
|
2168
|
+
:repo={it:dev:repo | limit 1}
|
|
2169
|
+
:file=*
|
|
2170
|
+
:path=foo/bar/baz.exe
|
|
2171
|
+
<(has)+ { it:dev:repo:commit | limit 1 }
|
|
2172
|
+
]
|
|
2173
|
+
''')
|
|
2174
|
+
self.nn(nodes[0].get('file'))
|
|
2175
|
+
self.nn(nodes[0].get('repo'))
|
|
2176
|
+
self.eq(nodes[0].get('path'), 'foo/bar/baz.exe')
|
|
2177
|
+
|
|
2178
|
+
self.len(1, await core.nodes('it:dev:repo:entry <(has)- it:dev:repo:commit'))
|
|
2179
|
+
|
|
2166
2180
|
props = {
|
|
2167
2181
|
'commit': commit,
|
|
2168
2182
|
'file': file,
|
|
@@ -2306,7 +2320,7 @@ class InfotechModelTest(s_t_utils.SynTest):
|
|
|
2306
2320
|
self.len(2, nodes)
|
|
2307
2321
|
|
|
2308
2322
|
nodes = await core.nodes('it:dev:repo <- *')
|
|
2309
|
-
self.len(
|
|
2323
|
+
self.len(5, nodes)
|
|
2310
2324
|
|
|
2311
2325
|
nodes = await core.nodes('it:dev:repo:commit')
|
|
2312
2326
|
self.len(3, nodes)
|
|
@@ -22,6 +22,7 @@ class MediaModelTest(s_t_utils.SynTest):
|
|
|
22
22
|
'file': file0,
|
|
23
23
|
'title': 'Synapse is awesome! ',
|
|
24
24
|
'summary': 'I forget ',
|
|
25
|
+
'body': 'It is Awesome ',
|
|
25
26
|
'published': 0,
|
|
26
27
|
'updated': 0,
|
|
27
28
|
'org': 'verteX',
|
|
@@ -34,7 +35,7 @@ class MediaModelTest(s_t_utils.SynTest):
|
|
|
34
35
|
|
|
35
36
|
q = '''[(media:news=$valu
|
|
36
37
|
:url=$p.url :file=$p.file :title=$p.title
|
|
37
|
-
:summary=$p.summary :published=$p.published :updated=$p.updated
|
|
38
|
+
:summary=$p.summary :body=$p.body :published=$p.published :updated=$p.updated
|
|
38
39
|
:org=$p.org :authors=$p.authors
|
|
39
40
|
:publisher=$p.publisher :publisher:name=$p."publisher:name"
|
|
40
41
|
:rss:feed=$p."rss:feed" :topics=$p.topics
|
|
@@ -49,6 +50,8 @@ class MediaModelTest(s_t_utils.SynTest):
|
|
|
49
50
|
self.eq(node.get('url:fqdn'), 'vertex.link')
|
|
50
51
|
self.eq(node.get('file'), 'sha256:' + file0)
|
|
51
52
|
self.eq(node.get('title'), 'synapse is awesome! ')
|
|
53
|
+
self.eq(node.get('summary'), 'I forget ')
|
|
54
|
+
self.eq(node.get('body'), 'It is Awesome ')
|
|
52
55
|
self.eq(node.get('published'), 0)
|
|
53
56
|
self.eq(node.get('updated'), 0)
|
|
54
57
|
self.eq(node.get('publisher'), publisher)
|
synapse/tests/test_model_risk.py
CHANGED
|
@@ -601,6 +601,7 @@ class RiskModelTest(s_t_utils.SynTest):
|
|
|
601
601
|
risk:mitigation=*
|
|
602
602
|
:vuln=*
|
|
603
603
|
:name=" FooBar "
|
|
604
|
+
:id=" IDa123 "
|
|
604
605
|
:type=foo.bar
|
|
605
606
|
:desc=BazFaz
|
|
606
607
|
:hardware=*
|
|
@@ -613,6 +614,7 @@ class RiskModelTest(s_t_utils.SynTest):
|
|
|
613
614
|
self.eq('BazFaz', nodes[0].props['desc'])
|
|
614
615
|
self.eq('vertex', nodes[0].get('reporter:name'))
|
|
615
616
|
self.eq('foo.bar.', nodes[0].get('type'))
|
|
617
|
+
self.eq('IDa123', nodes[0].get('id'))
|
|
616
618
|
self.nn(nodes[0].get('reporter'))
|
|
617
619
|
self.len(1, await core.nodes('risk:mitigation -> risk:vuln'))
|
|
618
620
|
self.len(1, await core.nodes('risk:mitigation -> it:prod:softver'))
|
synapse/tests/test_tools_aha.py
CHANGED
|
@@ -273,13 +273,13 @@ class AhaToolsTest(s_t_utils.SynTest):
|
|
|
273
273
|
|
|
274
274
|
async def mockCellInfo():
|
|
275
275
|
return {
|
|
276
|
-
'cell': {'ready': True, 'nexsindx': 10, '
|
|
276
|
+
'cell': {'ready': True, 'nexsindx': 10, 'active': True},
|
|
277
277
|
'synapse': {'verstring': s_version.verstring},
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
async def mockOutOfSyncCellInfo():
|
|
281
281
|
return {
|
|
282
|
-
'cell': {'ready': True, 'nexsindx': 5, '
|
|
282
|
+
'cell': {'ready': True, 'nexsindx': 5, 'active': False},
|
|
283
283
|
'synapse': {'verstring': s_version.verstring},
|
|
284
284
|
}
|
|
285
285
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import synapse.tests.utils as s_test
|
|
2
|
-
import synapse.tools.
|
|
2
|
+
import synapse.tools.axon.copy as s_copy
|
|
3
3
|
|
|
4
4
|
class Axon2AxonTest(s_test.SynTest):
|
|
5
5
|
|
|
@@ -15,7 +15,7 @@ class Axon2AxonTest(s_test.SynTest):
|
|
|
15
15
|
(size, sha256) = await srcaxon.put(b'visi')
|
|
16
16
|
|
|
17
17
|
outp = self.getTestOutp()
|
|
18
|
-
await
|
|
18
|
+
await s_copy.main([srcurl, dsturl], outp=outp)
|
|
19
19
|
self.true(await dstaxon.has(sha256))
|
|
20
20
|
outp.expect('Starting transfer at offset: 0')
|
|
21
21
|
outp.expect('[ 0] - e45bbb7e03acacf4d1cca4c16af1ec0c51d777d10e53ed3155bd3d8deb398f3f (4)')
|
|
@@ -23,11 +23,11 @@ class Axon2AxonTest(s_test.SynTest):
|
|
|
23
23
|
(size, sha256) = await srcaxon.put(b'vertex')
|
|
24
24
|
|
|
25
25
|
outp = self.getTestOutp()
|
|
26
|
-
await
|
|
26
|
+
await s_copy.main([srcurl, dsturl, '--offset', '1'], outp=outp)
|
|
27
27
|
self.true(await dstaxon.has(sha256))
|
|
28
28
|
outp.expect('Starting transfer at offset: 1')
|
|
29
29
|
outp.expect('[ 1] - e1b683e26a3aad218df6aa63afe9cf57fdb5dfaf5eb20cddac14305d67f48a02 (6)')
|
|
30
30
|
|
|
31
31
|
outp = self.getTestOutp()
|
|
32
|
-
self.eq(1, await
|
|
32
|
+
self.eq(1, await s_copy.main([], outp=outp))
|
|
33
33
|
outp.expect('arguments are required:')
|
|
@@ -5,7 +5,7 @@ import pathlib
|
|
|
5
5
|
from unittest import mock
|
|
6
6
|
|
|
7
7
|
import synapse.tests.utils as s_t_utils
|
|
8
|
-
import synapse.tools.
|
|
8
|
+
import synapse.tools.axon.get as s_get
|
|
9
9
|
|
|
10
10
|
class TestPullFile(s_t_utils.SynTest):
|
|
11
11
|
|
|
@@ -30,13 +30,13 @@ class TestPullFile(s_t_utils.SynTest):
|
|
|
30
30
|
with self.getTestDir() as wdir:
|
|
31
31
|
|
|
32
32
|
outp = self.getTestOutp()
|
|
33
|
-
self.eq(0, await
|
|
33
|
+
self.eq(0, await s_get.main(['-a', axonurl,
|
|
34
34
|
'-o', wdir,
|
|
35
35
|
'-l', testhash,
|
|
36
36
|
'-l', nonehash], outp))
|
|
37
37
|
oldcwd = os.getcwd()
|
|
38
38
|
os.chdir(wdir)
|
|
39
|
-
self.eq(0, await
|
|
39
|
+
self.eq(0, await s_get.main(['-a', axonurl,
|
|
40
40
|
'-l', visihash], outp))
|
|
41
41
|
|
|
42
42
|
os.chdir(oldcwd)
|
|
@@ -52,6 +52,6 @@ class TestPullFile(s_t_utils.SynTest):
|
|
|
52
52
|
self.true(outp.expect(f'Fetching {visihash} to file'))
|
|
53
53
|
|
|
54
54
|
with mock.patch('synapse.axon.Axon.get', self._getFail):
|
|
55
|
-
self.eq(0, await
|
|
55
|
+
self.eq(0, await s_get.main(['-a', axonurl,
|
|
56
56
|
'-l', visihash], outp))
|
|
57
57
|
self.isin('Error: Hit Exception', str(outp))
|
|
@@ -3,7 +3,7 @@ import hashlib
|
|
|
3
3
|
|
|
4
4
|
import synapse.common as s_common
|
|
5
5
|
|
|
6
|
-
import synapse.tools.
|
|
6
|
+
import synapse.tools.axon.put as s_put
|
|
7
7
|
|
|
8
8
|
import synapse.tests.utils as s_t_utils
|
|
9
9
|
|
|
@@ -43,7 +43,7 @@ class TestPushFile(s_t_utils.SynTest):
|
|
|
43
43
|
'-t', 'foo.bar,baz.faz',
|
|
44
44
|
visipath]
|
|
45
45
|
|
|
46
|
-
self.eq(0, await
|
|
46
|
+
self.eq(0, await s_put.main(args, outp))
|
|
47
47
|
self.true(outp.expect('Uploaded [visi.txt] to axon'))
|
|
48
48
|
self.true(outp.expect('file: visi.txt (4) added to core'))
|
|
49
49
|
|
|
@@ -51,7 +51,7 @@ class TestPushFile(s_t_utils.SynTest):
|
|
|
51
51
|
self.eq(b'visi', b''.join([buf async for buf in axonprox.get(visihash)]))
|
|
52
52
|
|
|
53
53
|
outp = self.getTestOutp()
|
|
54
|
-
self.eq(0, await
|
|
54
|
+
self.eq(0, await s_put.main(args, outp))
|
|
55
55
|
self.true(outp.expect('Axon already had [visi.txt]'))
|
|
56
56
|
|
|
57
57
|
self.eq(1, await coreprox.count(f'file:bytes={s_common.ehex(visihash)}'))
|
|
@@ -63,7 +63,7 @@ class TestPushFile(s_t_utils.SynTest):
|
|
|
63
63
|
args = ['-a', axonurl, nullpath]
|
|
64
64
|
|
|
65
65
|
outp = self.getTestOutp()
|
|
66
|
-
self.eq(0, await
|
|
66
|
+
self.eq(0, await s_put.main(args, outp))
|
|
67
67
|
self.true(outp.expect(f'filepath does not contain any files: {nullpath}'))
|
|
68
68
|
|
|
69
69
|
self.len(1, await axonprox.wants([nullhash]))
|
|
@@ -77,7 +77,7 @@ class TestPushFile(s_t_utils.SynTest):
|
|
|
77
77
|
'-t', 'empty',
|
|
78
78
|
nullpath]
|
|
79
79
|
|
|
80
|
-
self.eq(0, await
|
|
80
|
+
self.eq(0, await s_put.main(args, outp))
|
|
81
81
|
|
|
82
82
|
self.len(0, await axonprox.wants([nullhash]))
|
|
83
83
|
self.eq(b'', b''.join([buf async for buf in axonprox.get(nullhash)]))
|
|
@@ -100,7 +100,7 @@ class TestPushFile(s_t_utils.SynTest):
|
|
|
100
100
|
'-t', 'beef',
|
|
101
101
|
f'{dirn}/**']
|
|
102
102
|
|
|
103
|
-
self.eq(0, await
|
|
103
|
+
self.eq(0, await s_put.main(args, outp))
|
|
104
104
|
self.true(outp.expect('Uploaded [bar.txt] to axon'))
|
|
105
105
|
self.true(outp.expect('file: bar.txt (3) added to core'))
|
|
106
106
|
|
|
@@ -119,7 +119,7 @@ class TestPushFile(s_t_utils.SynTest):
|
|
|
119
119
|
'-r',
|
|
120
120
|
f'{dirn}/**']
|
|
121
121
|
|
|
122
|
-
self.eq(0, await
|
|
122
|
+
self.eq(0, await s_put.main(args, outp))
|
|
123
123
|
self.true(outp.expect('Uploaded [foo.txt] to axon'))
|
|
124
124
|
self.true(outp.expect('file: foo.txt (3) added to core'))
|
|
125
125
|
|