synapse 2.180.1__py311-none-any.whl → 2.182.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.

Files changed (90) hide show
  1. synapse/assets/__init__.py +35 -0
  2. synapse/assets/storm/migrations/model-0.2.28.storm +355 -0
  3. synapse/common.py +2 -1
  4. synapse/cortex.py +49 -35
  5. synapse/cryotank.py +1 -1
  6. synapse/datamodel.py +30 -0
  7. synapse/lib/ast.py +12 -7
  8. synapse/lib/auth.py +17 -0
  9. synapse/lib/cell.py +7 -9
  10. synapse/lib/chop.py +0 -1
  11. synapse/lib/drive.py +8 -8
  12. synapse/lib/layer.py +55 -13
  13. synapse/lib/lmdbslab.py +26 -5
  14. synapse/lib/modelrev.py +28 -1
  15. synapse/lib/modules.py +1 -0
  16. synapse/lib/nexus.py +1 -1
  17. synapse/lib/node.py +5 -0
  18. synapse/lib/parser.py +23 -16
  19. synapse/lib/scrape.py +1 -1
  20. synapse/lib/slabseqn.py +2 -2
  21. synapse/lib/snap.py +129 -0
  22. synapse/lib/storm.lark +16 -2
  23. synapse/lib/storm.py +20 -3
  24. synapse/lib/storm_format.py +1 -0
  25. synapse/lib/stormhttp.py +34 -1
  26. synapse/lib/stormlib/auth.py +5 -3
  27. synapse/lib/stormlib/cortex.py +5 -2
  28. synapse/lib/stormlib/easyperm.py +2 -2
  29. synapse/lib/stormlib/ipv6.py +2 -2
  30. synapse/lib/stormlib/model.py +114 -12
  31. synapse/lib/stormlib/project.py +1 -1
  32. synapse/lib/stormtypes.py +81 -7
  33. synapse/lib/types.py +7 -0
  34. synapse/lib/version.py +2 -2
  35. synapse/lib/view.py +47 -0
  36. synapse/models/inet.py +10 -3
  37. synapse/models/infotech.py +2 -1
  38. synapse/models/language.py +4 -0
  39. synapse/models/math.py +50 -0
  40. synapse/models/orgs.py +8 -0
  41. synapse/models/risk.py +9 -0
  42. synapse/tests/files/stormcov/pragma-nocov.storm +18 -0
  43. synapse/tests/test_assets.py +25 -0
  44. synapse/tests/test_cortex.py +129 -0
  45. synapse/tests/test_datamodel.py +6 -0
  46. synapse/tests/test_lib_cell.py +12 -0
  47. synapse/tests/test_lib_grammar.py +7 -1
  48. synapse/tests/test_lib_layer.py +35 -0
  49. synapse/tests/test_lib_lmdbslab.py +11 -9
  50. synapse/tests/test_lib_modelrev.py +655 -1
  51. synapse/tests/test_lib_slabseqn.py +5 -4
  52. synapse/tests/test_lib_snap.py +4 -0
  53. synapse/tests/test_lib_storm.py +110 -1
  54. synapse/tests/test_lib_stormhttp.py +99 -1
  55. synapse/tests/test_lib_stormlib_auth.py +15 -0
  56. synapse/tests/test_lib_stormlib_cortex.py +21 -4
  57. synapse/tests/test_lib_stormlib_iters.py +8 -5
  58. synapse/tests/test_lib_stormlib_model.py +45 -6
  59. synapse/tests/test_lib_stormtypes.py +158 -2
  60. synapse/tests/test_lib_types.py +6 -0
  61. synapse/tests/test_model_inet.py +10 -0
  62. synapse/tests/test_model_language.py +4 -0
  63. synapse/tests/test_model_math.py +22 -0
  64. synapse/tests/test_model_orgs.py +6 -2
  65. synapse/tests/test_model_risk.py +4 -0
  66. synapse/tests/test_tools_storm.py +1 -1
  67. synapse/tests/test_utils_stormcov.py +5 -0
  68. synapse/tests/utils.py +18 -5
  69. synapse/utils/stormcov/plugin.py +31 -1
  70. synapse/vendor/cpython/LICENSE +279 -0
  71. synapse/vendor/cpython/__init__.py +0 -0
  72. synapse/vendor/cpython/lib/__init__.py +0 -0
  73. synapse/vendor/cpython/lib/email/__init__.py +0 -0
  74. synapse/vendor/cpython/lib/email/_parseaddr.py +560 -0
  75. synapse/vendor/cpython/lib/email/utils.py +505 -0
  76. synapse/vendor/cpython/lib/ipaddress.py +2366 -0
  77. synapse/vendor/cpython/lib/test/__init__.py +0 -0
  78. synapse/vendor/cpython/lib/test/support/__init__.py +114 -0
  79. synapse/vendor/cpython/lib/test/test_email/__init__.py +0 -0
  80. synapse/vendor/cpython/lib/test/test_email/test_email.py +480 -0
  81. synapse/vendor/cpython/lib/test/test_email/test_utils.py +167 -0
  82. synapse/vendor/cpython/lib/test/test_ipaddress.py +2672 -0
  83. synapse/vendor/utils.py +4 -3
  84. {synapse-2.180.1.dist-info → synapse-2.182.0.dist-info}/METADATA +3 -3
  85. {synapse-2.180.1.dist-info → synapse-2.182.0.dist-info}/RECORD +88 -71
  86. {synapse-2.180.1.dist-info → synapse-2.182.0.dist-info}/WHEEL +1 -1
  87. synapse/lib/jupyter.py +0 -505
  88. synapse/tests/test_lib_jupyter.py +0 -224
  89. {synapse-2.180.1.dist-info → synapse-2.182.0.dist-info}/LICENSE +0 -0
  90. {synapse-2.180.1.dist-info → synapse-2.182.0.dist-info}/top_level.txt +0 -0
@@ -1,224 +0,0 @@
1
- import os
2
- import json
3
-
4
- import synapse.common as s_common
5
-
6
- import synapse.lib.cell as s_cell
7
- import synapse.lib.jupyter as s_jupyter
8
- import synapse.lib.msgpack as s_msgpack
9
- import synapse.lib.stormsvc as s_stormsvc
10
-
11
- import synapse.tests.utils as s_t_utils
12
-
13
- class TstsvcApi(s_cell.CellApi, s_stormsvc.StormSvc):
14
- _storm_svc_name = 'testsvc'
15
- _storm_svc_pkgs = (
16
- {
17
- 'name': 'testsvc',
18
- 'version': (0, 0, 1),
19
- 'synapse_version': '>=2.8.0,<3.0.0',
20
- 'commands': (
21
- {
22
- 'name': 'testsvc.magic',
23
- 'storm': '[inet:ipv4=0]',
24
- },
25
- )
26
- },
27
- )
28
-
29
- async def testmeth(self):
30
- return 'shazam'
31
-
32
- class Tstsvc(s_cell.Cell):
33
- cellapi = TstsvcApi
34
-
35
- class JupyterTest(s_t_utils.SynTest):
36
- testmods = ['synapse.tests.utils.TestModule']
37
-
38
- async def test_tempcorecmdr(self):
39
- outp = self.getTestOutp()
40
- cmdrcore = await s_jupyter.getTempCoreCmdr(self.testmods, outp)
41
- self.false(cmdrcore.isfini)
42
- nodes = await cmdrcore.eval('[test:str=beep]', cmdr=True)
43
- self.len(1, nodes)
44
- self.eq(nodes[0][0], ('test:str', 'beep'))
45
- self.true(outp.expect('cli> storm [test:str=beep]'))
46
- await cmdrcore.fini()
47
- self.true(cmdrcore.isfini)
48
-
49
- async def test_tempcoreprox(self):
50
- prox = await s_jupyter.getTempCoreProx(self.testmods)
51
- self.false(prox.isfini)
52
- msgs = await prox.storm('[test:str=beep]').list()
53
- nodes = [m[1] for m in msgs if m[0] == 'node']
54
- self.len(1, nodes)
55
- self.eq(nodes[0][0], ('test:str', 'beep'))
56
- await prox.fini()
57
- self.true(prox.isfini)
58
-
59
- async def test_tempcorecmdrstormsvc(self):
60
- cmdrcore, svcprox = await s_jupyter.getTempCoreCmdrStormsvc('testsvc', Tstsvc.anit)
61
-
62
- self.false(cmdrcore.isfini)
63
- self.false(svcprox.isfini)
64
-
65
- mesgs = await cmdrcore.storm('service.list')
66
- self.true(any(['true (testsvc)' in str(mesg) for mesg in mesgs]))
67
-
68
- nodes = await cmdrcore.eval('testsvc.magic')
69
- self.len(1, nodes)
70
-
71
- self.eq('shazam', await svcprox.testmeth())
72
-
73
- await cmdrcore.fini()
74
- self.true(cmdrcore.isfini)
75
-
76
- await svcprox.fini()
77
- self.true(svcprox.isfini)
78
-
79
- async def test_cmdrcore(self):
80
-
81
- async with self.getTestCoreAndProxy() as (realcore, core):
82
-
83
- outp = self.getTestOutp()
84
- async with await s_jupyter.CmdrCore.anit(core, outp=outp) as cmdrcore:
85
- podes = await cmdrcore.eval('[test:str=beep]',
86
- num=1, cmdr=False)
87
- self.len(1, podes)
88
- self.false(outp.expect('[test:str=beep]', throw=False))
89
-
90
- mesgs = await cmdrcore.storm('[test:str=boop]',
91
- num=1, cmdr=True)
92
- self.true(outp.expect('[test:str=boop]', throw=False))
93
- podes = [m[1] for m in mesgs if m[0] == 'node']
94
- self.gt(len(mesgs), len(podes))
95
- self.len(1, podes)
96
- self.eq(podes[0][0], ('test:str', 'boop'))
97
-
98
- # Opts works for cmdr=False
99
- podes = await cmdrcore.eval('[test:str=$foo]',
100
- {'vars': {'foo': 'duck'}},
101
- num=1, cmdr=False)
102
- self.len(1, podes)
103
- self.eq(podes[0][0], ('test:str', 'duck'))
104
-
105
- # Opts does not work with cmdr=True - we have no way to plumb it through.
106
- with self.getAsyncLoggerStream('synapse.lib.view',
107
- 'Error during storm execution') as stream:
108
- with self.raises(AssertionError):
109
- await cmdrcore.eval('[test:str=$foo]',
110
- opts={'vars': {'foo': 'fowl'}},
111
- cmdr=True)
112
- self.true(await stream.wait(6))
113
-
114
- # Assertion based tests
115
- podes = await cmdrcore.eval('test:int', num=0)
116
- self.len(0, podes)
117
- podes = await cmdrcore.eval('test:str', num=3)
118
- self.len(3, podes)
119
- await self.asyncraises(AssertionError, cmdrcore.eval('test:str', num=1))
120
-
121
- # Feed function for data loading
122
- data = [
123
- (('test:int', 137), {}),
124
- ]
125
-
126
- await cmdrcore.addFeedData('syn.nodes', data)
127
- podes = await cmdrcore.eval('test:int=137',
128
- num=1, cmdr=False)
129
- self.len(1, podes)
130
-
131
- # Raw cmdline test
132
- async with self.getTestCoreAndProxy() as (realcore, core):
133
-
134
- outp = self.getTestOutp()
135
- async with await s_jupyter.CmdrCore.anit(core, outp=outp) as cmdrcore:
136
- await cmdrcore.runCmdLine('help')
137
- self.true(outp.expect('cli> help'))
138
- self.true(outp.expect('List commands and display help output.'))
139
-
140
- async def test_log_supression(self):
141
-
142
- async with self.getTestCoreAndProxy() as (realcore, core):
143
-
144
- outp = self.getTestOutp()
145
- async with await s_jupyter.CmdrCore.anit(core, outp=outp) as cmdrcore:
146
- with self.getAsyncLoggerStream('synapse.lib.view') as stream:
147
- mesgs = await cmdrcore.storm('[test:int=beep]',
148
- num=0, cmdr=False,
149
- suppress_logging=True)
150
- self.stormIsInErr('invalid literal for int', mesgs)
151
- stream.seek(0)
152
- self.notin('Error during storm execution', stream.read())
153
-
154
- with self.getAsyncLoggerStream('synapse.lib.view',
155
- 'Error during storm execution') as stream:
156
- mesgs = await cmdrcore.storm('[test:int=beep]',
157
- num=0, cmdr=False,
158
- suppress_logging=False)
159
- self.true(await stream.wait(6))
160
- self.stormIsInErr('invalid literal for int', mesgs)
161
-
162
- def test_doc_data(self):
163
- with self.getTestDir() as dirn:
164
- s_common.gendir(dirn, 'docdata', 'stuff')
165
-
166
- docdata = s_common.genpath(dirn, 'docdata')
167
-
168
- root = s_common.genpath(dirn, 'synapse', 'userguides')
169
-
170
- d = {'key': 'value'}
171
-
172
- s_common.jssave(d, docdata, 'data.json')
173
- s_common.yamlsave(d, docdata, 'data.yaml')
174
- s_msgpack.dumpfile(d, os.path.join(docdata, 'data.mpk'))
175
- with s_common.genfile(docdata, 'stuff', 'data.txt') as fd:
176
- fd.write('beep'.encode())
177
- with s_common.genfile(docdata, 'data.jsonl') as fd:
178
- fd.write(json.dumps(d).encode() + b'\n')
179
- fd.write(json.dumps(d).encode() + b'\n')
180
- fd.write(json.dumps(d).encode() + b'\n')
181
-
182
- data = s_jupyter.getDocData('data.json', root)
183
- self.eq(data, d)
184
- data = s_jupyter.getDocData('data.yaml', root)
185
- self.eq(data, d)
186
- data = s_jupyter.getDocData('data.mpk', root)
187
- self.eq(data, d)
188
- data = s_jupyter.getDocData('stuff/data.txt', root)
189
- self.eq(data, b'beep')
190
- data = s_jupyter.getDocData('data.jsonl', root)
191
- self.eq(data, [d, d, d])
192
-
193
- self.raises(ValueError, s_jupyter.getDocData, 'newp.bin', root)
194
- self.raises(ValueError, s_jupyter.getDocData,
195
- '../../../../../../etc/passwd', root)
196
-
197
- async def test_stormcore(self):
198
- outp = self.getTestOutp()
199
- stormcore, svcprox = await s_jupyter.getTempCoreStormStormsvc('testsvc', Tstsvc.anit, outp=outp)
200
-
201
- self.false(stormcore.isfini)
202
- self.false(svcprox.isfini)
203
-
204
- msgs = await stormcore.storm('service.list')
205
- self.stormIsInPrint('true (testsvc)', msgs)
206
-
207
- await stormcore.storm('testsvc.magic', num=1)
208
-
209
- with self.raises(AssertionError):
210
- await stormcore.storm('testsvc.magic', num=999)
211
-
212
- outp.clear()
213
- msgs = await stormcore.storm('$lib.print(hello)', cli=True)
214
- self.stormIsInPrint('hello', msgs)
215
- outp.expect('storm> $lib.print(hello)')
216
- outp.expect('storm> $lib.print(hello)\nhello')
217
-
218
- self.eq('shazam', await svcprox.testmeth())
219
-
220
- await stormcore.fini()
221
- self.true(stormcore.isfini)
222
-
223
- await svcprox.fini()
224
- self.true(svcprox.isfini)