synapse 2.202.0__py311-none-any.whl → 2.204.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 (107) hide show
  1. synapse/axon.py +4 -4
  2. synapse/cmds/cortex.py +4 -6
  3. synapse/cmds/hive.py +10 -10
  4. synapse/common.py +17 -58
  5. synapse/cortex.py +6 -6
  6. synapse/data/__init__.py +3 -2
  7. synapse/data/iana.uris.mpk +1 -0
  8. synapse/lib/auth.py +3 -0
  9. synapse/lib/autodoc.py +3 -3
  10. synapse/lib/cell.py +21 -1
  11. synapse/lib/cli.py +2 -2
  12. synapse/lib/config.py +2 -2
  13. synapse/lib/encoding.py +4 -3
  14. synapse/lib/httpapi.py +7 -11
  15. synapse/lib/json.py +224 -0
  16. synapse/lib/lmdbslab.py +1 -1
  17. synapse/lib/oauth.py +176 -54
  18. synapse/lib/rstorm.py +18 -14
  19. synapse/lib/schemas.py +87 -1
  20. synapse/lib/scrape.py +35 -13
  21. synapse/lib/snap.py +2 -1
  22. synapse/lib/storm.lark +2 -2
  23. synapse/lib/storm.py +11 -6
  24. synapse/lib/stormhttp.py +11 -13
  25. synapse/lib/stormlib/aha.py +4 -4
  26. synapse/lib/stormlib/auth.py +1 -1
  27. synapse/lib/stormlib/cache.py +2 -2
  28. synapse/lib/stormlib/cortex.py +5 -5
  29. synapse/lib/stormlib/graph.py +1 -1
  30. synapse/lib/stormlib/imap.py +1 -1
  31. synapse/lib/stormlib/json.py +8 -11
  32. synapse/lib/stormlib/model.py +1 -1
  33. synapse/lib/stormlib/notifications.py +2 -2
  34. synapse/lib/stormlib/oauth.py +105 -2
  35. synapse/lib/stormlib/stats.py +4 -0
  36. synapse/lib/stormlib/stix.py +3 -4
  37. synapse/lib/stormlib/vault.py +6 -6
  38. synapse/lib/stormlib/xml.py +2 -2
  39. synapse/lib/stormtypes.py +19 -28
  40. synapse/lib/structlog.py +3 -3
  41. synapse/lib/types.py +2 -1
  42. synapse/lib/urlhelp.py +28 -4
  43. synapse/lib/version.py +2 -2
  44. synapse/lib/view.py +7 -3
  45. synapse/models/base.py +51 -2
  46. synapse/models/person.py +5 -2
  47. synapse/telepath.py +5 -3
  48. synapse/tests/files/__init__.py +0 -1
  49. synapse/tests/test_axon.py +1 -1
  50. synapse/tests/test_cmds_cortex.py +3 -2
  51. synapse/tests/test_cmds_hive.py +4 -4
  52. synapse/tests/test_common.py +29 -19
  53. synapse/tests/test_cortex.py +5 -5
  54. synapse/tests/test_lib_ast.py +3 -3
  55. synapse/tests/test_lib_autodoc.py +5 -5
  56. synapse/tests/test_lib_base.py +1 -1
  57. synapse/tests/test_lib_cell.py +16 -10
  58. synapse/tests/test_lib_config.py +2 -2
  59. synapse/tests/test_lib_encoding.py +2 -2
  60. synapse/tests/test_lib_grammar.py +86 -64
  61. synapse/tests/test_lib_httpapi.py +56 -13
  62. synapse/tests/test_lib_json.py +219 -0
  63. synapse/tests/test_lib_multislabseqn.py +2 -1
  64. synapse/tests/test_lib_node.py +2 -2
  65. synapse/tests/test_lib_scrape.py +50 -0
  66. synapse/tests/test_lib_storm.py +36 -8
  67. synapse/tests/test_lib_stormhttp.py +4 -4
  68. synapse/tests/test_lib_stormlib_auth.py +3 -2
  69. synapse/tests/test_lib_stormlib_cortex.py +10 -12
  70. synapse/tests/test_lib_stormlib_infosec.py +2 -3
  71. synapse/tests/test_lib_stormlib_json.py +18 -21
  72. synapse/tests/test_lib_stormlib_log.py +1 -1
  73. synapse/tests/test_lib_stormlib_oauth.py +603 -1
  74. synapse/tests/test_lib_stormlib_stats.py +13 -3
  75. synapse/tests/test_lib_stormlib_stix.py +5 -5
  76. synapse/tests/test_lib_stormtypes.py +4 -4
  77. synapse/tests/test_lib_structlog.py +5 -6
  78. synapse/tests/test_lib_urlhelp.py +7 -0
  79. synapse/tests/test_lib_view.py +8 -0
  80. synapse/tests/test_model_base.py +32 -0
  81. synapse/tests/test_model_infotech.py +2 -2
  82. synapse/tests/test_model_person.py +2 -0
  83. synapse/tests/test_telepath.py +0 -1
  84. synapse/tests/test_tools_cryo_cat.py +4 -3
  85. synapse/tests/test_tools_docker_validate.py +4 -2
  86. synapse/tests/test_tools_feed.py +30 -2
  87. synapse/tests/test_tools_genpkg.py +1 -1
  88. synapse/tests/test_tools_healthcheck.py +8 -7
  89. synapse/tests/test_utils.py +2 -2
  90. synapse/tests/utils.py +3 -3
  91. synapse/tools/autodoc.py +3 -3
  92. synapse/tools/changelog.py +2 -2
  93. synapse/tools/cryo/cat.py +3 -3
  94. synapse/tools/csvtool.py +2 -3
  95. synapse/tools/docker/validate.py +5 -5
  96. synapse/tools/feed.py +2 -1
  97. synapse/tools/genpkg.py +3 -2
  98. synapse/tools/healthcheck.py +2 -3
  99. synapse/tools/json2mpk.py +2 -2
  100. synapse/utils/getrefs.py +6 -6
  101. synapse/vendor/cpython/lib/json.py +35 -0
  102. synapse/vendor/cpython/lib/test/test_json.py +22 -0
  103. {synapse-2.202.0.dist-info → synapse-2.204.0.dist-info}/METADATA +4 -2
  104. {synapse-2.202.0.dist-info → synapse-2.204.0.dist-info}/RECORD +107 -102
  105. {synapse-2.202.0.dist-info → synapse-2.204.0.dist-info}/WHEEL +1 -1
  106. {synapse-2.202.0.dist-info → synapse-2.204.0.dist-info/licenses}/LICENSE +0 -0
  107. {synapse-2.202.0.dist-info → synapse-2.204.0.dist-info}/top_level.txt +0 -0
synapse/telepath.py CHANGED
@@ -394,7 +394,7 @@ class Share(s_base.Base):
394
394
  This should never be used by synapse core code. This is for sync client code convenience only.
395
395
  '''
396
396
  if s_threads.iden() == self.tid:
397
- raise s_exc.SynErr('Use of synchronous context manager in async code')
397
+ raise s_exc.SynErr(mesg='Use of synchronous context manager in async code')
398
398
 
399
399
  self._ctxobj = self.schedCoroSafePend(self.__aenter__())
400
400
  return self
@@ -593,7 +593,7 @@ class Proxy(s_base.Base):
593
593
 
594
594
  '''
595
595
  _link_task = None
596
- _link_event = asyncio.Event()
596
+ _link_event = None
597
597
  _all_proxies = set()
598
598
 
599
599
  async def __anit__(self, link, name):
@@ -650,6 +650,7 @@ class Proxy(s_base.Base):
650
650
  if not Proxy._all_proxies and Proxy._link_task is not None:
651
651
  Proxy._link_task.cancel()
652
652
  Proxy._link_task = None
653
+ Proxy._link_event = None
653
654
 
654
655
  Proxy._all_proxies.add(self)
655
656
 
@@ -657,6 +658,7 @@ class Proxy(s_base.Base):
657
658
  self.link.onfini(self.fini)
658
659
 
659
660
  if Proxy._link_task is None:
661
+ Proxy._link_event = asyncio.Event()
660
662
  Proxy._link_task = s_coro.create_task(Proxy._linkLoopTask())
661
663
 
662
664
  @classmethod
@@ -821,7 +823,7 @@ class Proxy(s_base.Base):
821
823
  This must not be used from async code, and it should never be used in core synapse code.
822
824
  '''
823
825
  if s_threads.iden() == self.tid:
824
- raise s_exc.SynErr('Use of synchronous context manager in async code')
826
+ raise s_exc.SynErr(mesg='Use of synchronous context manager in async code')
825
827
  self._ctxobj = self.schedCoroSafePend(self.__aenter__())
826
828
  return self
827
829
 
@@ -1,7 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Stdlib
3
3
  import os
4
- import json
5
4
  import logging
6
5
 
7
6
  log = logging.getLogger(__name__)
@@ -103,7 +103,7 @@ class HttpPushFile(s_httpapi.StreamHandler):
103
103
  assert item['filename'] == 'bytes'
104
104
 
105
105
  assert args.get('zip_password') == [b'test']
106
- assert args.get('dict') == [b'{"foo": "bar"}']
106
+ assert args.get('dict') == [b'{"foo":"bar"}']
107
107
  self.sendRestRetn(self.gotsize)
108
108
 
109
109
  class AxonTest(s_t_utils.SynTest):
@@ -4,6 +4,7 @@ import asyncio
4
4
  import synapse.common as s_common
5
5
 
6
6
  import synapse.lib.cmdr as s_cmdr
7
+ import synapse.lib.json as s_json
7
8
  import synapse.lib.encoding as s_encoding
8
9
  import synapse.lib.lmdbslab as s_lmdbslab
9
10
 
@@ -352,7 +353,7 @@ class CmdCoreTest(s_t_utils.SynTest):
352
353
  await cmdr.runCmdLine(f'storm --save-nodes {path} test:int')
353
354
  outp.expect('2 nodes')
354
355
 
355
- jsdata = [item for item in s_common.jslines(path)]
356
+ jsdata = [item for item in s_json.jslines(path)]
356
357
  self.len(2, jsdata)
357
358
  self.eq({tuple(n[0]) for n in jsdata},
358
359
  {('test:int', 20), ('test:int', 30)})
@@ -371,7 +372,7 @@ class CmdCoreTest(s_t_utils.SynTest):
371
372
  with s_common.genfile(stormfile) as fd:
372
373
  fd.write(b'[ inet:fqdn=$hehe ]')
373
374
 
374
- s_common.jssave(test_opts, optsfile)
375
+ s_json.jssave(test_opts, optsfile)
375
376
  s_common.yamlsave(test_opts, optsfile_yaml)
376
377
 
377
378
  outp = self.getTestOutp()
@@ -5,10 +5,10 @@ import synapse.lib.cmdr as s_cmdr
5
5
  import synapse.tests.utils as s_t_utils
6
6
 
7
7
  _json_output = '''[
8
- 1,
9
- 2,
10
- 3,
11
- 4
8
+ 1,
9
+ 2,
10
+ 3,
11
+ 4
12
12
  ]'''
13
13
 
14
14
  class CmdHiveTest(s_t_utils.SynTest):
@@ -1,12 +1,17 @@
1
1
  import os
2
+ import http
2
3
  import asyncio
3
4
  import logging
4
5
  import subprocess
5
6
 
6
7
  import yaml
8
+ import aiohttp
7
9
 
8
10
  import synapse.exc as s_exc
9
11
  import synapse.common as s_common
12
+
13
+ import synapse.lib.httpapi as s_httpapi
14
+
10
15
  import synapse.tests.utils as s_t_utils
11
16
 
12
17
  logger = logging.getLogger(__name__)
@@ -426,25 +431,6 @@ class CommonTest(s_t_utils.SynTest):
426
431
  retn = s_common.merggenr2([asyncl(lt) for lt in (l3, l2, l1)], reverse=True)
427
432
  self.eq((9, 8, 7, 6, 5, 4, 3, 2, 1), await alist(retn))
428
433
 
429
- def test_jsonsafe(self):
430
- items = (
431
- (None, None),
432
- (1234, None),
433
- ('1234', None),
434
- ({'asdf': 'haha'}, None),
435
- ({'a': (1,), 'b': [{'': 4}, 56, None, {'t': True, 'f': False}, 'oh my']}, None),
436
- (b'1234', s_exc.BadArg),
437
- ({'a': 'a', 2: 2}, s_exc.BadArg),
438
- ({'a', 'b', 'c'}, s_exc.BadArg),
439
- (s_common.novalu, s_exc.BadArg),
440
- )
441
- for (item, eret) in items:
442
- if eret is None:
443
- self.none(s_common.reqJsonSafeStrict(item))
444
- else:
445
- with self.raises(eret):
446
- s_common.reqJsonSafeStrict(item)
447
-
448
434
  def test_sslctx(self):
449
435
  with self.getTestDir(mirror='certdir') as dirn:
450
436
  cadir = s_common.genpath(dirn, 'cas')
@@ -481,3 +467,27 @@ class CommonTest(s_t_utils.SynTest):
481
467
  v = s_common.trimText(iv, n=n)
482
468
  self.le(len(v), n)
483
469
  self.eq(v, ev)
470
+
471
+ async def test_tornado_monkeypatch(self):
472
+ class JsonHandler(s_httpapi.Handler):
473
+ async def get(self):
474
+ resp = {
475
+ 'foo': 'bar',
476
+ 'html': '<html></html>'
477
+ }
478
+ self.write(resp)
479
+
480
+ async with self.getTestCore() as core:
481
+ core.addHttpApi('/api/v1/test_tornado/', JsonHandler, {'cell': core})
482
+ _, port = await core.addHttpsPort(0)
483
+ url = f'https://127.0.0.1:{port}/api/v1/test_tornado/'
484
+
485
+ async with aiohttp.ClientSession() as session:
486
+ async with session.get(url, ssl=False) as resp:
487
+ self.eq(resp.status, http.HTTPStatus.OK)
488
+
489
+ text = await resp.text()
490
+ self.eq(text, '{"foo":"bar","html":"<html><\\/html>"}')
491
+
492
+ json = await resp.json()
493
+ self.eq(json, {'foo': 'bar', 'html': '<html></html>'})
@@ -1559,8 +1559,8 @@ class CortexTest(s_t_utils.SynTest):
1559
1559
  self.eq(refs.get('fqdn'), ('inet:fqdn', 'woot.com'))
1560
1560
  self.eq(refs.get('ipv4'), ('inet:ipv4', 0x01020304))
1561
1561
 
1562
- self.len(1, await core.nodes('[meta:seen=($sorc, $valu)]',
1563
- opts={'vars': {'sorc': sorc, 'valu': node.ndef}}))
1562
+ self.len(1, await core.nodes('[test:str=testndef :somestr=$somestr :bar=$valu]',
1563
+ opts={'vars': {'somestr': sorc, 'valu': node.ndef}}))
1564
1564
 
1565
1565
  # test un-populated properties
1566
1566
  nodes = await core.nodes('[ps:contact="*"]')
@@ -1592,13 +1592,13 @@ class CortexTest(s_t_utils.SynTest):
1592
1592
  self.eq(ints, (('test:int', 1), ('test:int', 2), ('test:int', 3)))
1593
1593
 
1594
1594
  opts = {'vars': {'sorc': sorc}}
1595
- nodes = await core.nodes('meta:seen:source=$sorc -> *', opts=opts)
1595
+ nodes = await core.nodes('test:str:somestr=$sorc -> *', opts=opts)
1596
1596
 
1597
1597
  self.len(2, nodes)
1598
1598
  self.isin('inet:dns:a', {n.ndef[0] for n in nodes})
1599
1599
 
1600
1600
  opts = {'vars': {'sorc': sorc}}
1601
- nodes = await core.nodes('meta:seen:source=$sorc :node -> *', opts=opts)
1601
+ nodes = await core.nodes('test:str:somestr=$sorc :bar -> *', opts=opts)
1602
1602
 
1603
1603
  self.len(1, nodes)
1604
1604
  self.eq('inet:dns:a', nodes[0].ndef[0])
@@ -3955,7 +3955,7 @@ class CortexBasicTest(s_t_utils.SynTest):
3955
3955
  'refs': True,
3956
3956
  'edges': False,
3957
3957
  'forms': {},
3958
- 'pivots': ['<- meta:seen'],
3958
+ 'pivots': ['<(seen)- meta:source'],
3959
3959
  'degrees': 3,
3960
3960
  'filters': ['+#nope'],
3961
3961
  'filterinput': False,
@@ -1,4 +1,3 @@
1
- import json
2
1
  import math
3
2
  import asyncio
4
3
 
@@ -9,6 +8,7 @@ import synapse.common as s_common
9
8
  import synapse.datamodel as s_datamodel
10
9
 
11
10
  import synapse.lib.ast as s_ast
11
+ import synapse.lib.json as s_json
12
12
  import synapse.lib.snap as s_snap
13
13
 
14
14
  import synapse.tests.utils as s_test
@@ -1523,7 +1523,7 @@ class AstTest(s_test.SynTest):
1523
1523
  self.stormIsInPrint('stormpkg', msgs)
1524
1524
 
1525
1525
  # Make sure a JSON package loads
1526
- jsonpkg = json.loads(json.dumps(jsonpkg))
1526
+ jsonpkg = s_json.loads(s_json.dumps(jsonpkg))
1527
1527
  await core.stormlist('$lib.pkg.add($pkg)',
1528
1528
  opts={'vars': {'pkg': jsonpkg}})
1529
1529
  msgs = await core.stormlist('pkg.list')
@@ -1731,7 +1731,7 @@ class AstTest(s_test.SynTest):
1731
1731
  prints = list(filter(lambda m: m[0] == 'print', msgs))
1732
1732
  self.eq(len(prints), 3)
1733
1733
 
1734
- jmsgs = list(map(lambda m: json.loads(m[1]['mesg']), prints))
1734
+ jmsgs = list(map(lambda m: s_json.loads(m[1]['mesg']), prints))
1735
1735
  omsgs = sorted(jmsgs, key=lambda m: m[0])
1736
1736
  self.eq(omsgs[0][1], 'this should be first')
1737
1737
  self.eq(omsgs[1][1], 'toreturn called')
@@ -56,7 +56,7 @@ shave'''
56
56
  )
57
57
  }
58
58
  callsig = s_autodoc.genCallsig(rtype)
59
- self.eq(callsig, '(foo, bar=$lib.null, **kwargs)')
59
+ self.eq(callsig, '(foo, bar=(null), **kwargs)')
60
60
  self.eq(s_autodoc.genCallsig({}), '()')
61
61
  self.eq(s_autodoc.genCallsig({'args': ({'name': 'beep'},)}), '(beep)')
62
62
 
@@ -176,8 +176,8 @@ Returns:
176
176
 
177
177
  .. _test-lib-test-someargs:
178
178
 
179
- someargs(valu, bar=$lib.true, faz=$lib.null)
180
- ============================================
179
+ someargs(valu, bar=(true), faz=(null))
180
+ ======================================
181
181
 
182
182
  .. warning::
183
183
  ``$lib.test.someargs`` has been deprecated and will be removed in version v3.0.0.
@@ -252,8 +252,8 @@ Returns:
252
252
 
253
253
  .. _test-lib-test-someargs:
254
254
 
255
- $lib.test.someargs(valu, bar=$lib.true, faz=$lib.null)
256
- ======================================================
255
+ $lib.test.someargs(valu, bar=(true), faz=(null))
256
+ ================================================
257
257
 
258
258
  .. warning::
259
259
  ``$lib.test.someargs`` has been deprecated and will be removed in version v3.0.0.
@@ -483,7 +483,7 @@ class BaseTest(s_t_utils.SynTest):
483
483
  async def badgenr():
484
484
  yield 'foo'
485
485
  await asyncio.sleep(0)
486
- raise s_exc.SynErr('rando')
486
+ raise s_exc.SynErr(mesg='rando')
487
487
 
488
488
  async def slowgenr():
489
489
  yield 'foo'
@@ -1,7 +1,6 @@
1
1
  import os
2
2
  import ssl
3
3
  import sys
4
- import json
5
4
  import time
6
5
  import base64
7
6
  import signal
@@ -26,6 +25,7 @@ import synapse.lib.auth as s_auth
26
25
  import synapse.lib.base as s_base
27
26
  import synapse.lib.cell as s_cell
28
27
  import synapse.lib.coro as s_coro
28
+ import synapse.lib.json as s_json
29
29
  import synapse.lib.link as s_link
30
30
  import synapse.lib.drive as s_drive
31
31
  import synapse.lib.nexus as s_nexus
@@ -1822,10 +1822,13 @@ class CellTest(s_t_utils.SynTest):
1822
1822
 
1823
1823
  async def streamdone():
1824
1824
  while core.backupstreaming:
1825
- await asyncio.sleep(0)
1825
+ await asyncio.sleep(0.1)
1826
1826
 
1827
1827
  task = core.schedCoro(streamdone())
1828
- await asyncio.wait_for(task, 15)
1828
+ try:
1829
+ await asyncio.wait_for(task, 5)
1830
+ except TimeoutError:
1831
+ raise TimeoutError('Timeout waiting for streaming backup cleanup of bkup3 to complete.')
1829
1832
 
1830
1833
  self.eq(('bkup', 'bkup2'), sorted(await proxy.getBackups()))
1831
1834
  self.false(os.path.isdir(os.path.join(backdirn, 'bkup3')))
@@ -1839,7 +1842,10 @@ class CellTest(s_t_utils.SynTest):
1839
1842
  bkup4.write(msg)
1840
1843
 
1841
1844
  task = core.schedCoro(streamdone())
1842
- await asyncio.wait_for(task, 15)
1845
+ try:
1846
+ await asyncio.wait_for(task, 5)
1847
+ except TimeoutError:
1848
+ raise TimeoutError('Timeout waiting for streaming backup cleanup of bkup4 to complete.')
1843
1849
 
1844
1850
  self.eq(('bkup', 'bkup2'), sorted(await proxy.getBackups()))
1845
1851
 
@@ -3128,13 +3134,13 @@ class CellTest(s_t_utils.SynTest):
3128
3134
  self.nn(node.getTagProp('test', 'score'), 6)
3129
3135
 
3130
3136
  self.maxDiff = None
3131
- roles = s_t_utils.deguidify('[{"type": "role", "iden": "e1ef725990aa62ae3c4b98be8736d89f", "name": "all", "rules": [], "authgates": {"46cfde2c1682566602860f8df7d0cc83": {"rules": [[true, ["layer", "read"]]]}, "4d50eb257549436414643a71e057091a": {"rules": [[true, ["view", "read"]]]}}}]')
3132
- users = s_t_utils.deguidify('[{"type": "user", "iden": "a357138db50780b62093a6ce0d057fd8", "name": "root", "rules": [], "roles": [], "admin": true, "email": null, "locked": false, "archived": false, "authgates": {"46cfde2c1682566602860f8df7d0cc83": {"admin": true}, "4d50eb257549436414643a71e057091a": {"admin": true}}}, {"type": "user", "iden": "f77ac6744671a845c27e571071877827", "name": "visi", "rules": [[true, ["cron", "add"]], [true, ["dmon", "add"]], [true, ["trigger", "add"]]], "roles": [{"type": "role", "iden": "e1ef725990aa62ae3c4b98be8736d89f", "name": "all", "rules": [], "authgates": {"46cfde2c1682566602860f8df7d0cc83": {"rules": [[true, ["layer", "read"]]]}, "4d50eb257549436414643a71e057091a": {"rules": [[true, ["view", "read"]]]}}}], "admin": false, "email": null, "locked": false, "archived": false, "authgates": {"f21b7ae79c2dacb89484929a8409e5d8": {"admin": true}, "d7d0380dd4e743e35af31a20d014ed48": {"admin": true}}}]')
3133
- gates = s_t_utils.deguidify('[{"iden": "46cfde2c1682566602860f8df7d0cc83", "type": "layer", "users": [{"iden": "a357138db50780b62093a6ce0d057fd8", "rules": [], "admin": true}], "roles": [{"iden": "e1ef725990aa62ae3c4b98be8736d89f", "rules": [[true, ["layer", "read"]]], "admin": false}]}, {"iden": "d7d0380dd4e743e35af31a20d014ed48", "type": "trigger", "users": [{"iden": "f77ac6744671a845c27e571071877827", "rules": [], "admin": true}], "roles": []}, {"iden": "f21b7ae79c2dacb89484929a8409e5d8", "type": "cronjob", "users": [{"iden": "f77ac6744671a845c27e571071877827", "rules": [], "admin": true}], "roles": []}, {"iden": "4d50eb257549436414643a71e057091a", "type": "view", "users": [{"iden": "a357138db50780b62093a6ce0d057fd8", "rules": [], "admin": true}], "roles": [{"iden": "e1ef725990aa62ae3c4b98be8736d89f", "rules": [[true, ["view", "read"]]], "admin": false}]}, {"iden": "cortex", "type": "cortex", "users": [], "roles": []}]')
3137
+ roles = s_t_utils.deguidify('[{"type":"role","iden":"e1ef725990aa62ae3c4b98be8736d89f","name":"all","rules":[],"authgates":{"46cfde2c1682566602860f8df7d0cc83":{"rules":[[true,["layer","read"]]]},"4d50eb257549436414643a71e057091a":{"rules":[[true,["view","read"]]]}}}]')
3138
+ users = s_t_utils.deguidify('[{"type":"user","iden":"a357138db50780b62093a6ce0d057fd8","name":"root","rules":[],"roles":[],"admin":true,"email":null,"locked":false,"archived":false,"authgates":{"46cfde2c1682566602860f8df7d0cc83":{"admin":true},"4d50eb257549436414643a71e057091a":{"admin":true}}},{"type":"user","iden":"f77ac6744671a845c27e571071877827","name":"visi","rules":[[true,["cron","add"]],[true,["dmon","add"]],[true,["trigger","add"]]],"roles":[{"type":"role","iden":"e1ef725990aa62ae3c4b98be8736d89f","name":"all","rules":[],"authgates":{"46cfde2c1682566602860f8df7d0cc83":{"rules":[[true,["layer","read"]]]},"4d50eb257549436414643a71e057091a":{"rules":[[true,["view","read"]]]}}}],"admin":false,"email":null,"locked":false,"archived":false,"authgates":{"f21b7ae79c2dacb89484929a8409e5d8":{"admin":true},"d7d0380dd4e743e35af31a20d014ed48":{"admin":true}}}]')
3139
+ gates = s_t_utils.deguidify('[{"iden":"46cfde2c1682566602860f8df7d0cc83","type":"layer","users":[{"iden":"a357138db50780b62093a6ce0d057fd8","rules":[],"admin":true}],"roles":[{"iden":"e1ef725990aa62ae3c4b98be8736d89f","rules":[[true,["layer","read"]]],"admin":false}]},{"iden":"d7d0380dd4e743e35af31a20d014ed48","type":"trigger","users":[{"iden":"f77ac6744671a845c27e571071877827","rules":[],"admin":true}],"roles":[]},{"iden":"f21b7ae79c2dacb89484929a8409e5d8","type":"cronjob","users":[{"iden":"f77ac6744671a845c27e571071877827","rules":[],"admin":true}],"roles":[]},{"iden":"4d50eb257549436414643a71e057091a","type":"view","users":[{"iden":"a357138db50780b62093a6ce0d057fd8","rules":[],"admin":true}],"roles":[{"iden":"e1ef725990aa62ae3c4b98be8736d89f","rules":[[true,["view","read"]]],"admin":false}]},{"iden":"cortex","type":"cortex","users":[],"roles":[]}]')
3134
3140
 
3135
- self.eq(roles, s_t_utils.deguidify(json.dumps(await core.callStorm('return($lib.auth.roles.list())'))))
3136
- self.eq(users, s_t_utils.deguidify(json.dumps(await core.callStorm('return($lib.auth.users.list())'))))
3137
- self.eq(gates, s_t_utils.deguidify(json.dumps(await core.callStorm('return($lib.auth.gates.list())'))))
3141
+ self.eq(roles, s_t_utils.deguidify(s_json.dumps(await core.callStorm('return($lib.auth.roles.list())')).decode()))
3142
+ self.eq(users, s_t_utils.deguidify(s_json.dumps(await core.callStorm('return($lib.auth.users.list())')).decode()))
3143
+ self.eq(gates, s_t_utils.deguidify(s_json.dumps(await core.callStorm('return($lib.auth.gates.list())')).decode()))
3138
3144
 
3139
3145
  with self.raises(s_exc.BadTypeValu):
3140
3146
  await core.nodes('[ it:dev:str=foo +#test.newp ]')
@@ -1,5 +1,4 @@
1
1
  import copy
2
- import json
3
2
  import regex
4
3
  import pathlib
5
4
  import argparse
@@ -11,6 +10,7 @@ import synapse.data as s_data
11
10
  import synapse.common as s_common
12
11
 
13
12
  import synapse.lib.cell as s_cell
13
+ import synapse.lib.json as s_json
14
14
  import synapse.lib.config as s_config
15
15
 
16
16
  import synapse.tests.utils as s_test
@@ -396,7 +396,7 @@ class ConfTest(s_test.SynTest):
396
396
  self.true(filename.exists())
397
397
 
398
398
  with filename.open() as fp:
399
- schema = json.load(fp)
399
+ schema = s_json.load(fp)
400
400
 
401
401
  self.eq(schema, s_config.localSchemaRefHandler(
402
402
  "http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/core.json"
@@ -1,8 +1,8 @@
1
1
  import io
2
- import json
3
2
 
4
3
  import synapse.common as s_common
5
4
 
5
+ import synapse.lib.json as s_json
6
6
  import synapse.lib.msgpack as s_msgpack
7
7
  import synapse.lib.encoding as s_encoding
8
8
 
@@ -190,7 +190,7 @@ class EncTest(s_t_utils.SynTest):
190
190
 
191
191
  }
192
192
 
193
- buf = io.BytesIO(json.dumps(data).encode())
193
+ buf = io.BytesIO(s_json.dumps(data))
194
194
 
195
195
  lines = list(s_encoding.iterdata(buf, format='json'))
196
196
  self.len(1, lines)