synapse 2.134.0__py310-none-any.whl → 2.136.0__py310-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/axon.py +10 -2
- synapse/cortex.py +43 -29
- synapse/lib/ast.py +106 -48
- synapse/lib/cell.py +13 -5
- synapse/lib/layer.py +13 -1
- synapse/lib/parser.py +8 -40
- synapse/lib/storm.lark +25 -25
- synapse/lib/storm.py +4 -2
- synapse/lib/storm_format.py +6 -4
- synapse/lib/stormlib/auth.py +25 -3
- synapse/lib/stormlib/compression.py +176 -0
- synapse/lib/stormlib/graph.py +2 -0
- synapse/lib/stormtypes.py +77 -31
- synapse/lib/types.py +4 -1
- synapse/lib/version.py +2 -2
- synapse/lib/view.py +4 -1
- synapse/tests/test_axon.py +8 -2
- synapse/tests/test_cortex.py +38 -4
- synapse/tests/test_lib_grammar.py +64 -64
- synapse/tests/test_lib_httpapi.py +53 -1
- synapse/tests/test_lib_layer.py +20 -0
- synapse/tests/test_lib_rstorm.py +1 -1
- synapse/tests/test_lib_storm.py +40 -5
- synapse/tests/test_lib_stormlib_auth.py +16 -3
- synapse/tests/test_lib_stormlib_compression.py +61 -0
- synapse/tests/test_lib_stormlib_model.py +1 -1
- synapse/tests/test_lib_stormtypes.py +59 -6
- synapse/tests/test_lib_trigger.py +1 -1
- synapse/tests/test_lib_types.py +4 -2
- {synapse-2.134.0.dist-info → synapse-2.136.0.dist-info}/METADATA +4 -5
- {synapse-2.134.0.dist-info → synapse-2.136.0.dist-info}/RECORD +34 -32
- {synapse-2.134.0.dist-info → synapse-2.136.0.dist-info}/LICENSE +0 -0
- {synapse-2.134.0.dist-info → synapse-2.136.0.dist-info}/WHEEL +0 -0
- {synapse-2.134.0.dist-info → synapse-2.136.0.dist-info}/top_level.txt +0 -0
synapse/lib/stormtypes.py
CHANGED
|
@@ -953,7 +953,6 @@ class LibTags(Lib):
|
|
|
953
953
|
Normalize and prefix a list of syn:tag:part values so they can be applied.
|
|
954
954
|
|
|
955
955
|
Examples:
|
|
956
|
-
|
|
957
956
|
Add tag prefixes and then use them to tag nodes::
|
|
958
957
|
|
|
959
958
|
$tags = $lib.tags.prefix($result.tags, vtx.visi)
|
|
@@ -1506,6 +1505,7 @@ class LibBase(Lib):
|
|
|
1506
1505
|
|
|
1507
1506
|
@stormfunc(readonly=True)
|
|
1508
1507
|
async def _min(self, *args):
|
|
1508
|
+
args = await toprim(args)
|
|
1509
1509
|
# allow passing in a list of ints
|
|
1510
1510
|
vals = []
|
|
1511
1511
|
for arg in args:
|
|
@@ -1519,6 +1519,7 @@ class LibBase(Lib):
|
|
|
1519
1519
|
|
|
1520
1520
|
@stormfunc(readonly=True)
|
|
1521
1521
|
async def _max(self, *args):
|
|
1522
|
+
args = await toprim(args)
|
|
1522
1523
|
# allow passing in a list of ints
|
|
1523
1524
|
vals = []
|
|
1524
1525
|
for arg in args:
|
|
@@ -1938,6 +1939,18 @@ class LibAxon(Lib):
|
|
|
1938
1939
|
'returns': {'type': 'dict', 'desc': 'A dictionary containing runtime data about the Axon.'}}},
|
|
1939
1940
|
)
|
|
1940
1941
|
_storm_lib_path = ('axon',)
|
|
1942
|
+
_storm_lib_perms = (
|
|
1943
|
+
{'perm': ('storm', 'lib', 'axon', 'del'), 'gate': 'cortex',
|
|
1944
|
+
'desc': 'Controls the ability to remove a file from the Axon.'},
|
|
1945
|
+
{'perm': ('storm', 'lib', 'axon', 'get'), 'gate': 'cortex',
|
|
1946
|
+
'desc': 'Controls the ability to retrieve a file from the Axon.'},
|
|
1947
|
+
{'perm': ('storm', 'lib', 'axon', 'has'), 'gate': 'cortex',
|
|
1948
|
+
'desc': 'Controls the ability to check if the Axon contains a file.'},
|
|
1949
|
+
{'perm': ('storm', 'lib', 'axon', 'wget'), 'gate': 'cortex',
|
|
1950
|
+
'desc': 'Controls the ability to retrieve a file from URL and store it in the Axon.'},
|
|
1951
|
+
{'perm': ('storm', 'lib', 'axon', 'wput'), 'gate': 'cortex',
|
|
1952
|
+
'desc': 'Controls the ability to push a file from the Axon to a URL.'},
|
|
1953
|
+
)
|
|
1941
1954
|
|
|
1942
1955
|
def getObjLocals(self):
|
|
1943
1956
|
return {
|
|
@@ -3442,6 +3455,12 @@ class LibTelepath(Lib):
|
|
|
3442
3455
|
'returns': {'type': 'storm:proxy', 'desc': 'A object representing a Telepath Proxy.', }}},
|
|
3443
3456
|
)
|
|
3444
3457
|
_storm_lib_path = ('telepath',)
|
|
3458
|
+
_storm_lib_perms = (
|
|
3459
|
+
{'perm': ('storm', 'lib', 'telepath', 'open'), 'gate': 'cortex',
|
|
3460
|
+
'desc': 'Controls the ability to open an arbitrary telepath URL. USE WITH CAUTION.'},
|
|
3461
|
+
{'perm': ('storm', 'lib', 'telepath', 'open', '<scheme>'), 'gate': 'cortex',
|
|
3462
|
+
'desc': 'Controls the ability to open a telepath URL with a specific URI scheme. USE WITH CAUTION.'},
|
|
3463
|
+
)
|
|
3445
3464
|
|
|
3446
3465
|
def getObjLocals(self):
|
|
3447
3466
|
return {
|
|
@@ -3451,7 +3470,8 @@ class LibTelepath(Lib):
|
|
|
3451
3470
|
async def _methTeleOpen(self, url):
|
|
3452
3471
|
url = await tostr(url)
|
|
3453
3472
|
scheme = url.split('://')[0]
|
|
3454
|
-
self.runt.
|
|
3473
|
+
if not self.runt.allowed(('lib', 'telepath', 'open', scheme)):
|
|
3474
|
+
self.runt.confirm(('storm', 'lib', 'telepath', 'open', scheme))
|
|
3455
3475
|
return Proxy(self.runt, await self.runt.getTeleProxy(url))
|
|
3456
3476
|
|
|
3457
3477
|
@registry.registerType
|
|
@@ -4038,6 +4058,7 @@ class Bytes(Prim):
|
|
|
4038
4058
|
|
|
4039
4059
|
Example:
|
|
4040
4060
|
Compress bytes with gzip::
|
|
4061
|
+
|
|
4041
4062
|
$foo = $mybytez.gzip()''',
|
|
4042
4063
|
'type': {'type': 'function', '_funcname': '_methGzip',
|
|
4043
4064
|
'returns': {'type': 'bytes', 'desc': 'The gzip compressed bytes.', }}},
|
|
@@ -4049,6 +4070,7 @@ class Bytes(Prim):
|
|
|
4049
4070
|
|
|
4050
4071
|
Example:
|
|
4051
4072
|
Load bytes to a object::
|
|
4073
|
+
|
|
4052
4074
|
$foo = $mybytez.json()''',
|
|
4053
4075
|
'type': {'type': 'function', '_funcname': '_methJsonLoad',
|
|
4054
4076
|
'args': (
|
|
@@ -4082,8 +4104,9 @@ class Bytes(Prim):
|
|
|
4082
4104
|
Unpack structures from bytes using python struct.unpack syntax.
|
|
4083
4105
|
|
|
4084
4106
|
Examples:
|
|
4085
|
-
|
|
4086
|
-
|
|
4107
|
+
Unpack 3 unsigned 16 bit integers in little endian format::
|
|
4108
|
+
|
|
4109
|
+
($x, $y, $z) = $byts.unpack("<HHH")
|
|
4087
4110
|
''',
|
|
4088
4111
|
'type': {'type': 'function', '_funcname': 'unpack',
|
|
4089
4112
|
'args': (
|
|
@@ -6317,7 +6340,7 @@ class Layer(Prim):
|
|
|
6317
6340
|
formname = await tostr(formname, noneok=True)
|
|
6318
6341
|
|
|
6319
6342
|
if formname is not None and self.runt.snap.core.model.form(formname) is None:
|
|
6320
|
-
raise s_exc.NoSuchForm(formname)
|
|
6343
|
+
raise s_exc.NoSuchForm.init(formname)
|
|
6321
6344
|
|
|
6322
6345
|
iden = self.valu.get('iden')
|
|
6323
6346
|
layr = self.runt.snap.core.getLayer(iden)
|
|
@@ -6379,7 +6402,8 @@ class Layer(Prim):
|
|
|
6379
6402
|
raise s_exc.AuthDeny(mesg=mesg, user=self.runt.user.iden, username=self.runt.user.name)
|
|
6380
6403
|
|
|
6381
6404
|
scheme = url.split('://')[0]
|
|
6382
|
-
self.runt.
|
|
6405
|
+
if not self.runt.allowed(('lib', 'telepath', 'open', scheme)):
|
|
6406
|
+
self.runt.confirm(('storm', 'lib', 'telepath', 'open', scheme))
|
|
6383
6407
|
|
|
6384
6408
|
async with await s_telepath.openurl(url):
|
|
6385
6409
|
pass
|
|
@@ -6418,7 +6442,9 @@ class Layer(Prim):
|
|
|
6418
6442
|
raise s_exc.AuthDeny(mesg=mesg, user=self.runt.user.iden, username=self.runt.user.name)
|
|
6419
6443
|
|
|
6420
6444
|
scheme = url.split('://')[0]
|
|
6421
|
-
|
|
6445
|
+
|
|
6446
|
+
if not self.runt.allowed(('lib', 'telepath', 'open', scheme)):
|
|
6447
|
+
self.runt.confirm(('storm', 'lib', 'telepath', 'open', scheme))
|
|
6422
6448
|
|
|
6423
6449
|
async with await s_telepath.openurl(url):
|
|
6424
6450
|
pass
|
|
@@ -6540,10 +6566,11 @@ class Layer(Prim):
|
|
|
6540
6566
|
async def _methLayerSet(self, name, valu):
|
|
6541
6567
|
name = await tostr(name)
|
|
6542
6568
|
|
|
6543
|
-
if name
|
|
6544
|
-
valu
|
|
6545
|
-
|
|
6546
|
-
|
|
6569
|
+
if name in ('name', 'desc'):
|
|
6570
|
+
if valu is undef:
|
|
6571
|
+
valu = None
|
|
6572
|
+
else:
|
|
6573
|
+
valu = await tostr(await toprim(valu), noneok=True)
|
|
6547
6574
|
elif name == 'logedits':
|
|
6548
6575
|
valu = await tobool(valu)
|
|
6549
6576
|
else:
|
|
@@ -6899,12 +6926,12 @@ class View(Prim):
|
|
|
6899
6926
|
|
|
6900
6927
|
name = await tostr(name)
|
|
6901
6928
|
|
|
6902
|
-
if name
|
|
6903
|
-
valu
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
|
|
6907
|
-
|
|
6929
|
+
if name in ('name', 'desc', 'parent'):
|
|
6930
|
+
if valu is undef:
|
|
6931
|
+
valu = None
|
|
6932
|
+
else:
|
|
6933
|
+
valu = await tostr(await toprim(valu), noneok=True)
|
|
6934
|
+
|
|
6908
6935
|
elif name == 'nomerge':
|
|
6909
6936
|
valu = await tobool(valu)
|
|
6910
6937
|
elif name == 'layers':
|
|
@@ -7396,8 +7423,8 @@ class LibUsers(Lib):
|
|
|
7396
7423
|
'type': {'type': 'function', '_funcname': '_methUsersAdd',
|
|
7397
7424
|
'args': (
|
|
7398
7425
|
{'name': 'name', 'type': 'str', 'desc': 'The name of the user.', },
|
|
7399
|
-
{'name': 'passwd', 'type': 'str', 'desc':
|
|
7400
|
-
{'name': 'email', 'type': 'str', 'desc':
|
|
7426
|
+
{'name': 'passwd', 'type': 'str', 'desc': "The user's password.", 'default': None, },
|
|
7427
|
+
{'name': 'email', 'type': 'str', 'desc': "The user's email address.", 'default': None, },
|
|
7401
7428
|
{'name': 'iden', 'type': 'str', 'desc': 'The iden to use to create the user.', 'default': None, }
|
|
7402
7429
|
),
|
|
7403
7430
|
'returns': {'type': 'storm:auth:user',
|
|
@@ -7427,6 +7454,12 @@ class LibUsers(Lib):
|
|
|
7427
7454
|
'desc': 'The ``storm:auth:user`` object, or none if the user does not exist.', }}},
|
|
7428
7455
|
)
|
|
7429
7456
|
_storm_lib_path = ('auth', 'users')
|
|
7457
|
+
_storm_lib_perms = (
|
|
7458
|
+
{'perm': ('storm', 'lib', 'auth', 'users', 'add'), 'gate': 'cortex',
|
|
7459
|
+
'desc': 'Controls the ability to add a user to the system. USE WITH CAUTION!'},
|
|
7460
|
+
{'perm': ('storm', 'lib', 'auth', 'users', 'del'), 'gate': 'cortex',
|
|
7461
|
+
'desc': 'Controls the ability to remove a user from the system. USE WITH CAUTION!'},
|
|
7462
|
+
)
|
|
7430
7463
|
|
|
7431
7464
|
def getObjLocals(self):
|
|
7432
7465
|
return {
|
|
@@ -7454,7 +7487,8 @@ class LibUsers(Lib):
|
|
|
7454
7487
|
return User(self.runt, udef['iden'])
|
|
7455
7488
|
|
|
7456
7489
|
async def _methUsersAdd(self, name, passwd=None, email=None, iden=None):
|
|
7457
|
-
self.runt.
|
|
7490
|
+
if not self.runt.allowed(('auth', 'user', 'add')):
|
|
7491
|
+
self.runt.confirm(('storm', 'lib', 'auth', 'users', 'add'))
|
|
7458
7492
|
name = await tostr(name)
|
|
7459
7493
|
iden = await tostr(iden, True)
|
|
7460
7494
|
email = await tostr(email, True)
|
|
@@ -7463,7 +7497,8 @@ class LibUsers(Lib):
|
|
|
7463
7497
|
return User(self.runt, udef['iden'])
|
|
7464
7498
|
|
|
7465
7499
|
async def _methUsersDel(self, iden):
|
|
7466
|
-
self.runt.
|
|
7500
|
+
if not self.runt.allowed(('auth', 'user', 'del')):
|
|
7501
|
+
self.runt.confirm(('storm', 'lib', 'auth', 'users', 'del'))
|
|
7467
7502
|
await self.runt.snap.core.delUser(iden)
|
|
7468
7503
|
|
|
7469
7504
|
@registry.registerLib
|
|
@@ -7503,6 +7538,12 @@ class LibRoles(Lib):
|
|
|
7503
7538
|
'desc': 'The role by name, or null if it does not exist.', }}},
|
|
7504
7539
|
)
|
|
7505
7540
|
_storm_lib_path = ('auth', 'roles')
|
|
7541
|
+
_storm_lib_perms = (
|
|
7542
|
+
{'perm': ('storm', 'lib', 'auth', 'roles', 'add'), 'gate': 'cortex',
|
|
7543
|
+
'desc': 'Controls the ability to add a role to the system. USE WITH CAUTION!'},
|
|
7544
|
+
{'perm': ('storm', 'lib', 'auth', 'roles', 'del'), 'gate': 'cortex',
|
|
7545
|
+
'desc': 'Controls the ability to remove a role from the system. USE WITH CAUTION!'},
|
|
7546
|
+
)
|
|
7506
7547
|
|
|
7507
7548
|
def getObjLocals(self):
|
|
7508
7549
|
return {
|
|
@@ -7530,12 +7571,14 @@ class LibRoles(Lib):
|
|
|
7530
7571
|
return Role(self.runt, rdef['iden'])
|
|
7531
7572
|
|
|
7532
7573
|
async def _methRolesAdd(self, name):
|
|
7533
|
-
self.runt.
|
|
7574
|
+
if not self.runt.allowed(('auth', 'role', 'add')):
|
|
7575
|
+
self.runt.confirm(('storm', 'lib', 'auth', 'roles', 'add'))
|
|
7534
7576
|
rdef = await self.runt.snap.core.addRole(name)
|
|
7535
7577
|
return Role(self.runt, rdef['iden'])
|
|
7536
7578
|
|
|
7537
7579
|
async def _methRolesDel(self, iden):
|
|
7538
|
-
self.runt.
|
|
7580
|
+
if not self.runt.allowed(('auth', 'role', 'del')):
|
|
7581
|
+
self.runt.confirm(('storm', 'lib', 'auth', 'roles', 'del'))
|
|
7539
7582
|
await self.runt.snap.core.delRole(iden)
|
|
7540
7583
|
|
|
7541
7584
|
@registry.registerLib
|
|
@@ -8034,6 +8077,8 @@ class User(Prim):
|
|
|
8034
8077
|
'type': {'type': 'function', '_funcname': '_methUserGrant',
|
|
8035
8078
|
'args': (
|
|
8036
8079
|
{'name': 'iden', 'type': 'str', 'desc': 'The iden of the Role.', },
|
|
8080
|
+
{'name': 'indx', 'type': 'int', 'desc': 'The position of the Role as a 0 based index.',
|
|
8081
|
+
'default': None, },
|
|
8037
8082
|
),
|
|
8038
8083
|
'returns': {'type': 'null', }}},
|
|
8039
8084
|
{'name': 'setRoles', 'desc': '''
|
|
@@ -8140,20 +8185,20 @@ class User(Prim):
|
|
|
8140
8185
|
'returns': {'type': 'list',
|
|
8141
8186
|
'desc': 'A list of ``storm:auth:gates`` that the user has rules for.', }}},
|
|
8142
8187
|
{'name': 'name', 'desc': '''
|
|
8143
|
-
A
|
|
8188
|
+
A user's name. This can also be used to set a user's name.
|
|
8144
8189
|
|
|
8145
8190
|
Example:
|
|
8146
|
-
Change a
|
|
8191
|
+
Change a user's name::
|
|
8147
8192
|
|
|
8148
8193
|
$user=$lib.auth.users.byname(bob) $user.name=robert
|
|
8149
8194
|
''',
|
|
8150
8195
|
'type': {'type': 'stor', '_storfunc': '_storUserName',
|
|
8151
8196
|
'returns': {'type': 'str', }}},
|
|
8152
8197
|
{'name': 'email', 'desc': '''
|
|
8153
|
-
A
|
|
8198
|
+
A user's email. This can also be used to set the user's email.
|
|
8154
8199
|
|
|
8155
8200
|
Example:
|
|
8156
|
-
Change a
|
|
8201
|
+
Change a user's email address::
|
|
8157
8202
|
|
|
8158
8203
|
$user=$lib.auth.users.byname(bob) $user.email="robert@bobcorp.net"
|
|
8159
8204
|
''',
|
|
@@ -8294,9 +8339,10 @@ class User(Prim):
|
|
|
8294
8339
|
user = await self.runt.snap.core.auth.reqUser(self.valu)
|
|
8295
8340
|
return user.getAllowedReason(perm, gateiden=gateiden, default=default)
|
|
8296
8341
|
|
|
8297
|
-
async def _methUserGrant(self, iden):
|
|
8342
|
+
async def _methUserGrant(self, iden, indx=None):
|
|
8298
8343
|
self.runt.confirm(('auth', 'user', 'grant'))
|
|
8299
|
-
await
|
|
8344
|
+
indx = await toint(indx, noneok=True)
|
|
8345
|
+
await self.runt.snap.core.addUserRole(self.valu, iden, indx=indx)
|
|
8300
8346
|
|
|
8301
8347
|
async def _methUserSetRoles(self, idens):
|
|
8302
8348
|
self.runt.confirm(('auth', 'user', 'grant'))
|
|
@@ -8447,10 +8493,10 @@ class Role(Prim):
|
|
|
8447
8493
|
),
|
|
8448
8494
|
'returns': {'type': 'null', }}},
|
|
8449
8495
|
{'name': 'name', 'desc': '''
|
|
8450
|
-
A
|
|
8496
|
+
A role's name. This can also be used to set the role name.
|
|
8451
8497
|
|
|
8452
8498
|
Example:
|
|
8453
|
-
Change a
|
|
8499
|
+
Change a role's name::
|
|
8454
8500
|
|
|
8455
8501
|
$role=$lib.auth.roles.byname(analyst) $role.name=superheroes
|
|
8456
8502
|
''',
|
synapse/lib/types.py
CHANGED
|
@@ -385,7 +385,7 @@ class Bool(Type):
|
|
|
385
385
|
return int(bool(valu)), {}
|
|
386
386
|
|
|
387
387
|
def repr(self, valu):
|
|
388
|
-
return repr(bool(valu))
|
|
388
|
+
return repr(bool(valu)).lower()
|
|
389
389
|
|
|
390
390
|
class Array(Type):
|
|
391
391
|
|
|
@@ -1732,6 +1732,9 @@ class Taxonomy(Str):
|
|
|
1732
1732
|
def _normPyStr(self, text):
|
|
1733
1733
|
return self._normPyList(text.strip().strip('.').split('.'))
|
|
1734
1734
|
|
|
1735
|
+
def repr(self, norm):
|
|
1736
|
+
return norm.rstrip('.')
|
|
1737
|
+
|
|
1735
1738
|
class Tag(Str):
|
|
1736
1739
|
|
|
1737
1740
|
def postTypeInit(self):
|
synapse/lib/version.py
CHANGED
|
@@ -223,6 +223,6 @@ def reqVersion(valu, reqver,
|
|
|
223
223
|
##############################################################################
|
|
224
224
|
# The following are touched during the release process by bumpversion.
|
|
225
225
|
# Do not modify these directly.
|
|
226
|
-
version = (2,
|
|
226
|
+
version = (2, 136, 0)
|
|
227
227
|
verstring = '.'.join([str(x) for x in version])
|
|
228
|
-
commit = '
|
|
228
|
+
commit = 'dba42be36057d465def6a8f17294aac3677a161e'
|
synapse/lib/view.py
CHANGED
|
@@ -617,7 +617,10 @@ class View(s_nexus.Pusher): # type: ignore
|
|
|
617
617
|
self.core._calcViewsByLayer()
|
|
618
618
|
|
|
619
619
|
else:
|
|
620
|
-
|
|
620
|
+
if valu is None:
|
|
621
|
+
await self.info.pop(name)
|
|
622
|
+
else:
|
|
623
|
+
await self.info.set(name, valu)
|
|
621
624
|
|
|
622
625
|
await self.core.feedBeholder('view:set', {'iden': self.iden, 'name': name, 'valu': valu},
|
|
623
626
|
gates=[self.iden, self.layers[0].iden])
|
synapse/tests/test_axon.py
CHANGED
|
@@ -330,9 +330,11 @@ Bob,Smith,Little House at the end of Main Street,Gomorra,CA,12345'''
|
|
|
330
330
|
|
|
331
331
|
evt = asyncio.Event()
|
|
332
332
|
origlink = s_axon.Axon._sha256ToLink
|
|
333
|
-
async def fakelink(self,
|
|
333
|
+
async def fakelink(self, sha256_, link):
|
|
334
334
|
link.onfini(evt.set)
|
|
335
|
-
|
|
335
|
+
if sha256_ == pennhash:
|
|
336
|
+
sha256_ = b'newp'
|
|
337
|
+
await origlink(self, sha256_, link)
|
|
336
338
|
|
|
337
339
|
newdata = '\n'.join([data for i in range(500)])
|
|
338
340
|
size, sha256 = await axon.put(newdata.encode())
|
|
@@ -347,6 +349,10 @@ Bob,Smith,Little House at the end of Main Street,Gomorra,CA,12345'''
|
|
|
347
349
|
break
|
|
348
350
|
self.true(await s_coro.event_wait(evt, 5))
|
|
349
351
|
|
|
352
|
+
# make sure exceptions within sha256tolink get re-raised
|
|
353
|
+
await self.asyncraises(s_exc.NoSuchFile, s_t_utils.alist(axon.csvrows(pennhash)))
|
|
354
|
+
await self.asyncraises(s_exc.NoSuchFile, s_t_utils.alist(axon.readlines(s_common.ehex(pennhash))))
|
|
355
|
+
|
|
350
356
|
# CSV with alternative delimiter
|
|
351
357
|
data = '''foo|bar|baz
|
|
352
358
|
words|word|wrd'''
|
synapse/tests/test_cortex.py
CHANGED
|
@@ -1196,6 +1196,10 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
1196
1196
|
self.len(1, await core.nodes('test:int +#foo.bar:score<=30'))
|
|
1197
1197
|
self.len(1, await core.nodes('test:int +#foo.bar:score>=10'))
|
|
1198
1198
|
self.len(1, await core.nodes('test:int +#foo.bar:score*range=(10, 30)'))
|
|
1199
|
+
self.len(1, await core.nodes('test:int +#*:score'))
|
|
1200
|
+
self.len(1, await core.nodes('test:int +#foo.*:score'))
|
|
1201
|
+
self.len(1, await core.nodes('$tag=* test:int +#*:score'))
|
|
1202
|
+
self.len(1, await core.nodes('$tag=foo.* test:int +#foo.*:score'))
|
|
1199
1203
|
|
|
1200
1204
|
self.len(0, await core.nodes('test:int -#foo.bar'))
|
|
1201
1205
|
self.len(0, await core.nodes('test:int -#foo.bar:score'))
|
|
@@ -1317,6 +1321,24 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
1317
1321
|
with self.raises(s_exc.NoSuchType):
|
|
1318
1322
|
await core.addTagProp('derp', ('derp', {}), {})
|
|
1319
1323
|
|
|
1324
|
+
with self.raises(s_exc.BadTypeValu):
|
|
1325
|
+
await core.nodes("$tag=(foo, bar) test:int#$tag:prop")
|
|
1326
|
+
|
|
1327
|
+
with self.raises(s_exc.BadTypeValu):
|
|
1328
|
+
await core.nodes("$tag=(foo, bar) test:int +#$tag:prop")
|
|
1329
|
+
|
|
1330
|
+
with self.raises(s_exc.BadTypeValu):
|
|
1331
|
+
await core.nodes("$tag=(foo, bar) test:int +#$tag:prop=5")
|
|
1332
|
+
|
|
1333
|
+
with self.raises(s_exc.BadTypeValu):
|
|
1334
|
+
await core.nodes("test:int $tag=(foo, bar) $lib.print(#$tag:prop)")
|
|
1335
|
+
|
|
1336
|
+
with self.raises(s_exc.BadTypeValu):
|
|
1337
|
+
await core.nodes("test:int $tag=(foo, bar) [ +#$tag:prop=foo ]")
|
|
1338
|
+
|
|
1339
|
+
with self.raises(s_exc.BadTypeValu):
|
|
1340
|
+
await core.nodes("test:int $tag=(foo, bar) [ -#$tag:prop ]")
|
|
1341
|
+
|
|
1320
1342
|
# Ensure that the tagprops persist
|
|
1321
1343
|
async with self.getTestCore(dirn=dirn) as core:
|
|
1322
1344
|
# Ensure we can still work with a tagprop, after restart, that was
|
|
@@ -1496,7 +1518,7 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
1496
1518
|
self.eq(set(nodes[0].tags.keys()), {'foo', 'foo.v'})
|
|
1497
1519
|
|
|
1498
1520
|
# Cannot norm a list of tag parts directly when making tags on a node
|
|
1499
|
-
with self.raises(
|
|
1521
|
+
with self.raises(s_exc.BadTypeValu):
|
|
1500
1522
|
await wcore.nodes("$foo=(('foo', 'bar.baz'),) [test:int=2 +#$foo]")
|
|
1501
1523
|
|
|
1502
1524
|
# Can set a list of tags directly
|
|
@@ -1508,8 +1530,20 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
1508
1530
|
self.len(1, nodes)
|
|
1509
1531
|
self.eq(set(nodes[0].tags.keys()), {'foo', 'bar', 'bar.baz'})
|
|
1510
1532
|
|
|
1511
|
-
|
|
1512
|
-
|
|
1533
|
+
nodes = await wcore.nodes('$foo=$lib.set("foo", "bar") [test:int=5 +#$foo]')
|
|
1534
|
+
self.len(1, nodes)
|
|
1535
|
+
self.eq(set(nodes[0].tags.keys()), {'foo', 'bar'})
|
|
1536
|
+
|
|
1537
|
+
await self.asyncraises(s_exc.BadTypeValu, wcore.nodes("$tag='' #$tag"))
|
|
1538
|
+
await self.asyncraises(s_exc.BadTypeValu, wcore.nodes("$tag='' #$tag=2020"))
|
|
1539
|
+
await self.asyncraises(s_exc.BadTypeValu, wcore.nodes("$tag=$lib.null #foo.$tag"))
|
|
1540
|
+
await self.asyncraises(s_exc.BadTypeValu, wcore.nodes("$tag=(foo, bar) #$tag"))
|
|
1541
|
+
await self.asyncraises(s_exc.BadTypeValu, wcore.nodes("$tag=(foo, bar) ##$tag"))
|
|
1542
|
+
await self.asyncraises(s_exc.BadTypeValu, wcore.nodes("$tag=(foo, bar) inet:fqdn#$tag"))
|
|
1543
|
+
await self.asyncraises(s_exc.BadTypeValu, wcore.nodes("test:int $tag=$lib.null +#foo.$tag"))
|
|
1544
|
+
await self.asyncraises(s_exc.BadTypeValu, wcore.nodes("test:int $tag=(foo, bar) $lib.print(#$tag)"))
|
|
1545
|
+
await self.asyncraises(s_exc.BadTypeValu, wcore.nodes("test:int $tag=(foo, bar) +#$tag"))
|
|
1546
|
+
await self.asyncraises(s_exc.BadTypeValu, wcore.nodes("test:int $tag=(foo, bar) +#$tag=2020"))
|
|
1513
1547
|
|
|
1514
1548
|
async def test_base_types1(self):
|
|
1515
1549
|
|
|
@@ -4907,7 +4941,7 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
4907
4941
|
pode = podes[0]
|
|
4908
4942
|
self.true(s_node.tagged(pode, '#foo'))
|
|
4909
4943
|
|
|
4910
|
-
mesgs = await core.stormlist('$var="" test:str=foo [+?#$var=2019]
|
|
4944
|
+
mesgs = await core.stormlist('$var="" test:str=foo [+?#$var=2019]')
|
|
4911
4945
|
podes = [m[1] for m in mesgs if m[0] == 'node']
|
|
4912
4946
|
self.len(1, podes)
|
|
4913
4947
|
pode = podes[0]
|