synapse 2.189.0__py311-none-any.whl → 2.190.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/cortex.py +25 -5
- synapse/lib/storm.py +5 -1
- synapse/lib/stormhttp.py +3 -10
- synapse/lib/stormtypes.py +27 -17
- synapse/lib/version.py +2 -2
- synapse/lib/view.py +2 -5
- synapse/tests/test_cortex.py +73 -22
- synapse/tests/test_lib_stormhttp.py +9 -0
- synapse/tests/test_lib_stormtypes.py +16 -1
- {synapse-2.189.0.dist-info → synapse-2.190.0.dist-info}/METADATA +2 -2
- {synapse-2.189.0.dist-info → synapse-2.190.0.dist-info}/RECORD +14 -14
- {synapse-2.189.0.dist-info → synapse-2.190.0.dist-info}/LICENSE +0 -0
- {synapse-2.189.0.dist-info → synapse-2.190.0.dist-info}/WHEEL +0 -0
- {synapse-2.189.0.dist-info → synapse-2.190.0.dist-info}/top_level.txt +0 -0
synapse/cortex.py
CHANGED
|
@@ -5830,14 +5830,18 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
|
|
|
5830
5830
|
opts = self._initStormOpts(opts)
|
|
5831
5831
|
|
|
5832
5832
|
if self.stormpool is not None and opts.get('mirror', True):
|
|
5833
|
-
extra = await self.getLogExtra(text=text)
|
|
5834
5833
|
proxy = await self._getMirrorProxy(opts)
|
|
5835
5834
|
|
|
5836
5835
|
if proxy is not None:
|
|
5837
|
-
|
|
5836
|
+
proxname = proxy._ahainfo.get('name')
|
|
5837
|
+
extra = await self.getLogExtra(mirror=proxname, hash=s_storm.queryhash(text))
|
|
5838
|
+
logger.info(f'Offloading Storm query to mirror {proxname}.', extra=extra)
|
|
5838
5839
|
|
|
5839
5840
|
mirropts = await self._getMirrorOpts(opts)
|
|
5840
5841
|
|
|
5842
|
+
mirropts.setdefault('_loginfo', {})
|
|
5843
|
+
mirropts['_loginfo']['pool:from'] = self.ahasvcname
|
|
5844
|
+
|
|
5841
5845
|
try:
|
|
5842
5846
|
return await proxy.count(text, opts=mirropts)
|
|
5843
5847
|
|
|
@@ -5911,10 +5915,15 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
|
|
|
5911
5915
|
proxy = await self._getMirrorProxy(opts)
|
|
5912
5916
|
|
|
5913
5917
|
if proxy is not None:
|
|
5914
|
-
|
|
5918
|
+
proxname = proxy._ahainfo.get('name')
|
|
5919
|
+
extra = await self.getLogExtra(mirror=proxname, hash=s_storm.queryhash(text))
|
|
5920
|
+
logger.info(f'Offloading Storm query to mirror {proxname}.', extra=extra)
|
|
5915
5921
|
|
|
5916
5922
|
mirropts = await self._getMirrorOpts(opts)
|
|
5917
5923
|
|
|
5924
|
+
mirropts.setdefault('_loginfo', {})
|
|
5925
|
+
mirropts['_loginfo']['pool:from'] = self.ahasvcname
|
|
5926
|
+
|
|
5918
5927
|
try:
|
|
5919
5928
|
async for mesg in proxy.storm(text, opts=mirropts):
|
|
5920
5929
|
yield mesg
|
|
@@ -5941,10 +5950,15 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
|
|
|
5941
5950
|
proxy = await self._getMirrorProxy(opts)
|
|
5942
5951
|
|
|
5943
5952
|
if proxy is not None:
|
|
5944
|
-
|
|
5953
|
+
proxname = proxy._ahainfo.get('name')
|
|
5954
|
+
extra = await self.getLogExtra(mirror=proxname, hash=s_storm.queryhash(text))
|
|
5955
|
+
logger.info(f'Offloading Storm query to mirror {proxname}.', extra=extra)
|
|
5945
5956
|
|
|
5946
5957
|
mirropts = await self._getMirrorOpts(opts)
|
|
5947
5958
|
|
|
5959
|
+
mirropts.setdefault('_loginfo', {})
|
|
5960
|
+
mirropts['_loginfo']['pool:from'] = self.ahasvcname
|
|
5961
|
+
|
|
5948
5962
|
try:
|
|
5949
5963
|
return await proxy.callStorm(text, opts=mirropts)
|
|
5950
5964
|
except s_exc.TimeOut:
|
|
@@ -5966,10 +5980,15 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
|
|
|
5966
5980
|
proxy = await self._getMirrorProxy(opts)
|
|
5967
5981
|
|
|
5968
5982
|
if proxy is not None:
|
|
5969
|
-
|
|
5983
|
+
proxname = proxy._ahainfo.get('name')
|
|
5984
|
+
extra = await self.getLogExtra(mirror=proxname, hash=s_storm.queryhash(text))
|
|
5985
|
+
logger.info(f'Offloading Storm query to mirror {proxname}.', extra=extra)
|
|
5970
5986
|
|
|
5971
5987
|
mirropts = await self._getMirrorOpts(opts)
|
|
5972
5988
|
|
|
5989
|
+
mirropts.setdefault('_loginfo', {})
|
|
5990
|
+
mirropts['_loginfo']['pool:from'] = self.ahasvcname
|
|
5991
|
+
|
|
5973
5992
|
try:
|
|
5974
5993
|
async for mesg in proxy.exportStorm(text, opts=mirropts):
|
|
5975
5994
|
yield mesg
|
|
@@ -6152,6 +6171,7 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
|
|
|
6152
6171
|
info['text'] = text
|
|
6153
6172
|
info['username'] = user.name
|
|
6154
6173
|
info['user'] = user.iden
|
|
6174
|
+
info['hash'] = s_storm.queryhash(text)
|
|
6155
6175
|
stormlogger.log(self.stormloglvl, 'Executing storm query {%s} as [%s]', text, user.name,
|
|
6156
6176
|
extra={'synapse': info})
|
|
6157
6177
|
|
synapse/lib/storm.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import types
|
|
2
2
|
import pprint
|
|
3
3
|
import asyncio
|
|
4
|
+
import hashlib
|
|
4
5
|
import logging
|
|
5
6
|
import argparse
|
|
6
7
|
import contextlib
|
|
@@ -18,7 +19,6 @@ import synapse.lib.chop as s_chop
|
|
|
18
19
|
import synapse.lib.coro as s_coro
|
|
19
20
|
import synapse.lib.node as s_node
|
|
20
21
|
import synapse.lib.snap as s_snap
|
|
21
|
-
import synapse.lib.time as s_time
|
|
22
22
|
import synapse.lib.cache as s_cache
|
|
23
23
|
import synapse.lib.layer as s_layer
|
|
24
24
|
import synapse.lib.scope as s_scope
|
|
@@ -1681,6 +1681,10 @@ stormcmds = (
|
|
|
1681
1681
|
},
|
|
1682
1682
|
)
|
|
1683
1683
|
|
|
1684
|
+
@s_cache.memoize(size=1024)
|
|
1685
|
+
def queryhash(text):
|
|
1686
|
+
return hashlib.md5(text.encode(errors='surrogatepass'), usedforsecurity=False).hexdigest()
|
|
1687
|
+
|
|
1684
1688
|
class DmonManager(s_base.Base):
|
|
1685
1689
|
'''
|
|
1686
1690
|
Manager for StormDmon objects.
|
synapse/lib/stormhttp.py
CHANGED
|
@@ -292,13 +292,6 @@ class LibHttp(s_stormtypes.Lib):
|
|
|
292
292
|
'codereason': self.codereason,
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
-
def strify(self, item):
|
|
296
|
-
if isinstance(item, (list, tuple)):
|
|
297
|
-
return [(str(k), str(v)) for (k, v) in item]
|
|
298
|
-
elif isinstance(item, dict):
|
|
299
|
-
return {str(k): str(v) for k, v in item.items()}
|
|
300
|
-
return item
|
|
301
|
-
|
|
302
295
|
@s_stormtypes.stormfunc(readonly=True)
|
|
303
296
|
async def urlencode(self, text):
|
|
304
297
|
text = await s_stormtypes.tostr(text)
|
|
@@ -341,7 +334,7 @@ class LibHttp(s_stormtypes.Lib):
|
|
|
341
334
|
ssl_verify = await s_stormtypes.tobool(ssl_verify, noneok=True)
|
|
342
335
|
ssl_opts = await s_stormtypes.toprim(ssl_opts)
|
|
343
336
|
|
|
344
|
-
headers =
|
|
337
|
+
headers = s_stormtypes.strifyHttpArg(headers)
|
|
345
338
|
|
|
346
339
|
sock = await WebSocket.anit()
|
|
347
340
|
|
|
@@ -410,9 +403,9 @@ class LibHttp(s_stormtypes.Lib):
|
|
|
410
403
|
|
|
411
404
|
kwargs = {'allow_redirects': allow_redirects}
|
|
412
405
|
if params:
|
|
413
|
-
kwargs['params'] =
|
|
406
|
+
kwargs['params'] = s_stormtypes.strifyHttpArg(params, multi=True)
|
|
414
407
|
|
|
415
|
-
headers =
|
|
408
|
+
headers = s_stormtypes.strifyHttpArg(headers)
|
|
416
409
|
|
|
417
410
|
if proxy is not None:
|
|
418
411
|
self.runt.confirm(('storm', 'lib', 'inet', 'http', 'proxy'))
|
synapse/lib/stormtypes.py
CHANGED
|
@@ -60,6 +60,19 @@ def confirmEasyPerm(item, perm, mesg=None):
|
|
|
60
60
|
def allowedEasyPerm(item, perm):
|
|
61
61
|
return s_scope.get('runt').allowedEasyPerm(item, perm)
|
|
62
62
|
|
|
63
|
+
def strifyHttpArg(item, multi=False):
|
|
64
|
+
if isinstance(item, (list, tuple)):
|
|
65
|
+
return [(str(k), str(v)) for (k, v) in item]
|
|
66
|
+
elif isinstance(item, dict):
|
|
67
|
+
retn = {}
|
|
68
|
+
for name, valu in item.items():
|
|
69
|
+
if isinstance(valu, (list, tuple)) and multi:
|
|
70
|
+
retn[str(name)] = [str(v) for v in valu]
|
|
71
|
+
else:
|
|
72
|
+
retn[str(name)] = str(valu)
|
|
73
|
+
return retn
|
|
74
|
+
return item
|
|
75
|
+
|
|
63
76
|
class StormTypesRegistry:
|
|
64
77
|
# The following types are currently undefined.
|
|
65
78
|
base_undefined_types = (
|
|
@@ -2306,13 +2319,6 @@ class LibAxon(Lib):
|
|
|
2306
2319
|
'hashset': self.hashset,
|
|
2307
2320
|
}
|
|
2308
2321
|
|
|
2309
|
-
def strify(self, item):
|
|
2310
|
-
if isinstance(item, (list, tuple)):
|
|
2311
|
-
return [(str(k), str(v)) for (k, v) in item]
|
|
2312
|
-
elif isinstance(item, dict):
|
|
2313
|
-
return {str(k): str(v) for k, v in item.items()}
|
|
2314
|
-
return item
|
|
2315
|
-
|
|
2316
2322
|
@stormfunc(readonly=True)
|
|
2317
2323
|
async def readlines(self, sha256, errors='ignore'):
|
|
2318
2324
|
if not self.runt.allowed(('axon', 'get')):
|
|
@@ -2384,8 +2390,8 @@ class LibAxon(Lib):
|
|
|
2384
2390
|
if proxy is not None:
|
|
2385
2391
|
self.runt.confirm(('storm', 'lib', 'inet', 'http', 'proxy'))
|
|
2386
2392
|
|
|
2387
|
-
params =
|
|
2388
|
-
headers =
|
|
2393
|
+
params = strifyHttpArg(params, multi=True)
|
|
2394
|
+
headers = strifyHttpArg(headers)
|
|
2389
2395
|
|
|
2390
2396
|
await self.runt.snap.core.getAxon()
|
|
2391
2397
|
|
|
@@ -2423,8 +2429,8 @@ class LibAxon(Lib):
|
|
|
2423
2429
|
timeout = await toprim(timeout)
|
|
2424
2430
|
ssl_opts = await toprim(ssl_opts)
|
|
2425
2431
|
|
|
2426
|
-
params =
|
|
2427
|
-
headers =
|
|
2432
|
+
params = strifyHttpArg(params, multi=True)
|
|
2433
|
+
headers = strifyHttpArg(headers)
|
|
2428
2434
|
|
|
2429
2435
|
if proxy is not None:
|
|
2430
2436
|
self.runt.confirm(('storm', 'lib', 'inet', 'http', 'proxy'))
|
|
@@ -5008,9 +5014,12 @@ class List(Prim):
|
|
|
5008
5014
|
{'name': 'valu', 'type': 'any', 'desc': 'The value to check.', },
|
|
5009
5015
|
),
|
|
5010
5016
|
'returns': {'type': 'boolean', 'desc': 'True if the item is in the list, false otherwise.', }}},
|
|
5011
|
-
{'name': 'pop', 'desc': 'Pop and return the
|
|
5017
|
+
{'name': 'pop', 'desc': 'Pop and return the entry at the specified index in the list. If no index is specified, pop the last entry.',
|
|
5012
5018
|
'type': {'type': 'function', '_funcname': '_methListPop',
|
|
5013
|
-
'
|
|
5019
|
+
'args': (
|
|
5020
|
+
{'name': 'index', 'type': 'int', 'desc': 'Index of entry to pop.', 'default': -1},
|
|
5021
|
+
),
|
|
5022
|
+
'returns': {'type': 'any', 'desc': 'The entry at the specified index in the list.', }}},
|
|
5014
5023
|
{'name': 'size', 'desc': 'Return the length of the list.',
|
|
5015
5024
|
'type': {'type': 'function', '_funcname': '_methListSize',
|
|
5016
5025
|
'returns': {'type': 'int', 'desc': 'The size of the list.', }}},
|
|
@@ -5153,11 +5162,12 @@ class List(Prim):
|
|
|
5153
5162
|
return prim in self.valu
|
|
5154
5163
|
|
|
5155
5164
|
@stormfunc(readonly=True)
|
|
5156
|
-
async def _methListPop(self):
|
|
5165
|
+
async def _methListPop(self, index=-1):
|
|
5166
|
+
index = await toint(index)
|
|
5157
5167
|
try:
|
|
5158
|
-
return self.valu.pop()
|
|
5159
|
-
except IndexError:
|
|
5160
|
-
mesg =
|
|
5168
|
+
return self.valu.pop(index)
|
|
5169
|
+
except IndexError as exc:
|
|
5170
|
+
mesg = str(exc)
|
|
5161
5171
|
raise s_exc.StormRuntimeError(mesg=mesg)
|
|
5162
5172
|
|
|
5163
5173
|
@stormfunc(readonly=True)
|
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, 190, 0)
|
|
227
227
|
verstring = '.'.join([str(x) for x in version])
|
|
228
|
-
commit = '
|
|
228
|
+
commit = 'ea92cb42c33f8793e9d72834aa8d12b6456eee8b'
|
synapse/lib/view.py
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import shutil
|
|
2
2
|
import asyncio
|
|
3
|
-
import hashlib
|
|
4
3
|
import logging
|
|
5
|
-
import itertools
|
|
6
4
|
import collections
|
|
7
5
|
|
|
8
6
|
import synapse.exc as s_exc
|
|
9
7
|
import synapse.common as s_common
|
|
10
8
|
|
|
11
9
|
import synapse.lib.cell as s_cell
|
|
12
|
-
import synapse.lib.coro as s_coro
|
|
13
10
|
import synapse.lib.snap as s_snap
|
|
14
11
|
import synapse.lib.layer as s_layer
|
|
15
12
|
import synapse.lib.nexus as s_nexus
|
|
16
13
|
import synapse.lib.scope as s_scope
|
|
17
|
-
import synapse.lib.
|
|
14
|
+
import synapse.lib.storm as s_storm
|
|
18
15
|
import synapse.lib.scrape as s_scrape
|
|
19
16
|
import synapse.lib.msgpack as s_msgpack
|
|
20
17
|
import synapse.lib.schemas as s_schemas
|
|
@@ -1004,7 +1001,7 @@ class View(s_nexus.Pusher): # type: ignore
|
|
|
1004
1001
|
if editformat not in ('nodeedits', 'count', 'none'):
|
|
1005
1002
|
raise s_exc.BadConfValu(mesg=f'invalid edit format, got {editformat}', name='editformat', valu=editformat)
|
|
1006
1003
|
|
|
1007
|
-
texthash =
|
|
1004
|
+
texthash = s_storm.queryhash(text)
|
|
1008
1005
|
|
|
1009
1006
|
async def runStorm():
|
|
1010
1007
|
cancelled = False
|
synapse/tests/test_cortex.py
CHANGED
|
@@ -5,7 +5,6 @@ import time
|
|
|
5
5
|
import asyncio
|
|
6
6
|
import hashlib
|
|
7
7
|
import logging
|
|
8
|
-
import textwrap
|
|
9
8
|
|
|
10
9
|
import regex
|
|
11
10
|
|
|
@@ -16,13 +15,13 @@ import synapse.common as s_common
|
|
|
16
15
|
import synapse.cortex as s_cortex
|
|
17
16
|
import synapse.telepath as s_telepath
|
|
18
17
|
|
|
19
|
-
import synapse.lib.aha as s_aha
|
|
20
18
|
import synapse.lib.base as s_base
|
|
21
19
|
import synapse.lib.cell as s_cell
|
|
22
20
|
import synapse.lib.coro as s_coro
|
|
23
21
|
import synapse.lib.node as s_node
|
|
24
22
|
import synapse.lib.time as s_time
|
|
25
23
|
import synapse.lib.layer as s_layer
|
|
24
|
+
import synapse.lib.storm as s_storm
|
|
26
25
|
import synapse.lib.output as s_output
|
|
27
26
|
import synapse.lib.msgpack as s_msgpack
|
|
28
27
|
import synapse.lib.version as s_version
|
|
@@ -37,6 +36,10 @@ from synapse.tests.utils import alist
|
|
|
37
36
|
|
|
38
37
|
logger = logging.getLogger(__name__)
|
|
39
38
|
|
|
39
|
+
def jsonlines(text):
|
|
40
|
+
lines = [k for k in text.split('\n') if k]
|
|
41
|
+
return [json.loads(line) for line in lines]
|
|
42
|
+
|
|
40
43
|
class CortexTest(s_t_utils.SynTest):
|
|
41
44
|
'''
|
|
42
45
|
The tests that should be run with different types of layers
|
|
@@ -8072,6 +8075,8 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
8072
8075
|
|
|
8073
8076
|
async with self.getTestAha() as aha:
|
|
8074
8077
|
|
|
8078
|
+
ahanet = aha.conf.req('aha:network')
|
|
8079
|
+
|
|
8075
8080
|
async with await s_base.Base.anit() as base:
|
|
8076
8081
|
|
|
8077
8082
|
with self.getTestDir() as dirn:
|
|
@@ -8107,43 +8112,89 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
8107
8112
|
self.stormIsInPrint('Storm pool configuration set.', msgs)
|
|
8108
8113
|
|
|
8109
8114
|
await core00.fini()
|
|
8115
|
+
await core01.fini()
|
|
8110
8116
|
|
|
8111
8117
|
core00 = await base.enter_context(self.getTestCore(dirn=dirn00))
|
|
8118
|
+
core01 = await base.enter_context(self.getTestCore(dirn=dirn01, conf={'storm:log': True}))
|
|
8112
8119
|
|
|
8113
8120
|
await core00.stormpool.waitready(timeout=12)
|
|
8114
8121
|
|
|
8115
|
-
|
|
8116
|
-
|
|
8122
|
+
# storm()
|
|
8123
|
+
q = 'inet:asn=0'
|
|
8124
|
+
qhash = s_storm.queryhash(q)
|
|
8125
|
+
with self.getStructuredAsyncLoggerStream('synapse') as stream:
|
|
8126
|
+
msgs = await alist(core00.storm(q))
|
|
8117
8127
|
self.len(1, [m for m in msgs if m[0] == 'node'])
|
|
8118
8128
|
|
|
8119
|
-
stream.
|
|
8120
|
-
data = stream.read()
|
|
8121
|
-
self.isin('Offloading Storm query', data)
|
|
8129
|
+
data = stream.getvalue()
|
|
8122
8130
|
self.notin('Timeout', data)
|
|
8131
|
+
msgs = jsonlines(data)
|
|
8132
|
+
self.len(2, msgs)
|
|
8123
8133
|
|
|
8124
|
-
|
|
8125
|
-
|
|
8134
|
+
self.eq(msgs[0].get('message'), f'Offloading Storm query to mirror 01.core.{ahanet}.')
|
|
8135
|
+
self.eq(msgs[0].get('hash'), qhash)
|
|
8136
|
+
self.eq(msgs[0].get('mirror'), f'01.core.{ahanet}')
|
|
8126
8137
|
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
self.
|
|
8138
|
+
self.eq(msgs[1].get('message'), f'Executing storm query {{{q}}} as [root]')
|
|
8139
|
+
self.eq(msgs[1].get('hash'), qhash)
|
|
8140
|
+
self.eq(msgs[1].get('pool:from'), f'00.core.{ahanet}')
|
|
8141
|
+
|
|
8142
|
+
# callStorm()
|
|
8143
|
+
q = 'inet:asn=0 return($lib.true)'
|
|
8144
|
+
qhash = s_storm.queryhash(q)
|
|
8145
|
+
with self.getStructuredAsyncLoggerStream('synapse') as stream:
|
|
8146
|
+
self.true(await core00.callStorm(q))
|
|
8147
|
+
|
|
8148
|
+
data = stream.getvalue()
|
|
8130
8149
|
self.notin('Timeout', data)
|
|
8150
|
+
msgs = jsonlines(data)
|
|
8151
|
+
self.len(2, msgs)
|
|
8131
8152
|
|
|
8132
|
-
|
|
8133
|
-
|
|
8153
|
+
self.eq(msgs[0].get('message'), f'Offloading Storm query to mirror 01.core.{ahanet}.')
|
|
8154
|
+
self.eq(msgs[0].get('hash'), qhash)
|
|
8155
|
+
self.eq(msgs[0].get('mirror'), f'01.core.{ahanet}')
|
|
8134
8156
|
|
|
8135
|
-
|
|
8136
|
-
|
|
8137
|
-
self.
|
|
8157
|
+
self.eq(msgs[1].get('message'), f'Executing storm query {{{q}}} as [root]')
|
|
8158
|
+
self.eq(msgs[1].get('hash'), qhash)
|
|
8159
|
+
self.eq(msgs[1].get('pool:from'), f'00.core.{ahanet}')
|
|
8160
|
+
|
|
8161
|
+
# exportStorm()
|
|
8162
|
+
q = 'inet:asn=0'
|
|
8163
|
+
qhash = s_storm.queryhash(q)
|
|
8164
|
+
with self.getStructuredAsyncLoggerStream('synapse') as stream:
|
|
8165
|
+
self.len(1, await alist(core00.exportStorm(q)))
|
|
8166
|
+
|
|
8167
|
+
data = stream.getvalue()
|
|
8138
8168
|
self.notin('Timeout', data)
|
|
8169
|
+
msgs = jsonlines(data)
|
|
8170
|
+
self.len(2, msgs)
|
|
8139
8171
|
|
|
8140
|
-
|
|
8141
|
-
|
|
8172
|
+
self.eq(msgs[0].get('message'), f'Offloading Storm query to mirror 01.core.{ahanet}.')
|
|
8173
|
+
self.eq(msgs[0].get('hash'), qhash)
|
|
8174
|
+
self.eq(msgs[0].get('mirror'), f'01.core.{ahanet}')
|
|
8142
8175
|
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
self.
|
|
8176
|
+
self.eq(msgs[1].get('message'), f'Executing storm query {{{q}}} as [root]')
|
|
8177
|
+
self.eq(msgs[1].get('hash'), qhash)
|
|
8178
|
+
self.eq(msgs[1].get('pool:from'), f'00.core.{ahanet}')
|
|
8179
|
+
|
|
8180
|
+
# count()
|
|
8181
|
+
q = 'inet:asn=0'
|
|
8182
|
+
qhash = s_storm.queryhash(q)
|
|
8183
|
+
with self.getStructuredAsyncLoggerStream('synapse') as stream:
|
|
8184
|
+
self.eq(1, await core00.count(q))
|
|
8185
|
+
|
|
8186
|
+
data = stream.getvalue()
|
|
8146
8187
|
self.notin('Timeout', data)
|
|
8188
|
+
msgs = jsonlines(data)
|
|
8189
|
+
self.len(2, msgs)
|
|
8190
|
+
|
|
8191
|
+
self.eq(msgs[0].get('message'), f'Offloading Storm query to mirror 01.core.{ahanet}.')
|
|
8192
|
+
self.eq(msgs[0].get('hash'), qhash)
|
|
8193
|
+
self.eq(msgs[0].get('mirror'), f'01.core.{ahanet}')
|
|
8194
|
+
|
|
8195
|
+
self.eq(msgs[1].get('message'), f'Executing storm query {{{q}}} as [root]')
|
|
8196
|
+
self.eq(msgs[1].get('hash'), qhash)
|
|
8197
|
+
self.eq(msgs[1].get('pool:from'), f'00.core.{ahanet}')
|
|
8147
8198
|
|
|
8148
8199
|
with patch('synapse.cortex.CoreApi.getNexsIndx', _hang):
|
|
8149
8200
|
|
|
@@ -464,6 +464,15 @@ class StormHttpTest(s_test.SynTest):
|
|
|
464
464
|
self.isin('mesg', errinfo)
|
|
465
465
|
self.eq('', errinfo.get('mesg')) # timeouterror has no mesg
|
|
466
466
|
|
|
467
|
+
q = '''
|
|
468
|
+
$params=({"foo": ["bar", "baz"], "key": [["valu"]]})
|
|
469
|
+
$resp = $lib.inet.http.request(GET, $url, params=$params, ssl_verify=$lib.false)
|
|
470
|
+
return ( $resp.json() )
|
|
471
|
+
'''
|
|
472
|
+
resp = await core.callStorm(q, opts=opts)
|
|
473
|
+
data = resp.get('result')
|
|
474
|
+
self.eq(data.get('params'), {'foo': ['bar', 'baz'], 'key': ["('valu',)"]})
|
|
475
|
+
|
|
467
476
|
async def test_storm_http_post(self):
|
|
468
477
|
|
|
469
478
|
async with self.getTestCore() as core:
|
|
@@ -1665,8 +1665,23 @@ class StormTypesTest(s_test.SynTest):
|
|
|
1665
1665
|
self.eq('bar', await core.callStorm('$foo = (foo, bar) return($foo.1)'))
|
|
1666
1666
|
self.eq('foo', await core.callStorm('$foo = (foo, bar) return($foo."-2")'))
|
|
1667
1667
|
self.eq('bar', await core.callStorm('$foo = (foo, bar) return($foo.pop())'))
|
|
1668
|
-
|
|
1668
|
+
|
|
1669
|
+
self.eq(3, await core.callStorm('$list = ([1, 2, 3, 4]) return($list.pop(2))'))
|
|
1670
|
+
self.eq(2, await core.callStorm('$list = ([1, 2, 3, 4]) return($list.pop(-3))'))
|
|
1671
|
+
self.eq(4, await core.callStorm('$list = ([1, 2, 3, 4]) $list.pop(2) return($list.pop(2))'))
|
|
1672
|
+
self.eq([1, 3, 4], await core.callStorm('$list = ([1, 2, 3, 4]) $list.pop(1) return($list)'))
|
|
1673
|
+
|
|
1674
|
+
with self.raises(s_exc.StormRuntimeError) as exc:
|
|
1669
1675
|
await core.callStorm('$lib.list().pop()')
|
|
1676
|
+
self.eq(exc.exception.get('mesg'), 'pop from empty list')
|
|
1677
|
+
|
|
1678
|
+
with self.raises(s_exc.StormRuntimeError) as exc:
|
|
1679
|
+
await core.callStorm('$list = ([1, 2, 3, 4]) return($list.pop(13))')
|
|
1680
|
+
self.eq(exc.exception.get('mesg'), 'pop index out of range')
|
|
1681
|
+
|
|
1682
|
+
with self.raises(s_exc.StormRuntimeError) as exc:
|
|
1683
|
+
await core.callStorm('$list = ([1, 2, 3, 4]) return($list.pop(-5))')
|
|
1684
|
+
self.eq(exc.exception.get('mesg'), 'pop index out of range')
|
|
1670
1685
|
|
|
1671
1686
|
somelist = ["foo", "bar", "baz", "bar"]
|
|
1672
1687
|
q = '''
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: synapse
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.190.0
|
|
4
4
|
Summary: Synapse Intelligence Analysis Framework
|
|
5
5
|
Author-email: The Vertex Project LLC <root@vertex.link>
|
|
6
6
|
License: Apache License 2.0
|
|
@@ -19,7 +19,7 @@ Classifier: Operating System :: POSIX :: Linux
|
|
|
19
19
|
Requires-Python: >=3.11
|
|
20
20
|
Description-Content-Type: text/x-rst
|
|
21
21
|
License-File: LICENSE
|
|
22
|
-
Requires-Dist: pyOpenSSL<
|
|
22
|
+
Requires-Dist: pyOpenSSL<24.3.0,>=24.0.0
|
|
23
23
|
Requires-Dist: cryptography<44.0.0,>=43.0.1
|
|
24
24
|
Requires-Dist: msgpack<1.1.0,>=1.0.5
|
|
25
25
|
Requires-Dist: xxhash<3.6.0,>=1.4.4
|
|
@@ -2,7 +2,7 @@ synapse/__init__.py,sha256=R2kOXlF5j-8m6G0JkHuN7rXRPg_tHLmbMxr__94mHQk,1145
|
|
|
2
2
|
synapse/axon.py,sha256=DQu_Ps4BDRDnmdHmqCbpd3W_91yzhdo7AzAk-wtQC3s,61520
|
|
3
3
|
synapse/cells.py,sha256=eNvdglfAoTURVhGOLGcgMXCGpfsIX1a02SQnyiklo3E,308
|
|
4
4
|
synapse/common.py,sha256=JRGiA6FCkCZP2pBc3s_H7MsQGwc9jU_vkJFQP3XpVLs,36523
|
|
5
|
-
synapse/cortex.py,sha256=
|
|
5
|
+
synapse/cortex.py,sha256=kocNlRuWikEOhjW3XAEOsGhEweD5y8PCTpu6NC2sSH4,261067
|
|
6
6
|
synapse/cryotank.py,sha256=oTbAOKq-q8WqAkYmY46Mc8hy85W3ZcQMxmP2EJDFyZ0,12124
|
|
7
7
|
synapse/daemon.py,sha256=-xy6EnmD5CodWQs_S-v7apKILECmn5EEYBpEPG-MDns,16986
|
|
8
8
|
synapse/datamodel.py,sha256=KX56d5jkvPe7rxA3xPgo28NTGsuzHSdhMv55_p3oNKY,39652
|
|
@@ -141,12 +141,12 @@ synapse/lib/slabseqn.py,sha256=LJ2SZEsZlROBAD3mdS-3JxNVVPXXkBW8GIJXsW0OGG8,10287
|
|
|
141
141
|
synapse/lib/snap.py,sha256=QfNtFHV_76ABrm7Zf7WR5kVBB-MvuZmdmDfy0n1Whlo,59880
|
|
142
142
|
synapse/lib/spooled.py,sha256=pKPacX-fvZDUTUWPaKgyct_lk_3eoSsF9Ufh_cn_1fQ,5987
|
|
143
143
|
synapse/lib/storm.lark,sha256=ItEIPItfrCT5VmaoS1vm8FWD8Wv7b7B6ZWucCJCdO6s,26517
|
|
144
|
-
synapse/lib/storm.py,sha256=
|
|
144
|
+
synapse/lib/storm.py,sha256=7eh_yQkywPz_aYva-kzf2pnIcOaee3CT3IvtejDvoBI,217044
|
|
145
145
|
synapse/lib/storm_format.py,sha256=Q8mf9QWzPljwp70BC4dYv0MGWB_YUJi3Ul4T7ReqjlQ,4818
|
|
146
146
|
synapse/lib/stormctrl.py,sha256=XvyZ6M0Ew8sXsjGvRTWbXh0MjktZrGi_zQ9kNa7AWTE,285
|
|
147
|
-
synapse/lib/stormhttp.py,sha256=
|
|
147
|
+
synapse/lib/stormhttp.py,sha256=dttA2RkZNZZYZFeYtEKApX3QrqfX6Lef_RTsOReuQeY,28693
|
|
148
148
|
synapse/lib/stormsvc.py,sha256=dKREBhzYAncOXBbI-FYLRy9VusGIbRyF0TaDDz7mMXw,7581
|
|
149
|
-
synapse/lib/stormtypes.py,sha256
|
|
149
|
+
synapse/lib/stormtypes.py,sha256=-n_Z2PKJNj6ieW0dhhZiwhiCoWxB5jR3pLc212Y1Sg0,390546
|
|
150
150
|
synapse/lib/stormwhois.py,sha256=w7N2oCyMljNvi_sRt_bZb5BJwWwYkVGcRd7H_0oHY8Q,2554
|
|
151
151
|
synapse/lib/structlog.py,sha256=qiuD7TTdwCyYEDF2f-88G2iX54SuB-lJ1pqlYokL1r8,1303
|
|
152
152
|
synapse/lib/task.py,sha256=krDjQvNh0EpAs1PILK8CJJa9DMeM0depI0K8Eimp010,5733
|
|
@@ -157,8 +157,8 @@ synapse/lib/time.py,sha256=FKTYwpdvpuAj8p8sSodRjOxoA7Vu67CIbbXz55gtghk,9231
|
|
|
157
157
|
synapse/lib/trigger.py,sha256=mnfkoBHB88JfqPoxb5oflvAaBKZpNvYdxP247YS53fE,20697
|
|
158
158
|
synapse/lib/types.py,sha256=u89ukW38oDziRzeA6IWrPwwPD0Ds75u-gwJSXsQ4loY,69708
|
|
159
159
|
synapse/lib/urlhelp.py,sha256=j-DvWGi-xH0TcO0NbCuwG7guUuiV8wxIxfMyJOzDygo,2523
|
|
160
|
-
synapse/lib/version.py,sha256=
|
|
161
|
-
synapse/lib/view.py,sha256=
|
|
160
|
+
synapse/lib/version.py,sha256=jiPB4dGqrFuZjHFoXFRFi6hZR9DSKGfBirdUtGepW5g,7162
|
|
161
|
+
synapse/lib/view.py,sha256=ugB0VUDjy2GmNaywe2C32_gzUgzdIg25LYt7zn42bTE,60530
|
|
162
162
|
synapse/lib/crypto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
163
163
|
synapse/lib/crypto/coin.py,sha256=_dhlkzIrHT8BvHdJOWK7PDThz3sK3dDRnWAUqjRpZJc,4910
|
|
164
164
|
synapse/lib/crypto/ecc.py,sha256=e5XM8fsU3YnkT9u1eNROqOK8ccjp5QirIn7FljC_z1s,6522
|
|
@@ -270,7 +270,7 @@ synapse/tests/test_cmds_boss.py,sha256=SdBwM2qJHFzzfrjWYiZOLBKeye8uru7KeJ3NU_YSk
|
|
|
270
270
|
synapse/tests/test_cmds_cortex.py,sha256=LWFz8HyuvsIGjtz2DqXYh-R-5QbiQWzLlQKqew7gabY,17157
|
|
271
271
|
synapse/tests/test_cmds_hive.py,sha256=aRH_Gh8oF_1BsfpmffyhDDNIqnTqsuF2cavdtGke1-0,5912
|
|
272
272
|
synapse/tests/test_common.py,sha256=2SAJ4M2iLdZuPPV-j16QVwE073VrikyW75cYTPRMjWI,16940
|
|
273
|
-
synapse/tests/test_cortex.py,sha256=
|
|
273
|
+
synapse/tests/test_cortex.py,sha256=OeUSP0ZpRW93C6l_tjJCJ3kSQdz2sGveo9R_bXD7oJA,357775
|
|
274
274
|
synapse/tests/test_cryotank.py,sha256=ms2VkL0aUskMi-LArTzRt8LUYw0z_y8nQfOOBDiCkvI,12027
|
|
275
275
|
synapse/tests/test_daemon.py,sha256=QqKELhm1HF0q_8Kbk0Uf9fnUg3K5nLQ7MocGIyuKKIw,7715
|
|
276
276
|
synapse/tests/test_data.py,sha256=f8L-q6kpMq8XPG3hq1jwlyaFRQEinSBf7ZlsRFeCuoM,196
|
|
@@ -332,7 +332,7 @@ synapse/tests/test_lib_snap.py,sha256=OviJtj9N5LhBV-56TySkWvRly7f8VH9d-VBcNFLAtm
|
|
|
332
332
|
synapse/tests/test_lib_spooled.py,sha256=fkLuujrDqjeJtyByptmGZvJbM9QiETCAu4r_4PdLfZg,3929
|
|
333
333
|
synapse/tests/test_lib_storm.py,sha256=mATYbEaT0IdG6J0uO3HZSMRpQ_jBZO7essqOTP9Ok08,228626
|
|
334
334
|
synapse/tests/test_lib_storm_format.py,sha256=tEZgQMmKAeG8FQZE5HUjOT7bnKawVTpNaVQh_3Wa630,277
|
|
335
|
-
synapse/tests/test_lib_stormhttp.py,sha256=
|
|
335
|
+
synapse/tests/test_lib_stormhttp.py,sha256=aHMvZTbEaM7IDVFpgYnjrqbrPFXAGRa6tHf4vxgWt0c,43002
|
|
336
336
|
synapse/tests/test_lib_stormlib_aha.py,sha256=2x3KQa64LN86wzSdJwAu3QFb5NNR3WNx1o9aD3N954o,8796
|
|
337
337
|
synapse/tests/test_lib_stormlib_auth.py,sha256=zuYPK91k8uyazjSrjcR0jMEENaeGc0ZhZD8Pk9dSAx4,59849
|
|
338
338
|
synapse/tests/test_lib_stormlib_backup.py,sha256=3ZYE3swQ4A8aYJyVueFXzbekCdoKMC7jsHLoq0hTKGI,1644
|
|
@@ -372,7 +372,7 @@ synapse/tests/test_lib_stormlib_vault.py,sha256=pE_nDisXiyb-4Zm1hOrfsuEz3bjYwR8c
|
|
|
372
372
|
synapse/tests/test_lib_stormlib_xml.py,sha256=dWa9NkXXE28VZ3bTmMDbddo7VpUKsSEHTS1ojJr-F90,3704
|
|
373
373
|
synapse/tests/test_lib_stormlib_yaml.py,sha256=egTVXk8wW31V2msF__9WxP3THcqfysG1mYhc7hQG8rw,1358
|
|
374
374
|
synapse/tests/test_lib_stormsvc.py,sha256=J5-bmS_M3nkmJtmgUjyh7_vSwEzw_TxcMwe6q5ah1e8,43887
|
|
375
|
-
synapse/tests/test_lib_stormtypes.py,sha256=
|
|
375
|
+
synapse/tests/test_lib_stormtypes.py,sha256=RQw3BE3j9c6G-NPDbWEsrMbLXKjLuh5wFfRM8dgq2ak,310734
|
|
376
376
|
synapse/tests/test_lib_stormwhois.py,sha256=AWMUYEgZ5yqvDfPC_rM4evmhgfOA_Fv5aoTjmKmN1_0,4818
|
|
377
377
|
synapse/tests/test_lib_structlog.py,sha256=DGfzrfc2nybRq5RjwiUXd1v4sC5zl8d46RHgTmFD0iA,3964
|
|
378
378
|
synapse/tests/test_lib_task.py,sha256=Zby9Evlg_mBwE3_aF7p_5PIMhWp2Er7Y-ye4Y-3L5RQ,1646
|
|
@@ -602,8 +602,8 @@ synapse/vendor/xrpl/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
|
|
|
602
602
|
synapse/vendor/xrpl/tests/test_codec.py,sha256=Zwq6A5uZUK_FWDL3BA932c5b-rL3hnC6efobWHSLC4o,6651
|
|
603
603
|
synapse/vendor/xrpl/tests/test_main.py,sha256=kZQwWk7I6HrP-PMvLdsUUN4POvWD9I-iXDHOwdeF090,4299
|
|
604
604
|
synapse/vendor/xrpl/tests/test_main_test_cases.py,sha256=vTlUM4hJD2Hd2wCIdd9rfsvcMZZZQmNHWdCTTFeGz2Y,4221
|
|
605
|
-
synapse-2.
|
|
606
|
-
synapse-2.
|
|
607
|
-
synapse-2.
|
|
608
|
-
synapse-2.
|
|
609
|
-
synapse-2.
|
|
605
|
+
synapse-2.190.0.dist-info/LICENSE,sha256=xllut76FgcGL5zbIRvuRc7aezPbvlMUTWJPsVr2Sugg,11358
|
|
606
|
+
synapse-2.190.0.dist-info/METADATA,sha256=4lqXWvhF2Caumt9QBNLcOfxqXJvl2vSUcIHlad0IPT0,4598
|
|
607
|
+
synapse-2.190.0.dist-info/WHEEL,sha256=SzIPD_RU47f7h-36tIDPOo2oz_W3FX5e2XbmWR-qLbQ,93
|
|
608
|
+
synapse-2.190.0.dist-info/top_level.txt,sha256=v_1YsqjmoSCzCKs7oIhzTNmWtSYoORiBMv1TJkOhx8A,8
|
|
609
|
+
synapse-2.190.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|