synapse 2.219.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/data/__init__.py +4 -0
- synapse/data/lark/__init__.py +0 -0
- synapse/data/lark/imap.lark +8 -0
- synapse/exc.py +2 -0
- synapse/lib/json.py +6 -5
- synapse/lib/layer.py +134 -0
- synapse/lib/link.py +49 -50
- synapse/lib/parser.py +3 -5
- synapse/lib/rstorm.py +65 -2
- synapse/lib/snap.py +21 -13
- synapse/lib/storm.py +1 -0
- 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 +478 -37
- 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 +203 -60
- synapse/lib/version.py +2 -2
- synapse/tests/test_lib_grammar.py +2 -4
- synapse/tests/test_lib_json.py +29 -0
- synapse/tests/test_lib_layer.py +86 -67
- synapse/tests/test_lib_rstorm.py +132 -0
- synapse/tests/test_lib_storm.py +11 -1
- synapse/tests/test_lib_stormlib_env.py +3 -1
- synapse/tests/test_lib_stormlib_imap.py +1307 -230
- synapse/tests/test_lib_stormlib_utils.py +10 -0
- synapse/tests/test_lib_stormtypes.py +583 -2
- synapse/tools/aha/list.py +9 -9
- synapse/tools/aha/provision/service.py +2 -2
- synapse/utils/stormcov/plugin.py +2 -5
- {synapse-2.219.0.dist-info → synapse-2.221.0.dist-info}/METADATA +1 -2
- {synapse-2.219.0.dist-info → synapse-2.221.0.dist-info}/RECORD +55 -53
- /synapse/{lib → data/lark}/storm.lark +0 -0
- {synapse-2.219.0.dist-info → synapse-2.221.0.dist-info}/WHEEL +0 -0
- {synapse-2.219.0.dist-info → synapse-2.221.0.dist-info}/licenses/LICENSE +0 -0
- {synapse-2.219.0.dist-info → synapse-2.221.0.dist-info}/top_level.txt +0 -0
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.', }
|