synapse 2.160.0__py311-none-any.whl → 2.162.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 (71) hide show
  1. synapse/cortex.py +12 -7
  2. synapse/daemon.py +7 -2
  3. synapse/lib/agenda.py +8 -2
  4. synapse/lib/aha.py +4 -4
  5. synapse/lib/ast.py +3 -3
  6. synapse/lib/cell.py +20 -1
  7. synapse/lib/hiveauth.py +1 -1
  8. synapse/lib/httpapi.py +5 -0
  9. synapse/lib/layer.py +21 -1
  10. synapse/lib/nexus.py +9 -5
  11. synapse/lib/node.py +3 -4
  12. synapse/lib/rstorm.py +16 -0
  13. synapse/lib/schemas.py +2 -1
  14. synapse/lib/snap.py +20 -11
  15. synapse/lib/storm.py +19 -3
  16. synapse/lib/stormhttp.py +14 -2
  17. synapse/lib/stormlib/easyperm.py +5 -2
  18. synapse/lib/stormlib/gen.py +119 -44
  19. synapse/lib/stormlib/stix.py +6 -3
  20. synapse/lib/stormlib/vault.py +32 -15
  21. synapse/lib/stormtypes.py +187 -21
  22. synapse/lib/trigger.py +2 -0
  23. synapse/lib/version.py +2 -2
  24. synapse/lib/view.py +42 -10
  25. synapse/models/inet.py +9 -0
  26. synapse/models/infotech.py +28 -26
  27. synapse/models/orgs.py +3 -0
  28. synapse/models/proj.py +9 -2
  29. synapse/models/risk.py +32 -0
  30. synapse/telepath.py +6 -2
  31. synapse/tests/files/rstorm/testsvc.py +8 -1
  32. synapse/tests/files/stormpkg/testpkg.yaml +4 -0
  33. synapse/tests/test_axon.py +4 -4
  34. synapse/tests/test_cortex.py +66 -8
  35. synapse/tests/test_daemon.py +19 -0
  36. synapse/tests/test_lib_agenda.py +8 -0
  37. synapse/tests/test_lib_aha.py +18 -3
  38. synapse/tests/test_lib_ast.py +38 -16
  39. synapse/tests/test_lib_cell.py +3 -0
  40. synapse/tests/test_lib_grammar.py +4 -4
  41. synapse/tests/test_lib_httpapi.py +59 -0
  42. synapse/tests/test_lib_nexus.py +63 -0
  43. synapse/tests/test_lib_rstorm.py +38 -2
  44. synapse/tests/test_lib_snap.py +10 -0
  45. synapse/tests/test_lib_storm.py +61 -20
  46. synapse/tests/test_lib_stormhttp.py +21 -21
  47. synapse/tests/test_lib_stormlib_auth.py +3 -3
  48. synapse/tests/test_lib_stormlib_cell.py +1 -1
  49. synapse/tests/test_lib_stormlib_cortex.py +50 -2
  50. synapse/tests/test_lib_stormlib_gen.py +77 -0
  51. synapse/tests/test_lib_stormlib_json.py +2 -2
  52. synapse/tests/test_lib_stormlib_macro.py +1 -1
  53. synapse/tests/test_lib_stormlib_modelext.py +37 -37
  54. synapse/tests/test_lib_stormlib_oauth.py +20 -20
  55. synapse/tests/test_lib_stormlib_stix.py +3 -1
  56. synapse/tests/test_lib_stormlib_vault.py +1 -1
  57. synapse/tests/test_lib_stormtypes.py +159 -47
  58. synapse/tests/test_lib_stormwhois.py +1 -1
  59. synapse/tests/test_lib_trigger.py +11 -11
  60. synapse/tests/test_lib_view.py +23 -1
  61. synapse/tests/test_model_crypto.py +1 -1
  62. synapse/tests/test_model_inet.py +6 -0
  63. synapse/tests/test_model_orgs.py +2 -1
  64. synapse/tests/test_model_proj.py +6 -0
  65. synapse/tests/test_model_risk.py +10 -0
  66. synapse/tests/test_tools_storm.py +1 -1
  67. {synapse-2.160.0.dist-info → synapse-2.162.0.dist-info}/METADATA +5 -3
  68. {synapse-2.160.0.dist-info → synapse-2.162.0.dist-info}/RECORD +71 -71
  69. {synapse-2.160.0.dist-info → synapse-2.162.0.dist-info}/LICENSE +0 -0
  70. {synapse-2.160.0.dist-info → synapse-2.162.0.dist-info}/WHEEL +0 -0
  71. {synapse-2.160.0.dist-info → synapse-2.162.0.dist-info}/top_level.txt +0 -0
@@ -429,6 +429,44 @@ $request.reply(206, headers=$headers, body=({"no":"body"}))
429
429
  '''
430
430
  iden3 = await core.callStorm(q)
431
431
 
432
+ # $lib.dict accessor methods
433
+ q = '$api=$lib.cortex.httpapi.get($iden) return ($lib.dict.keys($api.vars))'
434
+ valu = await core.callStorm(q, opts={'vars': {'iden': iden3}})
435
+ self.eq(valu, ('hehe', 'items'))
436
+
437
+ q = '$api=$lib.cortex.httpapi.get($iden) return ($lib.dict.values($api.vars))'
438
+ valu = await core.callStorm(q, opts={'vars': {'iden': iden3}})
439
+ self.eq(valu, ('wow', ('1', '2', 3)))
440
+
441
+ q = '$api=$lib.cortex.httpapi.get($iden) return ($lib.dict.has($api.vars, anotherKey))'
442
+ valu = await core.callStorm(q, opts={'vars': {'iden': iden3}})
443
+ self.false(valu)
444
+
445
+ q = '''$api=$lib.cortex.httpapi.get($iden)
446
+ return ($lib.dict.update($api.vars, ({"hehe": "haha", "anotherKey": "anotherValu"}) ))'''
447
+ valu = await core.callStorm(q, opts={'vars': {'iden': iden3}})
448
+ self.none(valu)
449
+
450
+ q = '$api=$lib.cortex.httpapi.get($iden) return ($lib.dict.has($api.vars, anotherKey))'
451
+ valu = await core.callStorm(q, opts={'vars': {'iden': iden3}})
452
+ self.true(valu)
453
+
454
+ q = '$api=$lib.cortex.httpapi.get($iden) return ($lib.dict.values($api.vars))'
455
+ valu = await core.callStorm(q, opts={'vars': {'iden': iden3}})
456
+ self.eq(valu, ('haha', ('1', '2', 3), 'anotherValu'))
457
+
458
+ q = '$api=$lib.cortex.httpapi.get($iden) return ($lib.dict.pop($api.vars, anotherKey))'
459
+ valu = await core.callStorm(q, opts={'vars': {'iden': iden3}})
460
+ self.eq(valu, 'anotherValu')
461
+
462
+ q = '$api=$lib.cortex.httpapi.get($iden) return ($lib.dict.pop($api.vars, anotherKey, missingKey))'
463
+ valu = await core.callStorm(q, opts={'vars': {'iden': iden3}})
464
+ self.eq(valu, 'missingKey')
465
+
466
+ with self.raises(s_exc.BadArg):
467
+ q = '$api=$lib.cortex.httpapi.get($iden) return ($lib.dict.pop($api.vars, anotherKey))'
468
+ await core.callStorm(q, opts={'vars': {'iden': iden3}})
469
+
432
470
  msgs = await core.stormlist('cortex.httpapi.list')
433
471
  self.stormIsInPrint(f'0 {iden0}', msgs)
434
472
  self.stormIsInPrint(f'1 {iden1}', msgs)
@@ -569,7 +607,7 @@ $request.reply(206, headers=$headers, body=({"no":"body"}))
569
607
  msgs = await core.stormlist('cortex.httpapi.stat $iden', opts={'vars': {'iden': iden3}})
570
608
  self.stormIsInPrint(f'Iden: {iden3}', msgs)
571
609
  self.stormIsInPrint('The handler has the following runtime variables set:', msgs)
572
- self.stormIsInPrint('hehe => wow', msgs)
610
+ self.stormIsInPrint('hehe => haha', msgs)
573
611
  self.stormIsInPrint("items => ('1', '2', 3)", msgs)
574
612
 
575
613
  # Remove a user + view and stat the handler
@@ -999,7 +1037,11 @@ for $i in $values {
999
1037
  }
1000
1038
  // Cannot modify request headers
1001
1039
  $api.methods.post = ${
1002
- $request.headers.newp = haha
1040
+ if $request.headers.dictmethod {
1041
+ $lib.dict.update($request.headers, ({"newp": "haha"}))
1042
+ } else {
1043
+ $request.headers.newp = haha
1044
+ }
1003
1045
  }
1004
1046
  return ( ($api.iden, $api.owner.name) )
1005
1047
  '''
@@ -1029,6 +1071,12 @@ for $i in $values {
1029
1071
  self.eq(data.get('code'), 'StormRuntimeError')
1030
1072
  self.eq(data.get('mesg'), 'http:api:request:headers may not be modified by the runtime.')
1031
1073
 
1074
+ resp = await sess.post(f'https://localhost:{hport}/api/ext/testpath', headers={'dictmethod': '1'})
1075
+ self.eq(resp.status, 500)
1076
+ data = await resp.json()
1077
+ self.eq(data.get('code'), 'StormRuntimeError')
1078
+ self.eq(data.get('mesg'), 'http:api:request:headers may not be modified by the runtime.')
1079
+
1032
1080
  async def test_libcortex_httpapi_vars(self):
1033
1081
 
1034
1082
  async with self.getTestCore() as core:
@@ -1,3 +1,5 @@
1
+ import synapse.exc as s_exc
2
+
1
3
  import synapse.tests.utils as s_test
2
4
 
3
5
  class StormLibGenTest(s_test.SynTest):
@@ -112,6 +114,81 @@ class StormLibGenTest(s_test.SynTest):
112
114
  self.eq(nodes00[0].ndef, nodes01[0].ndef)
113
115
  self.ne(nodes01[0].ndef, nodes02[0].ndef)
114
116
 
117
+ q = 'gen.it.av.scan.result inet:fqdn vertex.link foosig --scanner-name barscn --time 2022'
118
+ nodes00 = await core.nodes(q)
119
+ self.len(1, nodes00)
120
+ self.eq('vertex.link', nodes00[0].get('target:fqdn'))
121
+ self.eq('foosig', nodes00[0].get('signame'))
122
+ self.eq('barscn', nodes00[0].get('scanner:name'))
123
+ self.eq('2022/01/01 00:00:00.000', nodes00[0].repr('time'))
124
+ nodes01 = await core.nodes(q)
125
+ self.eq(nodes00[0].ndef, nodes01[0].ndef)
126
+
127
+ nodes02 = await core.nodes('gen.it.av.scan.result inet:fqdn vertex.link foosig --scanner-name barscn')
128
+ self.eq(nodes00[0].ndef, nodes02[0].ndef)
129
+ self.eq('2022/01/01 00:00:00.000', nodes02[0].repr('time'))
130
+
131
+ nodes03 = await core.nodes('gen.it.av.scan.result inet:fqdn vertex.link foosig --scanner-name bazscn')
132
+ self.ne(nodes00[0].ndef, nodes03[0].ndef)
133
+
134
+ nodes04 = await core.nodes('gen.it.av.scan.result inet:fqdn vertex.link foosig --time 2022')
135
+ self.eq(nodes00[0].ndef, nodes04[0].ndef)
136
+
137
+ nodes05 = await core.nodes('gen.it.av.scan.result inet:fqdn vertex.link foosig --time 2023')
138
+ self.ne(nodes00[0].ndef, nodes05[0].ndef)
139
+
140
+ opts = {
141
+ 'vars': {
142
+ 'guid': '28c5902d115f29f1fcb818c0abeaa491',
143
+ 'ip': '1.2.3.4',
144
+ 'fqdn': 'vtk.lk',
145
+ }
146
+ }
147
+
148
+ self.len(1, await core.nodes('gen.it.av.scan.result file:bytes `guid:{$guid}` foosig', opts=opts))
149
+ self.len(1, await core.nodes('gen.it.av.scan.result inet:fqdn $fqdn foosig', opts=opts))
150
+ self.len(1, await core.nodes('gen.it.av.scan.result inet:ipv4 $ip foosig', opts=opts))
151
+ self.len(1, await core.nodes('gen.it.av.scan.result inet:ipv6 $ip foosig', opts=opts))
152
+ self.len(1, await core.nodes('gen.it.av.scan.result inet:url `http://{$fqdn}` foosig', opts=opts))
153
+ self.len(1, await core.nodes('gen.it.av.scan.result it:exec:proc $guid foosig', opts=opts))
154
+ self.len(1, await core.nodes('gen.it.av.scan.result it:host $guid foosig', opts=opts))
155
+
156
+ self.len(7, await core.nodes('''
157
+ file:bytes=`guid:{$guid}`
158
+ inet:fqdn=$fqdn
159
+ it:host=$guid
160
+ inet:ipv4=$ip
161
+ inet:ipv6:ipv4=$ip
162
+ it:exec:proc=$guid
163
+ inet:url=`http://{$fqdn}`
164
+ +{
165
+ ($form, $valu) = $node.ndef()
166
+ -> { gen.it.av.scan.result $form $valu foosig }
167
+ }=1
168
+ -> it:av:scan:result
169
+ ''', opts=opts))
170
+
171
+ nodes = await core.nodes('''
172
+ [ it:av:filehit=(`guid:{$lib.guid()}`, ($lib.guid(), fsig)) :sig:name=fsig ]
173
+ gen.it.av.scan.result file:bytes :file :sig:name
174
+ ''')
175
+ self.sorteq(['it:av:filehit', 'it:av:scan:result'], [n.ndef[0] for n in nodes])
176
+
177
+ with self.raises(s_exc.NoSuchType) as cm:
178
+ await core.nodes('gen.it.av.scan.result newp vertex.link foosig --try')
179
+ self.eq('No type or prop found for name newp.', cm.exception.errinfo['mesg'])
180
+
181
+ with self.raises(s_exc.BadArg) as cm:
182
+ await core.nodes('gen.it.av.scan.result ps:name nah foosig --try')
183
+ self.eq('Unsupported target form ps:name', cm.exception.errinfo['mesg'])
184
+
185
+ self.len(0, await core.nodes('gen.it.av.scan.result file:bytes newp foosig --try'))
186
+
187
+ self.none(await core.callStorm('return($lib.gen.itAvScanResultByTarget(inet:fqdn, vertex.link, $lib.null, try=$lib.true))'))
188
+ self.none(await core.callStorm('return($lib.gen.itAvScanResultByTarget(inet:fqdn, "..", barsig, try=$lib.true))'))
189
+ self.none(await core.callStorm('return($lib.gen.itAvScanResultByTarget(inet:fqdn, vertex.link, barsig, scanner=$lib.set(), try=$lib.true))'))
190
+ self.none(await core.callStorm('return($lib.gen.itAvScanResultByTarget(inet:fqdn, vertex.link, barsig, time=newp, try=$lib.true))'))
191
+
115
192
  # Stable guid test
116
193
  fork = await core.callStorm('return( $lib.view.get().fork().iden )')
117
194
 
@@ -27,7 +27,7 @@ class JsonTest(s_test.SynTest):
27
27
 
28
28
  opts = {'vars': {'schema': s_test.test_schema}}
29
29
  q = '''$schemaObj = $lib.json.schema($schema)
30
- $item=$lib.dict()
30
+ $item=({})
31
31
  $item."key:integer"=(4)
32
32
  return ( $schemaObj.validate($item) )
33
33
  '''
@@ -37,7 +37,7 @@ class JsonTest(s_test.SynTest):
37
37
  self.eq('Default string!', valu.get('key:string'))
38
38
 
39
39
  q = '''$schemaObj = $lib.json.schema($schema)
40
- $item=$lib.dict()
40
+ $item=({})
41
41
  $item."key:integer"=4
42
42
  return ( $schemaObj.validate($item) )
43
43
  '''
@@ -152,7 +152,7 @@ class MacroTest(s_test.SynTest):
152
152
  self.eq([('test:str', 'cooler')], [n.ndef for n in nodes])
153
153
 
154
154
  # Inner vars win on conflict
155
- q = 'macro.set data2 ${ $data=$lib.dict(value=beef) [test:str=$data.value +#cool.story] }'
155
+ q = 'macro.set data2 ${ $data=({"value": "beef"}) [test:str=$data.value +#cool.story] }'
156
156
  msgs = await core.stormlist(q)
157
157
  self.stormIsInPrint('Set macro: data2', msgs)
158
158
 
@@ -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'])
@@ -76,7 +76,7 @@ class StormlibVaultTest(s_test.SynTest):
76
76
 
77
77
  opts = {'vars': {'iden': uiden}, 'user': visi2.iden}
78
78
  msgs = await core.stormlist('$vault = $lib.vault.get($iden)', opts=opts)
79
- self.stormIsInErr(f'User (visi2) has insufficient permissions (requires: read).', msgs)
79
+ self.stormIsInErr(f'User requires read permission on vault: {uiden}.', msgs)
80
80
 
81
81
  # Set and delete data
82
82
  opts = {'vars': {'iden': uiden}}