synapse 2.220.0__py311-none-any.whl → 2.222.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.

Files changed (52) hide show
  1. synapse/cortex.py +34 -14
  2. synapse/data/lark/storm.lark +9 -6
  3. synapse/lib/ast.py +8 -2
  4. synapse/lib/layer.py +149 -8
  5. synapse/lib/parser.py +1 -0
  6. synapse/lib/rstorm.py +83 -2
  7. synapse/lib/schemas.py +4 -0
  8. synapse/lib/snap.py +21 -13
  9. synapse/lib/stormhttp.py +10 -10
  10. synapse/lib/stormlib/aha.py +3 -3
  11. synapse/lib/stormlib/auth.py +11 -11
  12. synapse/lib/stormlib/cell.py +1 -1
  13. synapse/lib/stormlib/cortex.py +10 -10
  14. synapse/lib/stormlib/env.py +4 -5
  15. synapse/lib/stormlib/ethereum.py +1 -1
  16. synapse/lib/stormlib/gen.py +3 -3
  17. synapse/lib/stormlib/hex.py +2 -2
  18. synapse/lib/stormlib/imap.py +2 -2
  19. synapse/lib/stormlib/infosec.py +2 -2
  20. synapse/lib/stormlib/iters.py +2 -2
  21. synapse/lib/stormlib/model.py +5 -5
  22. synapse/lib/stormlib/notifications.py +1 -1
  23. synapse/lib/stormlib/oauth.py +2 -2
  24. synapse/lib/stormlib/project.py +3 -3
  25. synapse/lib/stormlib/scrape.py +2 -1
  26. synapse/lib/stormlib/smtp.py +3 -3
  27. synapse/lib/stormlib/stats.py +2 -2
  28. synapse/lib/stormlib/stix.py +2 -2
  29. synapse/lib/stormlib/utils.py +19 -0
  30. synapse/lib/stormlib/vault.py +1 -1
  31. synapse/lib/stormlib/xml.py +2 -2
  32. synapse/lib/stormlib/yaml.py +1 -1
  33. synapse/lib/stormtypes.py +182 -64
  34. synapse/lib/version.py +2 -2
  35. synapse/models/orgs.py +3 -0
  36. synapse/tests/test_lib_grammar.py +4 -4
  37. synapse/tests/test_lib_layer.py +86 -67
  38. synapse/tests/test_lib_rstorm.py +180 -0
  39. synapse/tests/test_lib_storm.py +80 -1
  40. synapse/tests/test_lib_stormlib_auth.py +84 -0
  41. synapse/tests/test_lib_stormlib_cortex.py +1 -0
  42. synapse/tests/test_lib_stormlib_env.py +3 -1
  43. synapse/tests/test_lib_stormlib_utils.py +10 -0
  44. synapse/tests/test_lib_stormtypes.py +576 -2
  45. synapse/tests/test_model_orgs.py +6 -1
  46. synapse/tools/aha/list.py +9 -9
  47. synapse/tools/aha/provision/service.py +2 -2
  48. {synapse-2.220.0.dist-info → synapse-2.222.0.dist-info}/METADATA +1 -1
  49. {synapse-2.220.0.dist-info → synapse-2.222.0.dist-info}/RECORD +52 -52
  50. {synapse-2.220.0.dist-info → synapse-2.222.0.dist-info}/WHEEL +0 -0
  51. {synapse-2.220.0.dist-info → synapse-2.222.0.dist-info}/licenses/LICENSE +0 -0
  52. {synapse-2.220.0.dist-info → synapse-2.222.0.dist-info}/top_level.txt +0 -0
@@ -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': 'Yields', 'type': 'list',
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
- 'desc': 'Yields the results of the API calls as tuples of (svcname, (ok, info)).', }}},
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
- 'desc': 'Yields the results of the API calls as tuples containing (svcname, (ok, info)).', }}}
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',)
@@ -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 <bool>`.'}),
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|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},
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|list', 'desc': 'A path string or list of path elements.'},
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|list', 'desc': 'A property name or list of name parts.', 'default': None},
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|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},
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|list', 'desc': 'A path string or list of path parts.', 'default': None},
709
+ {'name': 'path', 'type': ['str', 'list'], 'desc': 'A path string or list of path parts.', 'default': None},
710
710
  ),
711
- 'returns': {'name': 'Yields', 'type': 'list', 'desc': '(<path>, <item>) tuples.'}}},
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': 'integer', 'default': None,
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 bool and a list of permission parts.', }}},
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': (
@@ -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': 'array', 'default': None,
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.'}
@@ -1029,7 +1029,7 @@ class HttpReq(s_stormtypes.StormType):
1029
1029
  if not isinstance(body, bytes):
1030
1030
  body = await s_stormtypes.toprim(body)
1031
1031
  body = s_json.dumps(body)
1032
- headers['Content-Type'] = 'application/json; charset=utf8"'
1032
+ headers['Content-Type'] = 'application/json; charset=utf8'
1033
1033
  headers['Content-Length'] = len(body)
1034
1034
 
1035
1035
  await self._methSendCode(code)
@@ -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': 'string',
1086
+ {'name': 'path', 'type': 'str',
1087
1087
  'desc': 'The extended HTTP API path.'},
1088
- {'name': 'name', 'type': 'string',
1088
+ {'name': 'name', 'type': 'str',
1089
1089
  'desc': 'Friendly name for the Extended HTTP API.', 'default': ''},
1090
- {'name': 'desc', 'type': 'string',
1090
+ {'name': 'desc', 'type': 'str',
1091
1091
  'desc': 'Description for the Extended HTTP API.', 'default': ''},
1092
- {'name': 'runas', 'type': 'string',
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': 'string',
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': 'string',
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': 'string',
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
- 'returns': {'type': 'list', 'desc': 'A list of ``http:api`` objects'}}},
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': 'string',
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.'},
@@ -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': 'obj', 'default': None,
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
- 'returns': {'type': 'str', 'desc': 'The environment variable string.'},
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))
@@ -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 (<bool>, <addr>) for status and checksummed address.', },
16
+ 'desc': 'A list of (<boolean>, <addr>) for status and checksummed address.', },
17
17
  }},
18
18
  )
19
19
 
@@ -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': ['str', 'hash:sha256'], 'desc': 'The SHA256 fingerprint for the file:bytes node.'},
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': ['str', 'hash:sha256'], 'desc': 'The SHA256 fingerprint for the certificate.'},
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': ['str', 'hash:sha256'], 'desc': 'The SHA256 fingerprint for the certificate.'},
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
  ),
@@ -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': 'bool', 'default': False,
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': 'bool', 'default': False,
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.', }
@@ -485,9 +485,9 @@ class ImapLib(s_stormtypes.Lib):
485
485
  'desc': 'The IMAP server port.'},
486
486
  {'type': 'int', 'name': 'timeout', 'default': 30,
487
487
  'desc': 'The time to wait for all commands on the server to execute.'},
488
- {'type': 'bool', 'name': 'ssl', 'default': True,
488
+ {'type': 'boolean', 'name': 'ssl', 'default': True,
489
489
  'desc': 'Use SSL to connect to the IMAP server.'},
490
- {'type': 'bool', 'name': 'ssl_verify', 'default': True,
490
+ {'type': 'boolean', 'name': 'ssl_verify', 'default': True,
491
491
  'desc': 'Perform SSL/TLS verification.'},
492
492
  ),
493
493
  'returns': {
@@ -422,7 +422,7 @@ class MitreAttackFlowLib(s_stormtypes.Lib):
422
422
  {'name': 'norm', 'desc': 'Normalize a MITRE ATT&CK Flow diagram in JSON format.',
423
423
  'type': {'type': 'function', '_funcname': '_norm',
424
424
  'args': (
425
- {'name': 'flow', 'type': 'data',
425
+ {'name': 'flow', 'type': 'dict',
426
426
  'desc': 'The MITRE ATT&CK Flow diagram in JSON format to normalize (flatten and sort).'},
427
427
  ),
428
428
  'returns': {'type': 'dict', 'desc': 'The normalized MITRE ATT&CK Flow diagram.', }
@@ -430,7 +430,7 @@ class MitreAttackFlowLib(s_stormtypes.Lib):
430
430
  {'name': 'ingest', 'desc': 'Ingest a MITRE ATT&CK Flow diagram in JSON format.',
431
431
  'type': {'type': 'function', '_funcname': '_storm_query',
432
432
  'args': (
433
- {'name': 'flow', 'type': 'data', 'desc': 'The JSON data to ingest.'},
433
+ {'name': 'flow', 'type': 'any', 'desc': 'The JSON data to ingest.'},
434
434
  ),
435
435
  'returns': {'type': ['node', 'null'], 'desc': 'The it:mitre:attack:flow node representing the ingested attack flow diagram.'}}},
436
436
 
@@ -19,7 +19,7 @@ class LibIters(s_stormtypes.Lib):
19
19
  'type': {
20
20
  'type': 'function', '_funcname': 'enum',
21
21
  'args': (
22
- {'type': 'iter', 'name': 'genr', 'desc': 'An iterable or generator.'},
22
+ {'type': 'list', 'name': 'genr', 'desc': 'An iterable or generator.'},
23
23
  ),
24
24
  'returns': {'name': 'yields', 'type': 'list',
25
25
  'desc': 'Yields (<indx>, <item>) tuples.'},
@@ -30,7 +30,7 @@ class LibIters(s_stormtypes.Lib):
30
30
  'type': {
31
31
  'type': 'function', '_funcname': '_zip',
32
32
  'args': (
33
- {'name': '*args', 'type': 'iter', 'desc': 'Iterables or generators.', },
33
+ {'name': '*args', 'type': 'list', 'desc': 'Iterables or generators.', },
34
34
  ),
35
35
  'returns': {'name': 'yields', 'type': 'list',
36
36
  'desc': 'Yields tuples with an item from each iterable or generator.'},
@@ -896,7 +896,7 @@ class LibModelMigrations(s_stormtypes.Lib, MigrationEditorMixin):
896
896
  'type': {'type': 'function', '_funcname': '_riskHasVulnToVulnerable',
897
897
  'args': (
898
898
  {'name': 'n', 'type': 'node', 'desc': 'The risk:hasvuln node to migrate.'},
899
- {'name': 'nodata', 'type': 'bool', 'default': False,
899
+ {'name': 'nodata', 'type': 'boolean', 'default': False,
900
900
  'desc': 'Do not copy nodedata to the risk:vulnerable node.'},
901
901
  ),
902
902
  'returns': {'type': 'list', 'desc': 'A list of idens for the risk:vulnerable nodes.'}}},
@@ -912,7 +912,7 @@ class LibModelMigrations(s_stormtypes.Lib, MigrationEditorMixin):
912
912
  'type': {'type': 'function', '_funcname': '_storm_query',
913
913
  'args': (
914
914
  {'name': 'n', 'type': 'node', 'desc': 'The inet:ssl:cert node to migrate.'},
915
- {'name': 'nodata', 'type': 'bool', 'default': False,
915
+ {'name': 'nodata', 'type': 'boolean', 'default': False,
916
916
  'desc': 'Do not copy nodedata to the inet:tls:servercert node.'},
917
917
  ),
918
918
  'returns': {'type': 'node', 'desc': 'The newly created inet:tls:servercert node.'}}},
@@ -1067,7 +1067,7 @@ class LibModelMigrations_0_2_31(s_stormtypes.Lib):
1067
1067
  {'name': 'listNodes', 'desc': 'Yield queued nodes.',
1068
1068
  'type': {'type': 'function', '_funcname': '_methListNodes',
1069
1069
  'args': (
1070
- {'name': 'form', 'type': 'form', 'default': None,
1070
+ {'name': 'form', 'type': 'str', 'default': None,
1071
1071
  'desc': 'Only yield entries matching the specified form.'},
1072
1072
  {'name': 'source', 'type': 'str', 'default': None,
1073
1073
  'desc': 'Only yield entries that were seen by the specified source.'},
@@ -1076,12 +1076,12 @@ class LibModelMigrations_0_2_31(s_stormtypes.Lib):
1076
1076
  {'name': 'size', 'type': 'int', 'default': None,
1077
1077
  'desc': 'Only yield up to this many entries.'},
1078
1078
  ),
1079
- 'returns': {'name': 'Yields', 'type': 'list',
1079
+ 'returns': {'name': 'yields', 'type': 'list',
1080
1080
  'desc': 'A tuple of (offset, form, valu, sources) values for the specified node.', }}},
1081
1081
  {'name': 'printNode', 'desc': 'Print detailed queued node information.',
1082
1082
  'type': {'type': 'function', '_funcname': '_methPrintNode',
1083
1083
  'args': (
1084
- {'name': 'offset', 'type': 'into', 'desc': 'The offset of the queued node to print.'},
1084
+ {'name': 'offset', 'type': 'int', 'desc': 'The offset of the queued node to print.'},
1085
1085
  ),
1086
1086
  'returns': {'type': 'null'}}},
1087
1087
  {'name': 'repairNode', 'desc': 'Repair a queued node.',
@@ -21,7 +21,7 @@ class NotifyLib(s_stormtypes.Lib):
21
21
  {'name': 'size', 'type': 'int', 'desc': 'The max number of notifications to yield.', 'default': None},
22
22
  ),
23
23
  'returns': {
24
- 'name': 'Yields', 'type': 'list',
24
+ 'name': 'yields', 'type': 'list',
25
25
  'desc': 'Yields (useriden, time, mesgtype, msgdata) tuples.'},
26
26
  },
27
27
  },
@@ -210,7 +210,7 @@ class OAuthV2Lib(s_stormtypes.Lib):
210
210
 
211
211
  Add a new provider which uses a custom Storm callback to obtain the client_assertion data. These
212
212
  callbacks are executed as the user who is performing the authorization_code workflow. The Storm
213
- callback must return data in a tuple of ``bool`` and a dictionary containing the assertion in the
213
+ callback must return data in a tuple of ``boolean`` and a dictionary containing the assertion in the
214
214
  key ``token``. Error messages should be in the key ``error``::
215
215
 
216
216
  $iden = $lib.guid(callstormexample, provider, oauth)
@@ -335,7 +335,7 @@ class OAuthV2Lib(s_stormtypes.Lib):
335
335
  'args': (
336
336
  {'name': 'iden', 'type': 'str', 'desc': 'The provider iden.'},
337
337
  ),
338
- 'returns': {'type': 'list', 'desc': 'List of (<bool>, <token/mesg>) for status and data.'},
338
+ 'returns': {'type': 'list', 'desc': 'List of (<boolean>, <token/mesg>) for status and data.'},
339
339
  },
340
340
  },
341
341
  {
@@ -659,12 +659,12 @@ class ProjectSprints(s_stormtypes.Prim):
659
659
  'args': (
660
660
  {'name': 'name', 'type': 'str', 'desc': 'The name (or iden) of the ProjectSprint to get.'},
661
661
  ),
662
- 'returns': {'type': 'proj:sprint', 'desc': 'The `proj:sprint` object', }}},
662
+ 'returns': {'type': 'proj:sprint', 'desc': 'The `proj:sprint` object.', }}},
663
663
  {'name': 'add', 'desc': 'Add a sprint.',
664
664
  'type': {'type': 'function', '_funcname': '_addProjSprint',
665
665
  'args': (
666
666
  {'name': 'name', 'type': 'str', 'desc': 'The name for the new ProjectSprint.'},
667
- {'name': 'period', 'type': 'ival', 'desc': 'The time interval the ProjectSprint runs for',
667
+ {'name': 'period', 'type': 'list', 'desc': 'The time interval the ProjectSprint runs for.',
668
668
  'default': None},
669
669
  ),
670
670
  'returns': {'type': 'proj:sprint', 'desc': 'The newly created `proj:sprint` object', }}},
@@ -673,7 +673,7 @@ class ProjectSprints(s_stormtypes.Prim):
673
673
  'args': (
674
674
  {'name': 'name', 'type': 'str', 'desc': 'The name of the Sprint to delete.'},
675
675
  ),
676
- 'returns': {'type': 'boolean', 'desc': 'True if the ProjectSprint can be found and deleted, otherwise False', }}}
676
+ 'returns': {'type': 'boolean', 'desc': 'True if the ProjectSprint can be found and deleted, otherwise False.', }}}
677
677
  )
678
678
 
679
679
  _storm_typename = 'proj:sprints'
@@ -59,6 +59,7 @@ class LibScrape(s_stormtypes.Lib):
59
59
  genMatches is a generic helper function for constructing scrape interfaces using pure Storm.
60
60
 
61
61
  It accepts the text, a regex pattern, and produce results that can easily be used to create
62
+ nodes.
62
63
 
63
64
  Notes:
64
65
  The pattern must have a named regular expression match for the key ``valu`` using the
@@ -91,7 +92,7 @@ class LibScrape(s_stormtypes.Lib):
91
92
  'desc': 'Regex flags to use (defaults to IGNORECASE).'},
92
93
  ),
93
94
  'returns': {'name': 'yields', 'type': 'list',
94
- 'desc': ''}}}
95
+ 'desc': 'Yields a list of (value, info) tuples scraped from the text.'}}}
95
96
  )
96
97
  _storm_lib_path = ('scrape', )
97
98
 
@@ -90,13 +90,13 @@ class SmtpMessage(s_stormtypes.StormType):
90
90
  'desc': 'The user name to use authenticating to the SMTP server.'},
91
91
  {'name': 'passwd', 'type': 'str', 'default': None,
92
92
  'desc': 'The password to use authenticating to the SMTP server.'},
93
- {'name': 'usetls', 'type': 'bool', 'default': False,
93
+ {'name': 'usetls', 'type': 'boolean', 'default': False,
94
94
  'desc': 'Initiate a TLS connection to the SMTP server.'},
95
- {'name': 'starttls', 'type': 'bool', 'default': False,
95
+ {'name': 'starttls', 'type': 'boolean', 'default': False,
96
96
  'desc': 'Use the STARTTLS directive with the SMTP server.'},
97
97
  {'name': 'timeout', 'type': 'int', 'default': 60,
98
98
  'desc': 'The timeout (in seconds) to wait for message delivery.'},
99
- {'type': 'bool', 'name': 'ssl_verify', 'default': True,
99
+ {'type': 'boolean', 'name': 'ssl_verify', 'default': True,
100
100
  'desc': 'Perform SSL/TLS verification.'},
101
101
  ),
102
102
  'returns': {'type': 'list', 'desc': 'An ($ok, $valu) tuple.'}}},
@@ -190,9 +190,9 @@ class StatTally(s_stormtypes.Prim):
190
190
  'type': {'type': 'function', '_funcname': 'sorted',
191
191
  'args': (
192
192
  {'name': 'byname', 'desc': 'Sort by counter name instead of value.',
193
- 'type': 'bool', 'default': False},
193
+ 'type': 'boolean', 'default': False},
194
194
  {'name': 'reverse', 'desc': 'Sort in descending order instead of ascending order.',
195
- 'type': 'bool', 'default': False},
195
+ 'type': 'boolean', 'default': False},
196
196
  ),
197
197
  'returns': {'type': 'list',
198
198
  'desc': 'List of (counter, value) tuples in sorted order.'}}},
@@ -645,7 +645,7 @@ class LibStix(s_stormtypes.Lib):
645
645
  'args': (
646
646
  {'type': 'dict', 'name': 'bundle', 'desc': 'The STIX bundle to lift nodes from.'},
647
647
  ),
648
- 'returns': {'name': 'Yields', 'type': 'node', 'desc': 'Yields nodes'}
648
+ 'returns': {'name': 'yields', 'type': 'node', 'desc': 'Yields nodes.'}
649
649
  }
650
650
  },
651
651
  )
@@ -856,7 +856,7 @@ class LibStixImport(s_stormtypes.Lib):
856
856
  {'type': 'dict', 'name': 'bundle', 'desc': 'The STIX bundle to ingest.'},
857
857
  {'type': 'dict', 'name': 'config', 'default': None, 'desc': 'An optional STIX ingest configuration.'},
858
858
  ),
859
- 'returns': {'name': 'Yields', 'type': 'node', 'desc': 'Yields nodes'}
859
+ 'returns': {'name': 'yields', 'type': 'node', 'desc': 'Yields nodes.'}
860
860
  },
861
861
  },
862
862
  )
@@ -1,3 +1,5 @@
1
+ import synapse.common as s_common
2
+
1
3
  import synapse.lib.stormtypes as s_stormtypes
2
4
 
3
5
  @s_stormtypes.registry.registerLib
@@ -6,6 +8,17 @@ class LibUtils(s_stormtypes.Lib):
6
8
  A Storm library for working with utility functions.
7
9
  '''
8
10
  _storm_locals = (
11
+ {'name': 'buid',
12
+ 'desc': '''
13
+ Calculate a buid from the provided valu.
14
+ ''',
15
+ 'type': {'type': 'function', '_funcname': '_buid',
16
+ 'args': (
17
+ {'name': 'valu', 'type': 'any',
18
+ 'desc': 'The value to calculate the buid from.'},
19
+ ),
20
+ 'returns': {'type': 'bytes', 'desc': 'The calculated buid.'},
21
+ }},
9
22
  {'name': 'todo',
10
23
  'desc': '''
11
24
  Create a todo tuple of (name, args, kwargs).
@@ -26,9 +39,15 @@ class LibUtils(s_stormtypes.Lib):
26
39
 
27
40
  def getObjLocals(self):
28
41
  return {
42
+ 'buid': self._buid,
29
43
  'todo': self._todo,
30
44
  }
31
45
 
46
+ @s_stormtypes.stormfunc(readonly=True)
47
+ async def _buid(self, valu):
48
+ valu = await s_stormtypes.toprim(valu)
49
+ return s_common.buid(valu)
50
+
32
51
  @s_stormtypes.stormfunc(readonly=True)
33
52
  async def _todo(self, _todoname, *args, **kwargs):
34
53
  _todoname = await s_stormtypes.tostr(_todoname)
@@ -365,7 +365,7 @@ class LibVault(s_stormtypes.Lib):
365
365
  {'name': 'list', 'desc': 'List vaults accessible to the current user.',
366
366
  'type': {'type': 'function', '_funcname': '_listVaults',
367
367
  'args': (),
368
- 'returns': {'type': 'list', 'desc': 'Yields vaults.'}}},
368
+ 'returns': {'name': 'yields', 'type': 'list', 'desc': 'Yields vaults.'}}},
369
369
  {'name': 'print', 'desc': 'Print the details of the specified vault.',
370
370
  'type': {'type': 'function', '_funcname': '_storm_query',
371
371
  'args': (
@@ -20,8 +20,8 @@ class XmlElement(s_stormtypes.Prim):
20
20
  'type': {'type': 'function', '_funcname': 'find',
21
21
  'args': (
22
22
  {'name': 'name', 'type': 'str', 'desc': 'The name of the XML tag.'},
23
- {'name': 'nested', 'type': 'bool', 'default': True,
24
- 'desc': 'Set to ``(false)`` to only find direct children.'},
23
+ {'name': 'nested', 'type': 'boolean', 'default': True,
24
+ 'desc': 'Set to ``(false)`` to only find direct children.'},
25
25
  ),
26
26
  'returns': {'type': 'generator', 'desc': 'A generator which yields xml:elements.'}}},
27
27
 
@@ -15,7 +15,7 @@ class LibYaml(s_stormtypes.Lib):
15
15
  {'name': 'save', 'desc': 'Encode data as a YAML string.',
16
16
  'type': {'type': 'function', '_funcname': 'save',
17
17
  'args': (
18
- {'name': 'valu', 'type': 'object', 'desc': 'The object to encode.'},
18
+ {'name': 'valu', 'type': 'prim', 'desc': 'The object to encode.'},
19
19
  {'name': 'sort_keys', 'type': 'boolean', 'desc': 'Sort object keys.', 'default': True},
20
20
  ),
21
21
  'returns': {'type': 'str', 'desc': 'A YAML string.'}}},