synapse 2.161.0__py311-none-any.whl → 2.163.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 (53) hide show
  1. synapse/axon.py +48 -40
  2. synapse/cortex.py +4 -0
  3. synapse/daemon.py +7 -2
  4. synapse/lib/cell.py +70 -3
  5. synapse/lib/layer.py +20 -1
  6. synapse/lib/oauth.py +1 -7
  7. synapse/lib/rstorm.py +16 -0
  8. synapse/lib/schemas.py +10 -0
  9. synapse/lib/storm.py +17 -1
  10. synapse/lib/stormhttp.py +52 -28
  11. synapse/lib/stormlib/stix.py +6 -3
  12. synapse/lib/stormtypes.py +336 -26
  13. synapse/lib/version.py +2 -2
  14. synapse/lib/view.py +15 -2
  15. synapse/models/inet.py +9 -0
  16. synapse/models/infotech.py +28 -26
  17. synapse/models/orgs.py +3 -0
  18. synapse/models/proj.py +9 -2
  19. synapse/models/risk.py +32 -0
  20. synapse/telepath.py +2 -0
  21. synapse/tests/files/rstorm/testsvc.py +8 -1
  22. synapse/tests/files/stormpkg/testpkg.yaml +4 -0
  23. synapse/tests/test_axon.py +4 -4
  24. synapse/tests/test_cortex.py +8 -8
  25. synapse/tests/test_daemon.py +19 -0
  26. synapse/tests/test_lib_ast.py +17 -17
  27. synapse/tests/test_lib_grammar.py +4 -4
  28. synapse/tests/test_lib_rstorm.py +38 -2
  29. synapse/tests/test_lib_storm.py +15 -15
  30. synapse/tests/test_lib_stormhttp.py +182 -19
  31. synapse/tests/test_lib_stormlib_auth.py +3 -3
  32. synapse/tests/test_lib_stormlib_cell.py +1 -1
  33. synapse/tests/test_lib_stormlib_cortex.py +50 -2
  34. synapse/tests/test_lib_stormlib_json.py +2 -2
  35. synapse/tests/test_lib_stormlib_macro.py +1 -1
  36. synapse/tests/test_lib_stormlib_modelext.py +37 -37
  37. synapse/tests/test_lib_stormlib_oauth.py +20 -20
  38. synapse/tests/test_lib_stormlib_stix.py +3 -1
  39. synapse/tests/test_lib_stormtypes.py +159 -52
  40. synapse/tests/test_lib_stormwhois.py +1 -1
  41. synapse/tests/test_lib_trigger.py +11 -11
  42. synapse/tests/test_lib_view.py +23 -1
  43. synapse/tests/test_model_crypto.py +1 -1
  44. synapse/tests/test_model_inet.py +6 -0
  45. synapse/tests/test_model_orgs.py +2 -1
  46. synapse/tests/test_model_proj.py +6 -0
  47. synapse/tests/test_model_risk.py +10 -0
  48. synapse/tests/test_tools_storm.py +1 -1
  49. {synapse-2.161.0.dist-info → synapse-2.163.0.dist-info}/METADATA +3 -1
  50. {synapse-2.161.0.dist-info → synapse-2.163.0.dist-info}/RECORD +53 -53
  51. {synapse-2.161.0.dist-info → synapse-2.163.0.dist-info}/LICENSE +0 -0
  52. {synapse-2.161.0.dist-info → synapse-2.163.0.dist-info}/WHEEL +0 -0
  53. {synapse-2.161.0.dist-info → synapse-2.163.0.dist-info}/top_level.txt +0 -0
@@ -12,16 +12,16 @@ class StormtypesModelextTest(s_test.SynTest):
12
12
  $lib.model.ext.addForm(_visi:int, int, $typeinfo, $forminfo)
13
13
 
14
14
  $propinfo = ({"doc": "A test prop doc."})
15
- $lib.model.ext.addFormProp(_visi:int, tick, (time, $lib.dict()), $propinfo)
15
+ $lib.model.ext.addFormProp(_visi:int, tick, (time, ({})), $propinfo)
16
16
 
17
17
  $univinfo = ({"doc": "A test univ doc."})
18
- $lib.model.ext.addUnivProp(_woot, (int, $lib.dict()), $univinfo)
18
+ $lib.model.ext.addUnivProp(_woot, (int, ({})), $univinfo)
19
19
 
20
20
  $tagpropinfo = ({"doc": "A test tagprop doc."})
21
- $lib.model.ext.addTagProp(score, (int, $lib.dict()), $tagpropinfo)
21
+ $lib.model.ext.addTagProp(score, (int, ({})), $tagpropinfo)
22
22
 
23
23
  $pinfo = ({"doc": "Extended a core model."})
24
- $lib.model.ext.addFormProp(test:int, _tick, (time, $lib.dict()), $propinfo)
24
+ $lib.model.ext.addFormProp(test:int, _tick, (time, ({})), $propinfo)
25
25
  ''')
26
26
 
27
27
  nodes = await core.nodes('[ _visi:int=10 :tick=20210101 ._woot=30 +#lol:score=99 ]')
@@ -37,11 +37,11 @@ class StormtypesModelextTest(s_test.SynTest):
37
37
  self.eq(nodes[0].get('_tick'), 1609459200000)
38
38
 
39
39
  with self.raises(s_exc.DupPropName):
40
- q = '''$lib.model.ext.addFormProp(_visi:int, tick, (time, $lib.dict()), $lib.dict())'''
40
+ q = '''$lib.model.ext.addFormProp(_visi:int, tick, (time, ({})), ({}))'''
41
41
  await core.callStorm(q)
42
42
 
43
43
  with self.raises(s_exc.DupPropName):
44
- q = '''$lib.model.ext.addUnivProp(_woot, (time, $lib.dict()), $lib.dict())'''
44
+ q = '''$lib.model.ext.addUnivProp(_woot, (time, ({})), ({}))'''
45
45
  await core.callStorm(q)
46
46
 
47
47
  # Grab the extended model definitions
@@ -64,45 +64,45 @@ class StormtypesModelextTest(s_test.SynTest):
64
64
  self.none(core.model.tagprop('score'))
65
65
 
66
66
  # Underscores can exist in extended names but only at specific locations
67
- q = '''$l =$lib.list('str', $lib.dict()) $d=$lib.dict(doc="Foo")
67
+ q = '''$l =$lib.list('str', ({})) $d=({"doc": "Foo"})
68
68
  $lib.model.ext.addFormProp('test:str', '_test:_myprop', $l, $d)
69
69
  '''
70
70
  self.none(await core.callStorm(q))
71
- q = '$lib.model.ext.addUnivProp(_woot:_stuff, (int, $lib.dict()), $lib.dict())'
71
+ q = '$lib.model.ext.addUnivProp(_woot:_stuff, (int, ({})), ({}))'
72
72
  self.none(await core.callStorm(q))
73
73
 
74
- q = '''$lib.model.ext.addTagProp(_score, (int, $lib.dict()), $lib.dict())'''
74
+ q = '''$lib.model.ext.addTagProp(_score, (int, ({})), ({}))'''
75
75
  self.none(await core.callStorm(q))
76
76
 
77
- q = '''$lib.model.ext.addTagProp(some:_score, (int, $lib.dict()), $lib.dict())'''
77
+ q = '''$lib.model.ext.addTagProp(some:_score, (int, ({})), ({}))'''
78
78
  self.none(await core.callStorm(q))
79
79
 
80
80
  with self.raises(s_exc.BadPropDef):
81
- q = '''$l =$lib.list('str', $lib.dict()) $d=$lib.dict(doc="Foo")
81
+ q = '''$l =$lib.list('str', ({})) $d=({"doc": "Foo"})
82
82
  $lib.model.ext.addFormProp('test:str', '_test:_my^prop', $l, $d)
83
83
  '''
84
84
  await core.callStorm(q)
85
85
 
86
86
  with self.raises(s_exc.BadPropDef):
87
- q = '''$l =$lib.list('str', $lib.dict()) $d=$lib.dict(doc="Foo")
87
+ q = '''$l =$lib.list('str', ({})) $d=({"doc": "Foo"})
88
88
  $lib.model.ext.addFormProp('test:str', '_test::_myprop', $l, $d)
89
89
  '''
90
90
  await core.callStorm(q)
91
91
 
92
92
  with self.raises(s_exc.BadPropDef):
93
- q = '''$lib.model.ext.addUnivProp(_woot^stuff, (int, $lib.dict()), $lib.dict())'''
93
+ q = '''$lib.model.ext.addUnivProp(_woot^stuff, (int, ({})), ({}))'''
94
94
  await core.callStorm(q)
95
95
 
96
96
  with self.raises(s_exc.BadPropDef):
97
- q = '''$lib.model.ext.addUnivProp(_woot:_stuff^2, (int, $lib.dict()), $lib.dict())'''
97
+ q = '''$lib.model.ext.addUnivProp(_woot:_stuff^2, (int, ({})), ({}))'''
98
98
  await core.callStorm(q)
99
99
 
100
100
  with self.raises(s_exc.BadPropDef):
101
- q = '''$lib.model.ext.addTagProp(some^score, (int, $lib.dict()), $lib.dict())'''
101
+ q = '''$lib.model.ext.addTagProp(some^score, (int, ({})), ({}))'''
102
102
  await core.callStorm(q)
103
103
 
104
104
  with self.raises(s_exc.BadPropDef):
105
- q = '''$lib.model.ext.addTagProp(_someones:_score^value, (int, $lib.dict()), $lib.dict())'''
105
+ q = '''$lib.model.ext.addTagProp(_someones:_score^value, (int, ({})), ({}))'''
106
106
  await core.callStorm(q)
107
107
 
108
108
  # Permission errors
@@ -110,27 +110,27 @@ class StormtypesModelextTest(s_test.SynTest):
110
110
  opts = {'user': visi.iden}
111
111
  with self.raises(s_exc.AuthDeny):
112
112
  await core.callStorm('''
113
- $typeinfo = $lib.dict()
114
- $forminfo = $lib.dict(doc="A test form doc.")
113
+ $typeinfo = ({})
114
+ $forminfo = ({"doc": "A test form doc."})
115
115
  $lib.model.ext.addForm(_visi:int, int, $typeinfo, $forminfo)
116
116
  ''', opts=opts)
117
117
 
118
118
  with self.raises(s_exc.AuthDeny):
119
119
  await core.callStorm('''
120
- $propinfo = $lib.dict(doc="A test prop doc.")
121
- $lib.model.ext.addFormProp(_visi:int, tick, (time, $lib.dict()), $propinfo)
120
+ $propinfo = ({"doc": "A test prop doc."})
121
+ $lib.model.ext.addFormProp(_visi:int, tick, (time, ({})), $propinfo)
122
122
  ''', opts=opts)
123
123
 
124
124
  with self.raises(s_exc.AuthDeny):
125
125
  await core.callStorm('''
126
- $univinfo = $lib.dict(doc="A test univ doc.")
127
- $lib.model.ext.addUnivProp(".woot", (int, $lib.dict()), $univinfo)
126
+ $univinfo = ({"doc": "A test univ doc."})
127
+ $lib.model.ext.addUnivProp(".woot", (int, ({})), $univinfo)
128
128
  ''', opts=opts)
129
129
 
130
130
  with self.raises(s_exc.AuthDeny):
131
131
  await core.callStorm('''
132
- $tagpropinfo = $lib.dict(doc="A test tagprop doc.")
133
- $lib.model.ext.addTagProp(score, (int, $lib.dict()), $tagpropinfo)
132
+ $tagpropinfo = ({"doc": "A test tagprop doc."})
133
+ $lib.model.ext.addTagProp(score, (int, ({})), $tagpropinfo)
134
134
  ''', opts=opts)
135
135
 
136
136
  # Reload the model extensions automatically
@@ -164,16 +164,16 @@ class StormtypesModelextTest(s_test.SynTest):
164
164
  $lib.model.ext.addForm(_visi:int, int, $typeinfo, $forminfo)
165
165
 
166
166
  $propinfo = ({"doc": "NEWP"})
167
- $lib.model.ext.addFormProp(_visi:int, tick, (time, $lib.dict()), $propinfo)
167
+ $lib.model.ext.addFormProp(_visi:int, tick, (time, ({})), $propinfo)
168
168
 
169
169
  $univinfo = ({"doc": "NEWP"})
170
- $lib.model.ext.addUnivProp(_woot, (int, $lib.dict()), $univinfo)
170
+ $lib.model.ext.addUnivProp(_woot, (int, ({})), $univinfo)
171
171
 
172
172
  $tagpropinfo = ({"doc": "NEWP"})
173
- $lib.model.ext.addTagProp(score, (int, $lib.dict()), $tagpropinfo)
173
+ $lib.model.ext.addTagProp(score, (int, ({})), $tagpropinfo)
174
174
 
175
175
  $pinfo = ({"doc": "NEWP"})
176
- $lib.model.ext.addFormProp(test:int, _tick, (time, $lib.dict()), $propinfo)
176
+ $lib.model.ext.addFormProp(test:int, _tick, (time, ({})), $propinfo)
177
177
  ''')
178
178
 
179
179
  q = '''return ($lib.model.ext.addExtModel($model_defs))'''
@@ -248,10 +248,10 @@ class StormtypesModelextTest(s_test.SynTest):
248
248
  self.eq(mesg['type'], 'init')
249
249
 
250
250
  await core.callStorm('''
251
- $lib.model.ext.addForm(_behold:score, int, $lib.dict(), $lib.dict(doc="first string"))
252
- $lib.model.ext.addFormProp(_behold:score, rank, (int, $lib.dict()), $lib.dict(doc="second string"))
253
- $lib.model.ext.addUnivProp(_beep, (int, $lib.dict()), $lib.dict(doc="third string"))
254
- $lib.model.ext.addTagProp(thingy, (int, $lib.dict()), $lib.dict(doc="fourth string"))
251
+ $lib.model.ext.addForm(_behold:score, int, ({}), ({"doc": "first string"}))
252
+ $lib.model.ext.addFormProp(_behold:score, rank, (int, ({})), ({"doc": "second string"}))
253
+ $lib.model.ext.addUnivProp(_beep, (int, ({})), ({"doc": "third string"}))
254
+ $lib.model.ext.addTagProp(thingy, (int, ({})), ({"doc": "fourth string"}))
255
255
  ''')
256
256
 
257
257
  formmesg = await sock.receive_json()
@@ -310,12 +310,12 @@ class StormtypesModelextTest(s_test.SynTest):
310
310
  async with self.getTestCore() as core:
311
311
 
312
312
  await core.callStorm('''
313
- $typeinfo = $lib.dict()
314
- $forminfo = $lib.dict(doc="A test form doc.")
313
+ $typeinfo = ({})
314
+ $forminfo = ({"doc": "A test form doc."})
315
315
  $lib.model.ext.addForm(_visi:int, int, $typeinfo, $forminfo)
316
316
 
317
- $propinfo = $lib.dict(doc="A test prop doc.")
318
- $lib.model.ext.addFormProp(_visi:int, tick, (time, $lib.dict()), $propinfo)
317
+ $propinfo = ({"doc": "A test prop doc."})
318
+ $lib.model.ext.addFormProp(_visi:int, tick, (time, ({})), $propinfo)
319
319
  ''')
320
320
 
321
321
  self.nn(core.model.form('_visi:int'))
@@ -326,7 +326,7 @@ class StormtypesModelextTest(s_test.SynTest):
326
326
  await core.callStorm(q)
327
327
  self.eq('Form has extended properties: tick', exc.exception.get('mesg'))
328
328
 
329
- await core.callStorm('$lib.model.ext.addFormProp(_visi:int, tock, (time, $lib.dict()), $lib.dict())')
329
+ await core.callStorm('$lib.model.ext.addFormProp(_visi:int, tock, (time, ({})), ({}))')
330
330
 
331
331
  self.nn(core.model.form('_visi:int'))
332
332
  self.nn(core.model.prop('_visi:int:tick'))
@@ -148,9 +148,9 @@ class OAuthTest(s_test.SynTest):
148
148
  $csec = boop
149
149
  $atkn = neato
150
150
  $asec = burrito
151
- $headers = $lib.dict(
152
- "content-type"="application/json"
153
- )
151
+ $headers = ({
152
+ "content-type": "application/json"
153
+ })
154
154
  $client = $lib.inet.http.oauth.v1.client($ckey, $csec, $atkn, $asec, $lib.inet.http.oauth.v1.SIG_HEADER)
155
155
  return($client.sign($url, headers=$headers))
156
156
  '''
@@ -182,13 +182,13 @@ class OAuthTest(s_test.SynTest):
182
182
  $csec = boop
183
183
  $atkn = neato
184
184
  $asec = burrito
185
- $headers = $lib.dict(
186
- "Content-Type"="application/json"
187
- )
188
- $body = $lib.dict(
189
- foo = bar,
190
- biz = baz,
191
- )
185
+ $headers = ({
186
+ "Content-Type": "application/json"
187
+ })
188
+ $body = ({
189
+ 'foo': 'bar',
190
+ 'biz': 'baz',
191
+ })
192
192
  $client = $lib.inet.http.oauth.v1.client($ckey, $csec, $atkn, $asec, $lib.inet.http.oauth.v1.SIG_BODY)
193
193
  return($client.sign($url, method='POST', headers=$headers, body=$body))
194
194
  '''
@@ -214,9 +214,9 @@ class OAuthTest(s_test.SynTest):
214
214
  $csec = boop
215
215
  $atkn = neato
216
216
  $asec = burrito
217
- $body = $lib.dict(
218
- awesome = possum,
219
- )
217
+ $body = ({
218
+ 'awesome': 'possum',
219
+ })
220
220
  $client = $lib.inet.http.oauth.v1.client($ckey, $csec, $atkn, $asec, $lib.inet.http.oauth.v1.SIG_BODY)
221
221
  return($client.sign($url, method='POST', headers=$lib.null, body=$body))
222
222
  '''
@@ -233,13 +233,13 @@ class OAuthTest(s_test.SynTest):
233
233
  $csec = boop
234
234
  $atkn = neato
235
235
  $asec = burrito
236
- $headers = $lib.dict(
237
- "Content-Type"="application/json"
238
- )
239
- $body = $lib.dict(
240
- foo = bar,
241
- biz = baz,
242
- )
236
+ $headers = ({
237
+ "Content-Type": "application/json"
238
+ })
239
+ $body = ({
240
+ 'foo': 'bar',
241
+ 'biz': 'baz',
242
+ })
243
243
  $client = $lib.inet.http.oauth.v1.client($ckey, $csec, $atkn, $asec, $lib.inet.http.oauth.v1.SIG_BODY)
244
244
  return($client.sign($url, headers=$headers, body=$body))
245
245
  '''
@@ -428,6 +428,7 @@ class StormLibStixTest(s_test.SynTest):
428
428
  "stix": {
429
429
  "vtx-mitigation": {
430
430
  "props": {
431
+ "desc": "return($desc)",
431
432
  "name": "{+:name return(:name)} return($node.repr())",
432
433
  "created": "return($lib.stix.export.timestamp(.created))",
433
434
  "modified": "return($lib.stix.export.timestamp(.created))",
@@ -440,13 +441,14 @@ class StormLibStixTest(s_test.SynTest):
440
441
  }
441
442
 
442
443
  [ risk:mitigation=c4f6dc09f1e1e6b7e7b05c9ce4186ce8 :name="patch stuff and do things" ]
443
-
444
+ $desc = "scopevar"
444
445
  $bundle.add($node)
445
446
 
446
447
  fini { return($bundle) }
447
448
  ''')
448
449
 
449
450
  self.eq('vtx-mitigation--2df2a437-e372-468b-b989-d01753603659', bund['objects'][1]['id'])
451
+ self.eq('scopevar', bund['objects'][1]['desc'])
450
452
  self.eq('patch stuff and do things', bund['objects'][1]['name'])
451
453
  self.nn(bund['objects'][1]['created'])
452
454
  self.nn(bund['objects'][1]['modified'])