synapse 2.196.0__py311-none-any.whl → 2.197.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 +12 -8
- synapse/cryotank.py +2 -2
- synapse/lib/cell.py +2 -2
- synapse/lib/config.py +3 -3
- synapse/lib/multislabseqn.py +2 -2
- synapse/lib/schemas.py +478 -1
- synapse/lib/storm.py +12 -394
- synapse/lib/stormlib/graph.py +0 -61
- synapse/lib/stormlib/index.py +52 -0
- synapse/lib/stormtypes.py +3 -1
- 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/orgs.py +6 -4
- synapse/tests/test_datamodel.py +7 -0
- synapse/tests/test_lib_aha.py +0 -40
- synapse/tests/test_lib_boss.py +15 -6
- synapse/tests/test_lib_cell.py +43 -0
- synapse/tests/test_lib_stormlib_index.py +39 -0
- synapse/tests/test_lib_task.py +31 -13
- synapse/tests/test_model_doc.py +38 -0
- synapse/tests/test_model_orgs.py +7 -0
- synapse/tools/genpkg.py +2 -2
- {synapse-2.196.0.dist-info → synapse-2.197.0.dist-info}/METADATA +1 -1
- {synapse-2.196.0.dist-info → synapse-2.197.0.dist-info}/RECORD +29 -27
- {synapse-2.196.0.dist-info → synapse-2.197.0.dist-info}/LICENSE +0 -0
- {synapse-2.196.0.dist-info → synapse-2.197.0.dist-info}/WHEEL +0 -0
- {synapse-2.196.0.dist-info → synapse-2.197.0.dist-info}/top_level.txt +0 -0
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',
|
|
@@ -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/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
|
+
)
|
synapse/lib/stormtypes.py
CHANGED
|
@@ -6839,7 +6839,8 @@ class Layer(Prim):
|
|
|
6839
6839
|
Implements the Storm api for a layer instance.
|
|
6840
6840
|
'''
|
|
6841
6841
|
_storm_locals = (
|
|
6842
|
-
{'name': 'iden', 'desc': 'The iden of the Layer.', 'type': 'str'
|
|
6842
|
+
{'name': 'iden', 'desc': 'The iden of the Layer.', 'type': 'str'},
|
|
6843
|
+
{'name': 'name', 'desc': 'The name of the Layer.', 'type': 'str'},
|
|
6843
6844
|
{'name': 'set', 'desc': 'Set an arbitrary value in the Layer definition.',
|
|
6844
6845
|
'type': {'type': 'function', '_funcname': '_methLayerSet',
|
|
6845
6846
|
'args': (
|
|
@@ -7194,6 +7195,7 @@ class Layer(Prim):
|
|
|
7194
7195
|
|
|
7195
7196
|
self.locls.update(self.getObjLocals())
|
|
7196
7197
|
self.locls['iden'] = self.valu.get('iden')
|
|
7198
|
+
self.locls['name'] = self.valu.get('name')
|
|
7197
7199
|
|
|
7198
7200
|
def __hash__(self):
|
|
7199
7201
|
return hash((self._storm_typename, self.locls['iden']))
|
synapse/lib/task.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import copy
|
|
2
1
|
import asyncio
|
|
3
2
|
import logging
|
|
4
3
|
|
|
@@ -6,6 +5,7 @@ import synapse.exc as s_exc
|
|
|
6
5
|
import synapse.common as s_common
|
|
7
6
|
|
|
8
7
|
import synapse.lib.base as s_base
|
|
8
|
+
import synapse.lib.msgpack as s_msgpack
|
|
9
9
|
|
|
10
10
|
logger = logging.getLogger(__name__)
|
|
11
11
|
|
|
@@ -104,7 +104,7 @@ class Task(s_base.Base):
|
|
|
104
104
|
pask = {
|
|
105
105
|
'iden': self.iden,
|
|
106
106
|
'name': self.name,
|
|
107
|
-
'info':
|
|
107
|
+
'info': s_msgpack.deepcopy(self.info),
|
|
108
108
|
'tick': self.tick,
|
|
109
109
|
'user': 'root',
|
|
110
110
|
'kids': {i: k.pack() for i, k in self.kids.items()},
|
|
@@ -115,6 +115,17 @@ class Task(s_base.Base):
|
|
|
115
115
|
|
|
116
116
|
return pask
|
|
117
117
|
|
|
118
|
+
def packv2(self):
|
|
119
|
+
return {
|
|
120
|
+
'iden': self.iden,
|
|
121
|
+
'name': self.name,
|
|
122
|
+
'info': s_msgpack.deepcopy(self.info),
|
|
123
|
+
'tick': self.tick,
|
|
124
|
+
'user': self.user.iden,
|
|
125
|
+
'username': self.user.name,
|
|
126
|
+
'kids': {i: k.packv2() for i, k in self.kids.items()},
|
|
127
|
+
}
|
|
128
|
+
|
|
118
129
|
def loop():
|
|
119
130
|
try:
|
|
120
131
|
return asyncio.get_running_loop()
|
synapse/lib/urlhelp.py
CHANGED
|
@@ -13,7 +13,7 @@ def chopurl(url):
|
|
|
13
13
|
'''
|
|
14
14
|
ret = {}
|
|
15
15
|
if url.find('://') == -1:
|
|
16
|
-
raise s_exc.BadUrl(':// not found in [{}]!'.format(url))
|
|
16
|
+
raise s_exc.BadUrl(mesg=':// not found in [{}]!'.format(url))
|
|
17
17
|
|
|
18
18
|
scheme, remain = url.split('://', 1)
|
|
19
19
|
ret['scheme'] = scheme.lower()
|
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, 197, 0)
|
|
227
227
|
verstring = '.'.join([str(x) for x in version])
|
|
228
|
-
commit = '
|
|
228
|
+
commit = 'c8c758131cae47ef21e23ac8242012459ebfce9d'
|