synapse 2.220.0__py311-none-any.whl → 2.221.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/lib/layer.py +134 -0
- synapse/lib/rstorm.py +65 -2
- synapse/lib/snap.py +21 -13
- synapse/lib/stormhttp.py +10 -10
- synapse/lib/stormlib/aha.py +3 -3
- synapse/lib/stormlib/auth.py +11 -11
- synapse/lib/stormlib/cell.py +1 -1
- synapse/lib/stormlib/cortex.py +9 -9
- synapse/lib/stormlib/env.py +4 -5
- synapse/lib/stormlib/ethereum.py +1 -1
- synapse/lib/stormlib/gen.py +3 -3
- synapse/lib/stormlib/hex.py +2 -2
- synapse/lib/stormlib/imap.py +2 -2
- synapse/lib/stormlib/infosec.py +2 -2
- synapse/lib/stormlib/iters.py +2 -2
- synapse/lib/stormlib/model.py +5 -5
- synapse/lib/stormlib/notifications.py +1 -1
- synapse/lib/stormlib/oauth.py +2 -2
- synapse/lib/stormlib/project.py +3 -3
- synapse/lib/stormlib/scrape.py +2 -1
- synapse/lib/stormlib/smtp.py +3 -3
- synapse/lib/stormlib/stats.py +2 -2
- synapse/lib/stormlib/stix.py +2 -2
- synapse/lib/stormlib/utils.py +19 -0
- synapse/lib/stormlib/vault.py +1 -1
- synapse/lib/stormlib/xml.py +2 -2
- synapse/lib/stormlib/yaml.py +1 -1
- synapse/lib/stormtypes.py +164 -60
- synapse/lib/version.py +2 -2
- synapse/tests/test_lib_layer.py +86 -67
- synapse/tests/test_lib_rstorm.py +132 -0
- synapse/tests/test_lib_storm.py +6 -0
- synapse/tests/test_lib_stormlib_env.py +3 -1
- synapse/tests/test_lib_stormlib_utils.py +10 -0
- synapse/tests/test_lib_stormtypes.py +551 -2
- synapse/tools/aha/list.py +9 -9
- synapse/tools/aha/provision/service.py +2 -2
- {synapse-2.220.0.dist-info → synapse-2.221.0.dist-info}/METADATA +1 -1
- {synapse-2.220.0.dist-info → synapse-2.221.0.dist-info}/RECORD +42 -42
- {synapse-2.220.0.dist-info → synapse-2.221.0.dist-info}/WHEEL +0 -0
- {synapse-2.220.0.dist-info → synapse-2.221.0.dist-info}/licenses/LICENSE +0 -0
- {synapse-2.220.0.dist-info → synapse-2.221.0.dist-info}/top_level.txt +0 -0
synapse/lib/layer.py
CHANGED
|
@@ -3352,6 +3352,98 @@ class Layer(s_nexus.Pusher):
|
|
|
3352
3352
|
_, changes = await self.saveNodeEdits(nodeedits, meta)
|
|
3353
3353
|
return bool(changes[0][2])
|
|
3354
3354
|
|
|
3355
|
+
async def delStorNode(self, buid, meta):
|
|
3356
|
+
'''
|
|
3357
|
+
Delete all node information in this layer.
|
|
3358
|
+
|
|
3359
|
+
Deletes props, tagprops, tags, n1edges, n2edges, nodedata, and node valu.
|
|
3360
|
+
'''
|
|
3361
|
+
sode = self._getStorNode(buid)
|
|
3362
|
+
if sode is None:
|
|
3363
|
+
return False
|
|
3364
|
+
|
|
3365
|
+
formname = sode.get('form')
|
|
3366
|
+
|
|
3367
|
+
edits = []
|
|
3368
|
+
nodeedits = []
|
|
3369
|
+
|
|
3370
|
+
for propname, propvalu in sode.get('props', {}).items():
|
|
3371
|
+
edits.append(
|
|
3372
|
+
(EDIT_PROP_DEL, (propname, *propvalu), ())
|
|
3373
|
+
)
|
|
3374
|
+
|
|
3375
|
+
for tagname, tprops in sode.get('tagprops', {}).items():
|
|
3376
|
+
for propname, propvalu in tprops.items():
|
|
3377
|
+
edits.append(
|
|
3378
|
+
(EDIT_TAGPROP_DEL, (tagname, propname, *propvalu), ())
|
|
3379
|
+
)
|
|
3380
|
+
|
|
3381
|
+
for tagname, tagvalu in sode.get('tags', {}).items():
|
|
3382
|
+
edits.append(
|
|
3383
|
+
(EDIT_TAG_DEL, (tagname, tagvalu), ())
|
|
3384
|
+
)
|
|
3385
|
+
|
|
3386
|
+
# EDIT_NODE_DEL will delete all nodedata and n1 edges if there is a valu in the sode
|
|
3387
|
+
if (valu := sode.get('valu')):
|
|
3388
|
+
edits.append(
|
|
3389
|
+
(EDIT_NODE_DEL, valu, ())
|
|
3390
|
+
)
|
|
3391
|
+
else:
|
|
3392
|
+
async for item in self.iterNodeData(buid):
|
|
3393
|
+
edits.append(
|
|
3394
|
+
(EDIT_NODEDATA_DEL, item, ())
|
|
3395
|
+
)
|
|
3396
|
+
await asyncio.sleep(0)
|
|
3397
|
+
|
|
3398
|
+
async for edge in self.iterNodeEdgesN1(buid):
|
|
3399
|
+
edits.append(
|
|
3400
|
+
(EDIT_EDGE_DEL, edge, ())
|
|
3401
|
+
)
|
|
3402
|
+
await asyncio.sleep(0)
|
|
3403
|
+
|
|
3404
|
+
nodeedits.append((buid, formname, edits))
|
|
3405
|
+
|
|
3406
|
+
n2edges = {}
|
|
3407
|
+
n1iden = s_common.ehex(buid)
|
|
3408
|
+
async for verb, n2iden in self.iterNodeEdgesN2(buid):
|
|
3409
|
+
n2edges.setdefault(n2iden, []).append((verb, n1iden))
|
|
3410
|
+
await asyncio.sleep(0)
|
|
3411
|
+
|
|
3412
|
+
n2forms = {}
|
|
3413
|
+
@s_cache.memoize()
|
|
3414
|
+
def getN2Form(n2iden):
|
|
3415
|
+
buid = s_common.uhex(n2iden)
|
|
3416
|
+
if (form := n2forms.get(buid)) is not None: # pragma: no cover
|
|
3417
|
+
return form
|
|
3418
|
+
|
|
3419
|
+
n2sode = self._getStorNode(buid)
|
|
3420
|
+
form = n2sode.get('form')
|
|
3421
|
+
n2forms[buid] = form
|
|
3422
|
+
return form
|
|
3423
|
+
|
|
3424
|
+
changed = False
|
|
3425
|
+
|
|
3426
|
+
async def batchEdits(size=1000):
|
|
3427
|
+
if len(nodeedits) < size:
|
|
3428
|
+
return changed
|
|
3429
|
+
|
|
3430
|
+
_, changes = await self.saveNodeEdits(nodeedits, meta)
|
|
3431
|
+
|
|
3432
|
+
nodeedits.clear()
|
|
3433
|
+
|
|
3434
|
+
if changed: # pragma: no cover
|
|
3435
|
+
return changed
|
|
3436
|
+
|
|
3437
|
+
return bool(changes[0][2])
|
|
3438
|
+
|
|
3439
|
+
for n2iden, edges in n2edges.items():
|
|
3440
|
+
edits = [(EDIT_EDGE_DEL, edge, ()) for edge in edges]
|
|
3441
|
+
nodeedits.append((s_common.uhex(n2iden), getN2Form(n2iden), edits))
|
|
3442
|
+
|
|
3443
|
+
changed = await batchEdits()
|
|
3444
|
+
|
|
3445
|
+
return await batchEdits(size=1)
|
|
3446
|
+
|
|
3355
3447
|
async def delStorNodeProp(self, buid, prop, meta):
|
|
3356
3448
|
pprop = self.core.model.reqProp(prop)
|
|
3357
3449
|
|
|
@@ -3365,6 +3457,48 @@ class Layer(s_nexus.Pusher):
|
|
|
3365
3457
|
_, changes = await self.saveNodeEdits(nodeedits, meta)
|
|
3366
3458
|
return bool(changes[0][2])
|
|
3367
3459
|
|
|
3460
|
+
async def delNodeData(self, buid, meta, name=None):
|
|
3461
|
+
'''
|
|
3462
|
+
Delete nodedata from a node in this layer. If name is not specified, delete all nodedata.
|
|
3463
|
+
'''
|
|
3464
|
+
sode = self._getStorNode(buid)
|
|
3465
|
+
if sode is None: # pragma: no cover
|
|
3466
|
+
return False
|
|
3467
|
+
|
|
3468
|
+
edits = []
|
|
3469
|
+
if name is None:
|
|
3470
|
+
async for item in self.iterNodeData(buid):
|
|
3471
|
+
edits.append((EDIT_NODEDATA_DEL, item, ()))
|
|
3472
|
+
await asyncio.sleep(0)
|
|
3473
|
+
|
|
3474
|
+
elif await self.hasNodeData(buid, name):
|
|
3475
|
+
edits.append((EDIT_NODEDATA_DEL, (name, None), ()))
|
|
3476
|
+
|
|
3477
|
+
if not edits:
|
|
3478
|
+
return False
|
|
3479
|
+
|
|
3480
|
+
nodeedits = [(buid, sode.get('form'), edits)]
|
|
3481
|
+
|
|
3482
|
+
_, changes = await self.saveNodeEdits(nodeedits, meta)
|
|
3483
|
+
return bool(changes[0][2])
|
|
3484
|
+
|
|
3485
|
+
async def delEdge(self, n1buid, verb, n2buid, meta):
|
|
3486
|
+
sode = self._getStorNode(n1buid)
|
|
3487
|
+
if sode is None: # pragma: no cover
|
|
3488
|
+
return False
|
|
3489
|
+
|
|
3490
|
+
if not await self.hasNodeEdge(n1buid, verb, n2buid): # pragma: no cover
|
|
3491
|
+
return False
|
|
3492
|
+
|
|
3493
|
+
edits = [
|
|
3494
|
+
(EDIT_EDGE_DEL, (verb, s_common.ehex(n2buid)), ())
|
|
3495
|
+
]
|
|
3496
|
+
|
|
3497
|
+
nodeedits = [(n1buid, sode.get('form'), edits)]
|
|
3498
|
+
|
|
3499
|
+
_, changes = await self.saveNodeEdits(nodeedits, meta)
|
|
3500
|
+
return bool(changes[0][2])
|
|
3501
|
+
|
|
3368
3502
|
async def storNodeEdits(self, nodeedits, meta):
|
|
3369
3503
|
|
|
3370
3504
|
saveoff, results = await self.saveNodeEdits(nodeedits, meta)
|
synapse/lib/rstorm.py
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import sys
|
|
2
3
|
import copy
|
|
4
|
+
import shlex
|
|
3
5
|
import pprint
|
|
4
6
|
import logging
|
|
7
|
+
import argparse
|
|
5
8
|
import contextlib
|
|
9
|
+
import subprocess
|
|
6
10
|
import collections
|
|
7
11
|
|
|
8
12
|
import vcr
|
|
@@ -25,7 +29,7 @@ import synapse.tools.storm as s_storm
|
|
|
25
29
|
import synapse.tools.genpkg as s_genpkg
|
|
26
30
|
|
|
27
31
|
|
|
28
|
-
re_directive = regex.compile(r'^\.\.\s(storm.*|[^:])::(?:\s(.*)$|$)')
|
|
32
|
+
re_directive = regex.compile(r'^\.\.\s(shell.*|storm.*|[^:])::(?:\s(.*)$|$)')
|
|
29
33
|
|
|
30
34
|
logger = logging.getLogger(__name__)
|
|
31
35
|
|
|
@@ -48,7 +52,6 @@ class OutPutRst(s_output.OutPutStr):
|
|
|
48
52
|
|
|
49
53
|
return s_output.OutPutStr.printf(self, mesg, addnl)
|
|
50
54
|
|
|
51
|
-
|
|
52
55
|
class StormOutput(s_cmds_cortex.StormCmd):
|
|
53
56
|
'''
|
|
54
57
|
Produce standard output from a stream of storm runtime messages.
|
|
@@ -329,6 +332,8 @@ class StormRst(s_base.Base):
|
|
|
329
332
|
self.core = None
|
|
330
333
|
|
|
331
334
|
self.handlers = {
|
|
335
|
+
'shell': self._handleShell,
|
|
336
|
+
'shell-env': self._handleShellEnv,
|
|
332
337
|
'storm': self._handleStorm,
|
|
333
338
|
'storm-cli': self._handleStormCli,
|
|
334
339
|
'storm-pkg': self._handleStormPkg,
|
|
@@ -596,6 +601,64 @@ class StormRst(s_base.Base):
|
|
|
596
601
|
raise s_exc.NoSuchCtor(mesg=f'Failed to get callback "{text}"', ctor=text)
|
|
597
602
|
self.context['storm-vcr-callback'] = cb
|
|
598
603
|
|
|
604
|
+
async def _handleShell(self, text):
|
|
605
|
+
'''
|
|
606
|
+
Execute shell with the supplied arguments.
|
|
607
|
+
'''
|
|
608
|
+
parser = argparse.ArgumentParser(add_help=False)
|
|
609
|
+
parser.add_argument('--include-stderr', action='store_true', help='Include stderr in output.')
|
|
610
|
+
parser.add_argument('--hide-query', action='store_true', help='Do not include the command in the output.')
|
|
611
|
+
parser.add_argument('--fail-ok', action='store_true', help='Non-zero return values are non-fatal.')
|
|
612
|
+
opts, args = parser.parse_known_args(shlex.split(text))
|
|
613
|
+
|
|
614
|
+
# Remove any command line arguments
|
|
615
|
+
query = text
|
|
616
|
+
query = query.replace('--include-stderr', '')
|
|
617
|
+
query = query.replace('--hide-query', '')
|
|
618
|
+
query = query.replace('--fail-ok', '')
|
|
619
|
+
query = query.strip()
|
|
620
|
+
|
|
621
|
+
env = self.context.get('shell-env')
|
|
622
|
+
|
|
623
|
+
stderr = None
|
|
624
|
+
if opts.include_stderr:
|
|
625
|
+
stderr = subprocess.STDOUT
|
|
626
|
+
|
|
627
|
+
proc = subprocess.run(args, stdout=subprocess.PIPE, stderr=stderr, env=env, text=True)
|
|
628
|
+
if proc.returncode != 0 and not opts.fail_ok:
|
|
629
|
+
mesg = f'Error when executing shell directive: {text} (rv: {proc.returncode})'
|
|
630
|
+
raise s_exc.SynErr(mesg=mesg)
|
|
631
|
+
|
|
632
|
+
self._printf('::\n\n')
|
|
633
|
+
|
|
634
|
+
if not opts.hide_query:
|
|
635
|
+
self._printf(f' {query}\n\n')
|
|
636
|
+
|
|
637
|
+
for line in proc.stdout.splitlines():
|
|
638
|
+
self._printf(f' {line}\n')
|
|
639
|
+
|
|
640
|
+
self._printf('\n\n')
|
|
641
|
+
|
|
642
|
+
async def _handleShellEnv(self, text):
|
|
643
|
+
'''
|
|
644
|
+
Env to use in subsequent shell queries.
|
|
645
|
+
|
|
646
|
+
Args:
|
|
647
|
+
text (str): [KEY=VALUE ...]
|
|
648
|
+
Note: No arguments will reset the shell environment.
|
|
649
|
+
'''
|
|
650
|
+
text = text.strip()
|
|
651
|
+
if not text:
|
|
652
|
+
return self.context.pop('shell-env')
|
|
653
|
+
|
|
654
|
+
env = {}
|
|
655
|
+
|
|
656
|
+
for item in text.split(' '):
|
|
657
|
+
key, val = item.split('=')
|
|
658
|
+
env[key] = val
|
|
659
|
+
|
|
660
|
+
self.context['shell-env'] = env
|
|
661
|
+
|
|
599
662
|
async def _readline(self, line):
|
|
600
663
|
|
|
601
664
|
match = re_directive.match(line)
|
synapse/lib/snap.py
CHANGED
|
@@ -1123,22 +1123,30 @@ class Snap(s_base.Base):
|
|
|
1123
1123
|
mesg = f'No property named "{full}".'
|
|
1124
1124
|
raise s_exc.NoSuchProp(mesg=mesg)
|
|
1125
1125
|
|
|
1126
|
-
if isinstance(valu, dict) and isinstance(prop.type, s_types.Guid) and cmpr
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
return
|
|
1126
|
+
if isinstance(valu, dict) and isinstance(prop.type, s_types.Guid) and cmpr in ('=', '?='):
|
|
1127
|
+
excignore = ()
|
|
1128
|
+
if cmpr == '?=':
|
|
1129
|
+
excignore = (s_exc.BadTypeValu,)
|
|
1131
1130
|
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1131
|
+
try:
|
|
1132
|
+
if prop.isform:
|
|
1133
|
+
if (node := await self._getGuidNodeByDict(prop, valu)) is not None:
|
|
1134
|
+
yield node
|
|
1135
|
+
return
|
|
1136
1136
|
|
|
1137
|
-
|
|
1138
|
-
|
|
1137
|
+
fname = prop.type.name
|
|
1138
|
+
if (form := prop.modl.form(fname)) is None:
|
|
1139
|
+
mesg = f'The property "{full}" type "{fname}" is not a form and cannot be lifted using a dictionary.'
|
|
1140
|
+
raise s_exc.BadTypeValu(mesg=mesg)
|
|
1139
1141
|
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
+
if (node := await self._getGuidNodeByDict(form, valu)) is None:
|
|
1143
|
+
return
|
|
1144
|
+
|
|
1145
|
+
norm = False
|
|
1146
|
+
valu = node.ndef[1]
|
|
1147
|
+
|
|
1148
|
+
except excignore:
|
|
1149
|
+
return
|
|
1142
1150
|
|
|
1143
1151
|
if norm:
|
|
1144
1152
|
cmprvals = prop.type.getStorCmprs(cmpr, valu)
|
synapse/lib/stormhttp.py
CHANGED
|
@@ -90,7 +90,7 @@ class LibHttp(s_stormtypes.Lib):
|
|
|
90
90
|
For APIs that accept an ssl_opts argument, the dictionary may contain the following values::
|
|
91
91
|
|
|
92
92
|
({
|
|
93
|
-
'verify': <
|
|
93
|
+
'verify': <boolean> - Perform SSL/TLS verification. Is overridden by the ssl_verify argument.
|
|
94
94
|
'client_cert': <str> - PEM encoded full chain certificate for use in mTLS.
|
|
95
95
|
'client_key': <str> - PEM encoded key for use in mTLS. Alternatively, can be included in client_cert.
|
|
96
96
|
'ca_cert': <str> - A PEM encoded full chain CA certificate for use when verifying the request.
|
|
@@ -116,9 +116,9 @@ class LibHttp(s_stormtypes.Lib):
|
|
|
116
116
|
'default': None},
|
|
117
117
|
{'name': 'timeout', 'type': 'int', 'desc': 'Total timeout for the request in seconds.',
|
|
118
118
|
'default': 300},
|
|
119
|
-
{'name': 'allow_redirects', 'type': '
|
|
119
|
+
{'name': 'allow_redirects', 'type': 'boolean', 'desc': 'If set to false, do not follow redirects.',
|
|
120
120
|
'default': True},
|
|
121
|
-
{'name': 'proxy', 'type': ['
|
|
121
|
+
{'name': 'proxy', 'type': ['boolean', 'str'],
|
|
122
122
|
'desc': 'Configure proxy usage. See $lib.inet.http help for additional details.', 'default': True},
|
|
123
123
|
{'name': 'ssl_opts', 'type': 'dict',
|
|
124
124
|
'desc': 'Optional SSL/TLS options. See $lib.inet.http help for additional details.',
|
|
@@ -141,7 +141,7 @@ class LibHttp(s_stormtypes.Lib):
|
|
|
141
141
|
'default': None},
|
|
142
142
|
{'name': 'timeout', 'type': 'int', 'desc': 'Total timeout for the request in seconds.',
|
|
143
143
|
'default': 300},
|
|
144
|
-
{'name': 'allow_redirects', 'type': '
|
|
144
|
+
{'name': 'allow_redirects', 'type': 'boolean', 'desc': 'If set to false, do not follow redirects.',
|
|
145
145
|
'default': True},
|
|
146
146
|
{'name': 'fields', 'type': 'list',
|
|
147
147
|
'desc': 'A list of info dictionaries containing the name, value or sha256, '
|
|
@@ -150,7 +150,7 @@ class LibHttp(s_stormtypes.Lib):
|
|
|
150
150
|
'and the corresponding file will be uploaded as the value for '
|
|
151
151
|
'the field.',
|
|
152
152
|
'default': None},
|
|
153
|
-
{'name': 'proxy', 'type': ['
|
|
153
|
+
{'name': 'proxy', 'type': ['boolean', 'str'],
|
|
154
154
|
'desc': 'Configure proxy usage. See $lib.inet.http help for additional details.', 'default': True},
|
|
155
155
|
{'name': 'ssl_opts', 'type': 'dict',
|
|
156
156
|
'desc': 'Optional SSL/TLS options. See $lib.inet.http help for additional details.',
|
|
@@ -170,9 +170,9 @@ class LibHttp(s_stormtypes.Lib):
|
|
|
170
170
|
'default': None},
|
|
171
171
|
{'name': 'timeout', 'type': 'int', 'desc': 'Total timeout for the request in seconds.',
|
|
172
172
|
'default': 300, },
|
|
173
|
-
{'name': 'allow_redirects', 'type': '
|
|
173
|
+
{'name': 'allow_redirects', 'type': 'boolean', 'desc': 'If set to true, follow redirects.',
|
|
174
174
|
'default': False},
|
|
175
|
-
{'name': 'proxy', 'type': ['
|
|
175
|
+
{'name': 'proxy', 'type': ['boolean', 'str'],
|
|
176
176
|
'desc': 'Configure proxy usage. See $lib.inet.http help for additional details.', 'default': True},
|
|
177
177
|
{'name': 'ssl_opts', 'type': 'dict',
|
|
178
178
|
'desc': 'Optional SSL/TLS options. See $lib.inet.http help for additional details.',
|
|
@@ -196,7 +196,7 @@ class LibHttp(s_stormtypes.Lib):
|
|
|
196
196
|
'default': None},
|
|
197
197
|
{'name': 'timeout', 'type': 'int', 'desc': 'Total timeout for the request in seconds.',
|
|
198
198
|
'default': 300},
|
|
199
|
-
{'name': 'allow_redirects', 'type': '
|
|
199
|
+
{'name': 'allow_redirects', 'type': 'boolean', 'desc': 'If set to false, do not follow redirects.',
|
|
200
200
|
'default': True},
|
|
201
201
|
{'name': 'fields', 'type': 'list',
|
|
202
202
|
'desc': 'A list of info dictionaries containing the name, value or sha256, '
|
|
@@ -205,7 +205,7 @@ class LibHttp(s_stormtypes.Lib):
|
|
|
205
205
|
'and the corresponding file will be uploaded as the value for '
|
|
206
206
|
'the field.',
|
|
207
207
|
'default': None},
|
|
208
|
-
{'name': 'proxy', 'type': ['
|
|
208
|
+
{'name': 'proxy', 'type': ['boolean', 'str'],
|
|
209
209
|
'desc': 'Configure proxy usage. See $lib.inet.http help for additional details.', 'default': True},
|
|
210
210
|
{'name': 'ssl_opts', 'type': 'dict',
|
|
211
211
|
'desc': 'Optional SSL/TLS options. See $lib.inet.http help for additional details.',
|
|
@@ -226,7 +226,7 @@ class LibHttp(s_stormtypes.Lib):
|
|
|
226
226
|
'default': 300},
|
|
227
227
|
{'name': 'params', 'type': 'dict', 'desc': 'Optional parameters which may be passed to the connection request.',
|
|
228
228
|
'default': None},
|
|
229
|
-
{'name': 'proxy', 'type': ['
|
|
229
|
+
{'name': 'proxy', 'type': ['boolean', 'str'],
|
|
230
230
|
'desc': 'Configure proxy usage. See $lib.inet.http help for additional details.', 'default': True},
|
|
231
231
|
{'name': 'ssl_opts', 'type': 'dict',
|
|
232
232
|
'desc': 'Optional SSL/TLS options. See $lib.inet.http help for additional details.',
|
synapse/lib/stormlib/aha.py
CHANGED
|
@@ -50,7 +50,7 @@ class AhaLib(s_stormtypes.Lib):
|
|
|
50
50
|
'desc': 'The AHA service information dictionary, or ``(null))``.', }}},
|
|
51
51
|
{'name': 'list', 'desc': 'Enumerate all of the AHA services.',
|
|
52
52
|
'type': {'type': 'function', '_funcname': '_methAhaList', 'args': (),
|
|
53
|
-
'returns': {'name': '
|
|
53
|
+
'returns': {'name': 'yields', 'type': 'list',
|
|
54
54
|
'desc': 'The AHA service dictionaries.', }}},
|
|
55
55
|
{'name': 'callPeerApi', 'desc': '''Call an API on all peers (leader and mirrors) of an AHA service and yield the responses from each.
|
|
56
56
|
|
|
@@ -91,7 +91,7 @@ class AhaLib(s_stormtypes.Lib):
|
|
|
91
91
|
'''},
|
|
92
92
|
),
|
|
93
93
|
'returns': {'name': 'yields', 'type': 'list',
|
|
94
|
-
|
|
94
|
+
'desc': 'Yields the results of the API calls as tuples of (svcname, (ok, info)).', }}},
|
|
95
95
|
{'name': 'callPeerGenr', 'desc': '''Call a generator API on all peers (leader and mirrors) of an AHA service and yield the responses from each.
|
|
96
96
|
|
|
97
97
|
Examples:
|
|
@@ -124,7 +124,7 @@ class AhaLib(s_stormtypes.Lib):
|
|
|
124
124
|
'''},
|
|
125
125
|
),
|
|
126
126
|
'returns': {'name': 'yields', 'type': 'list',
|
|
127
|
-
|
|
127
|
+
'desc': 'Yields the results of the API calls as tuples containing (svcname, (ok, info)).', }}}
|
|
128
128
|
|
|
129
129
|
)
|
|
130
130
|
_storm_lib_path = ('aha',)
|
synapse/lib/stormlib/auth.py
CHANGED
|
@@ -83,7 +83,7 @@ stormcmds = (
|
|
|
83
83
|
('--email', {'type': 'str', 'help': 'The email address to set for the user.'}),
|
|
84
84
|
('--passwd', {'type': 'str', 'help': 'The new password for the user. This is best passed into the runtime as a variable.'}),
|
|
85
85
|
('--admin', {'type': 'bool', 'help': 'True to make the user and admin, false to remove their remove their admin status.'}),
|
|
86
|
-
('--gate', {'type': 'str', 'help': 'The auth gate iden to grant or revoke admin status on. Use in conjunction with `--admin <
|
|
86
|
+
('--gate', {'type': 'str', 'help': 'The auth gate iden to grant or revoke admin status on. Use in conjunction with `--admin <boolean>`.'}),
|
|
87
87
|
('--locked', {'type': 'bool', 'help': 'True to lock the user, false to unlock them.'}),
|
|
88
88
|
),
|
|
89
89
|
'storm': '''
|
|
@@ -681,34 +681,34 @@ class UserJson(s_stormtypes.Prim):
|
|
|
681
681
|
{'name': 'get', 'desc': 'Return a stored JSON object or object property for the user.',
|
|
682
682
|
'type': {'type': 'function', '_funcname': 'get',
|
|
683
683
|
'args': (
|
|
684
|
-
{'name': 'path', 'type': 'str
|
|
685
|
-
{'name': 'prop', 'type': 'str
|
|
684
|
+
{'name': 'path', 'type': ['str', 'list'], 'desc': 'A path string or list of path parts.'},
|
|
685
|
+
{'name': 'prop', 'type': ['str', 'list'], 'desc': 'A property name or list of name parts.', 'default': None},
|
|
686
686
|
),
|
|
687
687
|
'returns': {'type': 'prim', 'desc': 'The previously stored value or ``(null)``.'}}},
|
|
688
688
|
|
|
689
689
|
{'name': 'set', 'desc': 'Set a JSON object or object property for the user.',
|
|
690
690
|
'type': {'type': 'function', '_funcname': 'set',
|
|
691
691
|
'args': (
|
|
692
|
-
{'name': 'path', 'type': 'str
|
|
692
|
+
{'name': 'path', 'type': ['str', 'list'], 'desc': 'A path string or list of path elements.'},
|
|
693
693
|
{'name': 'valu', 'type': 'prim', 'desc': 'The value to set as the JSON object or object property.'},
|
|
694
|
-
{'name': 'prop', 'type': 'str
|
|
694
|
+
{'name': 'prop', 'type': ['str', 'list'], 'desc': 'A property name or list of name parts.', 'default': None},
|
|
695
695
|
),
|
|
696
696
|
'returns': {'type': 'boolean', 'desc': 'True if the set operation was successful.'}}},
|
|
697
697
|
|
|
698
698
|
{'name': 'del', 'desc': 'Delete a stored JSON object or object property for the user.',
|
|
699
699
|
'type': {'type': 'function', '_funcname': '_del',
|
|
700
700
|
'args': (
|
|
701
|
-
{'name': 'path', 'type': 'str
|
|
702
|
-
{'name': 'prop', 'type': 'str
|
|
701
|
+
{'name': 'path', 'type': ['str', 'list'], 'desc': 'A path string or list of path parts.'},
|
|
702
|
+
{'name': 'prop', 'type': ['str', 'list'], 'desc': 'A property name or list of name parts.', 'default': None},
|
|
703
703
|
),
|
|
704
704
|
'returns': {'type': 'boolean', 'desc': 'True if the del operation was successful.'}}},
|
|
705
705
|
|
|
706
706
|
{'name': 'iter', 'desc': 'Yield (<path>, <valu>) tuples for the users JSON objects.',
|
|
707
707
|
'type': {'type': 'function', '_funcname': 'iter',
|
|
708
708
|
'args': (
|
|
709
|
-
{'name': 'path', 'type': 'str
|
|
709
|
+
{'name': 'path', 'type': ['str', 'list'], 'desc': 'A path string or list of path parts.', 'default': None},
|
|
710
710
|
),
|
|
711
|
-
'returns': {'name': '
|
|
711
|
+
'returns': {'name': 'yields', 'type': 'list', 'desc': '(<path>, <item>) tuples.'}}},
|
|
712
712
|
)
|
|
713
713
|
|
|
714
714
|
def __init__(self, runt, valu):
|
|
@@ -1046,7 +1046,7 @@ class User(s_stormtypes.Prim):
|
|
|
1046
1046
|
'args': (
|
|
1047
1047
|
{'name': 'name', 'type': 'str',
|
|
1048
1048
|
'desc': 'The name of the API key.'},
|
|
1049
|
-
{'name': 'duration', 'type': '
|
|
1049
|
+
{'name': 'duration', 'type': 'int', 'default': None,
|
|
1050
1050
|
'desc': 'Duration of time for the API key to be valid, in milliseconds.'},
|
|
1051
1051
|
),
|
|
1052
1052
|
'returns': {'type': 'list',
|
|
@@ -1569,7 +1569,7 @@ class LibAuth(s_stormtypes.Lib):
|
|
|
1569
1569
|
'args': (
|
|
1570
1570
|
{'name': 'text', 'type': 'str', 'desc': 'The string to process.', },
|
|
1571
1571
|
),
|
|
1572
|
-
'returns': {'type': 'list', 'desc': 'A tuple containing a
|
|
1572
|
+
'returns': {'type': 'list', 'desc': 'A tuple containing a boolean and a list of permission parts.', }}},
|
|
1573
1573
|
{'name': 'textFromRule', 'desc': 'Return a text string from a rule tuple.',
|
|
1574
1574
|
'type': {'type': 'function', '_funcname': 'textFromRule',
|
|
1575
1575
|
'args': (
|
synapse/lib/stormlib/cell.py
CHANGED
|
@@ -160,7 +160,7 @@ class CellLib(s_stormtypes.Lib):
|
|
|
160
160
|
''',
|
|
161
161
|
'type': {'type': 'function', '_funcname': '_trimNexsLog',
|
|
162
162
|
'args': (
|
|
163
|
-
{'name': 'consumers', 'type': '
|
|
163
|
+
{'name': 'consumers', 'type': 'list', 'default': None,
|
|
164
164
|
'desc': 'List of Telepath URLs for consumers of the Nexus log.'},
|
|
165
165
|
{'name': 'timeout', 'type': 'int', 'default': 30,
|
|
166
166
|
'desc': 'Time (in seconds) to wait for consumers to catch-up before culling.'}
|
synapse/lib/stormlib/cortex.py
CHANGED
|
@@ -1083,13 +1083,13 @@ class CortexHttpApi(s_stormtypes.Lib):
|
|
|
1083
1083
|
''',
|
|
1084
1084
|
'type': {'type': 'function', '_funcname': 'addHttpApi',
|
|
1085
1085
|
'args': (
|
|
1086
|
-
{'name': 'path', 'type': '
|
|
1086
|
+
{'name': 'path', 'type': 'str',
|
|
1087
1087
|
'desc': 'The extended HTTP API path.'},
|
|
1088
|
-
{'name': 'name', 'type': '
|
|
1088
|
+
{'name': 'name', 'type': 'str',
|
|
1089
1089
|
'desc': 'Friendly name for the Extended HTTP API.', 'default': ''},
|
|
1090
|
-
{'name': 'desc', 'type': '
|
|
1090
|
+
{'name': 'desc', 'type': 'str',
|
|
1091
1091
|
'desc': 'Description for the Extended HTTP API.', 'default': ''},
|
|
1092
|
-
{'name': 'runas', 'type': '
|
|
1092
|
+
{'name': 'runas', 'type': 'str',
|
|
1093
1093
|
'desc': 'Run the storm query as the API "owner" or as the authenticated "user".',
|
|
1094
1094
|
'default': 'owner'},
|
|
1095
1095
|
{'name': 'authenticated', 'type': 'boolean',
|
|
@@ -1103,14 +1103,14 @@ class CortexHttpApi(s_stormtypes.Lib):
|
|
|
1103
1103
|
{'name': 'del', 'desc': 'Delete an Extended HTTP API endpoint.',
|
|
1104
1104
|
'type': {'type': 'function', '_funcname': 'delHttpApi',
|
|
1105
1105
|
'args': (
|
|
1106
|
-
{'name': 'iden', 'type': '
|
|
1106
|
+
{'name': 'iden', 'type': 'str',
|
|
1107
1107
|
'desc': 'The iden of the API to delete.'},
|
|
1108
1108
|
),
|
|
1109
1109
|
'returns': {'type': 'null'}}},
|
|
1110
1110
|
{'name': 'get', 'desc': 'Get an Extended ``http:api`` object.',
|
|
1111
1111
|
'type': {'type': 'function', '_funcname': 'getHttpApi',
|
|
1112
1112
|
'args': (
|
|
1113
|
-
{'name': 'iden', 'type': '
|
|
1113
|
+
{'name': 'iden', 'type': 'str',
|
|
1114
1114
|
'desc': 'The iden of the API to retrieve.'},
|
|
1115
1115
|
),
|
|
1116
1116
|
'returns': {'type': 'http:api', 'desc': 'The ``http:api`` object.'}}},
|
|
@@ -1123,17 +1123,17 @@ class CortexHttpApi(s_stormtypes.Lib):
|
|
|
1123
1123
|
''',
|
|
1124
1124
|
'type': {'type': 'function', '_funcname': 'getHttpApiByPath',
|
|
1125
1125
|
'args': (
|
|
1126
|
-
{'name': 'path', 'type': '
|
|
1126
|
+
{'name': 'path', 'type': 'str',
|
|
1127
1127
|
'desc': 'Path to use to retrieve an object.'},
|
|
1128
1128
|
),
|
|
1129
1129
|
'returns': {'type': ['http:api', 'null'], 'desc': 'The ``http:api`` object or ``(null)`` if there is no match.'}}},
|
|
1130
1130
|
{'name': 'list', 'desc': 'Get all the Extended HTTP APIs on the Cortex',
|
|
1131
1131
|
'type': {'type': 'function', '_funcname': 'listHttpApis', 'args': (),
|
|
1132
|
-
|
|
1132
|
+
'returns': {'type': 'list', 'desc': 'A list of ``http:api`` objects'}}},
|
|
1133
1133
|
{'name': 'index', 'desc': 'Set the index for a given Extended HTTP API.',
|
|
1134
1134
|
'type': {'type': 'function', '_funcname': 'setHttpApiIndx',
|
|
1135
1135
|
'args': (
|
|
1136
|
-
{'name': 'iden', 'type': '
|
|
1136
|
+
{'name': 'iden', 'type': 'str',
|
|
1137
1137
|
'desc': 'The iden of the API to modify.'},
|
|
1138
1138
|
{'name': 'index', 'type': 'int', 'default': 0,
|
|
1139
1139
|
'desc': 'The new index of the API. Uses zero based indexing.'},
|
synapse/lib/stormlib/env.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import os
|
|
2
2
|
|
|
3
3
|
import synapse.exc as s_exc
|
|
4
|
-
import synapse.common as s_common
|
|
5
4
|
import synapse.lib.stormtypes as s_stormtypes
|
|
6
5
|
|
|
7
6
|
@s_stormtypes.registry.registerLib
|
|
@@ -21,10 +20,10 @@ class LibEnv(s_stormtypes.Lib):
|
|
|
21
20
|
'type': 'function', '_funcname': '_libEnvGet',
|
|
22
21
|
'args': (
|
|
23
22
|
{'name': 'name', 'type': 'str', 'desc': 'The name of the environment variable.', },
|
|
24
|
-
{'name': 'default', 'type': '
|
|
25
|
-
'desc': 'The value to return if the environment variable is not set.', },
|
|
23
|
+
{'name': 'default', 'type': 'prim', 'default': None,
|
|
24
|
+
'desc': 'The value to return if the environment variable is not set. Non-string values will be converted into their string forms.', },
|
|
26
25
|
),
|
|
27
|
-
|
|
26
|
+
'returns': {'type': ['str', 'null'], 'desc': 'The environment variable string.'},
|
|
28
27
|
},
|
|
29
28
|
},
|
|
30
29
|
)
|
|
@@ -47,4 +46,4 @@ class LibEnv(s_stormtypes.Lib):
|
|
|
47
46
|
mesg = f'Environment variable must start with SYN_STORM_ENV_ : {name}'
|
|
48
47
|
raise s_exc.BadArg(mesg=mesg)
|
|
49
48
|
|
|
50
|
-
return os.getenv(name, default=default)
|
|
49
|
+
return os.getenv(name, default=await s_stormtypes.tostr(default, noneok=True))
|
synapse/lib/stormlib/ethereum.py
CHANGED
|
@@ -13,7 +13,7 @@ class EthereumLib(s_stormtypes.Lib):
|
|
|
13
13
|
{'name': 'addr', 'type': 'str', 'desc': 'The Ethereum address to be converted.'},
|
|
14
14
|
),
|
|
15
15
|
'returns': {'type': 'list',
|
|
16
|
-
'desc': 'A list of (<
|
|
16
|
+
'desc': 'A list of (<boolean>, <addr>) for status and checksummed address.', },
|
|
17
17
|
}},
|
|
18
18
|
)
|
|
19
19
|
|
synapse/lib/stormlib/gen.py
CHANGED
|
@@ -140,7 +140,7 @@ class LibGen(s_stormtypes.Lib):
|
|
|
140
140
|
'desc': 'Returns a file:bytes node by SHA256, adding the node if it does not exist.',
|
|
141
141
|
'type': {'type': 'function', '_funcname': '_storm_query',
|
|
142
142
|
'args': (
|
|
143
|
-
{'name': 'sha256', 'type':
|
|
143
|
+
{'name': 'sha256', 'type': 'str', 'desc': 'The SHA256 fingerprint for the file:bytes node.'},
|
|
144
144
|
{'name': 'try', 'type': 'boolean', 'default': False,
|
|
145
145
|
'desc': 'Type normalization will fail silently instead of raising an exception.'},
|
|
146
146
|
),
|
|
@@ -149,7 +149,7 @@ class LibGen(s_stormtypes.Lib):
|
|
|
149
149
|
'desc': 'Returns a crypto:x509:cert node by SHA256, adding the node if it does not exist.',
|
|
150
150
|
'type': {'type': 'function', '_funcname': '_storm_query',
|
|
151
151
|
'args': (
|
|
152
|
-
{'name': 'sha256', 'type':
|
|
152
|
+
{'name': 'sha256', 'type': 'str', 'desc': 'The SHA256 fingerprint for the certificate.'},
|
|
153
153
|
{'name': 'try', 'type': 'boolean', 'default': False,
|
|
154
154
|
'desc': 'Type normalization will fail silently instead of raising an exception.'},
|
|
155
155
|
),
|
|
@@ -159,7 +159,7 @@ class LibGen(s_stormtypes.Lib):
|
|
|
159
159
|
'type': {'type': 'function', '_funcname': '_storm_query',
|
|
160
160
|
'args': (
|
|
161
161
|
{'name': 'server', 'type': ['str', 'inet:server'], 'desc': 'The server associated with the x509 certificate.'},
|
|
162
|
-
{'name': 'sha256', 'type':
|
|
162
|
+
{'name': 'sha256', 'type': 'str', 'desc': 'The SHA256 fingerprint for the certificate.'},
|
|
163
163
|
{'name': 'try', 'type': 'boolean', 'default': False,
|
|
164
164
|
'desc': 'Type normalization will fail silently instead of raising an exception.'},
|
|
165
165
|
),
|
synapse/lib/stormlib/hex.py
CHANGED
|
@@ -29,7 +29,7 @@ class HexLib(s_stormtypes.Lib):
|
|
|
29
29
|
'type': {'type': 'function', '_funcname': 'toint',
|
|
30
30
|
'args': (
|
|
31
31
|
{'name': 'valu', 'type': 'str', 'desc': 'The hex string to be converted.'},
|
|
32
|
-
{'name': 'signed', 'type': '
|
|
32
|
+
{'name': 'signed', 'type': 'boolean', 'default': False,
|
|
33
33
|
'desc': 'If true, convert to a signed integer.'},
|
|
34
34
|
),
|
|
35
35
|
'returns': {'type': 'int', 'desc': 'The resulting integer.', }
|
|
@@ -39,7 +39,7 @@ class HexLib(s_stormtypes.Lib):
|
|
|
39
39
|
'args': (
|
|
40
40
|
{'name': 'valu', 'type': 'int', 'desc': 'The integer to be converted.'},
|
|
41
41
|
{'name': 'length', 'type': 'int', 'desc': 'The number of bytes to use to represent the integer.'},
|
|
42
|
-
{'name': 'signed', 'type': '
|
|
42
|
+
{'name': 'signed', 'type': 'boolean', 'default': False,
|
|
43
43
|
'desc': 'If true, convert as a signed value.'},
|
|
44
44
|
),
|
|
45
45
|
'returns': {'type': 'str', 'desc': 'The resulting hex string.', }
|