synapse 2.193.0__py311-none-any.whl → 2.194.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/cortex.py +3 -7
- synapse/datamodel.py +6 -3
- synapse/exc.py +1 -1
- synapse/lib/agenda.py +17 -4
- synapse/lib/ast.py +217 -86
- synapse/lib/auth.py +1 -0
- synapse/lib/parser.py +4 -0
- synapse/lib/snap.py +40 -11
- synapse/lib/storm.lark +16 -1
- synapse/lib/storm.py +6 -4
- synapse/lib/storm_format.py +1 -0
- synapse/lib/stormctrl.py +88 -6
- synapse/lib/stormlib/cache.py +6 -2
- synapse/lib/stormlib/scrape.py +1 -1
- synapse/lib/stormlib/stix.py +8 -8
- synapse/lib/stormtypes.py +13 -5
- synapse/lib/version.py +2 -2
- synapse/lib/view.py +20 -3
- synapse/models/geopol.py +1 -0
- synapse/models/geospace.py +1 -0
- synapse/models/inet.py +3 -0
- synapse/models/infotech.py +10 -2
- synapse/models/orgs.py +7 -2
- synapse/models/person.py +15 -4
- synapse/models/risk.py +3 -0
- synapse/models/telco.py +10 -3
- synapse/tests/test_axon.py +6 -6
- synapse/tests/test_cortex.py +130 -11
- synapse/tests/test_exc.py +1 -0
- synapse/tests/test_lib_agenda.py +125 -1
- synapse/tests/test_lib_aha.py +13 -6
- synapse/tests/test_lib_ast.py +258 -9
- synapse/tests/test_lib_auth.py +6 -7
- synapse/tests/test_lib_grammar.py +14 -0
- synapse/tests/test_lib_layer.py +1 -1
- synapse/tests/test_lib_lmdbslab.py +3 -3
- synapse/tests/test_lib_storm.py +201 -25
- synapse/tests/test_lib_stormctrl.py +65 -0
- synapse/tests/test_lib_stormhttp.py +5 -5
- synapse/tests/test_lib_stormlib_auth.py +5 -5
- synapse/tests/test_lib_stormlib_cache.py +38 -6
- synapse/tests/test_lib_stormlib_modelext.py +3 -3
- synapse/tests/test_lib_stormlib_scrape.py +4 -4
- synapse/tests/test_lib_stormlib_spooled.py +1 -1
- synapse/tests/test_lib_stormlib_xml.py +5 -5
- synapse/tests/test_lib_stormtypes.py +54 -57
- synapse/tests/test_lib_view.py +1 -1
- synapse/tests/test_model_base.py +1 -2
- synapse/tests/test_model_geopol.py +4 -0
- synapse/tests/test_model_geospace.py +6 -0
- synapse/tests/test_model_inet.py +3 -0
- synapse/tests/test_model_infotech.py +10 -1
- synapse/tests/test_model_orgs.py +17 -2
- synapse/tests/test_model_person.py +23 -1
- synapse/tests/test_model_risk.py +11 -0
- synapse/tests/test_tools_healthcheck.py +4 -4
- synapse/tests/test_utils.py +17 -18
- synapse/tests/utils.py +0 -35
- synapse/tools/changelog.py +6 -4
- synapse/tools/storm.py +1 -1
- {synapse-2.193.0.dist-info → synapse-2.194.0.dist-info}/METADATA +5 -5
- {synapse-2.193.0.dist-info → synapse-2.194.0.dist-info}/RECORD +65 -64
- {synapse-2.193.0.dist-info → synapse-2.194.0.dist-info}/WHEEL +1 -1
- {synapse-2.193.0.dist-info → synapse-2.194.0.dist-info}/LICENSE +0 -0
- {synapse-2.193.0.dist-info → synapse-2.194.0.dist-info}/top_level.txt +0 -0
|
@@ -196,7 +196,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
196
196
|
|
|
197
197
|
await core.callStorm('$lib.jsonstor.set(hi, hehe, prop=foo)')
|
|
198
198
|
items = await core.callStorm('''
|
|
199
|
-
$list =
|
|
199
|
+
$list = ()
|
|
200
200
|
for $item in $lib.jsonstor.iter(bye) { $list.append($item) }
|
|
201
201
|
return($list)
|
|
202
202
|
''')
|
|
@@ -573,9 +573,9 @@ class StormTypesTest(s_test.SynTest):
|
|
|
573
573
|
self.eq(2, await core.callStorm('$x = asdf return($x.find(d))'))
|
|
574
574
|
self.eq(None, await core.callStorm('$x = asdf return($x.find(v))'))
|
|
575
575
|
|
|
576
|
-
self.eq(('f', 'o', 'o'), await core.callStorm('$x =
|
|
577
|
-
self.eq(('o', 'o', 'b', 'a'), await core.callStorm('$x =
|
|
578
|
-
self.eq(('o', 'o', 'b', 'a', 'r'), await core.callStorm('$x =
|
|
576
|
+
self.eq(('f', 'o', 'o'), await core.callStorm('$x = () $x.extend((f, o, o)) return($x)'))
|
|
577
|
+
self.eq(('o', 'o', 'b', 'a'), await core.callStorm('$x = (f, o, o, b, a, r) return($x.slice(1, 5))'))
|
|
578
|
+
self.eq(('o', 'o', 'b', 'a', 'r'), await core.callStorm('$x = (f, o, o, b, a, r) return($x.slice(1))'))
|
|
579
579
|
|
|
580
580
|
self.true(await core.callStorm('return($lib.trycast(inet:ipv4, 1.2.3.4).0)'))
|
|
581
581
|
self.false(await core.callStorm('return($lib.trycast(inet:ipv4, asdf).0)'))
|
|
@@ -595,11 +595,11 @@ class StormTypesTest(s_test.SynTest):
|
|
|
595
595
|
self.false(await core.callStorm('$x=(foo,bar) return($x.has((foo,bar)))'))
|
|
596
596
|
|
|
597
597
|
await core.addStormPkg(pdef)
|
|
598
|
-
nodes = await core.nodes('[ inet:asn=$lib.min(20,
|
|
598
|
+
nodes = await core.nodes('[ inet:asn=$lib.min(20, (0x30)) ]')
|
|
599
599
|
self.len(1, nodes)
|
|
600
600
|
self.eq(20, nodes[0].ndef[1])
|
|
601
601
|
|
|
602
|
-
nodes = await core.nodes('[ inet:asn=$lib.min(20,
|
|
602
|
+
nodes = await core.nodes('[ inet:asn=$lib.min(20, (10, 30)) ]')
|
|
603
603
|
self.len(1, nodes)
|
|
604
604
|
self.eq(10, nodes[0].ndef[1])
|
|
605
605
|
|
|
@@ -744,7 +744,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
744
744
|
await core.nodes('$lib.print($lib.len($true))', opts=opts)
|
|
745
745
|
self.eq(cm.exception.get('mesg'), 'Object builtins.bool does not have a length.')
|
|
746
746
|
|
|
747
|
-
mesgs = await core.stormlist('$lib.print(
|
|
747
|
+
mesgs = await core.stormlist('$lib.print((1,(2),3))')
|
|
748
748
|
self.stormIsInPrint("['1', 2, '3']", mesgs)
|
|
749
749
|
|
|
750
750
|
mesgs = await core.stormlist('$lib.print(${ $foo=bar })')
|
|
@@ -768,7 +768,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
768
768
|
mesgs = await core.stormlist('$lib.print($lib.queue.add(testq))')
|
|
769
769
|
self.stormIsInPrint("queue: testq", mesgs)
|
|
770
770
|
|
|
771
|
-
mesgs = await core.stormlist('$lib.pprint(
|
|
771
|
+
mesgs = await core.stormlist('$lib.pprint((1,2,3))')
|
|
772
772
|
self.stormIsInPrint("('1', '2', '3')", mesgs)
|
|
773
773
|
|
|
774
774
|
mesgs = await core.stormlist('$lib.pprint(({"foo": "1", "bar": "2"}))')
|
|
@@ -788,7 +788,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
788
788
|
# lib.guid()
|
|
789
789
|
opts = {'vars': {'x': {'foo': 'bar'}, 'y': ['foo']}}
|
|
790
790
|
guid00 = await core.callStorm('return($lib.guid($x, $y))', opts=opts)
|
|
791
|
-
guid01 = await core.callStorm('$x=({"foo": "bar"}) $y
|
|
791
|
+
guid01 = await core.callStorm('$x=({"foo": "bar"}) $y=(foo,) return($lib.guid($x, $y))')
|
|
792
792
|
self.eq(guid00, guid01)
|
|
793
793
|
|
|
794
794
|
guid00 = await core.callStorm('return($lib.guid(foo))')
|
|
@@ -1519,8 +1519,8 @@ class StormTypesTest(s_test.SynTest):
|
|
|
1519
1519
|
async def test_storm_lib_list(self):
|
|
1520
1520
|
async with self.getTestCore() as core:
|
|
1521
1521
|
# Base List object behavior
|
|
1522
|
-
q = '''
|
|
1523
|
-
$list
|
|
1522
|
+
q = '''
|
|
1523
|
+
$list=(1,2,3)
|
|
1524
1524
|
// __len__
|
|
1525
1525
|
$lib.print('List size is {len}', len=$lib.len($list))
|
|
1526
1526
|
// aiter/iter method
|
|
@@ -1541,7 +1541,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
1541
1541
|
}
|
|
1542
1542
|
$lib.print('Sum is now {sum}', sum=$sum)
|
|
1543
1543
|
// Empty lists may also be made
|
|
1544
|
-
$elst
|
|
1544
|
+
$elst=()
|
|
1545
1545
|
$lib.print('elst size is {len}', len=$lib.len($elst))
|
|
1546
1546
|
'''
|
|
1547
1547
|
msgs = await core.stormlist(q)
|
|
@@ -1570,26 +1570,13 @@ class StormTypesTest(s_test.SynTest):
|
|
|
1570
1570
|
ret = await core.callStorm(q)
|
|
1571
1571
|
self.eq(ret, ('bar', 'baz', 'foo',))
|
|
1572
1572
|
|
|
1573
|
-
# Sort a few text objects
|
|
1574
|
-
q = '$foo=$lib.text(foo) $bar=$lib.text(bar) $baz=$lib.text(baz) $v=($foo, $bar, $baz) $v.sort() return ($v)'
|
|
1575
|
-
ret = await core.callStorm(q)
|
|
1576
|
-
self.eq(ret, ('bar', 'baz', 'foo',))
|
|
1577
|
-
|
|
1578
1573
|
# incompatible sort types
|
|
1579
1574
|
with self.raises(s_exc.StormRuntimeError):
|
|
1580
1575
|
await core.callStorm('$v=(foo,bar,(1)) $v.sort() return ($v)')
|
|
1581
1576
|
|
|
1582
|
-
# mix Prims and heavy objects
|
|
1583
|
-
with self.raises(s_exc.StormRuntimeError):
|
|
1584
|
-
q = '$foo=$lib.text(foo) $bar=$lib.text(bar) $v=($foo, aString, $bar,) $v.sort() return ($v)'
|
|
1585
|
-
await core.callStorm(q)
|
|
1586
|
-
|
|
1587
1577
|
q = '$l = (1, 2, (3), 4, 1, (3), 3, asdf) return ( $l.unique() )'
|
|
1588
1578
|
self.eq(['1', '2', 3, '4', '3', 'asdf'], await core.callStorm(q))
|
|
1589
1579
|
|
|
1590
|
-
q = '$a=$lib.text(hehe) $b=$lib.text(haha) $c=$lib.text(hehe) $foo=($a, $b, $c) return ($foo.unique())'
|
|
1591
|
-
self.eq(['hehe', 'haha'], await core.callStorm(q))
|
|
1592
|
-
|
|
1593
1580
|
await core.addUser('lowuser1')
|
|
1594
1581
|
await core.addUser('lowuser2')
|
|
1595
1582
|
q = '''
|
|
@@ -1672,7 +1659,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
1672
1659
|
self.eq([1, 3, 4], await core.callStorm('$list = ([1, 2, 3, 4]) $list.pop(1) return($list)'))
|
|
1673
1660
|
|
|
1674
1661
|
with self.raises(s_exc.StormRuntimeError) as exc:
|
|
1675
|
-
await core.callStorm('$
|
|
1662
|
+
await core.callStorm('$foo=() $foo.pop()')
|
|
1676
1663
|
self.eq(exc.exception.get('mesg'), 'pop from empty list')
|
|
1677
1664
|
|
|
1678
1665
|
with self.raises(s_exc.StormRuntimeError) as exc:
|
|
@@ -1702,6 +1689,9 @@ class StormTypesTest(s_test.SynTest):
|
|
|
1702
1689
|
out = await core.callStorm(q, opts=opts)
|
|
1703
1690
|
self.eq(out, ["foo", "baz"])
|
|
1704
1691
|
|
|
1692
|
+
msgs = await core.stormlist('$list = $lib.list(foo, bar)')
|
|
1693
|
+
self.stormIsInWarn('$lib.list() is deprecated. Use ([]) instead.', msgs)
|
|
1694
|
+
|
|
1705
1695
|
async def test_storm_layer_getstornode(self):
|
|
1706
1696
|
|
|
1707
1697
|
async with self.getTestCore() as core:
|
|
@@ -1804,6 +1794,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
1804
1794
|
|
|
1805
1795
|
async def test_storm_text(self):
|
|
1806
1796
|
async with self.getTestCore() as core:
|
|
1797
|
+
# $lib.text() is deprecated (SYN-8482); test ensures the object works as expected until removed
|
|
1807
1798
|
nodes = await core.nodes('''
|
|
1808
1799
|
[ test:int=10 ] $text=$lib.text(hehe) { +test:int>=10 $text.add(haha) }
|
|
1809
1800
|
[ test:str=$text.str() ] +test:str''')
|
|
@@ -1817,6 +1808,10 @@ class StormTypesTest(s_test.SynTest):
|
|
|
1817
1808
|
self.stormIsInPrint('8', msgs)
|
|
1818
1809
|
self.stormIsInPrint('13', msgs)
|
|
1819
1810
|
|
|
1811
|
+
msgs = await core.stormlist('help --verbose $lib.text')
|
|
1812
|
+
self.stormIsInPrint('Warning', msgs)
|
|
1813
|
+
self.stormIsInPrint('$lib.text`` has been deprecated and will be removed in version 3.0.0', msgs)
|
|
1814
|
+
|
|
1820
1815
|
async def test_storm_set(self):
|
|
1821
1816
|
|
|
1822
1817
|
async with self.getTestCore() as core:
|
|
@@ -2139,14 +2134,14 @@ class StormTypesTest(s_test.SynTest):
|
|
|
2139
2134
|
|
|
2140
2135
|
# List
|
|
2141
2136
|
q = '''
|
|
2142
|
-
$list =
|
|
2137
|
+
$list = (1, 2, 3)
|
|
2143
2138
|
$set = $lib.set($list)
|
|
2144
2139
|
'''
|
|
2145
2140
|
msgs = await core.stormlist(q)
|
|
2146
2141
|
self.stormIsInErr('is mutable and cannot be used in a set', msgs)
|
|
2147
2142
|
|
|
2148
2143
|
q = '''
|
|
2149
|
-
$list =
|
|
2144
|
+
$list = (1, 2, 3, 1, 2, 3, 1, 2, 3)
|
|
2150
2145
|
$set = $lib.set()
|
|
2151
2146
|
$set.adds($list)
|
|
2152
2147
|
$lib.print('There are {count} items in the set', count=$lib.len($set))
|
|
@@ -2155,7 +2150,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
2155
2150
|
self.stormIsInPrint('There are 3 items in the set', msgs)
|
|
2156
2151
|
|
|
2157
2152
|
q = '''
|
|
2158
|
-
$list =
|
|
2153
|
+
$list = ((4, 5, 6, 7), (1, 2, 3, 4))
|
|
2159
2154
|
$set = $lib.set()
|
|
2160
2155
|
$set.adds($list)
|
|
2161
2156
|
$lib.print('There are {count} items in the set', count=$lib.len($set))
|
|
@@ -2212,7 +2207,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
2212
2207
|
|
|
2213
2208
|
# text
|
|
2214
2209
|
q = '''
|
|
2215
|
-
$text = $
|
|
2210
|
+
$text = () $text.append(beepboopgetthejedi)
|
|
2216
2211
|
$set = $lib.set($text)
|
|
2217
2212
|
'''
|
|
2218
2213
|
msgs = await core.stormlist(q)
|
|
@@ -2327,7 +2322,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
2327
2322
|
|
|
2328
2323
|
q = '''
|
|
2329
2324
|
inet:fqdn=vertex.link
|
|
2330
|
-
$path.meta.foobar =
|
|
2325
|
+
$path.meta.foobar = ('neato', 'burrito')
|
|
2331
2326
|
'''
|
|
2332
2327
|
msgs = [mesg async for mesg in proxy.storm(q)]
|
|
2333
2328
|
pode = [m[1] for m in msgs if m[0] == 'node'][0]
|
|
@@ -2350,7 +2345,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
2350
2345
|
|
|
2351
2346
|
q = '''
|
|
2352
2347
|
inet:fqdn=vertex.link
|
|
2353
|
-
$path.meta.$node =
|
|
2348
|
+
$path.meta.$node = ('foo', 'bar')
|
|
2354
2349
|
'''
|
|
2355
2350
|
msgs = [mesg async for mesg in proxy.storm(q)]
|
|
2356
2351
|
pode = [m[1] for m in msgs if m[0] == 'node'][0]
|
|
@@ -3427,8 +3422,6 @@ class StormTypesTest(s_test.SynTest):
|
|
|
3427
3422
|
self.eq('telepath:proxy:method', await core.callStorm('return( $lib.vars.type($lib.telepath.open($url).getCellInfo) )', opts))
|
|
3428
3423
|
self.eq('telepath:proxy:genrmethod', await core.callStorm('return( $lib.vars.type($lib.telepath.open($url).storm) )', opts))
|
|
3429
3424
|
|
|
3430
|
-
self.eq('text', await core.callStorm('return ( $lib.vars.type($lib.text(hehe)) )'))
|
|
3431
|
-
|
|
3432
3425
|
self.eq('node', await core.callStorm('[test:str=foo] return ($lib.vars.type($node))'))
|
|
3433
3426
|
self.eq('node:props', await core.callStorm('[test:str=foo] return ($lib.vars.type($node.props))'))
|
|
3434
3427
|
self.eq('node:data', await core.callStorm('[test:str=foo] return ($lib.vars.type($node.data))'))
|
|
@@ -3840,7 +3833,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
3840
3833
|
# Get the main view
|
|
3841
3834
|
mainiden = await core.callStorm('return($lib.view.get().iden)')
|
|
3842
3835
|
altview = await core.callStorm('''
|
|
3843
|
-
$layers =
|
|
3836
|
+
$layers = ()
|
|
3844
3837
|
for $layer in $lib.view.get().layers {
|
|
3845
3838
|
$layers.append($layer.iden)
|
|
3846
3839
|
}
|
|
@@ -3885,7 +3878,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
3885
3878
|
|
|
3886
3879
|
# List the views in the cortex
|
|
3887
3880
|
q = '''
|
|
3888
|
-
$views =
|
|
3881
|
+
$views = ()
|
|
3889
3882
|
for $view in $lib.view.list() {
|
|
3890
3883
|
$views.append($view.iden)
|
|
3891
3884
|
}
|
|
@@ -4310,7 +4303,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
4310
4303
|
view2['iden'],
|
|
4311
4304
|
)
|
|
4312
4305
|
self.eq(expect, await core.callStorm('''
|
|
4313
|
-
$views =
|
|
4306
|
+
$views = ()
|
|
4314
4307
|
for $view in $lib.view.list(deporder=$lib.true) {
|
|
4315
4308
|
$views.append($view.iden)
|
|
4316
4309
|
}
|
|
@@ -5445,7 +5438,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
5445
5438
|
self.eq(valu['none'], None)
|
|
5446
5439
|
self.eq(valu['bool'], True)
|
|
5447
5440
|
|
|
5448
|
-
q = '$list =
|
|
5441
|
+
q = '$list = () $list.append(foo) $list.append(bar) return($list)'
|
|
5449
5442
|
self.eq(('foo', 'bar'), await core.callStorm(q))
|
|
5450
5443
|
self.eq({'foo': 'bar'}, await core.callStorm('$dict = ({}) $dict.foo = bar return($dict)'))
|
|
5451
5444
|
q = '$tally = $lib.stats.tally() $tally.inc(foo) $tally.inc(foo) return($tally)'
|
|
@@ -5541,7 +5534,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
5541
5534
|
await core.nodes('[inet:ipv4=1.2.3.4]')
|
|
5542
5535
|
|
|
5543
5536
|
# TODO: should we asciify the buid here so it is json compatible?
|
|
5544
|
-
q = '''$list =
|
|
5537
|
+
q = '''$list = ()
|
|
5545
5538
|
for ($offs, $edit) in $lib.layer.get().edits(wait=$lib.false) {
|
|
5546
5539
|
$list.append($edit)
|
|
5547
5540
|
}
|
|
@@ -5954,7 +5947,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
5954
5947
|
with self.raises(s_ctrl.StormExit) as cm:
|
|
5955
5948
|
q = '[test:str=beep.sys] $lib.exit(foo)'
|
|
5956
5949
|
_ = await core.callStorm(q)
|
|
5957
|
-
self.eq(cm.exception.
|
|
5950
|
+
self.eq(cm.exception.get('mesg'), 'foo')
|
|
5958
5951
|
|
|
5959
5952
|
# Remote tests
|
|
5960
5953
|
async with core.getLocalProxy() as prox:
|
|
@@ -5968,7 +5961,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
5968
5961
|
q = '[test:str=beep.sys] $lib.exit()'
|
|
5969
5962
|
with self.raises(s_exc.SynErr) as cm:
|
|
5970
5963
|
_ = await prox.callStorm(q)
|
|
5971
|
-
self.eq(cm.exception.get('mesg'), '')
|
|
5964
|
+
self.eq(cm.exception.get('mesg'), 'StormExit: ')
|
|
5972
5965
|
self.eq(cm.exception.get('errx'), 'StormExit')
|
|
5973
5966
|
|
|
5974
5967
|
# A warn is emitted
|
|
@@ -5980,7 +5973,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
5980
5973
|
q = '[test:str=beep.sys] $lib.exit("foo {bar}", bar=baz)'
|
|
5981
5974
|
with self.raises(s_exc.SynErr) as cm:
|
|
5982
5975
|
_ = await prox.callStorm(q)
|
|
5983
|
-
self.eq(cm.exception.get('mesg'), 'foo baz')
|
|
5976
|
+
self.eq(cm.exception.get('mesg'), "StormExit: mesg='foo baz'")
|
|
5984
5977
|
self.eq(cm.exception.get('errx'), 'StormExit')
|
|
5985
5978
|
|
|
5986
5979
|
async def test_iter(self):
|
|
@@ -6003,7 +5996,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
6003
5996
|
self.len(2, nodes)
|
|
6004
5997
|
|
|
6005
5998
|
# set adds
|
|
6006
|
-
ret = await core.callStorm('$x=$lib.set() $y
|
|
5999
|
+
ret = await core.callStorm('$x=$lib.set() $y=(1,2,3) $x.adds($y) return($x)')
|
|
6007
6000
|
self.eq({'1', '2', '3'}, ret)
|
|
6008
6001
|
|
|
6009
6002
|
ret = await core.callStorm('$x=$lib.set() $y=({"foo": "1", "bar": "2"}) $x.adds($y) return($x)')
|
|
@@ -6019,7 +6012,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
6019
6012
|
self.eq({'a', 'b', 'c', 'd'}, ret)
|
|
6020
6013
|
|
|
6021
6014
|
# set rems
|
|
6022
|
-
ret = await core.callStorm('$x=$lib.set(1,2,3) $y
|
|
6015
|
+
ret = await core.callStorm('$x=$lib.set(1,2,3) $y=(1,2) $x.rems($y) return($x)')
|
|
6023
6016
|
self.eq({'3'}, ret)
|
|
6024
6017
|
|
|
6025
6018
|
scmd = '''
|
|
@@ -6043,7 +6036,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
6043
6036
|
self.eq({'d', 'c'}, ret)
|
|
6044
6037
|
|
|
6045
6038
|
# str join
|
|
6046
|
-
ret = await core.callStorm('$x
|
|
6039
|
+
ret = await core.callStorm('$x=(foo,bar,baz) $y=$lib.str.join("-", $x) return($y)')
|
|
6047
6040
|
self.eq('foo-bar-baz', ret)
|
|
6048
6041
|
|
|
6049
6042
|
ret = await core.callStorm('$y=$lib.str.join("-", (foo, bar, baz)) return($y)')
|
|
@@ -6093,7 +6086,7 @@ class StormTypesTest(s_test.SynTest):
|
|
|
6093
6086
|
self.eq(nodes[0].ndef[0], 'file:bytes')
|
|
6094
6087
|
sha256, size, created = nodes[0].get('sha256'), nodes[0].get('size'), nodes[0].get('.created')
|
|
6095
6088
|
|
|
6096
|
-
items = await core.callStorm('$x
|
|
6089
|
+
items = await core.callStorm('$x=() for $i in $lib.axon.list() { $x.append($i) } return($x)')
|
|
6097
6090
|
self.eq([(0, sha256, size)], items)
|
|
6098
6091
|
|
|
6099
6092
|
# test $lib.axon.del()
|
|
@@ -6108,21 +6101,21 @@ class StormTypesTest(s_test.SynTest):
|
|
|
6108
6101
|
self.eq((True, False), await core.callStorm('return($lib.axon.dels(($sha256, $sha256)))', opts=delopts))
|
|
6109
6102
|
self.false(await core.callStorm('return($lib.axon.del($sha256))', opts=delopts))
|
|
6110
6103
|
|
|
6111
|
-
items = await core.callStorm('$x
|
|
6104
|
+
items = await core.callStorm('$x=() for $i in $lib.axon.list() { $x.append($i) } return($x)')
|
|
6112
6105
|
self.len(0, items)
|
|
6113
6106
|
|
|
6114
6107
|
msgs = await core.stormlist(f'wget --no-ssl-verify https://127.0.0.1:{port}/api/v1/newp')
|
|
6115
6108
|
self.stormIsInWarn('HTTP code 404', msgs)
|
|
6116
6109
|
|
|
6117
|
-
self.len(1, await core.callStorm('$x
|
|
6110
|
+
self.len(1, await core.callStorm('$x=() for $i in $lib.axon.list() { $x.append($i) } return($x)'))
|
|
6118
6111
|
|
|
6119
6112
|
size, sha256 = await core.callStorm('return($lib.axon.put($buf))', opts={'vars': {'buf': b'foo'}})
|
|
6120
6113
|
|
|
6121
|
-
items = await core.callStorm('$x
|
|
6114
|
+
items = await core.callStorm('$x=() for $i in $lib.axon.list() { $x.append($i) } return($x)')
|
|
6122
6115
|
self.len(2, items)
|
|
6123
6116
|
self.eq((2, sha256, size), items[1])
|
|
6124
6117
|
|
|
6125
|
-
items = await core.callStorm('$x
|
|
6118
|
+
items = await core.callStorm('$x=() for $i in $lib.axon.list(2) { $x.append($i) } return($x)')
|
|
6126
6119
|
self.eq([(2, sha256, size)], items)
|
|
6127
6120
|
|
|
6128
6121
|
# test request timeout
|
|
@@ -6144,28 +6137,28 @@ class StormTypesTest(s_test.SynTest):
|
|
|
6144
6137
|
|
|
6145
6138
|
opts = {'vars': {'sha256': asdfitem[1]}}
|
|
6146
6139
|
self.eq(('asdf',), await core.callStorm('''
|
|
6147
|
-
$items =
|
|
6140
|
+
$items = ()
|
|
6148
6141
|
for $item in $lib.axon.readlines($sha256) { $items.append($item) }
|
|
6149
6142
|
return($items)
|
|
6150
6143
|
''', opts=opts))
|
|
6151
6144
|
|
|
6152
6145
|
opts = {'vars': {'sha256': linesitem[1]}}
|
|
6153
6146
|
self.eq(('vertex.link', 'woot.com'), await core.callStorm('''
|
|
6154
|
-
$items =
|
|
6147
|
+
$items = ()
|
|
6155
6148
|
for $item in $lib.axon.readlines($sha256) { $items.append($item) }
|
|
6156
6149
|
return($items)
|
|
6157
6150
|
''', opts=opts))
|
|
6158
6151
|
|
|
6159
6152
|
opts = {'vars': {'sha256': jsonsitem[1]}}
|
|
6160
6153
|
self.eq(({'fqdn': 'vertex.link'}, {'fqdn': 'woot.com'}), await core.callStorm('''
|
|
6161
|
-
$items =
|
|
6154
|
+
$items = ()
|
|
6162
6155
|
for $item in $lib.axon.jsonlines($sha256) { $items.append($item) }
|
|
6163
6156
|
return($items)
|
|
6164
6157
|
''', opts=opts))
|
|
6165
6158
|
|
|
6166
6159
|
async def waitlist():
|
|
6167
6160
|
items = await core.callStorm('''
|
|
6168
|
-
$x
|
|
6161
|
+
$x=()
|
|
6169
6162
|
for $i in $lib.axon.list(2, wait=$lib.true, timeout=1) {
|
|
6170
6163
|
$x.append($i)
|
|
6171
6164
|
}
|
|
@@ -6235,7 +6228,7 @@ words\tword\twrd'''
|
|
|
6235
6228
|
opts = {'vars': {'sha256': s_common.ehex(bin256)}}
|
|
6236
6229
|
with self.raises(s_exc.BadDataValu):
|
|
6237
6230
|
self.eq('', await core.callStorm('''
|
|
6238
|
-
$items =
|
|
6231
|
+
$items = ()
|
|
6239
6232
|
for $item in $lib.axon.readlines($sha256, errors=$lib.null) {
|
|
6240
6233
|
$items.append($item)
|
|
6241
6234
|
}
|
|
@@ -6243,7 +6236,7 @@ words\tword\twrd'''
|
|
|
6243
6236
|
''', opts=opts))
|
|
6244
6237
|
|
|
6245
6238
|
self.eq(('/$A\x00_v4\x1b',), await core.callStorm('''
|
|
6246
|
-
$items =
|
|
6239
|
+
$items = ()
|
|
6247
6240
|
for $item in $lib.axon.readlines($sha256, errors=ignore) { $items.append($item) }
|
|
6248
6241
|
return($items)
|
|
6249
6242
|
''', opts=opts))
|
|
@@ -6639,7 +6632,7 @@ words\tword\twrd'''
|
|
|
6639
6632
|
'newname': 'oops'
|
|
6640
6633
|
}})
|
|
6641
6634
|
|
|
6642
|
-
self.stormIsInErr('
|
|
6635
|
+
self.stormIsInErr('Setting name on auth:user is not marked readonly safe.', msgs)
|
|
6643
6636
|
|
|
6644
6637
|
mesg = 'Storm runtime is in readonly mode, cannot create or edit nodes and other graph data.'
|
|
6645
6638
|
|
|
@@ -6670,6 +6663,10 @@ words\tword\twrd'''
|
|
|
6670
6663
|
msgs = await core.stormlist(q, opts={'readonly': True, 'vars': {'iden': user}})
|
|
6671
6664
|
self.stormIsInErr(mesg, msgs)
|
|
6672
6665
|
|
|
6666
|
+
q = '$lib.pkg.add(({}))'
|
|
6667
|
+
msgs = await core.stormlist(q, opts={'readonly': True, 'vars': {'iden': user}})
|
|
6668
|
+
self.stormIsInErr('$lib.pkg.add() is not marked readonly safe.', msgs)
|
|
6669
|
+
|
|
6673
6670
|
async def test_storm_view_counts(self):
|
|
6674
6671
|
|
|
6675
6672
|
async with self.getTestCore() as core:
|
synapse/tests/test_lib_view.py
CHANGED
|
@@ -547,7 +547,7 @@ class ViewTest(s_t_utils.SynTest):
|
|
|
547
547
|
await core.nodes('inet:ipv4=0 | delnode')
|
|
548
548
|
|
|
549
549
|
edits = await core.callStorm('''
|
|
550
|
-
$nodeedits =
|
|
550
|
+
$nodeedits = ()
|
|
551
551
|
for ($offs, $edits) in $lib.layer.get().edits(wait=$lib.false) {
|
|
552
552
|
$nodeedits.extend($edits)
|
|
553
553
|
}
|
synapse/tests/test_model_base.py
CHANGED
|
@@ -338,8 +338,7 @@ class BaseTest(s_t_utils.SynTest):
|
|
|
338
338
|
'tel:mob:telem:cell:carrier', 'tel:mob:telem:imsi', 'tel:mob:telem:imei',
|
|
339
339
|
'tel:mob:telem:phone', 'tel:mob:telem:mac', 'tel:mob:telem:ipv4',
|
|
340
340
|
'tel:mob:telem:ipv6', 'tel:mob:telem:wifi', 'tel:mob:telem:wifi:ssid',
|
|
341
|
-
'tel:mob:telem:wifi:bssid', 'tel:mob:telem:
|
|
342
|
-
'tel:mob:telem:idfa', 'tel:mob:telem:name', 'tel:mob:telem:email',
|
|
341
|
+
'tel:mob:telem:wifi:bssid', 'tel:mob:telem:name', 'tel:mob:telem:email',
|
|
343
342
|
'tel:mob:telem:app', 'tel:mob:telem:data',
|
|
344
343
|
'inet:http:request:response:time', 'inet:http:request:response:code',
|
|
345
344
|
'inet:http:request:response:reason', 'inet:http:request:response:body',
|
|
@@ -18,6 +18,7 @@ class GeoPolModelTest(s_t_utils.SynTest):
|
|
|
18
18
|
]
|
|
19
19
|
''')
|
|
20
20
|
self.len(1, nodes)
|
|
21
|
+
node = nodes[0]
|
|
21
22
|
self.eq('visiland', nodes[0].get('name'))
|
|
22
23
|
self.eq(('visitopia',), nodes[0].get('names'))
|
|
23
24
|
self.eq(1640995200000, nodes[0].get('founded'))
|
|
@@ -29,6 +30,9 @@ class GeoPolModelTest(s_t_utils.SynTest):
|
|
|
29
30
|
self.len(2, await core.nodes('pol:country -> geo:name'))
|
|
30
31
|
self.len(3, await core.nodes('pol:country -> econ:currency'))
|
|
31
32
|
|
|
33
|
+
self.len(1, nodes := await core.nodes('[ pol:country=({"name": "visitopia"}) ]'))
|
|
34
|
+
self.eq(node.ndef, nodes[0].ndef)
|
|
35
|
+
|
|
32
36
|
nodes = await core.nodes('''
|
|
33
37
|
[ pol:vitals=*
|
|
34
38
|
:country={pol:country:name=visiland}
|
|
@@ -281,6 +281,12 @@ class GeoTest(s_t_utils.SynTest):
|
|
|
281
281
|
nodes = await core.nodes('[ geo:place=(hehe, haha) :names=("Foo Bar ", baz) ] -> geo:name')
|
|
282
282
|
self.eq(('baz', 'foo bar'), [n.ndef[1] for n in nodes])
|
|
283
283
|
|
|
284
|
+
nodes = await core.nodes('geo:place=(hehe, haha)')
|
|
285
|
+
node = nodes[0]
|
|
286
|
+
|
|
287
|
+
self.len(1, nodes := await core.nodes('[ geo:place=({"name": "baz"}) ]'))
|
|
288
|
+
self.eq(node.ndef, nodes[0].ndef)
|
|
289
|
+
|
|
284
290
|
async def test_eq(self):
|
|
285
291
|
|
|
286
292
|
async with self.getTestCore() as core:
|
synapse/tests/test_model_inet.py
CHANGED
|
@@ -3242,6 +3242,7 @@ class InetModelTest(s_t_utils.SynTest):
|
|
|
3242
3242
|
:type=chat.group
|
|
3243
3243
|
:group=$devsiden
|
|
3244
3244
|
:public=$lib.false
|
|
3245
|
+
:repost=*
|
|
3245
3246
|
)
|
|
3246
3247
|
|
|
3247
3248
|
(inet:service:message=(blackout, visi, 1715856900000, vertex, slack)
|
|
@@ -3291,6 +3292,7 @@ class InetModelTest(s_t_utils.SynTest):
|
|
|
3291
3292
|
self.nn(node.get('place'))
|
|
3292
3293
|
self.eq(node.get('place:name'), 'nyc')
|
|
3293
3294
|
|
|
3295
|
+
self.nn(nodes[0].get('repost'))
|
|
3294
3296
|
self.eq(nodes[0].get('group'), devsgrp.ndef[1])
|
|
3295
3297
|
self.false(nodes[0].get('public'))
|
|
3296
3298
|
self.eq(nodes[0].get('type'), 'chat.group.')
|
|
@@ -3320,6 +3322,7 @@ class InetModelTest(s_t_utils.SynTest):
|
|
|
3320
3322
|
nodes = await core.nodes('inet:service:message:type:taxonomy=chat.channel -> inet:service:message')
|
|
3321
3323
|
self.len(1, nodes)
|
|
3322
3324
|
self.eq(nodes[0].ndef, ('inet:service:message', 'c0d64c559e2f42d57b37b558458c068b'))
|
|
3325
|
+
self.len(1, await core.nodes('inet:service:message:repost :repost -> inet:service:message'))
|
|
3323
3326
|
|
|
3324
3327
|
q = '''
|
|
3325
3328
|
[ inet:service:resource=(web, api, vertex, slack)
|
|
@@ -761,7 +761,7 @@ class InfotechModelTest(s_t_utils.SynTest):
|
|
|
761
761
|
'techniques': teqs,
|
|
762
762
|
'url': url0,
|
|
763
763
|
}
|
|
764
|
-
q = '''[(it:prod:soft=$valu :name=$p.name :type=$p.type :names=$p.names
|
|
764
|
+
q = '''[(it:prod:soft=$valu :id="Foo " :name=$p.name :type=$p.type :names=$p.names
|
|
765
765
|
:desc=$p.desc :desc:short=$p."desc:short" :author:org=$p."author:org" :author:email=$p."author:email"
|
|
766
766
|
:author:acct=$p."author:acct" :author:person=$p."author:person"
|
|
767
767
|
:techniques=$p.techniques :url=$p.url )]'''
|
|
@@ -769,6 +769,7 @@ class InfotechModelTest(s_t_utils.SynTest):
|
|
|
769
769
|
self.len(1, nodes)
|
|
770
770
|
node = nodes[0]
|
|
771
771
|
self.eq(node.ndef, ('it:prod:soft', prod0))
|
|
772
|
+
self.eq(node.get('id'), 'Foo')
|
|
772
773
|
self.eq(node.get('name'), 'balloon maker')
|
|
773
774
|
self.eq(node.get('desc'), "Pennywise's patented balloon blower upper")
|
|
774
775
|
self.eq(node.get('desc:short'), 'balloon blower')
|
|
@@ -786,6 +787,10 @@ class InfotechModelTest(s_t_utils.SynTest):
|
|
|
786
787
|
self.eq(node.get('url'), url0)
|
|
787
788
|
self.len(1, await core.nodes('it:prod:soft:name="balloon maker" -> it:prod:soft:taxonomy'))
|
|
788
789
|
self.len(2, await core.nodes('it:prod:softname="balloon maker" -> it:prod:soft -> it:prod:softname'))
|
|
790
|
+
|
|
791
|
+
self.len(1, nodes := await core.nodes('[ it:prod:soft=({"name": "clowns inc"}) ]'))
|
|
792
|
+
self.eq(node.ndef, nodes[0].ndef)
|
|
793
|
+
|
|
789
794
|
# it:prod:softver - this does test a bunch of property related callbacks
|
|
790
795
|
ver0 = s_common.guid()
|
|
791
796
|
url1 = 'https://vertex.link/products/balloonmaker/release_101-beta.exe'
|
|
@@ -819,6 +824,10 @@ class InfotechModelTest(s_t_utils.SynTest):
|
|
|
819
824
|
self.eq(node.get('url'), url1)
|
|
820
825
|
self.eq(node.get('name'), 'balloonmaker')
|
|
821
826
|
self.eq(node.get('desc'), 'makes balloons')
|
|
827
|
+
|
|
828
|
+
self.len(1, nodes := await core.nodes('[ it:prod:softver=({"name": "clowns inc"}) ]'))
|
|
829
|
+
self.eq(node.ndef, nodes[0].ndef)
|
|
830
|
+
|
|
822
831
|
# callback node creation checks
|
|
823
832
|
self.len(1, await core.nodes('it:dev:str=V1.0.1-beta+exp.sha.5114f85'))
|
|
824
833
|
self.len(1, await core.nodes('it:dev:str=amd64'))
|
synapse/tests/test_model_orgs.py
CHANGED
|
@@ -60,6 +60,9 @@ class OuModelTest(s_t_utils.SynTest):
|
|
|
60
60
|
self.eq(node.get('desc'), 'MyDesc')
|
|
61
61
|
self.eq(node.get('prev'), goal)
|
|
62
62
|
|
|
63
|
+
self.len(1, nodes := await core.nodes('[ ou:goal=({"name": "foo goal"}) ]'))
|
|
64
|
+
self.eq(node.ndef, nodes[0].ndef)
|
|
65
|
+
|
|
63
66
|
nodes = await core.nodes('[(ou:hasgoal=$valu :stated=$lib.true :window="2019,2020")]',
|
|
64
67
|
opts={'vars': {'valu': (org0, goal)}})
|
|
65
68
|
self.len(1, nodes)
|
|
@@ -69,12 +72,13 @@ class OuModelTest(s_t_utils.SynTest):
|
|
|
69
72
|
self.eq(node.get('stated'), True)
|
|
70
73
|
self.eq(node.get('window'), (1546300800000, 1577836800000))
|
|
71
74
|
|
|
75
|
+
altgoal = s_common.guid()
|
|
72
76
|
timeline = s_common.guid()
|
|
73
77
|
|
|
74
78
|
props = {
|
|
75
79
|
'org': org0,
|
|
76
80
|
'goal': goal,
|
|
77
|
-
'goals': (goal,),
|
|
81
|
+
'goals': (goal, altgoal),
|
|
78
82
|
'actors': (acto,),
|
|
79
83
|
'camptype': 'get.pizza',
|
|
80
84
|
'name': 'MyName',
|
|
@@ -103,7 +107,7 @@ class OuModelTest(s_t_utils.SynTest):
|
|
|
103
107
|
self.eq(node.get('tag'), 'cno.camp.31337')
|
|
104
108
|
self.eq(node.get('org'), org0)
|
|
105
109
|
self.eq(node.get('goal'), goal)
|
|
106
|
-
self.eq(node.get('goals'), (goal,))
|
|
110
|
+
self.eq(node.get('goals'), sorted((goal, altgoal)))
|
|
107
111
|
self.eq(node.get('actors'), (acto,))
|
|
108
112
|
self.eq(node.get('name'), 'myname')
|
|
109
113
|
self.eq(node.get('names'), ('bar', 'foo'))
|
|
@@ -120,6 +124,10 @@ class OuModelTest(s_t_utils.SynTest):
|
|
|
120
124
|
self.eq(node.get('mitre:attack:campaign'), 'C0011')
|
|
121
125
|
self.eq(node.get('slogan'), 'for the people')
|
|
122
126
|
|
|
127
|
+
opts = {'vars': {'altgoal': altgoal}}
|
|
128
|
+
self.len(1, nodes := await core.nodes('[ ou:campaign=({"name": "foo", "goal": $altgoal}) ]', opts=opts))
|
|
129
|
+
self.eq(node.ndef, nodes[0].ndef)
|
|
130
|
+
|
|
123
131
|
self.len(1, await core.nodes(f'ou:campaign={camp} :slogan -> lang:phrase'))
|
|
124
132
|
nodes = await core.nodes(f'ou:campaign={camp} -> it:mitre:attack:campaign')
|
|
125
133
|
self.len(1, nodes)
|
|
@@ -405,6 +413,9 @@ class OuModelTest(s_t_utils.SynTest):
|
|
|
405
413
|
self.eq(node.get('place'), place0)
|
|
406
414
|
self.eq(node.get('url'), 'http://arrowcon.org/2018')
|
|
407
415
|
|
|
416
|
+
self.len(1, nodes := await core.nodes('[ ou:conference=({"name": "arrcon18"}) ]'))
|
|
417
|
+
self.eq(node.ndef, nodes[0].ndef)
|
|
418
|
+
|
|
408
419
|
props = {
|
|
409
420
|
'arrived': '201803010800',
|
|
410
421
|
'departed': '201803021500',
|
|
@@ -870,6 +881,7 @@ class OuModelTest(s_t_utils.SynTest):
|
|
|
870
881
|
] '''
|
|
871
882
|
nodes = await core.nodes(q)
|
|
872
883
|
self.len(1, nodes)
|
|
884
|
+
node = nodes[0]
|
|
873
885
|
self.nn(nodes[0].get('reporter'))
|
|
874
886
|
self.eq('foo bar', nodes[0].get('name'))
|
|
875
887
|
self.eq('vertex', nodes[0].get('reporter:name'))
|
|
@@ -884,6 +896,9 @@ class OuModelTest(s_t_utils.SynTest):
|
|
|
884
896
|
self.len(3, nodes)
|
|
885
897
|
self.len(3, await core.nodes('ou:industryname=baz -> ou:industry -> ou:industryname'))
|
|
886
898
|
|
|
899
|
+
self.len(1, nodes := await core.nodes('[ ou:industry=({"name": "faz"}) ]'))
|
|
900
|
+
self.eq(node.ndef, nodes[0].ndef)
|
|
901
|
+
|
|
887
902
|
async def test_ou_opening(self):
|
|
888
903
|
|
|
889
904
|
async with self.getTestCore() as core:
|
|
@@ -60,6 +60,9 @@ class PsModelTest(s_t_utils.SynTest):
|
|
|
60
60
|
self.eq(node.get('names'), ['billy bob'])
|
|
61
61
|
self.eq(node.get('photo'), file0)
|
|
62
62
|
|
|
63
|
+
self.len(1, nodes := await core.nodes('[ ps:person=({"name": "billy bob"}) ]'))
|
|
64
|
+
self.eq(node.ndef, nodes[0].ndef)
|
|
65
|
+
|
|
63
66
|
props = {
|
|
64
67
|
'dob': '2000',
|
|
65
68
|
'img': file0,
|
|
@@ -147,9 +150,11 @@ class PsModelTest(s_t_utils.SynTest):
|
|
|
147
150
|
'id:numbers': (('*', 'asdf'), ('*', 'qwer')),
|
|
148
151
|
'users': ('visi', 'invisigoth'),
|
|
149
152
|
'crypto:address': 'btc/1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2',
|
|
153
|
+
'langs': (lang00 := s_common.guid(),),
|
|
150
154
|
}
|
|
151
155
|
opts = {'vars': {'valu': con0, 'p': props}}
|
|
152
156
|
q = '''[(ps:contact=$valu
|
|
157
|
+
:bio="I am ironman."
|
|
153
158
|
:org=$p.org :asof=$p.asof :person=$p.person
|
|
154
159
|
:place=$p.place :place:name=$p."place:name" :name=$p.name
|
|
155
160
|
:title=$p.title :orgname=$p.orgname :user=$p.user
|
|
@@ -165,7 +170,7 @@ class PsModelTest(s_t_utils.SynTest):
|
|
|
165
170
|
:birth:place:name=$p."birth:place:name"
|
|
166
171
|
:death:place=$p."death:place" :death:place:loc=$p."death:place:loc"
|
|
167
172
|
:death:place:name=$p."death:place:name"
|
|
168
|
-
:service:accounts=(*, *)
|
|
173
|
+
:service:accounts=(*, *) :langs=$p.langs
|
|
169
174
|
)]'''
|
|
170
175
|
nodes = await core.nodes(q, opts=opts)
|
|
171
176
|
self.len(1, nodes)
|
|
@@ -178,6 +183,7 @@ class PsModelTest(s_t_utils.SynTest):
|
|
|
178
183
|
self.eq(node.get('place'), place)
|
|
179
184
|
self.eq(node.get('place:name'), 'the shire')
|
|
180
185
|
self.eq(node.get('name'), 'tony stark')
|
|
186
|
+
self.eq(node.get('bio'), 'I am ironman.')
|
|
181
187
|
self.eq(node.get('title'), 'ceo')
|
|
182
188
|
self.eq(node.get('titles'), ('haha', 'hehe'))
|
|
183
189
|
self.eq(node.get('orgname'), 'stark industries, inc')
|
|
@@ -211,6 +217,22 @@ class PsModelTest(s_t_utils.SynTest):
|
|
|
211
217
|
self.len(1, await core.nodes('ps:contact :death:place -> geo:place'))
|
|
212
218
|
self.len(2, await core.nodes('ps:contact :service:accounts -> inet:service:account'))
|
|
213
219
|
|
|
220
|
+
opts = {
|
|
221
|
+
'vars': {
|
|
222
|
+
'ctor': {
|
|
223
|
+
'email': 'v@vtx.lk',
|
|
224
|
+
'id:number': node.get('id:numbers')[0],
|
|
225
|
+
'lang': lang00,
|
|
226
|
+
'name': 'vi',
|
|
227
|
+
'orgname': 'vertex',
|
|
228
|
+
'title': 'haha',
|
|
229
|
+
'user': 'invisigoth',
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
}
|
|
233
|
+
self.len(1, nodes := await core.nodes('[ ps:contact=$ctor ]', opts=opts))
|
|
234
|
+
self.eq(node.ndef, nodes[0].ndef)
|
|
235
|
+
|
|
214
236
|
nodes = await core.nodes('''[
|
|
215
237
|
ps:achievement=*
|
|
216
238
|
:award=*
|