synapse 2.161.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 (48) hide show
  1. synapse/daemon.py +7 -2
  2. synapse/lib/cell.py +7 -3
  3. synapse/lib/layer.py +20 -1
  4. synapse/lib/rstorm.py +16 -0
  5. synapse/lib/storm.py +17 -1
  6. synapse/lib/stormlib/stix.py +6 -3
  7. synapse/lib/stormtypes.py +148 -19
  8. synapse/lib/version.py +2 -2
  9. synapse/lib/view.py +15 -2
  10. synapse/models/inet.py +9 -0
  11. synapse/models/infotech.py +28 -26
  12. synapse/models/orgs.py +3 -0
  13. synapse/models/proj.py +9 -2
  14. synapse/models/risk.py +32 -0
  15. synapse/telepath.py +2 -0
  16. synapse/tests/files/rstorm/testsvc.py +8 -1
  17. synapse/tests/files/stormpkg/testpkg.yaml +4 -0
  18. synapse/tests/test_axon.py +4 -4
  19. synapse/tests/test_cortex.py +6 -6
  20. synapse/tests/test_daemon.py +19 -0
  21. synapse/tests/test_lib_ast.py +16 -16
  22. synapse/tests/test_lib_grammar.py +4 -4
  23. synapse/tests/test_lib_rstorm.py +38 -2
  24. synapse/tests/test_lib_storm.py +14 -14
  25. synapse/tests/test_lib_stormhttp.py +18 -18
  26. synapse/tests/test_lib_stormlib_auth.py +3 -3
  27. synapse/tests/test_lib_stormlib_cell.py +1 -1
  28. synapse/tests/test_lib_stormlib_cortex.py +50 -2
  29. synapse/tests/test_lib_stormlib_json.py +2 -2
  30. synapse/tests/test_lib_stormlib_macro.py +1 -1
  31. synapse/tests/test_lib_stormlib_modelext.py +37 -37
  32. synapse/tests/test_lib_stormlib_oauth.py +20 -20
  33. synapse/tests/test_lib_stormlib_stix.py +3 -1
  34. synapse/tests/test_lib_stormtypes.py +127 -45
  35. synapse/tests/test_lib_stormwhois.py +1 -1
  36. synapse/tests/test_lib_trigger.py +11 -11
  37. synapse/tests/test_lib_view.py +23 -1
  38. synapse/tests/test_model_crypto.py +1 -1
  39. synapse/tests/test_model_inet.py +6 -0
  40. synapse/tests/test_model_orgs.py +2 -1
  41. synapse/tests/test_model_proj.py +6 -0
  42. synapse/tests/test_model_risk.py +10 -0
  43. synapse/tests/test_tools_storm.py +1 -1
  44. {synapse-2.161.0.dist-info → synapse-2.162.0.dist-info}/METADATA +3 -1
  45. {synapse-2.161.0.dist-info → synapse-2.162.0.dist-info}/RECORD +48 -48
  46. {synapse-2.161.0.dist-info → synapse-2.162.0.dist-info}/LICENSE +0 -0
  47. {synapse-2.161.0.dist-info → synapse-2.162.0.dist-info}/WHEEL +0 -0
  48. {synapse-2.161.0.dist-info → synapse-2.162.0.dist-info}/top_level.txt +0 -0
@@ -735,9 +735,9 @@ class StormTest(s_t_utils.SynTest):
735
735
  # check that the feed API uses toprim
736
736
  email = await core.callStorm('''
737
737
  $iden = $lib.guid()
738
- $props = $lib.dict(email=visi@vertex.link)
738
+ $props = ({"email": "visi@vertex.link"})
739
739
  $lib.feed.ingest(syn.nodes, (
740
- ( (ps:contact, $iden), $lib.dict(props=$props)),
740
+ ( (ps:contact, $iden), ({"props": $props})),
741
741
  ))
742
742
  ps:contact=$iden
743
743
  return(:email)
@@ -746,9 +746,9 @@ class StormTest(s_t_utils.SynTest):
746
746
 
747
747
  email = await core.callStorm('''
748
748
  $iden = $lib.guid()
749
- $props = $lib.dict(email=visi@vertex.link)
749
+ $props = ({"email": "visi@vertex.link"})
750
750
  yield $lib.feed.genr(syn.nodes, (
751
- ( (ps:contact, $iden), $lib.dict(props=$props)),
751
+ ( (ps:contact, $iden), ({"props": $props})),
752
752
  ))
753
753
  return(:email)
754
754
  ''')
@@ -777,7 +777,7 @@ class StormTest(s_t_utils.SynTest):
777
777
  # and again to test *not* creating it...
778
778
  self.eq(0, await core.callStorm('return($lib.queue.gen(woot).size())'))
779
779
 
780
- self.eq({'foo': 'bar'}, await core.callStorm('return($lib.dict( foo = bar ))'))
780
+ self.eq({'foo': 'bar'}, await core.callStorm('return(({ "foo" : "bar" }))'))
781
781
 
782
782
  ddef0 = await core.callStorm('return($lib.dmon.add(${ $lib.queue.gen(hehedmon).put(lolz) $lib.time.sleep(10) }, name=hehedmon))')
783
783
  ddef1 = await core.callStorm('return($lib.dmon.get($iden))', opts={'vars': {'iden': ddef0.get('iden')}})
@@ -1226,12 +1226,12 @@ class StormTest(s_t_utils.SynTest):
1226
1226
  await core.nodes('cron.list')
1227
1227
 
1228
1228
  self.eq({'foo': 'bar', 'baz': 'faz'}, await core.callStorm('''
1229
- return($lib.dict( // do foo thing
1230
- foo /* hehe */ = /* haha */ bar, //lol
1231
- baz // hehe
1232
- = // haha
1233
- faz // hehe
1234
- ))
1229
+ return(({ // do foo thing
1230
+ "foo" /* hehe */ : /* haha */ "bar", //lol
1231
+ "baz" // hehe
1232
+ : // haha
1233
+ "faz" // hehe
1234
+ }))
1235
1235
  '''))
1236
1236
 
1237
1237
  self.eq(('foo', 'bar', 'baz'), await core.callStorm('''
@@ -1805,7 +1805,7 @@ class StormTest(s_t_utils.SynTest):
1805
1805
 
1806
1806
  # Headers as list of tuples, params as dict
1807
1807
  q = '''
1808
- $params=$lib.dict(key=valu, foo=bar)
1808
+ $params=({"key": "valu", "foo": "bar"})
1809
1809
  $hdr = (
1810
1810
  ("User-Agent", "my fav ua"),
1811
1811
  )|
@@ -2045,7 +2045,7 @@ class StormTest(s_t_utils.SynTest):
2045
2045
  self.none(await core.callStorm('''
2046
2046
  [ ps:contact = * ]
2047
2047
  if $node {
2048
- $foo = $lib.dict()
2048
+ $foo = ({})
2049
2049
  $foo.bar = $lib.undef
2050
2050
  return($foo.bar)
2051
2051
  }
@@ -2064,7 +2064,7 @@ class StormTest(s_t_utils.SynTest):
2064
2064
  # runtsafe variants
2065
2065
  self.eq(('foo', 'baz'), await core.callStorm('$foo = (foo, bar, baz) $foo.1 = $lib.undef return($foo)'))
2066
2066
  self.eq(('foo', 'bar'), await core.callStorm('$foo = (foo, bar, baz) $foo."-1" = $lib.undef return($foo)'))
2067
- self.none(await core.callStorm('$foo = $lib.dict() $foo.bar = 10 $foo.bar = $lib.undef return($foo.bar)'))
2067
+ self.none(await core.callStorm('$foo = ({}) $foo.bar = 10 $foo.bar = $lib.undef return($foo.bar)'))
2068
2068
  self.eq(('woot',), await core.callStorm('''
2069
2069
  $foo = (foo, bar, baz)
2070
2070
  $foo.0 = $lib.undef
@@ -64,8 +64,8 @@ class StormHttpTest(s_test.SynTest):
64
64
 
65
65
  # Header and params as dict
66
66
  q = '''
67
- $params=$lib.dict(key=valu, foo=bar, baz=$lib.false)
68
- $hdr = $lib.dict(true=$lib.true)
67
+ $params=({"key": "valu", "foo": "bar", "baz": $lib.false})
68
+ $hdr = ({"true": $lib.true})
69
69
  $hdr."User-Agent"="Storm HTTP Stuff"
70
70
  $k = (0)
71
71
  $hdr.$k="Why"
@@ -240,7 +240,7 @@ class StormHttpTest(s_test.SynTest):
240
240
  opts = {'vars': {'url': url, 'noauth_url': noauth_url, 'newp_url': newp_url}}
241
241
 
242
242
  q = '''
243
- $params=$lib.dict(key=valu, foo=bar)
243
+ $params=({"key": "valu", "foo": "bar"})
244
244
  $hdr = (
245
245
  ("User-Agent", "Storm HTTP Stuff"),
246
246
  )
@@ -256,7 +256,7 @@ class StormHttpTest(s_test.SynTest):
256
256
  self.eq('1', headers.get('Head'))
257
257
 
258
258
  q = '''
259
- $params=$lib.dict(key=valu, redirect='http://test.newp/')
259
+ $params=({"key": "valu", "redirect": 'http://test.newp/'})
260
260
  $hdr = (
261
261
  ("User-Agent", "Storm HTTP Stuff"),
262
262
  )
@@ -273,7 +273,7 @@ class StormHttpTest(s_test.SynTest):
273
273
  self.eq('http://test.newp/', headers.get('Location'))
274
274
 
275
275
  q = '''
276
- $params=$lib.dict(key=valu, redirect=$noauth_url)
276
+ $params=({"key": "valu", "redirect": $noauth_url})
277
277
  $hdr = (
278
278
  ("User-Agent", "Storm HTTP Stuff"),
279
279
  )
@@ -286,7 +286,7 @@ class StormHttpTest(s_test.SynTest):
286
286
  self.eq(b'', body)
287
287
 
288
288
  q = '''
289
- $params=$lib.dict(key=valu, redirect=$newp_url)
289
+ $params=({"key": "valu", "redirect": $newp_url})
290
290
  $hdr = (
291
291
  ("User-Agent", "Storm HTTP Stuff"),
292
292
  )
@@ -299,7 +299,7 @@ class StormHttpTest(s_test.SynTest):
299
299
  self.eq(b'', body)
300
300
 
301
301
  q = '''
302
- $params=$lib.dict(key=valu, redirect="http://127.0.0.1/newp")
302
+ $params=({"key": "valu", "redirect": "http://127.0.0.1/newp"})
303
303
  $hdr = (
304
304
  ("User-Agent", "Storm HTTP Stuff"),
305
305
  )
@@ -321,7 +321,7 @@ class StormHttpTest(s_test.SynTest):
321
321
  url = f'https://root:root@127.0.0.1:{port}/api/v0/test'
322
322
  opts = {'vars': {'url': url}}
323
323
  q = '''
324
- $params=$lib.dict(key=valu, foo=bar)
324
+ $params=({"key": "valu", "foo": "bar"})
325
325
  $hdr = (
326
326
  ("User-Agent", "Storm HTTP Stuff"),
327
327
  )
@@ -337,7 +337,7 @@ class StormHttpTest(s_test.SynTest):
337
337
  url = f'https://root:root@127.0.0.1:{port}/api/v0/test'
338
338
  opts = {'vars': {'url': url, 'sleep': 1, 'timeout': 2}}
339
339
  q = '''
340
- $params=$lib.dict(key=valu, foo=bar, sleep=$sleep)
340
+ $params=({"key": "valu", "foo": "bar", "sleep": $sleep})
341
341
  $hdr = (
342
342
  ("User-Agent", "Storm HTTP Stuff"),
343
343
  )
@@ -351,7 +351,7 @@ class StormHttpTest(s_test.SynTest):
351
351
  url = f'https://root:root@127.0.0.1:{port}/api/v0/test'
352
352
  opts = {'vars': {'url': url, 'sleep': 10, 'timeout': 1}}
353
353
  q = '''
354
- $params=$lib.dict(key=valu, foo=bar, sleep=$sleep)
354
+ $params=({"key": "valu", "foo": "bar", "sleep": $sleep})
355
355
  $hdr = (
356
356
  ("User-Agent", "Storm HTTP Stuff"),
357
357
  )
@@ -374,7 +374,7 @@ class StormHttpTest(s_test.SynTest):
374
374
 
375
375
  adduser = '''
376
376
  $url = $lib.str.format("https://root:root@127.0.0.1:{port}/api/v1/auth/adduser", port=$port)
377
- $user = $lib.dict(name=$name, passwd=$passwd)
377
+ $user = ({"name": $name, "passwd": $passwd})
378
378
  $post = $lib.inet.http.post($url, json=$user, ssl_verify=$(0)).json().result.name
379
379
  $lib.print($post)
380
380
  [ test:str=$post ]
@@ -387,7 +387,7 @@ class StormHttpTest(s_test.SynTest):
387
387
  adduser = '''
388
388
  $url = $lib.str.format("https://root:root@127.0.0.1:{port}/api/v1/auth/adduser", port=$port)
389
389
  $user = $lib.str.format('{"name": "{name}", "passwd": "{passwd}"}', name=$name, passwd=$passwd)
390
- $header = $lib.dict("Content-Type"="application/json")
390
+ $header = ({"Content-Type": "application/json"})
391
391
  $post = $lib.inet.http.post($url, headers=$header, body=$user, ssl_verify=$(0)).json().result.name
392
392
  [ test:str=$post ]
393
393
  '''
@@ -400,7 +400,7 @@ class StormHttpTest(s_test.SynTest):
400
400
  url = f'https://root:root@127.0.0.1:{port}/api/v0/test'
401
401
  opts = {'vars': {'url': url, 'buf': b'1234'}}
402
402
  q = '''
403
- $params=$lib.dict(key=valu, foo=bar)
403
+ $params=({"key": "valu", "foo": "bar"})
404
404
  $resp = $lib.inet.http.post($url, params=$params, body=$buf, ssl_verify=$lib.false)
405
405
  return ( $resp.json() )
406
406
  '''
@@ -411,9 +411,9 @@ class StormHttpTest(s_test.SynTest):
411
411
 
412
412
  q = '''
413
413
  $fields=$lib.list(
414
- $lib.dict(name=foo, value=bar),
415
- $lib.dict(name=foo, value=bar2),
416
- $lib.dict(name=baz, value=cool)
414
+ ({"name": "foo", "value": "bar"}),
415
+ ({"name": "foo", "value": "bar2"}),
416
+ ({"name": "baz", "value": "cool"})
417
417
  )
418
418
  $resp = $lib.inet.http.post($url, fields=$fields, ssl_verify=$lib.false)
419
419
  return ( $resp.json() )
@@ -467,7 +467,7 @@ class StormHttpTest(s_test.SynTest):
467
467
  text = '''
468
468
  $url = $lib.str.format("https://root:root@127.0.0.1:{port}/api/v1/storm", port=$port)
469
469
  $stormq = "($size, $sha2) = $lib.bytes.put($lib.base64.decode('dmVydGV4')) [ test:str = $sha2 ] [ test:int = $size ]"
470
- $json = $lib.dict(query=$stormq)
470
+ $json = ({"query": $stormq})
471
471
  $bytez = $lib.inet.http.post($url, json=$json, ssl_verify=$(0))
472
472
  '''
473
473
  opts = {'vars': {'port': port}}
@@ -482,7 +482,7 @@ class StormHttpTest(s_test.SynTest):
482
482
 
483
483
  text = '''
484
484
  $url = $lib.str.format("https://root:root@127.0.0.1:{port}/api/v1/storm", port=$port)
485
- $json = $lib.dict(query="test:str")
485
+ $json = ({"query": "test:str"})
486
486
  $body = $json
487
487
  $resp=$lib.inet.http.post($url, json=$json, body=$body, ssl_verify=$(0))
488
488
  return ( ($resp.code, $resp.err) )
@@ -420,8 +420,8 @@ class StormLibAuthTest(s_test.SynTest):
420
420
  async with self.getTestCore() as core:
421
421
  self.none(await core.callStorm('return($lib.user.json.get(foo))'))
422
422
  self.none(await core.callStorm('return($lib.user.json.get(foo, prop=bar))'))
423
- self.true(await core.callStorm('return($lib.user.json.set(hi, $lib.dict(foo=bar, baz=faz)))'))
424
- self.true(await core.callStorm('return($lib.user.json.set(bye/bye, $lib.dict(zip=zop, bip=bop)))'))
423
+ self.true(await core.callStorm('return($lib.user.json.set(hi, ({"foo": "bar", "baz": "faz"})))'))
424
+ self.true(await core.callStorm('return($lib.user.json.set(bye/bye, ({"zip": "zop", "bip": "bop"})))'))
425
425
  self.eq('bar', await core.callStorm('return($lib.user.json.get(hi, prop=foo))'))
426
426
  self.eq({'foo': 'bar', 'baz': 'faz'}, await core.callStorm('return($lib.user.json.get(hi))'))
427
427
 
@@ -454,7 +454,7 @@ class StormLibAuthTest(s_test.SynTest):
454
454
  await core.callStorm('return($lib.auth.users.byname(root).json.get(bye/bye, prop=zip))', opts=asvisi)
455
455
 
456
456
  self.none(await core.callStorm('return($lib.user.json.get(hi))', opts=asvisi))
457
- await core.callStorm('if (not $lib.user.json.has(hehe)) { $lib.user.json.set(hehe, $lib.dict()) }', opts=asvisi)
457
+ await core.callStorm('if (not $lib.user.json.has(hehe)) { $lib.user.json.set(hehe, ({})) }', opts=asvisi)
458
458
 
459
459
  self.true(await core.callStorm('return($lib.user.json.set(hehe, haha, prop=foo))', opts=asvisi))
460
460
  self.true(await core.callStorm('return($lib.user.json.set(hehe, haha, prop=foo))', opts=asvisi))
@@ -187,7 +187,7 @@ class StormCellTest(s_test.SynTest):
187
187
  }
188
188
  $lib.exit('No view found for name={name}', name=$name)
189
189
  }
190
- $ret = $lib.dict()
190
+ $ret = ({})
191
191
  $ret.baseview=$get_view(default)
192
192
  $ret.fork1a=$get_view(base1a)
193
193
  $ret.fork2a=$get_view(base2a)
@@ -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:
@@ -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'])