synapse 2.204.1__py311-none-any.whl → 2.206.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 +4 -4
- synapse/common.py +0 -3
- synapse/cortex.py +14 -1
- synapse/lib/aha.py +13 -8
- synapse/lib/httpapi.py +196 -97
- synapse/lib/lmdbslab.py +2 -0
- synapse/lib/modelrev.py +3 -3
- synapse/lib/schemas.py +11 -0
- synapse/lib/spooled.py +2 -1
- synapse/lib/stormlib/aha.py +5 -1
- synapse/lib/stormlib/model.py +1 -1
- synapse/lib/stormtypes.py +10 -0
- synapse/lib/version.py +2 -2
- synapse/models/base.py +9 -0
- synapse/models/economic.py +15 -2
- synapse/models/inet.py +9 -1
- synapse/models/infotech.py +7 -0
- synapse/models/risk.py +2 -0
- synapse/models/telco.py +23 -2
- synapse/tests/test_axon.py +42 -41
- synapse/tests/test_common.py +4 -23
- synapse/tests/test_cortex.py +18 -6
- synapse/tests/test_lib_aha.py +17 -0
- synapse/tests/test_lib_cell.py +5 -3
- synapse/tests/test_lib_httpapi.py +225 -33
- synapse/tests/test_lib_lmdbslab.py +30 -0
- synapse/tests/test_lib_modelrev.py +7 -7
- synapse/tests/test_lib_spooled.py +2 -0
- synapse/tests/test_lib_stormlib_aha.py +7 -7
- synapse/tests/test_lib_stormlib_cortex.py +61 -60
- synapse/tests/test_model_economic.py +3 -0
- synapse/tests/test_model_infotech.py +2 -0
- synapse/tests/test_model_telco.py +7 -2
- synapse/tests/utils.py +3 -0
- synapse/tools/aha/easycert.py +4 -0
- synapse/tools/aha/mirror.py +6 -4
- {synapse-2.204.1.dist-info → synapse-2.206.0.dist-info}/METADATA +2 -3
- {synapse-2.204.1.dist-info → synapse-2.206.0.dist-info}/RECORD +41 -41
- {synapse-2.204.1.dist-info → synapse-2.206.0.dist-info}/WHEEL +1 -1
- {synapse-2.204.1.dist-info → synapse-2.206.0.dist-info}/licenses/LICENSE +0 -0
- {synapse-2.204.1.dist-info → synapse-2.206.0.dist-info}/top_level.txt +0 -0
synapse/tests/test_common.py
CHANGED
|
@@ -80,6 +80,7 @@ class CommonTest(s_t_utils.SynTest):
|
|
|
80
80
|
self.true(s_common.vertup('30.40.50') > (9, 0))
|
|
81
81
|
|
|
82
82
|
def test_common_file_helpers(self):
|
|
83
|
+
|
|
83
84
|
# genfile
|
|
84
85
|
with self.getTestDir() as testdir:
|
|
85
86
|
fd = s_common.genfile(testdir, 'woot', 'foo.bin')
|
|
@@ -149,30 +150,10 @@ class CommonTest(s_t_utils.SynTest):
|
|
|
149
150
|
retn = tuple(s_common.listdir(dirn, glob='*.txt'))
|
|
150
151
|
self.eq(retn, ((path,)))
|
|
151
152
|
|
|
152
|
-
# getDirSize: check against du
|
|
153
153
|
real, appr = s_common.getDirSize(dirn)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
self.eq(duappr, appr)
|
|
158
|
-
|
|
159
|
-
# The following does not work in a busybox based environment,
|
|
160
|
-
# but manual testing of the getDirSize() API does confirm
|
|
161
|
-
# that the results are still as expected when run there.
|
|
162
|
-
argv = ['du', '-B', '1', '-s', dirn]
|
|
163
|
-
proc = subprocess.run(argv, capture_output=True)
|
|
164
|
-
try:
|
|
165
|
-
proc.check_returncode()
|
|
166
|
-
except subprocess.CalledProcessError as e:
|
|
167
|
-
stderr = proc.stderr.decode()
|
|
168
|
-
if 'unrecognized option: B' in stderr and 'BusyBox' in stderr:
|
|
169
|
-
logger.warning(f'Unable to run {"".join(argv)} in BusyBox.')
|
|
170
|
-
else:
|
|
171
|
-
raise
|
|
172
|
-
else:
|
|
173
|
-
durealstr = proc.stdout.decode()
|
|
174
|
-
dureal = int(durealstr.split()[0])
|
|
175
|
-
self.eq(dureal, real)
|
|
154
|
+
self.eq(real % 512, 0)
|
|
155
|
+
self.gt(real, appr)
|
|
156
|
+
self.ge(appr, len(b'woot') + len(b'nope'))
|
|
176
157
|
|
|
177
158
|
def test_common_intify(self):
|
|
178
159
|
self.eq(s_common.intify(20), 20)
|
synapse/tests/test_cortex.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import copy
|
|
3
|
+
import http
|
|
3
4
|
import time
|
|
4
5
|
import asyncio
|
|
5
6
|
import hashlib
|
|
@@ -83,6 +84,12 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
83
84
|
|
|
84
85
|
await core.nodes('[ inet:ipv4=1.2.3.4 :asn=99 .seen=now +#foo:score=10 ]')
|
|
85
86
|
|
|
87
|
+
conf = {'modules': [('NewpModule', {})]}
|
|
88
|
+
warn = '''"'modules' Cortex config value" is deprecated'''
|
|
89
|
+
with self.assertWarnsRegex(DeprecationWarning, warn) as cm:
|
|
90
|
+
async with self.getTestCore(dirn=dirn, conf=conf) as core:
|
|
91
|
+
pass
|
|
92
|
+
|
|
86
93
|
async def test_cortex_cellguid(self):
|
|
87
94
|
iden = s_common.guid()
|
|
88
95
|
conf = {'cell:guid': iden}
|
|
@@ -1178,11 +1185,11 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
1178
1185
|
async with self.getHttpSess(port=port, auth=('visi', 'secret')) as sess:
|
|
1179
1186
|
body = {'query': 'return(asdf)', 'opts': {'user': core.auth.rootuser.iden}}
|
|
1180
1187
|
async with sess.get(f'https://localhost:{port}/api/v1/storm/call', json=body) as resp:
|
|
1181
|
-
self.eq(resp.status,
|
|
1188
|
+
self.eq(resp.status, http.HTTPStatus.FORBIDDEN)
|
|
1182
1189
|
|
|
1183
1190
|
async with self.getHttpSess(port=port) as sess:
|
|
1184
1191
|
resp = await sess.post(f'https://localhost:{port}/api/v1/storm/call')
|
|
1185
|
-
self.eq(
|
|
1192
|
+
self.eq(resp.status, http.HTTPStatus.UNAUTHORIZED)
|
|
1186
1193
|
|
|
1187
1194
|
async with self.getHttpSess() as sess:
|
|
1188
1195
|
async with sess.post(f'https://localhost:{port}/api/v1/login',
|
|
@@ -1193,12 +1200,14 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
1193
1200
|
|
|
1194
1201
|
body = {'query': 'return (asdf)'}
|
|
1195
1202
|
async with sess.get(f'https://localhost:{port}/api/v1/storm/call', json=body) as resp:
|
|
1203
|
+
self.eq(resp.status, http.HTTPStatus.OK)
|
|
1196
1204
|
retn = await resp.json()
|
|
1197
1205
|
self.eq('ok', retn.get('status'))
|
|
1198
1206
|
self.eq('asdf', retn['result'])
|
|
1199
1207
|
|
|
1200
1208
|
body = {'query': '$foo=() $bar=$foo.index(10) return ( $bar )'}
|
|
1201
1209
|
async with sess.get(f'https://localhost:{port}/api/v1/storm/call', json=body) as resp:
|
|
1210
|
+
self.eq(resp.status, http.HTTPStatus.BAD_REQUEST)
|
|
1202
1211
|
retn = await resp.json()
|
|
1203
1212
|
self.eq('err', retn.get('status'))
|
|
1204
1213
|
self.eq('StormRuntimeError', retn.get('code'))
|
|
@@ -1206,6 +1215,7 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
1206
1215
|
|
|
1207
1216
|
body = {'query': 'return ( $lib.exit() )'}
|
|
1208
1217
|
async with sess.post(f'https://localhost:{port}/api/v1/storm/call', json=body) as resp:
|
|
1218
|
+
self.eq(resp.status, http.HTTPStatus.BAD_REQUEST)
|
|
1209
1219
|
retn = await resp.json()
|
|
1210
1220
|
self.eq('err', retn.get('status'))
|
|
1211
1221
|
self.eq('StormExit', retn.get('code'))
|
|
@@ -1214,6 +1224,7 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
1214
1224
|
# No body
|
|
1215
1225
|
async with sess.get(f'https://localhost:{port}/api/v1/storm/call') as resp:
|
|
1216
1226
|
retn = await resp.json()
|
|
1227
|
+
self.eq(resp.status, http.HTTPStatus.BAD_REQUEST)
|
|
1217
1228
|
self.eq('err', retn.get('status'))
|
|
1218
1229
|
self.eq('SchemaViolation', retn.get('code'))
|
|
1219
1230
|
|
|
@@ -7402,18 +7413,17 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
7402
7413
|
|
|
7403
7414
|
async with self.getHttpSess(port=port) as sess:
|
|
7404
7415
|
resp = await sess.post(f'https://localhost:{port}/api/v1/storm/export')
|
|
7405
|
-
self.eq(
|
|
7416
|
+
self.eq(resp.status, http.HTTPStatus.UNAUTHORIZED)
|
|
7406
7417
|
|
|
7407
7418
|
async with self.getHttpSess(port=port, auth=('visi', 'secret')) as sess:
|
|
7408
7419
|
body = {'query': 'inet:ipv4', 'opts': {'user': core.auth.rootuser.iden}}
|
|
7409
7420
|
async with sess.get(f'https://localhost:{port}/api/v1/storm/export', json=body) as resp:
|
|
7410
|
-
self.eq(resp.status,
|
|
7421
|
+
self.eq(resp.status, http.HTTPStatus.FORBIDDEN)
|
|
7411
7422
|
|
|
7412
7423
|
async with self.getHttpSess(port=port, auth=('root', 'secret')) as sess:
|
|
7413
7424
|
|
|
7414
7425
|
resp = await sess.post(f'https://localhost:{port}/api/v1/storm/export')
|
|
7415
|
-
self.eq(
|
|
7416
|
-
|
|
7426
|
+
self.eq(resp.status, http.HTTPStatus.BAD_REQUEST)
|
|
7417
7427
|
reply = await resp.json()
|
|
7418
7428
|
self.eq('err', reply.get('status'))
|
|
7419
7429
|
self.eq('SchemaViolation', reply.get('code'))
|
|
@@ -7423,6 +7433,7 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
7423
7433
|
'opts': {'scrub': {'include': {'tags': ('visi',)}}},
|
|
7424
7434
|
}
|
|
7425
7435
|
resp = await sess.post(f'https://localhost:{port}/api/v1/storm/export', json=body)
|
|
7436
|
+
self.eq(resp.status, http.HTTPStatus.OK)
|
|
7426
7437
|
byts = await resp.read()
|
|
7427
7438
|
|
|
7428
7439
|
podes = [i[1] for i in s_msgpack.Unpk().feed(byts)]
|
|
@@ -7440,6 +7451,7 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
7440
7451
|
body = {'query': 'inet:ipv4=asdfasdf'}
|
|
7441
7452
|
resp = await sess.post(f'https://localhost:{port}/api/v1/storm/export', json=body)
|
|
7442
7453
|
retval = await resp.json()
|
|
7454
|
+
self.eq(resp.status, http.HTTPStatus.BAD_REQUEST)
|
|
7443
7455
|
self.eq('err', retval['status'])
|
|
7444
7456
|
self.eq('BadTypeValu', retval['code'])
|
|
7445
7457
|
|
synapse/tests/test_lib_aha.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import http
|
|
2
3
|
import asyncio
|
|
3
4
|
|
|
4
5
|
from unittest import mock
|
|
@@ -304,6 +305,7 @@ class AhaTest(s_test.SynTest):
|
|
|
304
305
|
|
|
305
306
|
async with self.getHttpSess(auth=('root', 'secret'), port=httpsport) as sess:
|
|
306
307
|
async with sess.get(svcsurl) as resp:
|
|
308
|
+
self.eq(resp.status, http.HTTPStatus.OK)
|
|
307
309
|
info = await resp.json()
|
|
308
310
|
self.eq(info.get('status'), 'ok')
|
|
309
311
|
result = info.get('result')
|
|
@@ -312,6 +314,7 @@ class AhaTest(s_test.SynTest):
|
|
|
312
314
|
{svcinfo.get('name') for svcinfo in result})
|
|
313
315
|
|
|
314
316
|
async with sess.get(svcsurl, json={'network': 'synapse'}) as resp:
|
|
317
|
+
self.eq(resp.status, http.HTTPStatus.OK)
|
|
315
318
|
info = await resp.json()
|
|
316
319
|
self.eq(info.get('status'), 'ok')
|
|
317
320
|
result = info.get('result')
|
|
@@ -320,6 +323,7 @@ class AhaTest(s_test.SynTest):
|
|
|
320
323
|
{svcinfo.get('name') for svcinfo in result})
|
|
321
324
|
|
|
322
325
|
async with sess.get(svcsurl, json={'network': 'newp'}) as resp:
|
|
326
|
+
self.eq(resp.status, http.HTTPStatus.OK)
|
|
323
327
|
info = await resp.json()
|
|
324
328
|
self.eq(info.get('status'), 'ok')
|
|
325
329
|
result = info.get('result')
|
|
@@ -327,11 +331,13 @@ class AhaTest(s_test.SynTest):
|
|
|
327
331
|
|
|
328
332
|
# Sad path
|
|
329
333
|
async with sess.get(svcsurl, json={'newp': 'hehe'}) as resp:
|
|
334
|
+
self.eq(resp.status, http.HTTPStatus.BAD_REQUEST)
|
|
330
335
|
info = await resp.json()
|
|
331
336
|
self.eq(info.get('status'), 'err')
|
|
332
337
|
self.eq(info.get('code'), 'SchemaViolation')
|
|
333
338
|
|
|
334
339
|
async with sess.get(svcsurl, json={'network': 'mynet', 'newp': 'hehe'}) as resp:
|
|
340
|
+
self.eq(resp.status, http.HTTPStatus.BAD_REQUEST)
|
|
335
341
|
info = await resp.json()
|
|
336
342
|
self.eq(info.get('status'), 'err')
|
|
337
343
|
self.eq(info.get('code'), 'SchemaViolation')
|
|
@@ -339,6 +345,7 @@ class AhaTest(s_test.SynTest):
|
|
|
339
345
|
# Sad path
|
|
340
346
|
async with self.getHttpSess(auth=('lowuser', 'lowuser'), port=httpsport) as sess:
|
|
341
347
|
async with sess.get(svcsurl) as resp:
|
|
348
|
+
self.eq(resp.status, http.HTTPStatus.FORBIDDEN)
|
|
342
349
|
info = await resp.json()
|
|
343
350
|
self.eq(info.get('status'), 'err')
|
|
344
351
|
self.eq(info.get('code'), 'AuthDeny')
|
|
@@ -877,6 +884,7 @@ class AhaTest(s_test.SynTest):
|
|
|
877
884
|
async with self.getHttpSess(auth=('root', 'secret'), port=httpsport) as sess:
|
|
878
885
|
# Simple request works
|
|
879
886
|
async with sess.post(url, json={'name': '00.foosvc'}) as resp:
|
|
887
|
+
self.eq(resp.status, http.HTTPStatus.OK)
|
|
880
888
|
info = await resp.json()
|
|
881
889
|
self.eq(info.get('status'), 'ok')
|
|
882
890
|
result = info.get('result')
|
|
@@ -904,6 +912,7 @@ class AhaTest(s_test.SynTest):
|
|
|
904
912
|
}
|
|
905
913
|
}
|
|
906
914
|
async with sess.post(url, json=data) as resp:
|
|
915
|
+
self.eq(resp.status, http.HTTPStatus.OK)
|
|
907
916
|
info = await resp.json()
|
|
908
917
|
self.eq(info.get('status'), 'ok')
|
|
909
918
|
result = info.get('result')
|
|
@@ -919,30 +928,37 @@ class AhaTest(s_test.SynTest):
|
|
|
919
928
|
|
|
920
929
|
# Sad path
|
|
921
930
|
async with sess.post(url) as resp:
|
|
931
|
+
self.eq(resp.status, http.HTTPStatus.BAD_REQUEST)
|
|
922
932
|
info = await resp.json()
|
|
923
933
|
self.eq(info.get('status'), 'err')
|
|
924
934
|
self.eq(info.get('code'), 'SchemaViolation')
|
|
925
935
|
async with sess.post(url, json={}) as resp:
|
|
936
|
+
self.eq(resp.status, http.HTTPStatus.BAD_REQUEST)
|
|
926
937
|
info = await resp.json()
|
|
927
938
|
self.eq(info.get('status'), 'err')
|
|
928
939
|
self.eq(info.get('code'), 'SchemaViolation')
|
|
929
940
|
async with sess.post(url, json={'name': 1234}) as resp:
|
|
941
|
+
self.eq(resp.status, http.HTTPStatus.BAD_REQUEST)
|
|
930
942
|
info = await resp.json()
|
|
931
943
|
self.eq(info.get('status'), 'err')
|
|
932
944
|
self.eq(info.get('code'), 'SchemaViolation')
|
|
933
945
|
async with sess.post(url, json={'name': ''}) as resp:
|
|
946
|
+
self.eq(resp.status, http.HTTPStatus.BAD_REQUEST)
|
|
934
947
|
info = await resp.json()
|
|
935
948
|
self.eq(info.get('status'), 'err')
|
|
936
949
|
self.eq(info.get('code'), 'SchemaViolation')
|
|
937
950
|
async with sess.post(url, json={'name': '00.newp', 'provinfo': 5309}) as resp:
|
|
951
|
+
self.eq(resp.status, http.HTTPStatus.BAD_REQUEST)
|
|
938
952
|
info = await resp.json()
|
|
939
953
|
self.eq(info.get('status'), 'err')
|
|
940
954
|
self.eq(info.get('code'), 'SchemaViolation')
|
|
941
955
|
async with sess.post(url, json={'name': '00.newp', 'provinfo': {'dmon:port': -1}}) as resp:
|
|
956
|
+
self.eq(resp.status, http.HTTPStatus.BAD_REQUEST)
|
|
942
957
|
info = await resp.json()
|
|
943
958
|
self.eq(info.get('status'), 'err')
|
|
944
959
|
self.eq(info.get('code'), 'SchemaViolation')
|
|
945
960
|
async with sess.post(url, json={'name': 'doom' * 16}) as resp:
|
|
961
|
+
self.eq(resp.status, http.HTTPStatus.BAD_REQUEST)
|
|
946
962
|
info = await resp.json()
|
|
947
963
|
self.eq(info.get('status'), 'err')
|
|
948
964
|
self.eq(info.get('code'), 'BadArg')
|
|
@@ -951,6 +967,7 @@ class AhaTest(s_test.SynTest):
|
|
|
951
967
|
await aha.addUser('lowuser', passwd='lowuser')
|
|
952
968
|
async with self.getHttpSess(auth=('lowuser', 'lowuser'), port=httpsport) as sess:
|
|
953
969
|
async with sess.post(url, json={'name': '00.newp'}) as resp:
|
|
970
|
+
self.eq(resp.status, http.HTTPStatus.FORBIDDEN)
|
|
954
971
|
info = await resp.json()
|
|
955
972
|
self.eq(info.get('status'), 'err')
|
|
956
973
|
self.eq(info.get('code'), 'AuthDeny')
|
synapse/tests/test_lib_cell.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import http
|
|
1
2
|
import os
|
|
2
3
|
import ssl
|
|
3
4
|
import sys
|
|
@@ -2923,7 +2924,7 @@ class CellTest(s_t_utils.SynTest):
|
|
|
2923
2924
|
headers2 = {'X-API-KEY': rtk1}
|
|
2924
2925
|
resp = await sess.post(f'https://localhost:{hport}/api/v1/auth/onepass/issue', headers=headers2,
|
|
2925
2926
|
json={'user': lowuser})
|
|
2926
|
-
self.eq(
|
|
2927
|
+
self.eq(resp.status, http.HTTPStatus.UNAUTHORIZED)
|
|
2927
2928
|
answ = await resp.json()
|
|
2928
2929
|
self.eq('err', answ['status'])
|
|
2929
2930
|
|
|
@@ -2945,7 +2946,7 @@ class CellTest(s_t_utils.SynTest):
|
|
|
2945
2946
|
|
|
2946
2947
|
resp = await sess.post(f'https://localhost:{hport}/api/v1/auth/onepass/issue', headers=headers2,
|
|
2947
2948
|
json={'user': lowuser})
|
|
2948
|
-
self.eq(
|
|
2949
|
+
self.eq(resp.status, http.HTTPStatus.UNAUTHORIZED)
|
|
2949
2950
|
answ = await resp.json()
|
|
2950
2951
|
self.eq('err', answ['status'])
|
|
2951
2952
|
|
|
@@ -2985,13 +2986,14 @@ class CellTest(s_t_utils.SynTest):
|
|
|
2985
2986
|
await cell.setUserLocked(lowuser, True)
|
|
2986
2987
|
resp = await sess.post(f'https://localhost:{hport}/api/v1/auth/password/{lowuser}', headers=headers2,
|
|
2987
2988
|
json={'passwd': 'secret'})
|
|
2988
|
-
self.eq(
|
|
2989
|
+
self.eq(resp.status, http.HTTPStatus.UNAUTHORIZED)
|
|
2989
2990
|
answ = await resp.json()
|
|
2990
2991
|
self.eq('err', answ['status'])
|
|
2991
2992
|
|
|
2992
2993
|
await cell.delUser(lowuser)
|
|
2993
2994
|
resp = await sess.post(f'https://localhost:{hport}/api/v1/auth/password/{lowuser}', headers=headers2,
|
|
2994
2995
|
json={'passwd': 'secret'})
|
|
2996
|
+
self.eq(resp.status, http.HTTPStatus.UNAUTHORIZED)
|
|
2995
2997
|
answ = await resp.json()
|
|
2996
2998
|
self.eq('err', answ['status'])
|
|
2997
2999
|
|