synapse 2.222.0__py311-none-any.whl → 2.224.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/common.py +2 -2
- synapse/cortex.py +159 -31
- synapse/cryotank.py +1 -1
- synapse/datamodel.py +1 -1
- synapse/lib/ast.py +5 -3
- synapse/lib/layer.py +6 -6
- synapse/lib/nexus.py +1 -1
- synapse/lib/schemas.py +2 -0
- synapse/lib/snap.py +15 -9
- synapse/lib/storm.py +35 -191
- synapse/lib/stormlib/auth.py +1 -1
- synapse/lib/stormlib/imap.py +12 -4
- synapse/lib/stormlib/mime.py +15 -5
- synapse/lib/stormlib/pkg.py +598 -0
- synapse/lib/stormlib/task.py +114 -0
- synapse/lib/stormtypes.py +43 -175
- synapse/lib/trigger.py +16 -14
- synapse/lib/version.py +2 -2
- synapse/lib/view.py +17 -14
- synapse/models/files.py +1 -1
- synapse/models/inet.py +25 -0
- synapse/models/proj.py +3 -0
- synapse/models/risk.py +6 -0
- synapse/models/syn.py +8 -0
- synapse/tests/test_common.py +4 -0
- synapse/tests/test_cortex.py +52 -1
- synapse/tests/test_lib_aha.py +68 -53
- synapse/tests/test_lib_ast.py +3 -0
- synapse/tests/test_lib_cell.py +12 -12
- synapse/tests/test_lib_storm.py +128 -248
- synapse/tests/test_lib_stormlib_imap.py +14 -0
- synapse/tests/test_lib_stormlib_mime.py +24 -0
- synapse/tests/test_lib_stormlib_pkg.py +456 -0
- synapse/tests/test_lib_stormlib_task.py +98 -0
- synapse/tests/test_lib_stormtypes.py +12 -100
- synapse/tests/test_lib_trigger.py +66 -3
- synapse/tests/test_lib_view.py +53 -0
- synapse/tests/test_model_files.py +11 -0
- synapse/tests/test_model_inet.py +23 -0
- synapse/tests/test_model_proj.py +3 -1
- synapse/tests/test_model_risk.py +10 -0
- synapse/tests/test_model_syn.py +54 -2
- synapse/tools/cryo/cat.py +2 -1
- synapse/tools/cryo/list.py +2 -0
- {synapse-2.222.0.dist-info → synapse-2.224.0.dist-info}/METADATA +1 -1
- {synapse-2.222.0.dist-info → synapse-2.224.0.dist-info}/RECORD +49 -45
- {synapse-2.222.0.dist-info → synapse-2.224.0.dist-info}/WHEEL +0 -0
- {synapse-2.222.0.dist-info → synapse-2.224.0.dist-info}/licenses/LICENSE +0 -0
- {synapse-2.222.0.dist-info → synapse-2.224.0.dist-info}/top_level.txt +0 -0
synapse/models/inet.py
CHANGED
|
@@ -3700,6 +3700,9 @@ class InetModule(s_module.CoreModule):
|
|
|
3700
3700
|
)),
|
|
3701
3701
|
('inet:service:platform', {}, (
|
|
3702
3702
|
|
|
3703
|
+
('id', ('str', {'strip': True}), {
|
|
3704
|
+
'doc': 'An ID which identifies the platform.'}),
|
|
3705
|
+
|
|
3703
3706
|
('url', ('inet:url', {}), {
|
|
3704
3707
|
'ex': 'https://twitter.com',
|
|
3705
3708
|
'alts': ('urls',),
|
|
@@ -3708,6 +3711,13 @@ class InetModule(s_module.CoreModule):
|
|
|
3708
3711
|
('urls', ('array', {'type': 'inet:url', 'sorted': True, 'uniq': True}), {
|
|
3709
3712
|
'doc': 'An array of alternate URLs for the platform.'}),
|
|
3710
3713
|
|
|
3714
|
+
('zone', ('inet:fqdn', {}), {
|
|
3715
|
+
'alts': ('zones',),
|
|
3716
|
+
'doc': 'The primary zone for the platform.'}),
|
|
3717
|
+
|
|
3718
|
+
('zones', ('array', {'type': 'inet:fqdn', 'sorted': True, 'uniq': True}), {
|
|
3719
|
+
'doc': 'An array of alternate zones for the platform.'}),
|
|
3720
|
+
|
|
3711
3721
|
('name', ('str', {'onespace': True, 'lower': True}), {
|
|
3712
3722
|
'ex': 'twitter',
|
|
3713
3723
|
'alts': ('names',),
|
|
@@ -3722,6 +3732,21 @@ class InetModule(s_module.CoreModule):
|
|
|
3722
3732
|
'disp': {'hint': 'text'},
|
|
3723
3733
|
'doc': 'A description of the service platform.'}),
|
|
3724
3734
|
|
|
3735
|
+
('parent', ('inet:service:platform', {}), {
|
|
3736
|
+
'doc': 'A parent platform which owns this platform.'}),
|
|
3737
|
+
|
|
3738
|
+
('status', ('inet:service:object:status', {}), {
|
|
3739
|
+
'doc': 'The status of the platform.'}),
|
|
3740
|
+
|
|
3741
|
+
('period', ('ival', {}), {
|
|
3742
|
+
'doc': 'The period when the platform existed.'}),
|
|
3743
|
+
|
|
3744
|
+
('creator', ('inet:service:account', {}), {
|
|
3745
|
+
'doc': 'The service account which created the platform.'}),
|
|
3746
|
+
|
|
3747
|
+
('remover', ('inet:service:account', {}), {
|
|
3748
|
+
'doc': 'The service account which removed or decommissioned the platform.'}),
|
|
3749
|
+
|
|
3725
3750
|
('provider', ('ou:org', {}), {
|
|
3726
3751
|
'doc': 'The organization which operates the platform.'}),
|
|
3727
3752
|
|
synapse/models/proj.py
CHANGED
|
@@ -166,6 +166,9 @@ class ProjectModule(s_module.CoreModule):
|
|
|
166
166
|
('created', ('time', {}), {
|
|
167
167
|
'doc': 'The time the comment was added.'}),
|
|
168
168
|
|
|
169
|
+
('ext:creator', ('ps:contact', {}), {
|
|
170
|
+
'doc': 'The contact information of the creator from an external system.'}),
|
|
171
|
+
|
|
169
172
|
('updated', ('time', {'ismax': True}), {
|
|
170
173
|
'doc': 'The last time the comment was updated.'}),
|
|
171
174
|
|
synapse/models/risk.py
CHANGED
|
@@ -269,6 +269,9 @@ class RiskModule(s_module.CoreModule):
|
|
|
269
269
|
|
|
270
270
|
(('risk:outage', 'impacted', None), {
|
|
271
271
|
'doc': 'The outage event impacted the availability of the target node.'}),
|
|
272
|
+
|
|
273
|
+
(('risk:alert', 'about', None), {
|
|
274
|
+
'doc': 'The alert is about the target node.'}),
|
|
272
275
|
),
|
|
273
276
|
'forms': (
|
|
274
277
|
|
|
@@ -800,6 +803,9 @@ class RiskModule(s_module.CoreModule):
|
|
|
800
803
|
('detected', ('time', {}), {
|
|
801
804
|
'doc': 'The time the alerted condition was detected.'}),
|
|
802
805
|
|
|
806
|
+
('updated', ('time', {}), {
|
|
807
|
+
'doc': 'The time the alert was most recently modified.'}),
|
|
808
|
+
|
|
803
809
|
('vuln', ('risk:vuln', {}), {
|
|
804
810
|
'doc': 'The optional vulnerability that the alert indicates.'}),
|
|
805
811
|
|
synapse/models/syn.py
CHANGED
|
@@ -365,6 +365,14 @@ class SynModule(s_module.CoreModule):
|
|
|
365
365
|
('nodedata', ('array', {'type': 'syn:nodedata'}), {
|
|
366
366
|
'deprecated': True,
|
|
367
367
|
'doc': 'The list of nodedata that may be added by the command.', 'uniq': True, 'sorted': True, 'ro': True}),
|
|
368
|
+
('deprecated', ('bool', {}), {
|
|
369
|
+
'doc': 'Set to true if this command is scheduled to be removed.'}),
|
|
370
|
+
('deprecated:version', ('it:semver', {}), {
|
|
371
|
+
'doc': 'The Synapse version when this command will be removed.'}),
|
|
372
|
+
('deprecated:date', ('time', {}), {
|
|
373
|
+
'doc': 'The date when this command will be removed.'}),
|
|
374
|
+
('deprecated:mesg', ('str', {}), {
|
|
375
|
+
'doc': 'Optional description of this deprecation.'}),
|
|
368
376
|
)),
|
|
369
377
|
),
|
|
370
378
|
}),)
|
synapse/tests/test_common.py
CHANGED
|
@@ -75,6 +75,10 @@ class CommonTest(s_t_utils.SynTest):
|
|
|
75
75
|
self.ne('15c8a3727942fa01e04d6a7a525666a2', s_common.guid(item))
|
|
76
76
|
self.eq('15c8a3727942fa01e04d6a7a525666a2', s_common.guid(s_common.flatten(item)))
|
|
77
77
|
|
|
78
|
+
item = {'foo': 'bar', 'baz': 10, 'gronk': True, 'hehe': ['ha', 'ha'], 'tupl': (1, 'two', 1.23), 'newp': None}
|
|
79
|
+
self.ne('02efa9b7612f371dbb65a596cd303d9a', s_common.guid(item))
|
|
80
|
+
self.eq('02efa9b7612f371dbb65a596cd303d9a', s_common.guid(s_common.flatten(item)))
|
|
81
|
+
|
|
78
82
|
def test_common_vertup(self):
|
|
79
83
|
self.eq(s_common.vertup('1.3.30'), (1, 3, 30))
|
|
80
84
|
self.true(s_common.vertup('30.40.50') > (9, 0))
|
synapse/tests/test_cortex.py
CHANGED
|
@@ -426,7 +426,7 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
426
426
|
self.len(1, await core00.nodes('test:str=foo', opts=view00opts))
|
|
427
427
|
|
|
428
428
|
layr = core01.getLayer(layr01iden)
|
|
429
|
-
await layr.storNodeEdits((), {})
|
|
429
|
+
await layr.storNodeEdits((), {'user': s_common.guid()})
|
|
430
430
|
|
|
431
431
|
async def test_cortex_must_upgrade(self):
|
|
432
432
|
|
|
@@ -6650,6 +6650,57 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
6650
6650
|
with self.raises(s_exc.BadPropDef):
|
|
6651
6651
|
await prox.addTagProp('_blah:blah^blah', ('int', {}), {})
|
|
6652
6652
|
|
|
6653
|
+
# Mirrors on newer model versions should not be able to add extended model elements
|
|
6654
|
+
# based on model elements the leader doesn't have
|
|
6655
|
+
async with self.getTestAha() as aha:
|
|
6656
|
+
|
|
6657
|
+
conf = {'aha:provision': await aha.addAhaSvcProv('00.cortex')}
|
|
6658
|
+
core00 = await aha.enter_context(self.getTestCore(conf=conf))
|
|
6659
|
+
|
|
6660
|
+
conf = {'aha:provision': await aha.addAhaSvcProv('01.cortex', {'mirror': 'cortex'})}
|
|
6661
|
+
core01 = await aha.enter_context(self.getTestCore(conf=conf))
|
|
6662
|
+
|
|
6663
|
+
# Add a type directly to the mirror's model to simulate different model version
|
|
6664
|
+
core01.model.addType('_newmodel:type', 'str', {}, {})
|
|
6665
|
+
|
|
6666
|
+
with self.raises(s_exc.NoSuchType):
|
|
6667
|
+
await core01.addType('_test:type', '_newmodel:type', {}, {})
|
|
6668
|
+
|
|
6669
|
+
await core01.sync()
|
|
6670
|
+
self.none(core01.model.type('_test:type'))
|
|
6671
|
+
|
|
6672
|
+
with self.raises(s_exc.NoSuchType):
|
|
6673
|
+
await core01.addUnivProp('_woot', ('_newmodel:type', {}), {})
|
|
6674
|
+
|
|
6675
|
+
await core01.sync()
|
|
6676
|
+
self.none(core01.model.prop('._woot'))
|
|
6677
|
+
|
|
6678
|
+
with self.raises(s_exc.NoSuchType):
|
|
6679
|
+
await core01.addForm('_hehe:haha', '_newmodel:type', {}, {})
|
|
6680
|
+
|
|
6681
|
+
await core01.sync()
|
|
6682
|
+
self.none(core01.model.form('_hehe:haha'))
|
|
6683
|
+
|
|
6684
|
+
with self.raises(s_exc.NoSuchType):
|
|
6685
|
+
await core01.addFormProp('inet:asn', '_newer', ('_newmodel:type', {}), {})
|
|
6686
|
+
|
|
6687
|
+
await core01.sync()
|
|
6688
|
+
self.none(core01.model.prop('inet:asn:_newer'))
|
|
6689
|
+
|
|
6690
|
+
with self.raises(s_exc.NoSuchType):
|
|
6691
|
+
await core01.addTagProp('user', ('_newmodel:type', {}), {})
|
|
6692
|
+
|
|
6693
|
+
await core01.sync()
|
|
6694
|
+
self.none(core01.model.tagprop('user'))
|
|
6695
|
+
|
|
6696
|
+
core01.model.addForm('_newmodel:type', {}, {})
|
|
6697
|
+
|
|
6698
|
+
with self.raises(s_exc.NoSuchForm):
|
|
6699
|
+
await core01.addEdge(('_newmodel:type', '_foo', None), {})
|
|
6700
|
+
|
|
6701
|
+
await core01.sync()
|
|
6702
|
+
self.none(core01.model.edge(('_newmodel:type', '_foo', None)))
|
|
6703
|
+
|
|
6653
6704
|
async def test_cortex_axon(self):
|
|
6654
6705
|
async with self.getTestCore() as core:
|
|
6655
6706
|
# By default, a cortex has a local Axon instance available
|
synapse/tests/test_lib_aha.py
CHANGED
|
@@ -42,6 +42,20 @@ class ExecTeleCaller(s_cell.Cell):
|
|
|
42
42
|
resp = await meth(*args, **kwargs)
|
|
43
43
|
return resp
|
|
44
44
|
|
|
45
|
+
class SpecialPathApi(s_cell.CellApi):
|
|
46
|
+
async def __anit__(self, cell, link, user, path):
|
|
47
|
+
await super().__anit__(cell, link, user)
|
|
48
|
+
self.path = path
|
|
49
|
+
|
|
50
|
+
async def getTestPath(self):
|
|
51
|
+
return self.path
|
|
52
|
+
|
|
53
|
+
class PathAwareCell(s_cell.Cell):
|
|
54
|
+
async def getCellApi(self, link, user, path):
|
|
55
|
+
if not path:
|
|
56
|
+
return await self.cellapi.anit(self, link, user)
|
|
57
|
+
return await SpecialPathApi.anit(self, link, user, path)
|
|
58
|
+
|
|
45
59
|
class AhaTest(s_test.SynTest):
|
|
46
60
|
|
|
47
61
|
async def test_lib_aha_clone(self):
|
|
@@ -132,36 +146,36 @@ class AhaTest(s_test.SynTest):
|
|
|
132
146
|
|
|
133
147
|
async def test_lib_aha_offon(self):
|
|
134
148
|
with self.getTestDir() as dirn:
|
|
135
|
-
|
|
149
|
+
cell0_dirn = s_common.gendir(dirn, 'cell0')
|
|
136
150
|
async with self.getTestAha(dirn=dirn) as aha:
|
|
137
151
|
|
|
138
152
|
replaymult = 1
|
|
139
153
|
if s_common.envbool('SYNDEV_NEXUS_REPLAY'):
|
|
140
154
|
replaymult = 2
|
|
141
155
|
|
|
142
|
-
purl = await aha.addAhaSvcProv('0.
|
|
156
|
+
purl = await aha.addAhaSvcProv('0.cell')
|
|
143
157
|
|
|
144
158
|
wait00 = aha.waiter(1 * replaymult, 'aha:svcadd')
|
|
145
159
|
|
|
146
160
|
conf = {'aha:provision': purl}
|
|
147
|
-
async with self.
|
|
161
|
+
async with self.getTestCell(dirn=cell0_dirn, conf=conf) as cell:
|
|
148
162
|
self.len(1 * replaymult, await wait00.wait(timeout=6))
|
|
149
163
|
|
|
150
|
-
svc = await aha.getAhaSvc('0.
|
|
164
|
+
svc = await aha.getAhaSvc('0.cell...')
|
|
151
165
|
linkiden = svc.get('svcinfo', {}).get('online')
|
|
152
166
|
|
|
153
167
|
# Tear down the Aha cell.
|
|
154
168
|
await aha.__aexit__(None, None, None)
|
|
155
169
|
|
|
156
|
-
with self.getAsyncLoggerStream('synapse.lib.aha', f'Set [0.
|
|
170
|
+
with self.getAsyncLoggerStream('synapse.lib.aha', f'Set [0.cell.synapse] offline.') as stream:
|
|
157
171
|
async with self.getTestAha(dirn=dirn) as aha:
|
|
158
172
|
self.true(await asyncio.wait_for(stream.wait(), timeout=12))
|
|
159
|
-
svc = await aha.getAhaSvc('0.
|
|
173
|
+
svc = await aha.getAhaSvc('0.cell...')
|
|
160
174
|
self.notin('online', svc.get('svcinfo'))
|
|
161
175
|
|
|
162
176
|
# Try setting something down a second time
|
|
163
|
-
await aha.setAhaSvcDown('0.
|
|
164
|
-
svc = await aha.getAhaSvc('0.
|
|
177
|
+
await aha.setAhaSvcDown('0.cell', linkiden, network='synapse')
|
|
178
|
+
svc = await aha.getAhaSvc('0.cell...')
|
|
165
179
|
self.notin('online', svc.get('svcinfo'))
|
|
166
180
|
|
|
167
181
|
async def test_lib_aha_basics(self):
|
|
@@ -190,7 +204,7 @@ class AhaTest(s_test.SynTest):
|
|
|
190
204
|
|
|
191
205
|
async with self.getTestAha() as aha:
|
|
192
206
|
|
|
193
|
-
|
|
207
|
+
cell0_dirn = s_common.gendir(aha.dirn, 'cell0')
|
|
194
208
|
|
|
195
209
|
ahaurls = await aha.getAhaUrls()
|
|
196
210
|
|
|
@@ -200,76 +214,77 @@ class AhaTest(s_test.SynTest):
|
|
|
200
214
|
if s_common.envbool('SYNDEV_NEXUS_REPLAY'):
|
|
201
215
|
replaymult = 2
|
|
202
216
|
|
|
203
|
-
conf = {'aha:provision': await aha.addAhaSvcProv('0.
|
|
204
|
-
async with self.
|
|
217
|
+
conf = {'aha:provision': await aha.addAhaSvcProv('0.cell')}
|
|
218
|
+
async with self.getTestCell(dirn=cell0_dirn, conf=conf) as cell:
|
|
205
219
|
|
|
206
220
|
await wait00.wait(timeout=2)
|
|
207
221
|
|
|
208
222
|
with self.raises(s_exc.NoSuchName):
|
|
209
223
|
await s_telepath.getAhaProxy({'host': 'hehe.haha'})
|
|
210
224
|
|
|
211
|
-
async with await s_telepath.openurl('aha://
|
|
225
|
+
async with await s_telepath.openurl('aha://cell...') as proxy:
|
|
212
226
|
self.nn(await proxy.getCellIden())
|
|
213
227
|
|
|
214
228
|
with self.raises(s_exc.BadArg):
|
|
215
|
-
_proxy = await
|
|
216
|
-
await _proxy.modAhaSvcInfo('
|
|
229
|
+
_proxy = await cell.ahaclient.proxy(timeout=2)
|
|
230
|
+
await _proxy.modAhaSvcInfo('cell...', {'newp': 'newp'})
|
|
217
231
|
|
|
218
|
-
async with await s_telepath.openurl('aha://0.
|
|
232
|
+
async with await s_telepath.openurl('aha://0.cell...') as proxy:
|
|
219
233
|
self.nn(await proxy.getCellIden())
|
|
220
234
|
|
|
221
235
|
# force a reconnect...
|
|
222
|
-
proxy = await
|
|
236
|
+
proxy = await cell.ahaclient.proxy(timeout=2)
|
|
223
237
|
async with aha.waiter(2 * replaymult, 'aha:svcadd'):
|
|
224
238
|
await proxy.fini()
|
|
225
239
|
|
|
226
|
-
async with await s_telepath.openurl('aha://
|
|
240
|
+
async with await s_telepath.openurl('aha://cell...') as proxy:
|
|
227
241
|
self.nn(await proxy.getCellIden())
|
|
228
242
|
|
|
229
243
|
# force the service into passive mode...
|
|
230
244
|
async with aha.waiter(3 * replaymult, 'aha:svcdown', 'aha:svcadd', timeout=6):
|
|
231
|
-
await
|
|
245
|
+
await cell.setCellActive(False)
|
|
232
246
|
|
|
233
247
|
with self.raises(s_exc.NoSuchName):
|
|
234
|
-
async with await s_telepath.openurl('aha://
|
|
248
|
+
async with await s_telepath.openurl('aha://cell...') as proxy:
|
|
235
249
|
pass
|
|
236
250
|
|
|
237
|
-
async with await s_telepath.openurl('aha://0.
|
|
251
|
+
async with await s_telepath.openurl('aha://0.cell...') as proxy:
|
|
238
252
|
self.nn(await proxy.getCellIden())
|
|
239
253
|
|
|
240
254
|
async with aha.waiter(1 * replaymult, 'aha:svcadd', timeout=6):
|
|
241
|
-
await
|
|
255
|
+
await cell.setCellActive(True)
|
|
242
256
|
|
|
243
|
-
async with await s_telepath.openurl('aha://
|
|
257
|
+
async with await s_telepath.openurl('aha://cell...') as proxy:
|
|
244
258
|
self.nn(await proxy.getCellIden())
|
|
245
259
|
|
|
246
260
|
wait01 = aha.waiter(2 * replaymult, 'aha:svcadd')
|
|
247
261
|
|
|
248
|
-
conf = {'aha:provision': await aha.addAhaSvcProv('0.
|
|
249
|
-
async with self.
|
|
262
|
+
conf = {'aha:provision': await aha.addAhaSvcProv('0.cell')}
|
|
263
|
+
async with self.getTestCell(ctor=PathAwareCell, conf=conf) as cell:
|
|
250
264
|
|
|
251
|
-
info = await
|
|
265
|
+
info = await cell.getCellInfo()
|
|
266
|
+
celliden = info['cell']['iden']
|
|
252
267
|
|
|
253
|
-
self.eq(info['cell']['aha'], {'name': '0.
|
|
268
|
+
self.eq(info['cell']['aha'], {'name': '0.cell', 'leader': 'cell', 'network': 'synapse'})
|
|
254
269
|
|
|
255
270
|
await wait01.wait(timeout=2)
|
|
256
271
|
|
|
257
|
-
async with await s_telepath.openurl('aha://
|
|
258
|
-
self.
|
|
272
|
+
async with await s_telepath.openurl('aha://cell.synapse') as proxy:
|
|
273
|
+
self.eq(celliden, await proxy.getCellIden())
|
|
259
274
|
|
|
260
|
-
async with await s_telepath.openurl('aha://0.
|
|
261
|
-
self.
|
|
262
|
-
await proxy.puts('hehe', ('hehe', 'haha'))
|
|
275
|
+
async with await s_telepath.openurl('aha://0.cell.synapse') as proxy:
|
|
276
|
+
self.eq(celliden, await proxy.getCellIden())
|
|
263
277
|
|
|
264
|
-
async with await s_telepath.openurl('aha://0.
|
|
265
|
-
self.
|
|
278
|
+
async with await s_telepath.openurl('aha://0.cell.synapse/*/hehe/haha') as proxy:
|
|
279
|
+
self.eq(celliden, await proxy.getCellIden())
|
|
280
|
+
self.eq(('hehe', 'haha'), await proxy.getTestPath())
|
|
266
281
|
|
|
267
282
|
async with aha.getLocalProxy() as ahaproxy:
|
|
268
283
|
|
|
269
284
|
svcs = [x async for x in ahaproxy.getAhaSvcs('synapse')]
|
|
270
285
|
self.len(2, svcs)
|
|
271
286
|
names = [s['name'] for s in svcs]
|
|
272
|
-
self.sorteq(('
|
|
287
|
+
self.sorteq(('cell.synapse', '0.cell.synapse'), names)
|
|
273
288
|
|
|
274
289
|
self.none(await ahaproxy.getCaCert('vertex.link'))
|
|
275
290
|
cacert0 = await ahaproxy.genCaCert('vertex.link')
|
|
@@ -278,7 +293,7 @@ class AhaTest(s_test.SynTest):
|
|
|
278
293
|
self.eq(cacert0, cacert1)
|
|
279
294
|
self.eq(cacert0, await ahaproxy.getCaCert('vertex.link'))
|
|
280
295
|
|
|
281
|
-
csrpem =
|
|
296
|
+
csrpem = cell.certdir.genHostCsr('cell.vertex.link').decode()
|
|
282
297
|
|
|
283
298
|
hostcert00 = await ahaproxy.signHostCsr(csrpem)
|
|
284
299
|
hostcert01 = await ahaproxy.signHostCsr(csrpem)
|
|
@@ -287,7 +302,7 @@ class AhaTest(s_test.SynTest):
|
|
|
287
302
|
self.nn(hostcert01)
|
|
288
303
|
self.ne(hostcert00, hostcert01)
|
|
289
304
|
|
|
290
|
-
csrpem =
|
|
305
|
+
csrpem = cell.certdir.genUserCsr('visi@vertex.link').decode()
|
|
291
306
|
|
|
292
307
|
usercert00 = await ahaproxy.signUserCsr(csrpem)
|
|
293
308
|
usercert01 = await ahaproxy.signUserCsr(csrpem)
|
|
@@ -310,7 +325,7 @@ class AhaTest(s_test.SynTest):
|
|
|
310
325
|
self.eq(info.get('status'), 'ok')
|
|
311
326
|
result = info.get('result')
|
|
312
327
|
self.len(2, result)
|
|
313
|
-
self.eq({'0.
|
|
328
|
+
self.eq({'0.cell.synapse', 'cell.synapse'},
|
|
314
329
|
{svcinfo.get('name') for svcinfo in result})
|
|
315
330
|
|
|
316
331
|
async with sess.get(svcsurl, json={'network': 'synapse'}) as resp:
|
|
@@ -319,7 +334,7 @@ class AhaTest(s_test.SynTest):
|
|
|
319
334
|
self.eq(info.get('status'), 'ok')
|
|
320
335
|
result = info.get('result')
|
|
321
336
|
self.len(2, result)
|
|
322
|
-
self.eq({'0.
|
|
337
|
+
self.eq({'0.cell.synapse', 'cell.synapse'},
|
|
323
338
|
{svcinfo.get('name') for svcinfo in result})
|
|
324
339
|
|
|
325
340
|
async with sess.get(svcsurl, json={'network': 'newp'}) as resp:
|
|
@@ -351,10 +366,10 @@ class AhaTest(s_test.SynTest):
|
|
|
351
366
|
self.eq(info.get('code'), 'AuthDeny')
|
|
352
367
|
|
|
353
368
|
async with aha.getLocalProxy() as ahaproxy:
|
|
354
|
-
await ahaproxy.delAhaSvc('
|
|
355
|
-
await ahaproxy.delAhaSvc('0.
|
|
356
|
-
self.none(await ahaproxy.getAhaSvc('
|
|
357
|
-
self.none(await ahaproxy.getAhaSvc('0.
|
|
369
|
+
await ahaproxy.delAhaSvc('cell', network='synapse')
|
|
370
|
+
await ahaproxy.delAhaSvc('0.cell', network='synapse')
|
|
371
|
+
self.none(await ahaproxy.getAhaSvc('cell.synapse'))
|
|
372
|
+
self.none(await ahaproxy.getAhaSvc('0.cell.synapse'))
|
|
358
373
|
self.len(0, [s async for s in ahaproxy.getAhaSvcs()])
|
|
359
374
|
|
|
360
375
|
with self.raises(s_exc.BadArg):
|
|
@@ -431,24 +446,24 @@ class AhaTest(s_test.SynTest):
|
|
|
431
446
|
async with self.getTestAha() as aha:
|
|
432
447
|
|
|
433
448
|
wait00 = aha.waiter(1, 'aha:svcadd')
|
|
434
|
-
conf = {'aha:provision': await aha.addAhaSvcProv('0.
|
|
449
|
+
conf = {'aha:provision': await aha.addAhaSvcProv('0.cell')}
|
|
435
450
|
|
|
436
|
-
async with self.
|
|
451
|
+
async with self.getTestCell(conf=conf) as cell:
|
|
437
452
|
|
|
438
453
|
self.true(await wait00.wait(timeout=2))
|
|
439
454
|
|
|
440
|
-
async with await s_telepath.openurl('aha://0.
|
|
455
|
+
async with await s_telepath.openurl('aha://0.cell...') as proxy:
|
|
441
456
|
self.nn(await proxy.getCellIden())
|
|
442
457
|
|
|
443
|
-
proxy = await
|
|
458
|
+
proxy = await cell.ahaclient.proxy()
|
|
444
459
|
|
|
445
460
|
# avoid race to notify client...
|
|
446
|
-
async with
|
|
461
|
+
async with cell.ahaclient.waiter(1, 'tele:client:linkloop', timeout=2):
|
|
447
462
|
await aha.fini()
|
|
448
463
|
self.true(await proxy.waitfini(timeout=10))
|
|
449
464
|
|
|
450
465
|
with self.raises(asyncio.TimeoutError):
|
|
451
|
-
await
|
|
466
|
+
await cell.ahaclient.proxy(timeout=0.1)
|
|
452
467
|
|
|
453
468
|
async def test_lib_aha_onlink_fail(self):
|
|
454
469
|
|
|
@@ -463,12 +478,12 @@ class AhaTest(s_test.SynTest):
|
|
|
463
478
|
aha.testerr = True
|
|
464
479
|
wait00 = aha.waiter(1, 'aha:svcadd')
|
|
465
480
|
|
|
466
|
-
conf = {'aha:provision': await aha.addAhaSvcProv('0.
|
|
467
|
-
async with self.
|
|
481
|
+
conf = {'aha:provision': await aha.addAhaSvcProv('0.cell')}
|
|
482
|
+
async with self.getTestCell(conf=conf) as cell:
|
|
468
483
|
|
|
469
484
|
self.none(await wait00.wait(timeout=2))
|
|
470
485
|
|
|
471
|
-
svc = await aha.getAhaSvc('0.
|
|
486
|
+
svc = await aha.getAhaSvc('0.cell...')
|
|
472
487
|
self.none(svc)
|
|
473
488
|
|
|
474
489
|
wait01 = aha.waiter(1 * replaymult, 'aha:svcadd')
|
|
@@ -476,11 +491,11 @@ class AhaTest(s_test.SynTest):
|
|
|
476
491
|
|
|
477
492
|
self.nn(await wait01.wait(timeout=2))
|
|
478
493
|
|
|
479
|
-
svc = await aha.getAhaSvc('0.
|
|
494
|
+
svc = await aha.getAhaSvc('0.cell...')
|
|
480
495
|
self.nn(svc)
|
|
481
496
|
self.nn(svc.get('svcinfo', {}).get('online'))
|
|
482
497
|
|
|
483
|
-
async with await s_telepath.openurl('aha://0.
|
|
498
|
+
async with await s_telepath.openurl('aha://0.cell...') as proxy:
|
|
484
499
|
self.nn(await proxy.getCellIden())
|
|
485
500
|
|
|
486
501
|
async def test_lib_aha_bootstrap(self):
|
synapse/tests/test_lib_ast.py
CHANGED
|
@@ -3095,6 +3095,9 @@ class AstTest(s_test.SynTest):
|
|
|
3095
3095
|
with self.raises(s_exc.StormRuntimeError):
|
|
3096
3096
|
self.len(1, await core.nodes('inet:ipv4=1.2.3.4 <(seen)- *=woot'))
|
|
3097
3097
|
|
|
3098
|
+
with self.raises(s_exc.NoSuchForm):
|
|
3099
|
+
self.len(1, await core.nodes('$foo=(null) inet:ipv4=1.2.3.4 <(seen)- $foo'))
|
|
3100
|
+
|
|
3098
3101
|
self.len(1, await core.nodes('inet:ipv4=1.2.3.4 <(seen)- *'))
|
|
3099
3102
|
self.len(1, await core.nodes('inet:ipv4=1.2.3.4 <(seen)- meta:source'))
|
|
3100
3103
|
self.len(1, await core.nodes('inet:ipv4=1.2.3.4 <(seen)- meta:source:name'))
|
synapse/tests/test_lib_cell.py
CHANGED
|
@@ -1587,22 +1587,22 @@ class CellTest(s_t_utils.SynTest):
|
|
|
1587
1587
|
|
|
1588
1588
|
with self.getTestDir() as dirn:
|
|
1589
1589
|
|
|
1590
|
-
async with self.
|
|
1590
|
+
async with self.getTestCell(dirn=dirn) as cell:
|
|
1591
1591
|
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1592
|
+
cell.certdir.genCaCert('localca')
|
|
1593
|
+
cell.certdir.genHostCert('localhost', signas='localca')
|
|
1594
|
+
cell.certdir.genUserCert('root@localhost', signas='localca')
|
|
1595
|
+
cell.certdir.genUserCert('newp@localhost', signas='localca')
|
|
1596
1596
|
|
|
1597
|
-
root = await
|
|
1597
|
+
root = await cell.auth.addUser('root@localhost')
|
|
1598
1598
|
await root.setAdmin(True)
|
|
1599
1599
|
|
|
1600
|
-
async with self.
|
|
1600
|
+
async with self.getTestCell(dirn=dirn) as cell:
|
|
1601
1601
|
|
|
1602
|
-
addr, port = await
|
|
1602
|
+
addr, port = await cell.dmon.listen('ssl://0.0.0.0:0?hostname=localhost&ca=localca')
|
|
1603
1603
|
|
|
1604
1604
|
async with await s_telepath.openurl(f'ssl://root@127.0.0.1:{port}?hostname=localhost') as proxy:
|
|
1605
|
-
self.eq(
|
|
1605
|
+
self.eq(cell.iden, await proxy.getCellIden())
|
|
1606
1606
|
|
|
1607
1607
|
with self.raises(s_exc.BadCertHost):
|
|
1608
1608
|
url = f'ssl://root@127.0.0.1:{port}?hostname=borked.localhost'
|
|
@@ -1616,12 +1616,12 @@ class CellTest(s_t_utils.SynTest):
|
|
|
1616
1616
|
self.eq(cm.exception.get('username'), 'newp@localhost')
|
|
1617
1617
|
|
|
1618
1618
|
# add newp
|
|
1619
|
-
unfo = await
|
|
1619
|
+
unfo = await cell.addUser('newp@localhost')
|
|
1620
1620
|
async with await s_telepath.openurl(f'ssl://newp@127.0.0.1:{port}?hostname=localhost') as proxy:
|
|
1621
|
-
self.eq(
|
|
1621
|
+
self.eq(cell.iden, await proxy.getCellIden())
|
|
1622
1622
|
|
|
1623
1623
|
# Lock newp
|
|
1624
|
-
await
|
|
1624
|
+
await cell.setUserLocked(unfo.get('iden'), True)
|
|
1625
1625
|
with self.raises(s_exc.AuthDeny) as cm:
|
|
1626
1626
|
url = f'ssl://newp@127.0.0.1:{port}?hostname=localhost'
|
|
1627
1627
|
async with await s_telepath.openurl(url) as proxy:
|