synapse 2.190.0__py311-none-any.whl → 2.192.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 (49) hide show
  1. synapse/axon.py +54 -23
  2. synapse/common.py +9 -0
  3. synapse/cortex.py +3 -2
  4. synapse/datamodel.py +8 -1
  5. synapse/lib/ast.py +6 -2
  6. synapse/lib/cell.py +55 -7
  7. synapse/lib/msgpack.py +10 -3
  8. synapse/lib/nexus.py +2 -1
  9. synapse/lib/stormhttp.py +32 -35
  10. synapse/lib/stormlib/model.py +37 -0
  11. synapse/lib/stormtypes.py +102 -20
  12. synapse/lib/version.py +2 -2
  13. synapse/models/auth.py +2 -1
  14. synapse/models/base.py +20 -0
  15. synapse/models/crypto.py +5 -2
  16. synapse/models/economic.py +45 -11
  17. synapse/models/inet.py +78 -21
  18. synapse/models/person.py +11 -4
  19. synapse/models/risk.py +6 -0
  20. synapse/models/syn.py +22 -12
  21. synapse/models/telco.py +3 -1
  22. synapse/tests/test_axon.py +10 -0
  23. synapse/tests/test_cortex.py +60 -17
  24. synapse/tests/test_lib_agenda.py +1 -6
  25. synapse/tests/test_lib_ast.py +6 -0
  26. synapse/tests/test_lib_cell.py +63 -4
  27. synapse/tests/test_lib_httpapi.py +11 -6
  28. synapse/tests/test_lib_lmdbslab.py +1 -4
  29. synapse/tests/test_lib_stormhttp.py +57 -12
  30. synapse/tests/test_lib_stormlib_cortex.py +1 -3
  31. synapse/tests/test_lib_stormlib_log.py +1 -6
  32. synapse/tests/test_lib_stormlib_model.py +28 -0
  33. synapse/tests/test_lib_stormtypes.py +1 -2
  34. synapse/tests/test_lib_trigger.py +2 -3
  35. synapse/tests/test_model_base.py +12 -2
  36. synapse/tests/test_model_inet.py +23 -0
  37. synapse/tests/test_model_person.py +2 -0
  38. synapse/tests/test_model_risk.py +5 -0
  39. synapse/tests/test_model_syn.py +198 -0
  40. synapse/tests/test_servers_univ.py +0 -12
  41. synapse/tests/test_tools_apikey.py +227 -0
  42. synapse/tests/test_utils.py +23 -4
  43. synapse/tests/utils.py +39 -5
  44. synapse/tools/apikey.py +93 -0
  45. {synapse-2.190.0.dist-info → synapse-2.192.0.dist-info}/METADATA +4 -4
  46. {synapse-2.190.0.dist-info → synapse-2.192.0.dist-info}/RECORD +49 -47
  47. {synapse-2.190.0.dist-info → synapse-2.192.0.dist-info}/LICENSE +0 -0
  48. {synapse-2.190.0.dist-info → synapse-2.192.0.dist-info}/WHEEL +0 -0
  49. {synapse-2.190.0.dist-info → synapse-2.192.0.dist-info}/top_level.txt +0 -0
synapse/lib/stormtypes.py CHANGED
@@ -3,6 +3,7 @@ import copy
3
3
  import gzip
4
4
  import json
5
5
  import time
6
+
6
7
  import regex
7
8
  import types
8
9
  import base64
@@ -39,6 +40,7 @@ import synapse.lib.stormctrl as s_stormctrl
39
40
  logger = logging.getLogger(__name__)
40
41
 
41
42
  AXON_MINVERS_PROXY = (2, 97, 0)
43
+ AXON_MINVERS_PROXYTRUE = (2, 192, 0)
42
44
  AXON_MINVERS_SSLOPTS = '>=2.162.0'
43
45
 
44
46
  class Undef:
@@ -73,6 +75,79 @@ def strifyHttpArg(item, multi=False):
73
75
  return retn
74
76
  return item
75
77
 
78
+ async def resolveCoreProxyUrl(valu):
79
+ '''
80
+ Resolve a proxy value to a proxy URL.
81
+
82
+ Args:
83
+ valu (str|None|bool): The proxy value.
84
+
85
+ Returns:
86
+ (str|None): A proxy URL string or None.
87
+ '''
88
+ runt = s_scope.get('runt')
89
+
90
+ match valu:
91
+ case None:
92
+ s_common.deprecated('Setting the HTTP proxy argument $lib.null', curv='2.192.0')
93
+ await runt.snap.warnonce('Setting the HTTP proxy argument to $lib.null is deprecated. Use $lib.true instead.')
94
+ return await runt.snap.core.getConfOpt('http:proxy')
95
+
96
+ case True:
97
+ return await runt.snap.core.getConfOpt('http:proxy')
98
+
99
+ case False:
100
+ runt.confirm(('storm', 'lib', 'inet', 'http', 'proxy'))
101
+ return None
102
+
103
+ case str():
104
+ runt.confirm(('storm', 'lib', 'inet', 'http', 'proxy'))
105
+ return valu
106
+
107
+ case _:
108
+ raise s_exc.BadArg(mesg='HTTP proxy argument must be a string or bool.')
109
+
110
+ async def resolveAxonProxyArg(valu):
111
+ '''
112
+ Resolve a proxy value to the kwarg to set for an Axon HTTP call.
113
+
114
+ Args:
115
+ valu (str|null|bool): The proxy value.
116
+
117
+ Returns:
118
+ tuple: A retn tuple where the proxy kwarg should not be set if ok=False, otherwise a proxy URL or None.
119
+ '''
120
+ runt = s_scope.get('runt')
121
+
122
+ axonvers = runt.snap.core.axoninfo['synapse']['version']
123
+ if axonvers < AXON_MINVERS_PROXY:
124
+ await runt.snap.warnonce(f'Axon version does not support proxy argument: {axonvers} < {AXON_MINVERS_PROXY}')
125
+ return False, None
126
+
127
+ match valu:
128
+ case None:
129
+ s_common.deprecated('Setting the Storm HTTP proxy argument $lib.null', curv='2.192.0')
130
+ await runt.snap.warnonce('Setting the Storm HTTP proxy argument to $lib.null is deprecated. Use $lib.true instead.')
131
+ if axonvers >= AXON_MINVERS_PROXYTRUE:
132
+ return True, True
133
+ return True, None
134
+
135
+ case True:
136
+ if axonvers < AXON_MINVERS_PROXYTRUE:
137
+ return True, None
138
+ return True, True
139
+
140
+ case False:
141
+ runt.confirm(('storm', 'lib', 'inet', 'http', 'proxy'))
142
+ return True, False
143
+
144
+ case str():
145
+ runt.confirm(('storm', 'lib', 'inet', 'http', 'proxy'))
146
+ return True, valu
147
+
148
+ case _:
149
+ raise s_exc.BadArg(mesg='HTTP proxy argument must be a string or bool.')
150
+
76
151
  class StormTypesRegistry:
77
152
  # The following types are currently undefined.
78
153
  base_undefined_types = (
@@ -1993,11 +2068,18 @@ class LibAxon(Lib):
1993
2068
 
1994
2069
  For APIs that accept an ssl_opts argument, the dictionary may contain the following values::
1995
2070
 
1996
- {
2071
+ ({
1997
2072
  'verify': <bool> - Perform SSL/TLS verification. Is overridden by the ssl argument.
1998
2073
  'client_cert': <str> - PEM encoded full chain certificate for use in mTLS.
1999
2074
  'client_key': <str> - PEM encoded key for use in mTLS. Alternatively, can be included in client_cert.
2000
- }
2075
+ })
2076
+
2077
+ For APIs that accept a proxy argument, the following values are supported::
2078
+
2079
+ $lib.null: Deprecated - Use the proxy defined by the http:proxy configuration option if set.
2080
+ $lib.true: Use the proxy defined by the http:proxy configuration option if set.
2081
+ $lib.false: Do not use the proxy defined by the http:proxy configuration option if set.
2082
+ <str>: A proxy URL string.
2001
2083
  '''
2002
2084
  _storm_locals = (
2003
2085
  {'name': 'wget', 'desc': """
@@ -2031,8 +2113,8 @@ class LibAxon(Lib):
2031
2113
  'desc': 'Set to False to disable SSL/TLS certificate verification.', 'default': True},
2032
2114
  {'name': 'timeout', 'type': 'int', 'desc': 'Timeout for the download operation.',
2033
2115
  'default': None},
2034
- {'name': 'proxy', 'type': ['boolean', 'null', 'str'],
2035
- 'desc': 'Set to a proxy URL string or $lib.false to disable proxy use.', 'default': None},
2116
+ {'name': 'proxy', 'type': ['bool', 'str'],
2117
+ 'desc': 'Configure proxy usage. See $lib.axon help for additional details.', 'default': True},
2036
2118
  {'name': 'ssl_opts', 'type': 'dict',
2037
2119
  'desc': 'Optional SSL/TLS options. See $lib.axon help for additional details.',
2038
2120
  'default': None},
@@ -2054,8 +2136,8 @@ class LibAxon(Lib):
2054
2136
  'desc': 'Set to False to disable SSL/TLS certificate verification.', 'default': True},
2055
2137
  {'name': 'timeout', 'type': 'int', 'desc': 'Timeout for the download operation.',
2056
2138
  'default': None},
2057
- {'name': 'proxy', 'type': ['boolean', 'null', 'str'],
2058
- 'desc': 'Set to a proxy URL string or $lib.false to disable proxy use.', 'default': None},
2139
+ {'name': 'proxy', 'type': ['bool', 'str'],
2140
+ 'desc': 'Configure proxy usage. See $lib.axon help for additional details.', 'default': True},
2059
2141
  {'name': 'ssl_opts', 'type': 'dict',
2060
2142
  'desc': 'Optional SSL/TLS options. See $lib.axon help for additional details.',
2061
2143
  'default': None},
@@ -2370,7 +2452,7 @@ class LibAxon(Lib):
2370
2452
  return await axon.del_(sha256b)
2371
2453
 
2372
2454
  async def wget(self, url, headers=None, params=None, method='GET', json=None, body=None,
2373
- ssl=True, timeout=None, proxy=None, ssl_opts=None):
2455
+ ssl=True, timeout=None, proxy=True, ssl_opts=None):
2374
2456
 
2375
2457
  if not self.runt.allowed(('axon', 'wget')):
2376
2458
  self.runt.confirm(('storm', 'lib', 'axon', 'wget'))
@@ -2387,20 +2469,19 @@ class LibAxon(Lib):
2387
2469
  proxy = await toprim(proxy)
2388
2470
  ssl_opts = await toprim(ssl_opts)
2389
2471
 
2390
- if proxy is not None:
2391
- self.runt.confirm(('storm', 'lib', 'inet', 'http', 'proxy'))
2392
-
2393
2472
  params = strifyHttpArg(params, multi=True)
2394
2473
  headers = strifyHttpArg(headers)
2395
2474
 
2396
2475
  await self.runt.snap.core.getAxon()
2397
2476
 
2398
2477
  kwargs = {}
2399
- axonvers = self.runt.snap.core.axoninfo['synapse']['version']
2400
- if axonvers >= AXON_MINVERS_PROXY:
2478
+
2479
+ ok, proxy = await resolveAxonProxyArg(proxy)
2480
+ if ok:
2401
2481
  kwargs['proxy'] = proxy
2402
2482
 
2403
2483
  if ssl_opts is not None:
2484
+ axonvers = self.runt.snap.core.axoninfo['synapse']['version']
2404
2485
  mesg = f'The ssl_opts argument requires an Axon Synapse version {AXON_MINVERS_SSLOPTS}, ' \
2405
2486
  f'but the Axon is running {axonvers}'
2406
2487
  s_version.reqVersion(axonvers, AXON_MINVERS_SSLOPTS, mesg=mesg)
@@ -2413,7 +2494,7 @@ class LibAxon(Lib):
2413
2494
  return resp
2414
2495
 
2415
2496
  async def wput(self, sha256, url, headers=None, params=None, method='PUT',
2416
- ssl=True, timeout=None, proxy=None, ssl_opts=None):
2497
+ ssl=True, timeout=None, proxy=True, ssl_opts=None):
2417
2498
 
2418
2499
  if not self.runt.allowed(('axon', 'wput')):
2419
2500
  self.runt.confirm(('storm', 'lib', 'axon', 'wput'))
@@ -2432,23 +2513,24 @@ class LibAxon(Lib):
2432
2513
  params = strifyHttpArg(params, multi=True)
2433
2514
  headers = strifyHttpArg(headers)
2434
2515
 
2435
- if proxy is not None:
2436
- self.runt.confirm(('storm', 'lib', 'inet', 'http', 'proxy'))
2437
-
2438
- axon = self.runt.snap.core.axon
2439
- sha256byts = s_common.uhex(sha256)
2516
+ await self.runt.snap.core.getAxon()
2440
2517
 
2441
2518
  kwargs = {}
2442
- axonvers = self.runt.snap.core.axoninfo['synapse']['version']
2443
- if axonvers >= AXON_MINVERS_PROXY:
2519
+
2520
+ ok, proxy = await resolveAxonProxyArg(proxy)
2521
+ if ok:
2444
2522
  kwargs['proxy'] = proxy
2445
2523
 
2446
2524
  if ssl_opts is not None:
2525
+ axonvers = self.runt.snap.core.axoninfo['synapse']['version']
2447
2526
  mesg = f'The ssl_opts argument requires an Axon Synapse version {AXON_MINVERS_SSLOPTS}, ' \
2448
2527
  f'but the Axon is running {axonvers}'
2449
2528
  s_version.reqVersion(axonvers, AXON_MINVERS_SSLOPTS, mesg=mesg)
2450
2529
  kwargs['ssl_opts'] = ssl_opts
2451
2530
 
2531
+ axon = self.runt.snap.core.axon
2532
+ sha256byts = s_common.uhex(sha256)
2533
+
2452
2534
  return await axon.wput(sha256byts, url, headers=headers, params=params, method=method,
2453
2535
  ssl=ssl, timeout=timeout, **kwargs)
2454
2536
 
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, 190, 0)
226
+ version = (2, 192, 0)
227
227
  verstring = '.'.join([str(x) for x in version])
228
- commit = 'ea92cb42c33f8793e9d72834aa8d12b6456eee8b'
228
+ commit = '8a442a534d27fff4c6189922c4b0ea85d332f18e'
synapse/models/auth.py CHANGED
@@ -43,7 +43,8 @@ class AuthModule(s_module.CoreModule):
43
43
  'doc': 'The WiFi SSID that the credentials allow access to.',
44
44
  }),
45
45
  ('web:acct', ('inet:web:acct', {}), {
46
- 'doc': 'The web account that the credentials allow access to.',
46
+ 'deprecated': True,
47
+ 'doc': 'Deprecated. Use :service:account.',
47
48
  }),
48
49
  ('service:account', ('inet:service:account', {}), {
49
50
  'doc': 'The service account that the credentials allow access to.'}),
synapse/models/base.py CHANGED
@@ -56,6 +56,10 @@ class BaseModule(s_module.CoreModule):
56
56
  'interfaces': ('meta:taxonomy',),
57
57
  'doc': 'A taxonomy of event types for meta:event nodes.'}),
58
58
 
59
+ ('meta:ruleset:type:taxonomy', ('taxonomy', {}), {
60
+ 'interfaces': ('meta:taxonomy',),
61
+ 'doc': 'A taxonomy for meta:ruleset types.'}),
62
+
59
63
  ('meta:ruleset', ('guid', {}), {
60
64
  'doc': 'A set of rules linked with -(has)> edges.'}),
61
65
 
@@ -99,6 +103,9 @@ class BaseModule(s_module.CoreModule):
99
103
  'deprecated': True,
100
104
  'doc': 'A generic digraph time edge to show relationships outside the model.'}),
101
105
 
106
+ ('meta:activity', ('int', {'enums': prioenums, 'enums:strict': False}), {
107
+ 'doc': 'A generic activity level enumeration.'}),
108
+
102
109
  ('meta:priority', ('int', {'enums': prioenums, 'enums:strict': False}), {
103
110
  'doc': 'A generic priority enumeration.'}),
104
111
 
@@ -120,6 +127,9 @@ class BaseModule(s_module.CoreModule):
120
127
  ),
121
128
  },
122
129
  'doc': 'A node which represents an aggregate count of a specific type.'}),
130
+
131
+ ('markdown', ('str', {}), {
132
+ 'doc': 'A markdown string.'}),
123
133
  ),
124
134
  'interfaces': (
125
135
  ('meta:taxonomy', {
@@ -182,6 +192,12 @@ class BaseModule(s_module.CoreModule):
182
192
 
183
193
  ('url', ('inet:url', {}), {
184
194
  'doc': 'A URL which documents the meta source.'}),
195
+
196
+ ('ingest:latest', ('time', {}), {
197
+ 'doc': 'Used by ingest logic to capture the last time a feed ingest ran.'}),
198
+
199
+ ('ingest:offset', ('int', {}), {
200
+ 'doc': 'Used by ingest logic to capture the current ingest offset within a feed.'}),
185
201
  )),
186
202
 
187
203
  ('meta:seen', {}, (
@@ -263,6 +279,10 @@ class BaseModule(s_module.CoreModule):
263
279
  ('meta:ruleset', {}, (
264
280
  ('name', ('str', {'lower': True, 'onespace': True}), {
265
281
  'doc': 'A name for the ruleset.'}),
282
+
283
+ ('type', ('meta:ruleset:type:taxonomy', {}), {
284
+ 'doc': 'The ruleset type.'}),
285
+
266
286
  ('desc', ('str', {}), {
267
287
  'disp': {'hint': 'text'},
268
288
  'doc': 'A description of the ruleset.'}),
synapse/models/crypto.py CHANGED
@@ -82,6 +82,11 @@ class CryptoModule(s_module.CoreModule):
82
82
  'ex': 'btc',
83
83
  }),
84
84
  ('crypto:currency:address', ('comp', {'fields': (('coin', 'crypto:currency:coin'), ('iden', 'str')), 'sepr': '/'}), {
85
+
86
+ 'interfaces': ('econ:pay:instrument',),
87
+ 'template': {
88
+ 'instrument': 'crypto currency address'},
89
+
85
90
  'doc': 'An individual crypto currency address.',
86
91
  'ex': 'btc/1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2',
87
92
  }),
@@ -364,8 +369,6 @@ class CryptoModule(s_module.CoreModule):
364
369
  'doc': 'The coin specific address identifier.', 'ro': True, }),
365
370
  ('desc', ('str', {}), {
366
371
  'doc': 'A free-form description of the address.'}),
367
- ('contact', ('ps:contact', {}), {
368
- 'doc': 'Contact information associated with the address.'}),
369
372
  )),
370
373
 
371
374
  ('crypto:algorithm', {}, ()),
@@ -23,6 +23,11 @@ class EconModule(s_module.CoreModule):
23
23
  'doc': 'An Issuer Id Number (IIN).'}),
24
24
 
25
25
  ('econ:pay:card', ('guid', {}), {
26
+
27
+ 'interfaces': ('econ:pay:instrument',),
28
+ 'template': {
29
+ 'instrument': 'payment card'},
30
+
26
31
  'doc': 'A single payment card.'}),
27
32
 
28
33
  ('econ:purchase', ('guid', {}), {
@@ -71,6 +76,11 @@ class EconModule(s_module.CoreModule):
71
76
  'doc': 'A bank account type taxonomy.'}),
72
77
 
73
78
  ('econ:bank:account', ('guid', {}), {
79
+
80
+ 'interfaces': ('econ:pay:instrument',),
81
+ 'template': {
82
+ 'instrument': 'bank account'},
83
+
74
84
  'doc': 'A bank account.'}),
75
85
 
76
86
  ('econ:bank:balance', ('guid', {}), {
@@ -87,6 +97,25 @@ class EconModule(s_module.CoreModule):
87
97
 
88
98
  ('econ:bank:swift:bic', ('str', {'regex': '[A-Z]{6}[A-Z0-9]{5}'}), {
89
99
  'doc': 'A Society for Worldwide Interbank Financial Telecommunication (SWIFT) Business Identifier Code (BIC).'}),
100
+
101
+ ('econ:pay:instrument', ('ndef', {'interface': 'econ:pay:instrument'}), {
102
+ 'doc': 'A node which may act as a payment instrument.'}),
103
+ ),
104
+
105
+ 'interfaces': (
106
+ ('econ:pay:instrument', {
107
+
108
+ 'doc': 'An interface for forms which may act as a payment instrument.',
109
+ 'template': {
110
+ 'instrument': 'instrument',
111
+ },
112
+
113
+ 'props': (
114
+
115
+ ('contact', ('ps:contact', {}), {
116
+ 'doc': 'The primary contact for the {instrument}.'}),
117
+ ),
118
+ }),
90
119
  ),
91
120
 
92
121
  'edges': (
@@ -134,9 +163,6 @@ class EconModule(s_module.CoreModule):
134
163
 
135
164
  ('account', ('econ:bank:account', {}), {
136
165
  'doc': 'A bank account associated with the payment card.'}),
137
-
138
- ('contact', ('ps:contact', {}), {
139
- 'doc': 'The contact information associated with the payment card.'}),
140
166
  )),
141
167
 
142
168
  ('econ:purchase', {}, (
@@ -209,17 +235,26 @@ class EconModule(s_module.CoreModule):
209
235
  ('from:cash', ('bool', {}), {
210
236
  'doc': 'Set to true if the payment input was in cash.'}),
211
237
 
238
+ ('to:instrument', ('econ:pay:instrument', {}), {
239
+ 'doc': 'The payment instrument which received funds from the payment.'}),
240
+
241
+ ('from:instrument', ('econ:pay:instrument', {}), {
242
+ 'doc': 'The payment instrument used to make the payment.'}),
243
+
212
244
  ('from:account', ('econ:bank:account', {}), {
213
- 'doc': 'The bank account which made the payment.'}),
245
+ 'deprecated': True,
246
+ 'doc': 'Deprecated. Please use :from:instrument.'}),
214
247
 
215
248
  ('from:pay:card', ('econ:pay:card', {}), {
216
- 'doc': 'The payment card making the payment.'}),
249
+ 'deprecated': True,
250
+ 'doc': 'Deprecated. Please use :from:instrument.'}),
217
251
 
218
252
  ('from:contract', ('ou:contract', {}), {
219
253
  'doc': 'A contract used as an aggregate payment source.'}),
220
254
 
221
255
  ('from:coinaddr', ('crypto:currency:address', {}), {
222
- 'doc': 'The crypto currency address making the payment.'}),
256
+ 'deprecated': True,
257
+ 'doc': 'Deprecated. Please use :from:instrument.'}),
223
258
 
224
259
  ('from:contact', ('ps:contact', {}), {
225
260
  'doc': 'Contact information for the entity making the payment.'}),
@@ -228,10 +263,12 @@ class EconModule(s_module.CoreModule):
228
263
  'doc': 'Set to true if the payment output was in cash.'}),
229
264
 
230
265
  ('to:account', ('econ:bank:account', {}), {
231
- 'doc': 'The bank account which received the payment.'}),
266
+ 'deprecated': True,
267
+ 'doc': 'Deprecated. Please use :to:instrument.'}),
232
268
 
233
269
  ('to:coinaddr', ('crypto:currency:address', {}), {
234
- 'doc': 'The crypto currency address receiving the payment.'}),
270
+ 'deprecated': True,
271
+ 'doc': 'Deprecated. Please use :to:instrument.'}),
235
272
 
236
273
  ('to:contact', ('ps:contact', {}), {
237
274
  'doc': 'Contact information for the person/org being paid.'}),
@@ -448,9 +485,6 @@ class EconModule(s_module.CoreModule):
448
485
  ('iban', ('econ:bank:iban', {}), {
449
486
  'doc': 'The IBAN for the account.'}),
450
487
 
451
- ('contact', ('ps:contact', {}), {
452
- 'doc': 'The contact information associated with the bank account.'}),
453
-
454
488
  ('issuer', ('ou:org', {}), {
455
489
  'doc': 'The bank which issued the account.'}),
456
490