synapse 2.196.0__py311-none-any.whl → 2.198.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/axon.py +3 -0
- synapse/common.py +3 -0
- synapse/cortex.py +13 -11
- synapse/cryotank.py +2 -2
- synapse/lib/aha.py +3 -0
- synapse/lib/ast.py +277 -165
- synapse/lib/auth.py +39 -11
- synapse/lib/cell.py +24 -6
- synapse/lib/config.py +3 -3
- synapse/lib/hive.py +2 -1
- synapse/lib/hiveauth.py +10 -1
- synapse/lib/jsonstor.py +6 -5
- synapse/lib/layer.py +6 -5
- synapse/lib/multislabseqn.py +2 -2
- synapse/lib/node.py +10 -4
- synapse/lib/parser.py +46 -21
- synapse/lib/schemas.py +491 -1
- synapse/lib/snap.py +68 -26
- synapse/lib/storm.lark +13 -11
- synapse/lib/storm.py +13 -395
- synapse/lib/storm_format.py +3 -2
- synapse/lib/stormlib/graph.py +0 -61
- synapse/lib/stormlib/index.py +52 -0
- synapse/lib/stormtypes.py +16 -5
- synapse/lib/task.py +13 -2
- synapse/lib/urlhelp.py +1 -1
- synapse/lib/version.py +2 -2
- synapse/models/doc.py +62 -0
- synapse/models/infotech.py +18 -0
- synapse/models/orgs.py +6 -4
- synapse/models/risk.py +9 -0
- synapse/models/syn.py +18 -2
- synapse/tests/files/stormpkg/badendpoints.yaml +7 -0
- synapse/tests/files/stormpkg/testpkg.yaml +8 -0
- synapse/tests/test_cortex.py +108 -0
- synapse/tests/test_datamodel.py +7 -0
- synapse/tests/test_lib_aha.py +12 -42
- synapse/tests/test_lib_ast.py +57 -0
- synapse/tests/test_lib_auth.py +143 -2
- synapse/tests/test_lib_boss.py +15 -6
- synapse/tests/test_lib_cell.py +43 -0
- synapse/tests/test_lib_grammar.py +54 -2
- synapse/tests/test_lib_lmdbslab.py +24 -0
- synapse/tests/test_lib_storm.py +20 -0
- synapse/tests/test_lib_stormlib_index.py +39 -0
- synapse/tests/test_lib_stormlib_macro.py +3 -3
- synapse/tests/test_lib_stormtypes.py +14 -2
- synapse/tests/test_lib_task.py +31 -13
- synapse/tests/test_model_doc.py +38 -0
- synapse/tests/test_model_infotech.py +13 -0
- synapse/tests/test_model_orgs.py +7 -0
- synapse/tests/test_model_risk.py +6 -0
- synapse/tests/test_model_syn.py +58 -0
- synapse/tests/test_tools_genpkg.py +10 -0
- synapse/tools/genpkg.py +2 -2
- synapse/tools/hive/load.py +1 -0
- {synapse-2.196.0.dist-info → synapse-2.198.0.dist-info}/METADATA +1 -1
- {synapse-2.196.0.dist-info → synapse-2.198.0.dist-info}/RECORD +61 -58
- {synapse-2.196.0.dist-info → synapse-2.198.0.dist-info}/LICENSE +0 -0
- {synapse-2.196.0.dist-info → synapse-2.198.0.dist-info}/WHEEL +0 -0
- {synapse-2.196.0.dist-info → synapse-2.198.0.dist-info}/top_level.txt +0 -0
synapse/lib/storm.lark
CHANGED
|
@@ -40,7 +40,7 @@ _editblock: "[" _editoper* "]"
|
|
|
40
40
|
// A single edit operation
|
|
41
41
|
_editoper: editnodeadd
|
|
42
42
|
| editpropset | editunivset | edittagpropset | edittagadd | editcondpropset
|
|
43
|
-
| editpropdel | editunivdel | edittagpropdel | edittagdel
|
|
43
|
+
| editpropsetmulti | editpropdel | editunivdel | edittagpropdel | edittagdel
|
|
44
44
|
| editparens | edgeaddn1 | edgedeln1 | edgeaddn2 | edgedeln2
|
|
45
45
|
|
|
46
46
|
// Parenthesis in an edit block don't have incoming nodes
|
|
@@ -48,18 +48,20 @@ editparens: "(" editnodeadd _editoper* ")"
|
|
|
48
48
|
edittagadd: "+" [SETTAGOPER] tagname [(EQSPACE | EQNOSPACE) _valu]
|
|
49
49
|
editunivdel: EXPRMINUS univprop
|
|
50
50
|
edittagdel: EXPRMINUS tagname
|
|
51
|
-
editpropset: relprop (EQSPACE | EQNOSPACE | MODSET | TRYSET |
|
|
51
|
+
editpropset: relprop (EQSPACE | EQNOSPACE | MODSET | TRYSET | TRYMODSET) _valu
|
|
52
52
|
editcondpropset: relprop condsetoper _valu
|
|
53
|
+
editpropsetmulti: relprop (MODSETMULTI | TRYMODSETMULTI) _valu
|
|
53
54
|
editpropdel: EXPRMINUS relprop
|
|
54
|
-
editunivset: univprop (EQSPACE | EQNOSPACE | MODSET | TRYSET |
|
|
55
|
-
editnodeadd: formname (EQSPACE | EQNOSPACE | MODSET | TRYSET |
|
|
56
|
-
edittagpropset: "+" tagprop (EQSPACE | EQNOSPACE | MODSET | TRYSET |
|
|
55
|
+
editunivset: univprop (EQSPACE | EQNOSPACE | MODSET | TRYSET | TRYMODSET) _valu
|
|
56
|
+
editnodeadd: formname (EQSPACE | EQNOSPACE | MODSET | TRYSET | TRYMODSET) _valu
|
|
57
|
+
edittagpropset: "+" tagprop (EQSPACE | EQNOSPACE | MODSET | TRYSET | TRYMODSET) _valu
|
|
57
58
|
edittagpropdel: EXPRMINUS tagprop
|
|
58
59
|
|
|
59
60
|
EQSPACE: /((?<=\s)=|=(?=\s))/
|
|
60
61
|
MODSET.4: "+=" | "-="
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
TRYMODSET.1: "?+=" | "?-="
|
|
63
|
+
MODSETMULTI.4: "++=" | "--="
|
|
64
|
+
TRYMODSETMULTI.1: "?++=" | "?--="
|
|
63
65
|
TRYSET.1: "?="
|
|
64
66
|
SETTAGOPER: "?"
|
|
65
67
|
|
|
@@ -226,10 +228,10 @@ _EDGEN2JOININIT: "<+("
|
|
|
226
228
|
// comparisons to an expression like '<(2)'
|
|
227
229
|
_EDGEN2INIT: /\<\((?=(?>(?<EDGEN2INITRECUR>\(((?>[^()"'`]+|(?&EDGEN2INITRECUR)|`(?:[^`\\]|\\.)*`|"(?:[^"\\]|\\.)*"|'''.*?'''|'[^']*'(?!'))*)\))|'''.*?'''|`(?:[^`\\]|\\.)*`|"(?:[^"\\]|\\.)*"|'[^']*'(?!')|[^)])*\)[\-\+])/
|
|
228
230
|
|
|
229
|
-
edgeaddn1: _EDGEADDN1INIT _valu _EDGEN1FINI baresubquery
|
|
230
|
-
edgedeln1: _EDGEN1INIT _valu _EDGEN1FINI baresubquery
|
|
231
|
-
edgeaddn2: _EDGEN2INIT _valu _EDGEADDN2FINI baresubquery
|
|
232
|
-
edgedeln2: _EDGEN2INIT _valu _EDGEN2FINI baresubquery
|
|
231
|
+
edgeaddn1: _EDGEADDN1INIT _valu _EDGEN1FINI (baresubquery | _varvalu)
|
|
232
|
+
edgedeln1: _EDGEN1INIT _valu _EDGEN1FINI (baresubquery | _varvalu)
|
|
233
|
+
edgeaddn2: _EDGEN2INIT _valu _EDGEADDN2FINI (baresubquery | _varvalu)
|
|
234
|
+
edgedeln2: _EDGEN2INIT _valu _EDGEN2FINI (baresubquery | _varvalu)
|
|
233
235
|
|
|
234
236
|
_REVERSE: /reverse(?=[\s\(])/
|
|
235
237
|
liftreverse: _REVERSE "(" (liftformtag | liftpropby | liftprop | liftbyarray | lifttagtag | liftbytag | liftbytagprop | liftbyformtagprop) ")"
|
synapse/lib/storm.py
CHANGED
|
@@ -26,14 +26,13 @@ import synapse.lib.config as s_config
|
|
|
26
26
|
import synapse.lib.autodoc as s_autodoc
|
|
27
27
|
import synapse.lib.grammar as s_grammar
|
|
28
28
|
import synapse.lib.msgpack as s_msgpack
|
|
29
|
+
import synapse.lib.schemas as s_schemas
|
|
29
30
|
import synapse.lib.spooled as s_spooled
|
|
30
31
|
import synapse.lib.version as s_version
|
|
31
32
|
import synapse.lib.hashitem as s_hashitem
|
|
32
33
|
import synapse.lib.stormctrl as s_stormctrl
|
|
33
34
|
import synapse.lib.stormtypes as s_stormtypes
|
|
34
35
|
|
|
35
|
-
import synapse.lib.stormlib.graph as s_stormlib_graph
|
|
36
|
-
|
|
37
36
|
logger = logging.getLogger(__name__)
|
|
38
37
|
|
|
39
38
|
addtriggerdescr = '''
|
|
@@ -190,391 +189,6 @@ Examples:
|
|
|
190
189
|
wget https://vertex.link https://vtx.lk
|
|
191
190
|
'''
|
|
192
191
|
|
|
193
|
-
permdef_schema = {
|
|
194
|
-
'type': 'object',
|
|
195
|
-
'properties': {
|
|
196
|
-
'perm': {'type': 'array', 'items': {'type': 'string'}},
|
|
197
|
-
'desc': {'type': 'string'},
|
|
198
|
-
'gate': {'type': 'string'},
|
|
199
|
-
'ex': {'type': 'string'}, # Example string
|
|
200
|
-
'workflowconfig': {'type': 'boolean'},
|
|
201
|
-
'default': {'type': 'boolean', 'default': False},
|
|
202
|
-
},
|
|
203
|
-
'required': ['perm', 'desc', 'gate'],
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
reqValidPermDef = s_config.getJsValidator(permdef_schema)
|
|
207
|
-
|
|
208
|
-
reqValidPkgdef = s_config.getJsValidator({
|
|
209
|
-
'type': 'object',
|
|
210
|
-
'properties': {
|
|
211
|
-
'name': {'type': 'string'},
|
|
212
|
-
'version': {
|
|
213
|
-
'type': 'string',
|
|
214
|
-
'pattern': s_version.semverstr,
|
|
215
|
-
},
|
|
216
|
-
'build': {
|
|
217
|
-
'type' 'object'
|
|
218
|
-
'properties': {
|
|
219
|
-
'time': {'type': 'number'},
|
|
220
|
-
},
|
|
221
|
-
'required': ['time'],
|
|
222
|
-
},
|
|
223
|
-
'codesign': {
|
|
224
|
-
'type': 'object',
|
|
225
|
-
'properties': {
|
|
226
|
-
'sign': {'type': 'string'},
|
|
227
|
-
'cert': {'type': 'string'},
|
|
228
|
-
},
|
|
229
|
-
'required': ['cert', 'sign'],
|
|
230
|
-
},
|
|
231
|
-
# TODO: Remove me after Synapse 3.0.0.
|
|
232
|
-
'synapse_minversion': {
|
|
233
|
-
'type': ['array', 'null'],
|
|
234
|
-
'items': {'type': 'number'}
|
|
235
|
-
},
|
|
236
|
-
'synapse_version': {
|
|
237
|
-
'type': 'string',
|
|
238
|
-
},
|
|
239
|
-
'modules': {
|
|
240
|
-
'type': ['array', 'null'],
|
|
241
|
-
'items': {'$ref': '#/definitions/module'}
|
|
242
|
-
},
|
|
243
|
-
'docs': {
|
|
244
|
-
'type': ['array', 'null'],
|
|
245
|
-
'items': {'$ref': '#/definitions/doc'},
|
|
246
|
-
},
|
|
247
|
-
'logo': {
|
|
248
|
-
'type': 'object',
|
|
249
|
-
'properties': {
|
|
250
|
-
'mime': {'type': 'string'},
|
|
251
|
-
'file': {'type': 'string'},
|
|
252
|
-
},
|
|
253
|
-
'additionalProperties': True,
|
|
254
|
-
'required': ['mime', 'file'],
|
|
255
|
-
},
|
|
256
|
-
'commands': {
|
|
257
|
-
'type': ['array', 'null'],
|
|
258
|
-
'items': {'$ref': '#/definitions/command'},
|
|
259
|
-
},
|
|
260
|
-
'graphs': {
|
|
261
|
-
'type': ['array', 'null'],
|
|
262
|
-
'items': s_stormlib_graph.gdefSchema,
|
|
263
|
-
},
|
|
264
|
-
'desc': {'type': 'string'},
|
|
265
|
-
'svciden': {'type': ['string', 'null'], 'pattern': s_config.re_iden},
|
|
266
|
-
'onload': {'type': 'string'},
|
|
267
|
-
'author': {
|
|
268
|
-
'type': 'object',
|
|
269
|
-
'properties': {
|
|
270
|
-
'url': {'type': 'string'},
|
|
271
|
-
'name': {'type': 'string'},
|
|
272
|
-
},
|
|
273
|
-
'required': ['name', 'url'],
|
|
274
|
-
},
|
|
275
|
-
'depends': {
|
|
276
|
-
'properties': {
|
|
277
|
-
'requires': {'type': 'array', 'items': {'$ref': '#/definitions/require'}},
|
|
278
|
-
'conflicts': {'type': 'array', 'items': {'$ref': '#/definitions/conflict'}},
|
|
279
|
-
},
|
|
280
|
-
'additionalProperties': True,
|
|
281
|
-
},
|
|
282
|
-
'perms': {
|
|
283
|
-
'type': 'array',
|
|
284
|
-
'items': permdef_schema,
|
|
285
|
-
},
|
|
286
|
-
'configvars': {
|
|
287
|
-
'type': 'array',
|
|
288
|
-
'items': {
|
|
289
|
-
'type': 'object',
|
|
290
|
-
'properties': {
|
|
291
|
-
'name': {'type': 'string'},
|
|
292
|
-
'varname': {'type': 'string'},
|
|
293
|
-
'desc': {'type': 'string'},
|
|
294
|
-
'default': {},
|
|
295
|
-
'workflowconfig': {'type': 'boolean'},
|
|
296
|
-
'type': {'$ref': '#/definitions/configvartype'},
|
|
297
|
-
'scopes': {
|
|
298
|
-
'type': 'array',
|
|
299
|
-
'items': {
|
|
300
|
-
'type': 'string',
|
|
301
|
-
'enum': ['global', 'self']
|
|
302
|
-
},
|
|
303
|
-
},
|
|
304
|
-
},
|
|
305
|
-
'required': ['name', 'varname', 'desc', 'type', 'scopes'],
|
|
306
|
-
},
|
|
307
|
-
},
|
|
308
|
-
},
|
|
309
|
-
'additionalProperties': True,
|
|
310
|
-
'required': ['name', 'version'],
|
|
311
|
-
'definitions': {
|
|
312
|
-
'doc': {
|
|
313
|
-
'type': 'object',
|
|
314
|
-
'properties': {
|
|
315
|
-
'title': {'type': 'string'},
|
|
316
|
-
'content': {'type': 'string'},
|
|
317
|
-
},
|
|
318
|
-
'additionalProperties': True,
|
|
319
|
-
'required': ['title', 'content'],
|
|
320
|
-
},
|
|
321
|
-
'module': {
|
|
322
|
-
'type': 'object',
|
|
323
|
-
'properties': {
|
|
324
|
-
'name': {'type': 'string'},
|
|
325
|
-
'storm': {'type': 'string'},
|
|
326
|
-
'modconf': {'type': 'object'},
|
|
327
|
-
'apidefs': {
|
|
328
|
-
'type': ['array', 'null'],
|
|
329
|
-
'items': {'$ref': '#/definitions/apidef'},
|
|
330
|
-
},
|
|
331
|
-
'asroot': {'type': 'boolean'},
|
|
332
|
-
'asroot:perms': {'type': 'array',
|
|
333
|
-
'items': {'type': 'array',
|
|
334
|
-
'items': {'type': 'string'}},
|
|
335
|
-
},
|
|
336
|
-
},
|
|
337
|
-
'additionalProperties': True,
|
|
338
|
-
'required': ['name', 'storm']
|
|
339
|
-
},
|
|
340
|
-
'apidef': {
|
|
341
|
-
'type': 'object',
|
|
342
|
-
'properties': {
|
|
343
|
-
'name': {'type': 'string'},
|
|
344
|
-
'desc': {'type': 'string'},
|
|
345
|
-
'deprecated': {'$ref': '#/definitions/deprecatedItem'},
|
|
346
|
-
'type': {
|
|
347
|
-
'type': 'object',
|
|
348
|
-
'properties': {
|
|
349
|
-
'type': {
|
|
350
|
-
'type': 'string',
|
|
351
|
-
'enum': ['function']
|
|
352
|
-
},
|
|
353
|
-
'args': {
|
|
354
|
-
'type': 'array',
|
|
355
|
-
'items': {'$ref': '#/definitions/apiarg'},
|
|
356
|
-
},
|
|
357
|
-
'returns': {
|
|
358
|
-
'type': 'object',
|
|
359
|
-
'properties': {
|
|
360
|
-
'name': {
|
|
361
|
-
'type': 'string',
|
|
362
|
-
'enum': ['yields'],
|
|
363
|
-
},
|
|
364
|
-
'desc': {'type': 'string'},
|
|
365
|
-
'type': {
|
|
366
|
-
'oneOf': [
|
|
367
|
-
{'$ref': '#/definitions/apitype'},
|
|
368
|
-
{'type': 'array', 'items': {'$ref': '#/definitions/apitype'}},
|
|
369
|
-
],
|
|
370
|
-
},
|
|
371
|
-
},
|
|
372
|
-
'additionalProperties': False,
|
|
373
|
-
'required': ['type', 'desc']
|
|
374
|
-
},
|
|
375
|
-
},
|
|
376
|
-
'additionalProperties': False,
|
|
377
|
-
'required': ['type', 'returns'],
|
|
378
|
-
},
|
|
379
|
-
},
|
|
380
|
-
'additionalProperties': False,
|
|
381
|
-
'required': ['name', 'desc', 'type']
|
|
382
|
-
},
|
|
383
|
-
'apiarg': {
|
|
384
|
-
'type': 'object',
|
|
385
|
-
'properties': {
|
|
386
|
-
'name': {'type': 'string'},
|
|
387
|
-
'desc': {'type': 'string'},
|
|
388
|
-
'type': {
|
|
389
|
-
'oneOf': [
|
|
390
|
-
{'$ref': '#/definitions/apitype'},
|
|
391
|
-
{'type': 'array', 'items': {'$ref': '#/definitions/apitype'}},
|
|
392
|
-
],
|
|
393
|
-
},
|
|
394
|
-
'default': {'type': ['boolean', 'integer', 'string', 'null']},
|
|
395
|
-
},
|
|
396
|
-
'additionalProperties': False,
|
|
397
|
-
'required': ['name', 'desc', 'type']
|
|
398
|
-
},
|
|
399
|
-
'deprecatedItem': {
|
|
400
|
-
'type': 'object',
|
|
401
|
-
'properties': {
|
|
402
|
-
'eolvers': {'type': 'string', 'minLength': 1,
|
|
403
|
-
'description': "The version which will not longer support the item."},
|
|
404
|
-
'eoldate': {'type': 'string', 'minLength': 1,
|
|
405
|
-
'description': 'Optional string indicating Synapse releases after this date may no longer support the item.'},
|
|
406
|
-
'mesg': {'type': ['string', 'null'], 'default': None,
|
|
407
|
-
'description': 'Optional message to include in the warning text.'}
|
|
408
|
-
},
|
|
409
|
-
'oneOf': [
|
|
410
|
-
{
|
|
411
|
-
'required': ['eolvers'],
|
|
412
|
-
'not': {'required': ['eoldate']}
|
|
413
|
-
},
|
|
414
|
-
{
|
|
415
|
-
'required': ['eoldate'],
|
|
416
|
-
'not': {'required': ['eolvers']}
|
|
417
|
-
}
|
|
418
|
-
],
|
|
419
|
-
'additionalProperties': False,
|
|
420
|
-
},
|
|
421
|
-
'apitype': {
|
|
422
|
-
'type': 'string',
|
|
423
|
-
},
|
|
424
|
-
'command': {
|
|
425
|
-
'type': 'object',
|
|
426
|
-
'properties': {
|
|
427
|
-
'name': {
|
|
428
|
-
'type': 'string',
|
|
429
|
-
'pattern': s_grammar.re_scmd
|
|
430
|
-
},
|
|
431
|
-
'cmdargs': {
|
|
432
|
-
'type': ['array', 'null'],
|
|
433
|
-
'items': {'$ref': '#/definitions/cmdarg'},
|
|
434
|
-
},
|
|
435
|
-
'cmdinputs': {
|
|
436
|
-
'type': ['array', 'null'],
|
|
437
|
-
'items': {'$ref': '#/definitions/cmdinput'},
|
|
438
|
-
},
|
|
439
|
-
'storm': {'type': 'string'},
|
|
440
|
-
'forms': {'$ref': '#/definitions/cmdformhints'},
|
|
441
|
-
'perms': {'type': 'array',
|
|
442
|
-
'items': {'type': 'array',
|
|
443
|
-
'items': {'type': 'string'}},
|
|
444
|
-
},
|
|
445
|
-
},
|
|
446
|
-
'additionalProperties': True,
|
|
447
|
-
'required': ['name', 'storm']
|
|
448
|
-
},
|
|
449
|
-
'cmdarg': {
|
|
450
|
-
'type': 'array',
|
|
451
|
-
'items': [
|
|
452
|
-
{'type': 'string'},
|
|
453
|
-
{
|
|
454
|
-
'type': 'object',
|
|
455
|
-
'properties': {
|
|
456
|
-
'help': {'type': 'string'},
|
|
457
|
-
'default': {},
|
|
458
|
-
'dest': {'type': 'string'},
|
|
459
|
-
'required': {'type': 'boolean'},
|
|
460
|
-
'action': {'type': 'string'},
|
|
461
|
-
'nargs': {'type': ['string', 'integer']},
|
|
462
|
-
'choices': {
|
|
463
|
-
'type': 'array',
|
|
464
|
-
'uniqueItems': True,
|
|
465
|
-
'minItems': 1,
|
|
466
|
-
},
|
|
467
|
-
'type': {
|
|
468
|
-
'type': 'string',
|
|
469
|
-
'enum': list(s_datamodel.Model().types)
|
|
470
|
-
},
|
|
471
|
-
},
|
|
472
|
-
}
|
|
473
|
-
],
|
|
474
|
-
'additionalItems': False,
|
|
475
|
-
},
|
|
476
|
-
'cmdinput': {
|
|
477
|
-
'type': 'object',
|
|
478
|
-
'properties': {
|
|
479
|
-
'form': {'type': 'string'},
|
|
480
|
-
'help': {'type': 'string'},
|
|
481
|
-
},
|
|
482
|
-
'additionalProperties': True,
|
|
483
|
-
'required': ['form'],
|
|
484
|
-
},
|
|
485
|
-
'configvartype': {
|
|
486
|
-
'anyOf': [
|
|
487
|
-
{'type': 'array', 'items': {'$ref': '#/definitions/configvartype'}},
|
|
488
|
-
{'type': 'string'},
|
|
489
|
-
]
|
|
490
|
-
},
|
|
491
|
-
# deprecated
|
|
492
|
-
'cmdformhints': {
|
|
493
|
-
'type': 'object',
|
|
494
|
-
'properties': {
|
|
495
|
-
'input': {
|
|
496
|
-
'type': 'array',
|
|
497
|
-
'uniqueItems': True,
|
|
498
|
-
'items': {
|
|
499
|
-
'type': 'string',
|
|
500
|
-
}
|
|
501
|
-
},
|
|
502
|
-
'output': {
|
|
503
|
-
'type': 'array',
|
|
504
|
-
'uniqueItems': True,
|
|
505
|
-
'items': {
|
|
506
|
-
'type': 'string',
|
|
507
|
-
}
|
|
508
|
-
},
|
|
509
|
-
'nodedata': {
|
|
510
|
-
'type': 'array',
|
|
511
|
-
'uniqueItems': True,
|
|
512
|
-
'items': {
|
|
513
|
-
'type': 'array',
|
|
514
|
-
'items': [
|
|
515
|
-
{'type': 'string'},
|
|
516
|
-
{'type': 'string'},
|
|
517
|
-
],
|
|
518
|
-
'additionalItems': False,
|
|
519
|
-
},
|
|
520
|
-
},
|
|
521
|
-
}
|
|
522
|
-
},
|
|
523
|
-
'require': {
|
|
524
|
-
'type': 'object',
|
|
525
|
-
'properties': {
|
|
526
|
-
'name': {'type': 'string'},
|
|
527
|
-
'version': {'type': 'string'},
|
|
528
|
-
'desc': {'type': 'string'},
|
|
529
|
-
'optional': {'type': 'boolean'},
|
|
530
|
-
},
|
|
531
|
-
'additionalItems': True,
|
|
532
|
-
'required': ('name', 'version'),
|
|
533
|
-
},
|
|
534
|
-
'conflict': {
|
|
535
|
-
'type': 'object',
|
|
536
|
-
'properties': {
|
|
537
|
-
'name': {'type': 'string'},
|
|
538
|
-
'version': {'type': 'string'},
|
|
539
|
-
'desc': {'type': 'string'},
|
|
540
|
-
},
|
|
541
|
-
'additionalItems': True,
|
|
542
|
-
'required': ('name',),
|
|
543
|
-
},
|
|
544
|
-
}
|
|
545
|
-
})
|
|
546
|
-
|
|
547
|
-
reqValidDdef = s_config.getJsValidator({
|
|
548
|
-
'type': 'object',
|
|
549
|
-
'properties': {
|
|
550
|
-
'name': {'type': 'string'},
|
|
551
|
-
'storm': {'type': 'string'},
|
|
552
|
-
'view': {'type': 'string', 'pattern': s_config.re_iden},
|
|
553
|
-
'user': {'type': 'string', 'pattern': s_config.re_iden},
|
|
554
|
-
'iden': {'type': 'string', 'pattern': s_config.re_iden},
|
|
555
|
-
'enabled': {'type': 'boolean', 'default': True},
|
|
556
|
-
'stormopts': {
|
|
557
|
-
'oneOf': [
|
|
558
|
-
{'type': 'null'},
|
|
559
|
-
{'$ref': '#/definitions/stormopts'}
|
|
560
|
-
]
|
|
561
|
-
}
|
|
562
|
-
},
|
|
563
|
-
'additionalProperties': True,
|
|
564
|
-
'required': ['iden', 'user', 'storm'],
|
|
565
|
-
'definitions': {
|
|
566
|
-
'stormopts': {
|
|
567
|
-
'type': 'object',
|
|
568
|
-
'properties': {
|
|
569
|
-
'repr': {'type': 'boolean'},
|
|
570
|
-
'path': {'type': 'string'},
|
|
571
|
-
'show': {'type': 'array', 'items': {'type': 'string'}}
|
|
572
|
-
},
|
|
573
|
-
'additionalProperties': True,
|
|
574
|
-
},
|
|
575
|
-
}
|
|
576
|
-
})
|
|
577
|
-
|
|
578
192
|
stormcmds = (
|
|
579
193
|
{
|
|
580
194
|
'name': 'queue.add',
|
|
@@ -1685,7 +1299,7 @@ stormcmds = (
|
|
|
1685
1299
|
|
|
1686
1300
|
@s_cache.memoize(size=1024)
|
|
1687
1301
|
def queryhash(text):
|
|
1688
|
-
return
|
|
1302
|
+
return s_common.queryhash(text)
|
|
1689
1303
|
|
|
1690
1304
|
class DmonManager(s_base.Base):
|
|
1691
1305
|
'''
|
|
@@ -2463,11 +2077,15 @@ class Runtime(s_base.Base):
|
|
|
2463
2077
|
|
|
2464
2078
|
class Parser:
|
|
2465
2079
|
|
|
2466
|
-
def __init__(self, prog=None, descr=None, root=None):
|
|
2080
|
+
def __init__(self, prog=None, descr=None, root=None, model=None):
|
|
2467
2081
|
|
|
2468
2082
|
if root is None:
|
|
2469
2083
|
root = self
|
|
2470
2084
|
|
|
2085
|
+
if model is None:
|
|
2086
|
+
model = s_datamodel.Model()
|
|
2087
|
+
self.model = model
|
|
2088
|
+
|
|
2471
2089
|
self.prog = prog
|
|
2472
2090
|
self.descr = descr
|
|
2473
2091
|
|
|
@@ -2495,7 +2113,7 @@ class Parser:
|
|
|
2495
2113
|
assert len(names)
|
|
2496
2114
|
|
|
2497
2115
|
argtype = opts.get('type')
|
|
2498
|
-
if argtype is not None and argtype not in
|
|
2116
|
+
if argtype is not None and argtype not in s_schemas.datamodel_basetypes:
|
|
2499
2117
|
mesg = f'Argument type "{argtype}" is not a valid model type name'
|
|
2500
2118
|
raise s_exc.BadArg(mesg=mesg, argtype=str(argtype))
|
|
2501
2119
|
|
|
@@ -2643,7 +2261,7 @@ class Parser:
|
|
|
2643
2261
|
valu = todo.popleft()
|
|
2644
2262
|
if argtype is not None:
|
|
2645
2263
|
try:
|
|
2646
|
-
valu =
|
|
2264
|
+
valu = self.model.type(argtype).norm(valu)[0]
|
|
2647
2265
|
except Exception:
|
|
2648
2266
|
mesg = f'Invalid value for type ({argtype}): {valu}'
|
|
2649
2267
|
return self.help(mesg=mesg)
|
|
@@ -2666,7 +2284,7 @@ class Parser:
|
|
|
2666
2284
|
valu = todo.popleft()
|
|
2667
2285
|
if argtype is not None:
|
|
2668
2286
|
try:
|
|
2669
|
-
valu =
|
|
2287
|
+
valu = self.model.type(argtype).norm(valu)[0]
|
|
2670
2288
|
except Exception:
|
|
2671
2289
|
mesg = f'Invalid value for type ({argtype}): {valu}'
|
|
2672
2290
|
return self.help(mesg=mesg)
|
|
@@ -2689,7 +2307,7 @@ class Parser:
|
|
|
2689
2307
|
|
|
2690
2308
|
if argtype is not None:
|
|
2691
2309
|
try:
|
|
2692
|
-
valu =
|
|
2310
|
+
valu = self.model.type(argtype).norm(valu)[0]
|
|
2693
2311
|
except Exception:
|
|
2694
2312
|
mesg = f'Invalid value for type ({argtype}): {valu}'
|
|
2695
2313
|
return self.help(mesg=mesg)
|
|
@@ -2718,7 +2336,7 @@ class Parser:
|
|
|
2718
2336
|
valu = todo.popleft()
|
|
2719
2337
|
if argtype is not None:
|
|
2720
2338
|
try:
|
|
2721
|
-
valu =
|
|
2339
|
+
valu = self.model.type(argtype).norm(valu)[0]
|
|
2722
2340
|
except Exception:
|
|
2723
2341
|
mesg = f'Invalid value for type ({argtype}): {valu}'
|
|
2724
2342
|
return self.help(mesg=mesg)
|
|
@@ -2945,7 +2563,7 @@ class Cmd:
|
|
|
2945
2563
|
return self.__class__.__doc__
|
|
2946
2564
|
|
|
2947
2565
|
def getArgParser(self):
|
|
2948
|
-
return Parser(prog=self.getName(), descr=self.getDescr())
|
|
2566
|
+
return Parser(prog=self.getName(), descr=self.getDescr(), model=self.runt.model)
|
|
2949
2567
|
|
|
2950
2568
|
async def setArgv(self, argv):
|
|
2951
2569
|
|
synapse/lib/storm_format.py
CHANGED
|
@@ -55,6 +55,7 @@ TerminalPygMap = {
|
|
|
55
55
|
'LSQB': p_t.Punctuation,
|
|
56
56
|
'MCASEBARE': p_t.Literal.String,
|
|
57
57
|
'MODSET': p_t.Operator,
|
|
58
|
+
'MODSETMULTI': p_t.Operator,
|
|
58
59
|
'NONQUOTEWORD': p_t.Literal,
|
|
59
60
|
'NOT': p_t.Keyword,
|
|
60
61
|
'NULL': p_t.Keyword,
|
|
@@ -74,8 +75,8 @@ TerminalPygMap = {
|
|
|
74
75
|
'TAGSEGNOVAR': p_t.Name,
|
|
75
76
|
'TRIPLEQUOTEDSTRING': p_t.Literal.String,
|
|
76
77
|
'TRYSET': p_t.Operator,
|
|
77
|
-
'
|
|
78
|
-
'
|
|
78
|
+
'TRYMODSET': p_t.Operator,
|
|
79
|
+
'TRYMODSETMULTI': p_t.Operator,
|
|
79
80
|
'UNIVNAME': p_t.Name,
|
|
80
81
|
'UNSET': p_t.Operator,
|
|
81
82
|
'EXPRUNIVNAME': p_t.Name,
|
synapse/lib/stormlib/graph.py
CHANGED
|
@@ -5,67 +5,6 @@ import synapse.lib.msgpack as s_msgpack
|
|
|
5
5
|
import synapse.lib.schemas as s_schemas
|
|
6
6
|
import synapse.lib.stormtypes as s_stormtypes
|
|
7
7
|
|
|
8
|
-
gdefSchema = {
|
|
9
|
-
'type': 'object',
|
|
10
|
-
'properties': {
|
|
11
|
-
'iden': {'type': 'string', 'pattern': s_config.re_iden},
|
|
12
|
-
'name': {'type': 'string', 'minLength': 1},
|
|
13
|
-
'desc': {'type': 'string', 'default': ''},
|
|
14
|
-
'scope': {'type': 'string', 'enum': ['user', 'power-up']},
|
|
15
|
-
'creator': {'type': 'string', 'pattern': s_config.re_iden},
|
|
16
|
-
'power-up': {'type': 'string', 'minLength': 1},
|
|
17
|
-
'maxsize': {'type': 'number', 'minimum': 0},
|
|
18
|
-
'existing': {'type': 'array', 'items': {'type': 'string'}},
|
|
19
|
-
'created': {'type': 'number'},
|
|
20
|
-
'updated': {'type': 'number'},
|
|
21
|
-
'refs': {'type': 'boolean', 'default': False},
|
|
22
|
-
'edges': {'type': 'boolean', 'default': True},
|
|
23
|
-
'edgelimit': {'type': 'number', 'default': 3000},
|
|
24
|
-
'degrees': {'type': ['integer', 'null'], 'minimum': 0},
|
|
25
|
-
'filterinput': {'type': 'boolean', 'default': True},
|
|
26
|
-
'yieldfiltered': {'type': 'boolean', 'default': False},
|
|
27
|
-
'filters': {
|
|
28
|
-
'type': ['array', 'null'],
|
|
29
|
-
'items': {'type': 'string'}
|
|
30
|
-
},
|
|
31
|
-
'pivots': {
|
|
32
|
-
'type': ['array', 'null'],
|
|
33
|
-
'items': {'type': 'string'}
|
|
34
|
-
},
|
|
35
|
-
'forms': {
|
|
36
|
-
'type': 'object',
|
|
37
|
-
'patternProperties': {
|
|
38
|
-
'^.*$': {
|
|
39
|
-
'type': 'object',
|
|
40
|
-
'properties': {
|
|
41
|
-
'filters': {
|
|
42
|
-
'type': ['array', 'null'],
|
|
43
|
-
'items': {'type': 'string'}
|
|
44
|
-
},
|
|
45
|
-
'pivots': {
|
|
46
|
-
'type': ['array', 'null'],
|
|
47
|
-
'items': {'type': 'string'}
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
'additionalProperties': False,
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
'permissions': s_msgpack.deepcopy(s_schemas.easyPermSchema)
|
|
55
|
-
},
|
|
56
|
-
'additionalProperties': False,
|
|
57
|
-
'required': ['iden', 'name', 'scope'],
|
|
58
|
-
'allOf': [
|
|
59
|
-
{
|
|
60
|
-
'if': {'properties': {'scope': {'const': 'power-up'}}},
|
|
61
|
-
'then': {'required': ['power-up']},
|
|
62
|
-
'else': {'required': ['creator']},
|
|
63
|
-
}
|
|
64
|
-
]
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
reqValidGdef = s_config.getJsValidator(gdefSchema)
|
|
68
|
-
|
|
69
8
|
USER_EDITABLE = {
|
|
70
9
|
'desc',
|
|
71
10
|
'name',
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import synapse.lib.stormtypes as s_stormtypes
|
|
2
|
+
|
|
3
|
+
stormcmds = (
|
|
4
|
+
{
|
|
5
|
+
'name': 'index.count.prop',
|
|
6
|
+
'descr': '''
|
|
7
|
+
Display the number of properties or property values in the view.
|
|
8
|
+
|
|
9
|
+
Examples:
|
|
10
|
+
|
|
11
|
+
// Display the number of file:path:ext properties in the view.
|
|
12
|
+
index.count.prop file:path:ext
|
|
13
|
+
|
|
14
|
+
// Display the number of file:path:ext properties with the value
|
|
15
|
+
// "exe" in the view.
|
|
16
|
+
index.count.prop file:path:ext --value exe
|
|
17
|
+
|
|
18
|
+
''',
|
|
19
|
+
'cmdargs': (
|
|
20
|
+
('prop', {'help': 'The name of the form or property to count.'}),
|
|
21
|
+
('--value', {'help': 'The specific value to count instances of.',
|
|
22
|
+
'default': s_stormtypes.undef}),
|
|
23
|
+
),
|
|
24
|
+
'storm': '''
|
|
25
|
+
|
|
26
|
+
$conf = (
|
|
27
|
+
{"columns": [
|
|
28
|
+
{"name": "Count", "width": 12},
|
|
29
|
+
{"name": "Layer Iden", "width": 32},
|
|
30
|
+
{"name": "Layer Name"},
|
|
31
|
+
],
|
|
32
|
+
"separators": {
|
|
33
|
+
'data:row': ''
|
|
34
|
+
},
|
|
35
|
+
})
|
|
36
|
+
$printer = $lib.tabular.printer($conf)
|
|
37
|
+
|
|
38
|
+
$lib.print($printer.header())
|
|
39
|
+
|
|
40
|
+
$total = (0)
|
|
41
|
+
for $layer in $lib.view.get().layers {
|
|
42
|
+
|
|
43
|
+
$count = $layer.getPropCount($cmdopts.prop, valu=$cmdopts.value)
|
|
44
|
+
|
|
45
|
+
$total = ($total + $count)
|
|
46
|
+
|
|
47
|
+
$lib.print($printer.row(($count, $layer.iden, $layer.name)))
|
|
48
|
+
}
|
|
49
|
+
$lib.print(`Total: {$total}`)
|
|
50
|
+
''',
|
|
51
|
+
},
|
|
52
|
+
)
|